Index: openacs-4/packages/highcharts/highcharts.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/highcharts/highcharts.info,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/highcharts/highcharts.info 23 Oct 2022 18:41:18 -0000 1.1.2.1 @@ -0,0 +1,26 @@ + + + + + Highcharts + Highcharts + f + t + f + f + + + Gustaf Neumann + The Highcharts library is a JavaScript and TypeScript package for producing data visualizations (line/bar/pie charts etc.). The OpenACS package offers support to load this library either via CDN or from a local installation (via acs-admin and global administration UI). + 0 + + + + + + + + + + + Index: openacs-4/packages/highcharts/tcl/resource-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/highcharts/tcl/resource-init.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/highcharts/tcl/resource-init.tcl 23 Oct 2022 18:41:18 -0000 1.1.2.1 @@ -0,0 +1 @@ +::highcharts::register_urns Index: openacs-4/packages/highcharts/tcl/resource-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/highcharts/tcl/resource-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/highcharts/tcl/resource-procs.tcl 23 Oct 2022 18:41:18 -0000 1.1.2.1 @@ -0,0 +1,201 @@ +ad_library { + + Support for the JavaScript/Typescrip Highcharts library- + + This script defines the following public procs: + + ::highcharts::resource_info + ::highcharts::download + + + @author Gustaf Neumann + @creation-date 23 Oct 2022 +} + +namespace eval ::highcharts { + + set package_id [apm_package_id_from_key "highcharts"] + + # + # The Highcharts configuration can be tailored via the OpenACS + # configuration file: + # + # ns_section ns/server/${server}/acs/highcharts + # ns_param HighchartsVersion 10.2.1 + # + set ::highcharts::version [parameter::get \ + -package_id $package_id \ + -parameter HighchartsVersion \ + -default 10.2.1] + + ad_proc ::highcharts::resource_info { + {-version ""} + } { + + Get information about available version(s) of Highcharts, + from the local filesystem, or from CDN. + + } { + # + # If no version is specified, use the namespaced variable. + # + if {$version eq ""} { + set version $::highcharts::version + } + + # + # Setup variables for access via CDN vs. local resources. + # + set resourceDir [acs_package_root_dir highcharts/www/resources] + set resourceUrl /resources/highcharts/$version + set cdnHost cdnjs.cloudflare.com + set cdn //$cdnHost/ + + if {[file exists $resourceDir/$version]} { + # + # Local version is installed + # + set prefix $resourceUrl/code + set cdnHost "" + set cspMap "" + } else { + # + # Use CDN + # + # cloudflare has the following resources: + # + # https://cdnjs.cloudflare.com/ajax/libs/highcharts/10.2.1/highcharts.js + # https://cdnjs.cloudflare.com/ajax/libs/highcharts/10.2.1/highcharts.min.js + # + # https://cdnjs.cloudflare.com/ajax/libs/highcharts/10.2.1/modules/exporting.js + # https://cdnjs.cloudflare.com/ajax/libs/highcharts/10.2.1/modules/exporting.min.js + # + # We just need the CSS file, which is on the CDN in the + # "font" directory. + set prefix ${cdn}ajax/libs/highcharts/$version + set cspMap [subst { + urn:ad:css:highcharts { + script-src $cdnHost + }}] + # + # + # Other potential sources: + # + # https://www.highcharts.com/blog/download/ + # https://www.jsdelivr.com/package/npm/highcharts + } + + # + # Return the dict with at least the required fields + # + lappend result \ + resourceName "Highcharts" \ + resourceDir $resourceDir \ + cdn $cdn \ + cdnHost $cdnHost \ + prefix $prefix \ + cssFiles {} \ + jsFiles {} \ + extraFiles {} \ + downloadURLs [subst { + https://code.highcharts.com/zips/Highcharts-$version.zip + }] \ + cspMap $cspMap \ + urnMap {} + + + return $result + } + + ad_proc -private ::highcharts::download { + {-version ""} + } { + Download Highcharts in the specified version and put it + into a directory structure similar to the CDN to support the + installation of multiple versions. + } { + # + # If no version is specified, use the namespaced variable. + # + if {$version eq ""} { + set version ${::highcharts::version} + } + + set resource_info [resource_info -version $version] + ::util::resources::download \ + -resource_info $resource_info \ + -version_dir $version + + set resourceDir [dict get $resource_info resourceDir] + ns_log notice " ::highcharts::download resourceDir $resourceDir" + + # + # Do we have unzip installed? + # + set unzip [::util::which unzip] + if {$unzip eq ""} { + error "can't install Highcharts locally; no unzip program found on PATH" + } + + # + # Do we have a writable output directory under resourceDir? + # + if {![file isdirectory $resourceDir]} { + file mkdir $resourceDir + } + if {![file writable $resourceDir]} { + error "directory $resourceDir is not writable" + } + + # + # So far, everything is fine, unpack the dowloaded zip file + # + foreach url [dict get $resource_info downloadURLs] { + set fn [file tail $url] + util::unzip \ + -overwrite \ + -source $resourceDir/$version/$fn \ + -destination $resourceDir/$version + } + } + + ad_proc -private ::highcharts::register_urns {} { + Register URNs either with local or with CDN URLs. + } { + set resource_info [::highcharts::resource_info] + set prefix [dict get $resource_info prefix] + + if {[dict exists $resource_info cdnHost] && [dict get $resource_info cdnHost] ne ""} { + # + # Settings for the CDN, in case it differs + # + dict set urns urn:ad:js:highcharts $prefix/highcharts.min.js + dict set urns urn:ad:js:highcharts-more $prefix/highcharts-more.min.js + dict set urns urn:ad:js:highcharts/modules/exporting $prefix/modules/exporting.min.js + + } else { + # + # Settings for local installs + # + dict set urns urn:ad:js:highcharts $prefix/highcharts.js + dict set urns urn:ad:js:highcharts-more $prefix/highcharts-more.js + dict set urns urn:ad:js:highcharts/modules/exporting $prefix/modules/exporting.js + } + + foreach {URN resource} $urns { + template::register_urn \ + -urn $URN \ + -resource $resource \ + -csp_list [expr {[dict exists $resource_info cspMap $URN] + ? [dict get $resource_info cspMap $URN] + : ""}] + } + } +} + + +# Local variables: +# mode: tcl +# tcl-indent-level: 4 +# indent-tabs-mode: nil +# End: Index: openacs-4/packages/highcharts/www/sitewide-admin/download.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/highcharts/www/sitewide-admin/download.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/highcharts/www/sitewide-admin/download.tcl 23 Oct 2022 18:41:18 -0000 1.1.2.1 @@ -0,0 +1,16 @@ +ad_page_contract { + @author Gustaf Neumann + + @creation-date Jan 04, 2017 +} { + {version:word,notnull ""} +} + +::highcharts::download -version $version +ad_returnredirect . + +# Local variables: +# mode: tcl +# tcl-indent-level: 4 +# indent-tabs-mode: nil +# End: Index: openacs-4/packages/highcharts/www/sitewide-admin/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/highcharts/www/sitewide-admin/index.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/highcharts/www/sitewide-admin/index.adp 23 Oct 2022 18:41:18 -0000 1.1.2.1 @@ -0,0 +1,11 @@ + +@title;literal@ +@context;literal@ + +

@title;noquote@

+ + + + +

For developer information, look into the Highcharts Manual. +

For a quick test, check the Sample page. Index: openacs-4/packages/highcharts/www/sitewide-admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/highcharts/www/sitewide-admin/index.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/highcharts/www/sitewide-admin/index.tcl 23 Oct 2022 18:41:18 -0000 1.1.2.1 @@ -0,0 +1,19 @@ +ad_page_contract { + @author Gustaf Neumann + + @creation-date Aug 6, 2018 +} { +} + +set version $::highcharts::version +set resource_info [::highcharts::resource_info] +set download_url download + +set title "[dict get $resource_info resourceName] Package - Sitewide Admin" +set context [list $title] + +# Local variables: +# mode: tcl +# tcl-indent-level: 4 +# indent-tabs-mode: nil +# End: Index: openacs-4/packages/highcharts/www/sitewide-admin/sample.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/highcharts/www/sitewide-admin/sample.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/highcharts/www/sitewide-admin/sample.adp 23 Oct 2022 18:41:18 -0000 1.1.2.1 @@ -0,0 +1,14 @@ + +@title;literal@ +@context;literal@ + +

@title;noquote@

+ +
+
+

+ Bubble chart demonstrating a decorative 3D rendering effect using + gradient fills on the bubbles. +

+
+ Index: openacs-4/packages/highcharts/www/sitewide-admin/sample.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/highcharts/www/sitewide-admin/sample.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/highcharts/www/sitewide-admin/sample.tcl 23 Oct 2022 18:41:18 -0000 1.1.2.1 @@ -0,0 +1,167 @@ +ad_page_contract { + Sample page for Highcharts + @author Gustaf Neumann + + @creation-date Oct 23, 2022 +} { +} + +set resource_info [::bootstrap_icons::resource_info] + +set title "Highcharts Sample Page" +set context [list [list "." "Highcharts"] $title] + +# +# Collect generic names +# + +# +# Generic URL for CSS (based on URN) +# +#set CSS_URL urn:ad:css:bootstrap-icons + +template::add_body_script -src urn:ad:js:highcharts +template::add_body_script -src urn:ad:js:highcharts-more +template::add_body_script -src urn:ad:js:highcharts/modules/exporting + +#template::head::add_css -href $CSS_URL + +template::head::add_style -style { + #container { + height: 400px; + } + + .highcharts-figure, + .highcharts-data-table table { + min-width: 310px; + max-width: 800px; + margin: 1em auto; + } + + .highcharts-data-table table { + font-family: Verdana, sans-serif; + border-collapse: collapse; + border: 1px solid #ebebeb; + margin: 10px auto; + text-align: center; + width: 100%; + max-width: 500px; + } + + .highcharts-data-table caption { + padding: 1em 0; + font-size: 1.2em; + color: #555; + } + + .highcharts-data-table th { + font-weight: 600; + padding: 0.5em; + } + + .highcharts-data-table td, + .highcharts-data-table th, + .highcharts-data-table caption { + padding: 0.5em; + } + + .highcharts-data-table thead tr, + .highcharts-data-table tr:nth-child(even) { + background: #f8f8f8; + } + + .highcharts-data-table tr:hover { + background: #f1f7ff; + } +} + +# +# JavaScript +# +template::add_body_script -script { + Highcharts.chart('container', { + + chart: { + type: 'bubble', + plotBorderWidth: 1, + zoomType: 'xy' + }, + + title: { + text: 'Highcharts bubbles with radial gradient fill' + }, + + xAxis: { + gridLineWidth: 1, + accessibility: { + rangeDescription: 'Range: 0 to 100.' + } + }, + + yAxis: { + startOnTick: false, + endOnTick: false, + accessibility: { + rangeDescription: 'Range: 0 to 100.' + } + }, + + series: [{ + data: [ + [9, 81, 63], + [98, 5, 89], + [51, 50, 73], + [41, 22, 14], + [58, 24, 20], + [78, 37, 34], + [55, 56, 53], + [18, 45, 70], + [42, 44, 28], + [3, 52, 59], + [31, 18, 97], + [79, 91, 63], + [93, 23, 23], + [44, 83, 22] + ], + marker: { + fillColor: { + radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 }, + stops: [ + [0, 'rgba(255,255,255,0.5)'], + [1, Highcharts.color(Highcharts.getOptions().colors[0]).setOpacity(0.5).get('rgba')] + ] + } + } + }, { + data: [ + [42, 38, 20], + [6, 18, 1], + [1, 93, 55], + [57, 2, 90], + [80, 76, 22], + [11, 74, 96], + [88, 56, 10], + [30, 47, 49], + [57, 62, 98], + [4, 16, 16], + [46, 10, 11], + [22, 87, 89], + [57, 91, 82], + [45, 15, 98] + ], + marker: { + fillColor: { + radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 }, + stops: [ + [0, 'rgba(255,255,255,0.5)'], + [1, Highcharts.color(Highcharts.getOptions().colors[1]).setOpacity(0.5).get('rgba')] + ] + } + } + }] + + }); +} + + +