diff --git a/jspwiki-plugins/jspwiki-plugins-chartist/pom.xml b/jspwiki-plugins/jspwiki-plugins-chartist/pom.xml new file mode 100644 index 0000000000..a1dd5b5392 --- /dev/null +++ b/jspwiki-plugins/jspwiki-plugins-chartist/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + + org.apache.jspwiki + jspwiki-plugins + 3.0.0-SNAPSHOT + + jspwiki-plugins-chartist + jar + + + ${project.groupId} + jspwiki-main + ${project.version} + provided + + + + \ No newline at end of file diff --git a/jspwiki-plugins/jspwiki-plugins-chartist/readme.txt b/jspwiki-plugins/jspwiki-plugins-chartist/readme.txt new file mode 100644 index 0000000000..934f5de2b1 --- /dev/null +++ b/jspwiki-plugins/jspwiki-plugins-chartist/readme.txt @@ -0,0 +1,68 @@ +!!! How to include this plugin with your jspwiki deployment (using maven) + +If you're building out your infrastructure, maven can help. + +You probably have a project that includes the jspwiki war file as a dependency. + +All that's needed to add a dependency for this library. + + + org.apache.jspwiki + jspwiki-plugins-chartist + LATEST + + +Then build as normal. + +!!! How to include this plugin with your jspwiki deployment (without maven) + +Download the jspwiki chartist-plugin jar file. +Add it to ./webapps/jspwiki/WEB-INF/lib, replace "jspwiki" with your context path. +Restart the server. + +!!! Removing the plugin from your jspwiki deployment. + +Just delete the file from ./WEB-INF/lib/jspwiki-plugins-chartist-VERSION.jar +and restart the server. + +!!! Upgrading + +New version? just replace the old jar file with the new one, then restart the server. + +!!! Usage + +Edit a wiki page. Then include the chartist plugin. Only one instance is required per wiki page. + + [{org.apache.jspwiki.plugins.chartist.ChartistPlugin}] + +Then insert the chart anywhere you need it. Copy inbetween example-start and example-end. +Note: when copy and pasting, the plain text editor will auto wrap the text in {{{ and }}}. +You'll need to remove those. In addition, the plugin reference may get an extra '['. Remove that too. + +example-start + +%%chartist-line { + high: 15, + low: -5 +} +|| Monday || Tuesday || Wednesday || Thursday || Friday +| 12| 9 | 7 | 8 | 5 +| 2 | 1 | 3.5| 7 | 3 +| 1 | 3 | 4 | 5 | 6 +/% + +example-end + +Then save the page. Hopefully a chart will render. If it does not, check the browser console for potential clues. + +!!! Maintenance notes + +Currently, this is at chartist v1.5.0. +sourced Dec 2025 by pulling the webjar, then extracting +the umd.js and css files and placing in the src/main/resources/META-INF/chartist-plugin + +The webjar, at this point in time, has a directory with a "." as a path, which is strange. +This caused the java compiled to to complain, otherwise the webjar is the way to go. + +Chartist is MIT licensed. + diff --git a/jspwiki-plugins/jspwiki-plugins-chartist/src/main/java/org/apache/jspwiki/plugins/chartist/ChartistPlugin.java b/jspwiki-plugins/jspwiki-plugins-chartist/src/main/java/org/apache/jspwiki/plugins/chartist/ChartistPlugin.java new file mode 100644 index 0000000000..5d8ec00aab --- /dev/null +++ b/jspwiki-plugins/jspwiki-plugins-chartist/src/main/java/org/apache/jspwiki/plugins/chartist/ChartistPlugin.java @@ -0,0 +1,82 @@ +/* + * Copyright 2025 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jspwiki.plugins.chartist; + +import java.util.Locale; +import java.util.Map; +import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.exceptions.PluginException; +import org.apache.wiki.api.plugin.Plugin; + +/** + * Chartlist-js plugin for JSPWiki. + * + * See readme for deployment and usage guide. + * @since 3.0.0 + */ +public class ChartistPlugin implements Plugin { + + @Override + public String execute(Context context, Map params) throws PluginException { + StringBuilder sb = new StringBuilder(); + sb.append(""" + + + + """); + // + // + + return sb.toString(); + } + + @Override + public String getSnipExample() { + return Plugin.super.getSnipExample(); + } + + @Override + public String getDisplayName(Locale locale) { + return Plugin.super.getDisplayName(locale); + } +} + diff --git a/jspwiki-plugins/jspwiki-plugins-chartist/src/main/resources/META-INF/resources/chartist-plugin/Wiki.Chartist.Behavior.js b/jspwiki-plugins/jspwiki-plugins-chartist/src/main/resources/META-INF/resources/chartist-plugin/Wiki.Chartist.Behavior.js new file mode 100644 index 0000000000..5658223c22 --- /dev/null +++ b/jspwiki-plugins/jspwiki-plugins-chartist/src/main/resources/META-INF/resources/chartist-plugin/Wiki.Chartist.Behavior.js @@ -0,0 +1,236 @@ +/* + * Copyright 2025 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var ChartistChart = new Class({ + + Implements: Options, + + options: { + container: "chartist-line" //classname of container + }, + + initialize: function(el, options){ + + + var self = this, + args = el.className, + bars, data, i, len, table, clazz; + + self.setOptions(options); + + clazz = this.options.container; + + this.render(); + }, + + getArguments: function( args ){ + + var options = this.options; + return options; + }, + + + /* + Function: render + Render a graphBar and add it before or inside the element. + Arguments: + el - element + val - converted value in range 0-100, + percent - position of the graphBar in the group, converted to a % + DOM Structure of a graphbar + (start code) + span.graphBar-Group[style="width=..px"] + span.graphBar[style="width=..%,background-color=.."] + span.graphBar[style="width=..%,background-color=.."] //only for progress bars + (end) + */ + render: function(el, val, percent){ + console.debug("looking for charts to build"); + var css_selector = '[class^=chartist]'; + const matches = document.querySelectorAll(css_selector); + console.debug("found " + matches.length + " charts to build"); + for (var i=0; i < matches.length; i++) { + this.chartist_behavior(matches[i]); + }; + + + }, + chartist_behavior: function (element) { + var type = element.className.split('-')[1] || 'line', // line or bar or pie + //var type = chartistClass.sliceArgs(element)[0] || "line", // line or bar or pie + options = this.grabOptions( + element, + 'span.chartist-options' + ), //default display:none + data, + el; + + type = type.capitalize(); + + if (type.match(/Line|Bar|Pie/)) { + console.info("chartifying element "); + console.debug(element); + + + var pageContent = element.querySelector('.wikitable'); + if (null===pageContent) { + pageContent = element.parentElement.parentElement; + //iterate until we find 'element', then get the next table element + var x=0; + var found=false; + for (x=0; x < pageContent.children.length; x++) { + var p = pageContent.children[x]; + //this should be a "p" element. + for (var j=0; j < p.children.length; j++) { + if (p.children[j] === element) { + found = true; + break; + } + } + if (found) break; + } + + if (found) { + element = pageContent.children[x+1]; + //this should be the next "p" containing the table. + } else { + console.warn("failed to locate the table for " + element); + return; + } + } else { + element = pageContent; + } + + data = this.getTableData(element); + var table = element; + if (data) { + console.debug("got table data " + type); + console.debug(data); + el = ['div', ['div.ct-chart.ct-golden-section']] + .slick() + .inject(table, 'after'); + + table.addClass('chartist-table'); //default display:none; + + if (type == 'Pie') { + data.series = data.series[0]; + } + //Chartist(el.getFirst(), data, { type: type }, + //Wiki.evalOptions(options, data.labels, data.series)) + + new Chartist[type + "Chart"]( + el.getFirst(), + data, + this.evalOptions(options, data.labels, data.series) + ); + } else { + console.warn("no data returned for chart, skipping"); + } + + } else { + console.warn("skipping element as the type " + type + " doesn't match anything i currently process"); + } + }, + /* +Function: grabOptions + Read the chartist options, and encapsulate it in a hidden container dom element +*/ + grabOptions: function (element, container) { + var el, + fragment = new DocumentFragment(); + + while ((el = element.firstChild) && el.nodeType == 3) { + fragment.appendChild(el); + } + + fragment = fragment.textContent.trim(); + + if (fragment != '') { + container.slick({ text: fragment }).inject(element, 'top'); + } + return fragment; + }, + + /* +Function: evalOptions + Validate and parse the options string, into a regular javascript object +*/ + evalOptions: function (options, labels, series) { + if (options != '') { + try { + return Function( + 'labels', + 'series', + 'return ' + options + )(labels, series); // jshint ignore:line + } catch (err) { + console.log('Options eval err', err, options); + return null; + } + } + }, + + /* +Function: getTableData + Parse regular html table, and collect the LABELS and SERIES data-sets. +*/ + getTableData: function (table) { + var rows = table.rows, + tlen = rows.length, + i, + j, + row, + rlen, + labels = undefined, + series = []; + + for (i = 0; i < tlen; i++) { + row = Array.from(rows[i].cells); + rlen = row.length; + + if (row[0].tagName.test(/TH/i)) { + //get LABELS + labels = []; + for (j = 0; j < rlen; j++) { + labels[j] = row[j].innerHTML; + } + } else { + //get SERIES ; convert to numbers + for (j = 0; j < rlen; j++) { + row[j] = +row[j].textContent; + } + series.push(row); + } + } + console.debug("chart data returned was " + series); + return series[0] ? { labels: labels, series: series } : null; + } +}); + +Wiki.add( ".chartist-line", function( element ){ + new ChartistChart( ( element ), { + container: element + }); +}) +Wiki.add( ".chartist-bar", function( element ){ + new ChartistChart( ( element ), { + container: element + }); +}) +Wiki.add( ".chartist-pie", function( element ){ + new ChartistChart( ( element ), { + container: element + }); +}) \ No newline at end of file diff --git a/jspwiki-plugins/jspwiki-plugins-chartist/src/main/resources/META-INF/resources/chartist-plugin/index.css b/jspwiki-plugins/jspwiki-plugins-chartist/src/main/resources/META-INF/resources/chartist-plugin/index.css new file mode 100644 index 0000000000..1eb48b9d32 --- /dev/null +++ b/jspwiki-plugins/jspwiki-plugins-chartist/src/main/resources/META-INF/resources/chartist-plugin/index.css @@ -0,0 +1,2 @@ +.ct-label{fill:rgba(0,0,0,.4);color:rgba(0,0,0,.4);font-size:.75rem;line-height:1}.ct-chart-bar .ct-label,.ct-chart-line .ct-label{display:flex}.ct-chart-donut .ct-label,.ct-chart-pie .ct-label{dominant-baseline:central}.ct-label.ct-horizontal.ct-start{align-items:flex-end;justify-content:flex-start;text-align:left}.ct-label.ct-horizontal.ct-end{align-items:flex-start;justify-content:flex-start;text-align:left}.ct-label.ct-vertical.ct-start{align-items:flex-end;justify-content:flex-end;text-align:right}.ct-label.ct-vertical.ct-end{align-items:flex-end;justify-content:flex-start;text-align:left}.ct-chart-bar .ct-label.ct-horizontal.ct-start{align-items:flex-end;justify-content:center;text-align:center}.ct-chart-bar .ct-label.ct-horizontal.ct-end{align-items:flex-start;justify-content:center;text-align:center}.ct-chart-bar.ct-horizontal-bars .ct-label.ct-horizontal.ct-start{align-items:flex-end;justify-content:flex-start;text-align:left}.ct-chart-bar.ct-horizontal-bars .ct-label.ct-horizontal.ct-end{align-items:flex-start;justify-content:flex-start;text-align:left}.ct-chart-bar.ct-horizontal-bars .ct-label.ct-vertical.ct-start{align-items:center;justify-content:flex-end;text-align:right}.ct-chart-bar.ct-horizontal-bars .ct-label.ct-vertical.ct-end{align-items:center;justify-content:flex-start;text-align:left}.ct-grid{stroke:rgba(0,0,0,.2);stroke-width:1px;stroke-dasharray:2px}.ct-grid-background{fill:none}.ct-point{stroke-width:10px;stroke-linecap:round}.ct-line{fill:none;stroke-width:4px}.ct-area{stroke:none;fill-opacity:.1}.ct-bar{fill:none;stroke-width:10px}.ct-slice-donut{fill:none;stroke-width:60px}.ct-series-a .ct-bar,.ct-series-a .ct-line,.ct-series-a .ct-point,.ct-series-a .ct-slice-donut{stroke:#d70206}.ct-series-a .ct-area,.ct-series-a .ct-slice-pie{fill:#d70206}.ct-series-b .ct-bar,.ct-series-b .ct-line,.ct-series-b .ct-point,.ct-series-b .ct-slice-donut{stroke:#f05b4f}.ct-series-b .ct-area,.ct-series-b .ct-slice-pie{fill:#f05b4f}.ct-series-c .ct-bar,.ct-series-c .ct-line,.ct-series-c .ct-point,.ct-series-c .ct-slice-donut{stroke:#f4c63d}.ct-series-c .ct-area,.ct-series-c .ct-slice-pie{fill:#f4c63d}.ct-series-d .ct-bar,.ct-series-d .ct-line,.ct-series-d .ct-point,.ct-series-d .ct-slice-donut{stroke:#d17905}.ct-series-d .ct-area,.ct-series-d .ct-slice-pie{fill:#d17905}.ct-series-e .ct-bar,.ct-series-e .ct-line,.ct-series-e .ct-point,.ct-series-e .ct-slice-donut{stroke:#453d3f}.ct-series-e .ct-area,.ct-series-e .ct-slice-pie{fill:#453d3f}.ct-series-f .ct-bar,.ct-series-f .ct-line,.ct-series-f .ct-point,.ct-series-f .ct-slice-donut{stroke:#59922b}.ct-series-f .ct-area,.ct-series-f .ct-slice-pie{fill:#59922b}.ct-series-g .ct-bar,.ct-series-g .ct-line,.ct-series-g .ct-point,.ct-series-g .ct-slice-donut{stroke:#0544d3}.ct-series-g .ct-area,.ct-series-g .ct-slice-pie{fill:#0544d3}.ct-series-h .ct-bar,.ct-series-h .ct-line,.ct-series-h .ct-point,.ct-series-h .ct-slice-donut{stroke:#6b0392}.ct-series-h .ct-area,.ct-series-h .ct-slice-pie{fill:#6b0392}.ct-series-i .ct-bar,.ct-series-i .ct-line,.ct-series-i .ct-point,.ct-series-i .ct-slice-donut{stroke:#e6805e}.ct-series-i .ct-area,.ct-series-i .ct-slice-pie{fill:#e6805e}.ct-series-j .ct-bar,.ct-series-j .ct-line,.ct-series-j .ct-point,.ct-series-j .ct-slice-donut{stroke:#dda458}.ct-series-j .ct-area,.ct-series-j .ct-slice-pie{fill:#dda458}.ct-series-k .ct-bar,.ct-series-k .ct-line,.ct-series-k .ct-point,.ct-series-k .ct-slice-donut{stroke:#eacf7d}.ct-series-k .ct-area,.ct-series-k .ct-slice-pie{fill:#eacf7d}.ct-series-l .ct-bar,.ct-series-l .ct-line,.ct-series-l .ct-point,.ct-series-l .ct-slice-donut{stroke:#86797d}.ct-series-l .ct-area,.ct-series-l .ct-slice-pie{fill:#86797d}.ct-series-m .ct-bar,.ct-series-m .ct-line,.ct-series-m .ct-point,.ct-series-m .ct-slice-donut{stroke:#b2c326}.ct-series-m .ct-area,.ct-series-m .ct-slice-pie{fill:#b2c326}.ct-series-n .ct-bar,.ct-series-n .ct-line,.ct-series-n .ct-point,.ct-series-n .ct-slice-donut{stroke:#6188e2}.ct-series-n .ct-area,.ct-series-n .ct-slice-pie{fill:#6188e2}.ct-series-o .ct-bar,.ct-series-o .ct-line,.ct-series-o .ct-point,.ct-series-o .ct-slice-donut{stroke:#a748ca}.ct-series-o .ct-area,.ct-series-o .ct-slice-pie{fill:#a748ca}.ct-square{display:block;position:relative;width:100%}.ct-square:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:100%}.ct-square:after{content:"";display:table;clear:both}.ct-square>svg{display:block;position:absolute;top:0;left:0}.ct-minor-second{display:block;position:relative;width:100%}.ct-minor-second:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:93.75%}.ct-minor-second:after{content:"";display:table;clear:both}.ct-minor-second>svg{display:block;position:absolute;top:0;left:0}.ct-major-second{display:block;position:relative;width:100%}.ct-major-second:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:88.8888888889%}.ct-major-second:after{content:"";display:table;clear:both}.ct-major-second>svg{display:block;position:absolute;top:0;left:0}.ct-minor-third{display:block;position:relative;width:100%}.ct-minor-third:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:83.3333333333%}.ct-minor-third:after{content:"";display:table;clear:both}.ct-minor-third>svg{display:block;position:absolute;top:0;left:0}.ct-major-third{display:block;position:relative;width:100%}.ct-major-third:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:80%}.ct-major-third:after{content:"";display:table;clear:both}.ct-major-third>svg{display:block;position:absolute;top:0;left:0}.ct-perfect-fourth{display:block;position:relative;width:100%}.ct-perfect-fourth:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:75%}.ct-perfect-fourth:after{content:"";display:table;clear:both}.ct-perfect-fourth>svg{display:block;position:absolute;top:0;left:0}.ct-perfect-fifth{display:block;position:relative;width:100%}.ct-perfect-fifth:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:66.6666666667%}.ct-perfect-fifth:after{content:"";display:table;clear:both}.ct-perfect-fifth>svg{display:block;position:absolute;top:0;left:0}.ct-minor-sixth{display:block;position:relative;width:100%}.ct-minor-sixth:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:62.5%}.ct-minor-sixth:after{content:"";display:table;clear:both}.ct-minor-sixth>svg{display:block;position:absolute;top:0;left:0}.ct-golden-section{display:block;position:relative;width:100%}.ct-golden-section:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:61.804697157%}.ct-golden-section:after{content:"";display:table;clear:both}.ct-golden-section>svg{display:block;position:absolute;top:0;left:0}.ct-major-sixth{display:block;position:relative;width:100%}.ct-major-sixth:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:60%}.ct-major-sixth:after{content:"";display:table;clear:both}.ct-major-sixth>svg{display:block;position:absolute;top:0;left:0}.ct-minor-seventh{display:block;position:relative;width:100%}.ct-minor-seventh:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:56.25%}.ct-minor-seventh:after{content:"";display:table;clear:both}.ct-minor-seventh>svg{display:block;position:absolute;top:0;left:0}.ct-major-seventh{display:block;position:relative;width:100%}.ct-major-seventh:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:53.3333333333%}.ct-major-seventh:after{content:"";display:table;clear:both}.ct-major-seventh>svg{display:block;position:absolute;top:0;left:0}.ct-octave{display:block;position:relative;width:100%}.ct-octave:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:50%}.ct-octave:after{content:"";display:table;clear:both}.ct-octave>svg{display:block;position:absolute;top:0;left:0}.ct-major-tenth{display:block;position:relative;width:100%}.ct-major-tenth:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:40%}.ct-major-tenth:after{content:"";display:table;clear:both}.ct-major-tenth>svg{display:block;position:absolute;top:0;left:0}.ct-major-eleventh{display:block;position:relative;width:100%}.ct-major-eleventh:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:37.5%}.ct-major-eleventh:after{content:"";display:table;clear:both}.ct-major-eleventh>svg{display:block;position:absolute;top:0;left:0}.ct-major-twelfth{display:block;position:relative;width:100%}.ct-major-twelfth:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:33.3333333333%}.ct-major-twelfth:after{content:"";display:table;clear:both}.ct-major-twelfth>svg{display:block;position:absolute;top:0;left:0}.ct-double-octave{display:block;position:relative;width:100%}.ct-double-octave:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:25%}.ct-double-octave:after{content:"";display:table;clear:both}.ct-double-octave>svg{display:block;position:absolute;top:0;left:0} +/*# sourceMappingURL=index.css.map */ \ No newline at end of file diff --git a/jspwiki-plugins/jspwiki-plugins-chartist/src/main/resources/META-INF/resources/chartist-plugin/index.umd.js b/jspwiki-plugins/jspwiki-plugins-chartist/src/main/resources/META-INF/resources/chartist-plugin/index.umd.js new file mode 100644 index 0000000000..af2d3c1692 --- /dev/null +++ b/jspwiki-plugins/jspwiki-plugins-chartist/src/main/resources/META-INF/resources/chartist-plugin/index.umd.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Chartist={})}(this,(function(e){"use strict";const t={svg:"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/xmlns/",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",ct:"http://gionkunz.github.com/chartist-js/ct"},s={"&":"&","<":"<",">":">",'"':""","'":"'"};function i(e,t){return"number"==typeof e?e+t:e}function n(e){if("string"==typeof e){const t=/^(\d+)\s*(.*)$/g.exec(e);return{value:t?+t[1]:0,unit:(null==t?void 0:t[2])||void 0}}return{value:Number(e)}}function r(e){return String.fromCharCode(97+e%26)}const a=2221e-19;function o(e){return Math.floor(Math.log(Math.abs(e))/Math.LN10)}function l(e,t,s){return t/s.range*e}function h(e,t){const s=Math.pow(10,t||8);return Math.round(e*s)/s}function c(e){if(1===e)return e;function t(e,s){return e%s==0?s:t(s,e%s)}function s(e){return e*e+1}let i,n=2,r=2;if(e%2==0)return 2;do{n=s(n)%e,r=s(s(r))%e,i=t(Math.abs(n-r),e)}while(1===i);return i}function u(e,t,s,i){const n=(i-90)*Math.PI/180;return{x:e+s*Math.cos(n),y:t+s*Math.sin(n)}}function d(e,t,s){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const n={high:t.high,low:t.low,valueRange:0,oom:0,step:0,min:0,max:0,range:0,numberOfSteps:0,values:[]};n.valueRange=n.high-n.low,n.oom=o(n.valueRange),n.step=Math.pow(10,n.oom),n.min=Math.floor(n.low/n.step)*n.step,n.max=Math.ceil(n.high/n.step)*n.step,n.range=n.max-n.min,n.numberOfSteps=Math.round(n.range/n.step);const r=l(e,n.step,n),u=r=s)n.step=1;else if(i&&d=s)n.step=d;else{let t=0;for(;;){if(u&&l(e,n.step,n)<=s)n.step*=2;else{if(u||!(l(e,n.step/2,n)>=s))break;if(n.step/=2,i&&n.step%1!=0){n.step*=2;break}}if(t++>1e3)throw new Error("Exceeded maximum number of iterations while optimizing scale step!")}}function m(e,t){return e===(e+=t)&&(e*=1+(t>0?a:-a)),e}n.step=Math.max(n.step,a);let p=n.min,f=n.max;for(;p+n.step<=n.low;)p=m(p,n.step);for(;f-n.step>=n.high;)f=m(f,-n.step);n.min=p,n.max=f,n.range=n.max-n.min;const g=[];for(let e=n.min;e<=n.max;e=m(e,n.step)){const t=h(e);t!==g[g.length-1]&&g.push(t)}return n.values=g,n}function m(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t=arguments.length,s=new Array(t>1?t-1:0),i=1;ie;function f(e,t){return Array.from({length:e},t?(e,s)=>t(s):()=>{})}const g=(e,t)=>e+(t||0),x=(e,t)=>f(Math.max(...e.map((e=>e.length))),(s=>t(...e.map((e=>e[s])))));function v(e,t){return null!==e&&"object"==typeof e&&Reflect.has(e,t)}function y(e){return null!==e&&isFinite(e)}function w(e){return!e&&0!==e}function b(e){return y(e)?Number(e):void 0}function E(e){return!!Array.isArray(e)&&e.every(Array.isArray)}function A(e,t){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=0;e[s?"reduceRight":"reduce"](((e,s,n)=>t(s,i++,n)),void 0)}function M(e,t){const s=Array.isArray(e)?e[t]:v(e,"data")?e.data[t]:null;return v(s,"meta")?s.meta:void 0}function N(e){return null==e||"number"==typeof e&&isNaN(e)}function C(e){return Array.isArray(e)&&e.every((e=>Array.isArray(e)||v(e,"data")))}function O(e){return"object"==typeof e&&null!==e&&(Reflect.has(e,"x")||Reflect.has(e,"y"))}function L(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y";return O(e)&&v(e,t)?b(e[t]):b(e)}function S(e,t,s){const i={high:void 0===(t={...t,...s?"x"===s?t.axisX:t.axisY:{}}).high?-Number.MAX_VALUE:+t.high,low:void 0===t.low?Number.MAX_VALUE:+t.low},n=void 0===t.high,r=void 0===t.low;return(n||r)&&function e(t){if(!N(t))if(Array.isArray(t))for(let s=0;si.high&&(i.high=e),r&&e0||(i.high=1),i.low=0)),i}function B(e){let t,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0;const r={labels:(e.labels||[]).slice(),series:z(e.series,i,n)},a=r.labels.length;return E(r.series)?(t=Math.max(a,...r.series.map((e=>e.length))),r.series.forEach((e=>{e.push(...f(Math.max(0,t-e.length)))}))):t=r.series.length,r.labels.push(...f(Math.max(0,t-a),(()=>""))),s&&k(r),r}function k(e){var t;null===(t=e.labels)||void 0===t||t.reverse(),e.series.reverse();for(const t of e.series)v(t,"data")?t.data.reverse():Array.isArray(t)&&t.reverse()}function _(e,t){if(!N(e))return t?function(e,t){let s,i;if("object"!=typeof e){const n=b(e);"x"===t?s=n:i=n}else v(e,"x")&&(s=b(e.x)),v(e,"y")&&(i=b(e.y));if(void 0!==s||void 0!==i)return{x:s,y:i}}(e,t):b(e)}function j(e,t){return Array.isArray(e)?e.map((e=>v(e,"value")?_(e.value,t):_(e,t))):j(e.data,t)}function z(e,t,s){if(C(e))return e.map((e=>j(e,t)));const i=j(e,t);return s?i.map((e=>[e])):i}function I(e,t,s){const i={increasingX:!1,fillHoles:!1,...s},n=[];let r=!0;for(let s=0;s=2&&e[s]<=e[s-2]&&(r=!0),r&&(n.push({pathCoordinates:[],valueData:[]}),r=!1),n[n.length-1].pathCoordinates.push(e[s],e[s+1]),n[n.length-1].valueData.push(t[s/2]));return n}function P(e){let t="";return null==e?e:(t="number"==typeof e?""+e:"object"==typeof e?JSON.stringify({data:e}):String(e),Object.keys(s).reduce(((e,t)=>e.replaceAll(t,s[t])),t))}class X{call(e,t){return this.svgElements.forEach((s=>Reflect.apply(s[e],s,t))),this}attr(){for(var e=arguments.length,t=new Array(e),s=0;s3&&void 0!==arguments[3]&&arguments[3],a=arguments.length>4?arguments[4]:void 0;const{easing:o,...l}=s,h={};let c,u;o&&(c=Array.isArray(o)?o:V[o]),l.begin=i(l.begin,"ms"),l.dur=i(l.dur,"ms"),c&&(l.calcMode="spline",l.keySplines=c.join(" "),l.keyTimes="0;1"),r&&(l.fill="freeze",h[t]=l.from,e.attr(h),u=n(l.begin||0).value,l.begin="indefinite");const d=e.elem("animate",{attributeName:t,...l});r&&setTimeout((()=>{try{d._node.beginElement()}catch(s){h[t]=l.to,e.attr(h),d.remove()}}),u);const m=d.getNode();a&&m.addEventListener("beginEvent",(()=>a.emit("animationBegin",{element:e,animate:m,params:s}))),m.addEventListener("endEvent",(()=>{a&&a.emit("animationEnd",{element:e,animate:m,params:s}),r&&(h[t]=l.to,e.attr(h),d.remove())}))}class R{attr(e,s){return"string"==typeof e?s?this._node.getAttributeNS(s,e):this._node.getAttribute(e):(Object.keys(e).forEach((s=>{if(void 0!==e[s])if(-1!==s.indexOf(":")){const i=s.split(":");this._node.setAttributeNS(t[i[0]],s,String(e[s]))}else this._node.setAttribute(s,String(e[s]))})),this)}elem(e,t,s){return new R(e,t,s,this,arguments.length>3&&void 0!==arguments[3]&&arguments[3])}parent(){return this._node.parentNode instanceof SVGElement?new R(this._node.parentNode):null}root(){let e=this._node;for(;"svg"!==e.nodeName&&e.parentElement;)e=e.parentElement;return new R(e)}querySelector(e){const t=this._node.querySelector(e);return t?new R(t):null}querySelectorAll(e){const t=this._node.querySelectorAll(e);return new X(t)}getNode(){return this._node}foreignObject(e,s,i){let n,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("string"==typeof e){const t=document.createElement("div");t.innerHTML=e,n=t.firstChild}else n=e;n instanceof Element&&n.setAttribute("xmlns",t.xmlns);const a=this.elem("foreignObject",s,i,r);return a._node.appendChild(n),a}text(e){return this._node.appendChild(document.createTextNode(e)),this}empty(){for(;this._node.firstChild;)this._node.removeChild(this._node.firstChild);return this}remove(){var e;return null===(e=this._node.parentNode)||void 0===e||e.removeChild(this._node),this.parent()}replace(e){var t;return null===(t=this._node.parentNode)||void 0===t||t.replaceChild(e._node,this._node),e}append(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&this._node.firstChild?this._node.insertBefore(e._node,this._node.firstChild):this._node.appendChild(e._node),this}classes(){const e=this._node.getAttribute("class");return e?e.trim().split(/\s+/):[]}addClass(e){return this._node.setAttribute("class",this.classes().concat(e.trim().split(/\s+/)).filter((function(e,t,s){return s.indexOf(e)===t})).join(" ")),this}removeClass(e){const t=e.trim().split(/\s+/);return this._node.setAttribute("class",this.classes().filter((e=>-1===t.indexOf(e))).join(" ")),this}removeAllClasses(){return this._node.setAttribute("class",""),this}height(){return this._node.clientHeight}width(){return this._node.clientWidth}animate(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s=arguments.length>2?arguments[2]:void 0;return Object.keys(e).forEach((i=>{const n=e[i];Array.isArray(n)?n.forEach((e=>Y(this,i,e,!1,s))):Y(this,i,n,t,s)})),this}constructor(e,s,i,n,r=!1){e instanceof Element?this._node=e:(this._node=document.createElementNS(t.svg,e),"svg"===e&&this.attr({"xmlns:ct":t.ct})),s&&this.attr(s),i&&this.addClass(i),n&&(r&&n._node.firstChild?n._node.insertBefore(this._node,n._node.firstChild):n._node.appendChild(this._node))}}function G(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"100%",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"100%",n=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;if(!e)throw new Error("Container element is not found");Array.from(e.querySelectorAll("svg")).filter((e=>e.getAttributeNS(t.xmlns,"ct"))).forEach((t=>e.removeChild(t)));const a=new R("svg").attr({width:s,height:i}).attr({style:"width: ".concat(s,"; height: ").concat(i,";")});return n&&a.addClass(n),r&&a.attr({viewBox:"0 0 ".concat(r.width," ").concat(r.height)}),e.appendChild(a.getNode()),a}function D(e){return"number"==typeof e?{top:e,right:e,bottom:e,left:e}:void 0===e?{top:0,right:0,bottom:0,left:0}:{top:"number"==typeof e.top?e.top:0,right:"number"==typeof e.right?e.right:0,bottom:"number"==typeof e.bottom?e.bottom:0,left:"number"==typeof e.left?e.left:0}}function U(e,t){var s,i,r,a,o,l;const h=Boolean(t.axisX||t.axisY),c=(null===(s=t.axisY)||void 0===s?void 0:s.offset)||0,u=(null===(i=t.axisX)||void 0===i?void 0:i.offset)||0,d=null===(r=t.axisY)||void 0===r?void 0:r.position,m=null===(a=t.axisX)||void 0===a?void 0:a.position;let p=(null===(o=t.viewBox)||void 0===o?void 0:o.width)||e.width()||n(t.width).value||0,f=(null===(l=t.viewBox)||void 0===l?void 0:l.height)||e.height()||n(t.height).value||0;const g=D(t.chartPadding);p=Math.max(p,c+g.left+g.right),f=Math.max(f,u+g.top+g.bottom);const x={x1:0,x2:0,y1:0,y2:0,padding:g,width(){return this.x2-this.x1},height(){return this.y1-this.y2}};return h?("start"===m?(x.y2=g.top+u,x.y1=Math.max(f-g.bottom,x.y2+1)):(x.y2=g.top,x.y1=Math.max(f-g.bottom-u,x.y2+1)),"start"===d?(x.x1=g.left+c,x.x2=Math.max(p-g.right,x.x1+1)):(x.x1=g.left,x.x2=Math.max(p-g.right-c,x.x1+1))):(x.x1=g.left,x.x2=Math.max(p-g.right,x.x1+1),x.y2=g.top,x.y1=Math.max(f-g.bottom,x.y2+1)),x}function H(e,t,s,i,n,r,a,o){const l={["".concat(s.units.pos,"1")]:e,["".concat(s.units.pos,"2")]:e,["".concat(s.counterUnits.pos,"1")]:i,["".concat(s.counterUnits.pos,"2")]:i+n},h=r.elem("line",l,a.join(" "));o.emit("draw",{type:"grid",axis:s,index:t,group:r,element:h,...l})}function T(e,t,s,i){const n=e.elem("rect",{x:t.x1,y:t.y2,width:t.width(),height:t.height()},s,!0);i.emit("draw",{type:"gridBackground",group:e,element:n})}function Q(e,t,s,i,n,r,a,o,l,h){const c={[n.units.pos]:e+a[n.units.pos],[n.counterUnits.pos]:a[n.counterUnits.pos],[n.units.len]:t,[n.counterUnits.len]:Math.max(0,r-10)},u=Math.round(c[n.units.len]),d=Math.round(c[n.counterUnits.len]),m=document.createElement("span");m.className=l.join(" "),m.style[n.units.len]=u+"px",m.style[n.counterUnits.len]=d+"px",m.textContent=String(i);const p=o.foreignObject(m,{style:"overflow: visible;",...c});h.emit("draw",{type:"label",axis:n,index:s,group:o,element:p,text:i,...c})}function F(e,t,s){let i;const n=[];function r(n){const r=i;i=m({},e),t&&t.forEach((e=>{window.matchMedia(e[0]).matches&&(i=m({},i,e[1]))})),s&&n&&s.emit("optionsChanged",{previousOptions:r,currentOptions:i})}if(!window.matchMedia)throw new Error("window.matchMedia not found! Make sure you're using a polyfill.");return t&&t.forEach((e=>{const t=window.matchMedia(e[0]);t.addEventListener("change",r),n.push(t)})),r(),{removeMediaQueryListeners:function(){n.forEach((e=>e.removeEventListener("change",r)))},getCurrentOptions:()=>i}}R.Easing=V;const q={m:["x","y"],l:["x","y"],c:["x1","y1","x2","y2","x","y"],a:["rx","ry","xAr","lAf","sf","x","y"]},W={accuracy:3};function Z(e,t,s,i,n,r){const a={command:n?e.toLowerCase():e.toUpperCase(),...t,...r?{data:r}:{}};s.splice(i,0,a)}function $(e,t){e.forEach(((s,i)=>{q[s.command.toLowerCase()].forEach(((n,r)=>{t(s,n,i,r,e)}))}))}class J{static join(e){const t=new J(arguments.length>1&&void 0!==arguments[1]&&arguments[1],arguments.length>2?arguments[2]:void 0);for(let s=0;s2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0;return Z("M",{x:+e,y:+t},this.pathElements,this.pos++,s,i),this}line(e,t){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0;return Z("L",{x:+e,y:+t},this.pathElements,this.pos++,s,i),this}curve(e,t,s,i,n,r){let a=arguments.length>6&&void 0!==arguments[6]&&arguments[6],o=arguments.length>7?arguments[7]:void 0;return Z("C",{x1:+e,y1:+t,x2:+s,y2:+i,x:+n,y:+r},this.pathElements,this.pos++,a,o),this}arc(e,t,s,i,n,r,a){let o=arguments.length>7&&void 0!==arguments[7]&&arguments[7],l=arguments.length>8?arguments[8]:void 0;return Z("A",{rx:e,ry:t,xAr:s,lAf:i,sf:n,x:r,y:a},this.pathElements,this.pos++,o,l),this}parse(e){const t=e.replace(/([A-Za-z])(-?[0-9])/g,"$1 $2").replace(/([0-9])([A-Za-z])/g,"$1 $2").split(/[\s,]+/).reduce(((e,t)=>(t.match(/[A-Za-z]/)&&e.push([]),e[e.length-1].push(t),e)),[]);"Z"===t[t.length-1][0].toUpperCase()&&t.pop();const s=t.map((e=>{const t=e.shift(),s=q[t.toLowerCase()];return{command:t,...s.reduce(((t,s,i)=>(t[s]=+e[i],t)),{})}}));return this.pathElements.splice(this.pos,0,...s),this.pos+=s.length,this}stringify(){const e=Math.pow(10,this.options.accuracy);return this.pathElements.reduce(((t,s)=>{const i=q[s.command.toLowerCase()].map((t=>{const i=s[t];return this.options.accuracy?Math.round(i*e)/e:i}));return t+s.command+i.join(",")}),"")+(this.close?"Z":"")}scale(e,t){return $(this.pathElements,((s,i)=>{s[i]*="x"===i[0]?e:t})),this}translate(e,t){return $(this.pathElements,((s,i)=>{s[i]+="x"===i[0]?e:t})),this}transform(e){return $(this.pathElements,((t,s,i,n,r)=>{const a=e(t,s,i,n,r);(a||0===a)&&(t[s]=a)})),this}clone(){const e=new J(arguments.length>0&&void 0!==arguments[0]&&arguments[0]||this.close);return e.pos=this.pos,e.pathElements=this.pathElements.slice().map((e=>({...e}))),e.options={...this.options},e}splitByCommand(e){const t=[new J];return this.pathElements.forEach((s=>{s.command===e.toUpperCase()&&0!==t[t.length-1].pathElements.length&&t.push(new J),t[t.length-1].pathElements.push(s)})),t}constructor(e=!1,t){this.close=e,this.pathElements=[],this.pos=0,this.options={...W,...t}}}function K(e){const t={fillHoles:!1,...e};return function(e,s){const i=new J;let n=!0;for(let r=0;r1)return J.join(n.map((t=>e(t.pathCoordinates,t.valueData))));{if(s=n[0].pathCoordinates,i=n[0].valueData,s.length<=4)return K()(s,i);const e=[],t=[],r=s.length/2,a=[],o=[],l=[],h=[];for(let i=0;i0!=o[e]>0?a[e]=0:(a[e]=3*(h[e-1]+h[e])/((2*h[e]+h[e-1])/o[e-1]+(h[e]+2*h[e-1])/o[e]),isFinite(a[e])||(a[e]=0));const c=(new J).move(e[0],t[0],!1,i[0]);for(let s=0;s1)return J.join(a.map((t=>e(t.pathCoordinates,t.valueData))));{if(n=a[0].pathCoordinates,r=a[0].valueData,n.length<=4)return K()(n,r);const e=(new J).move(n[0],n[1],!1,r[0]),t=!1;for(let a=0,o=n.length;o-2*Number(!t)>a;a+=2){const t=[{x:+n[a-2],y:+n[a-1]},{x:+n[a],y:+n[a+1]},{x:+n[a+2],y:+n[a+3]},{x:+n[a+4],y:+n[a+5]}];o-4===a?t[3]=t[2]:a||(t[0]={x:+n[a],y:+n[a+1]}),e.curve(s*(-t[0].x+6*t[1].x+t[2].x)/6+i*t[2].x,s*(-t[0].y+6*t[1].y+t[2].y)/6+i*t[2].y,s*(t[1].x+6*t[2].x-t[3].x)/6+i*t[2].x,s*(t[1].y+6*t[2].y-t[3].y)/6+i*t[2].y,t[2].x,t[2].y,!1,r[(a+2)/2])}return e}}return K()([],[])}},monotoneCubic:ee});class se{on(e,t){const{allListeners:s,listeners:i}=this;"*"===e?s.add(t):(i.has(e)||i.set(e,new Set),i.get(e).add(t))}off(e,t){const{allListeners:s,listeners:i}=this;if("*"===e)t?s.delete(t):s.clear();else if(i.has(e)){const s=i.get(e);t?s.delete(t):s.clear(),s.size||i.delete(e)}}emit(e,t){const{allListeners:s,listeners:i}=this;i.has(e)&&i.get(e).forEach((e=>e(t))),s.forEach((s=>s(e,t)))}constructor(){this.listeners=new Map,this.allListeners=new Set}}const ie=new WeakMap;class ne{update(e,t){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];var i;(e&&(this.data=e||{},this.data.labels=this.data.labels||[],this.data.series=this.data.series||[],this.eventEmitter.emit("data",{type:"update",data:this.data})),t)&&(this.options=m({},s?this.options:this.defaultOptions,t),this.initializeTimeoutId||(null===(i=this.optionsProvider)||void 0===i||i.removeMediaQueryListeners(),this.optionsProvider=F(this.options,this.responsiveOptions,this.eventEmitter)));return!this.initializeTimeoutId&&this.optionsProvider&&this.createChart(this.optionsProvider.getCurrentOptions()),this}detach(){var e;this.initializeTimeoutId?window.clearTimeout(this.initializeTimeoutId):(window.removeEventListener("resize",this.resizeListener),null===(e=this.optionsProvider)||void 0===e||e.removeMediaQueryListeners());return ie.delete(this.container),this}on(e,t){return this.eventEmitter.on(e,t),this}off(e,t){return this.eventEmitter.off(e,t),this}initialize(){window.addEventListener("resize",this.resizeListener),this.optionsProvider=F(this.options,this.responsiveOptions,this.eventEmitter),this.eventEmitter.on("optionsChanged",(()=>this.update())),this.options.plugins&&this.options.plugins.forEach((e=>{Array.isArray(e)?e[0](this,e[1]):e(this)})),this.eventEmitter.emit("data",{type:"initial",data:this.data}),this.createChart(this.optionsProvider.getCurrentOptions()),this.initializeTimeoutId=null}constructor(e,t,s,i,n){this.data=t,this.defaultOptions=s,this.options=i,this.responsiveOptions=n,this.eventEmitter=new se,this.resizeListener=()=>this.update(),this.initializeTimeoutId=setTimeout((()=>this.initialize()),0);const r="string"==typeof e?document.querySelector(e):e;if(!r)throw new Error("Target element ".concat("string"==typeof e?'"'.concat(e,'"'):""," is not found"));this.container=r;const a=ie.get(r);a&&a.detach(),ie.set(r,this)}}const re={x:{pos:"x",len:"width",dir:"horizontal",rectStart:"x1",rectEnd:"x2",rectOffset:"y2"},y:{pos:"y",len:"height",dir:"vertical",rectStart:"y2",rectEnd:"y1",rectOffset:"x1"}};class ae{createGridAndLabels(e,t,s,i){const n="x"===this.units.pos?s.axisX:s.axisY,r=this.ticks.map(((e,t)=>this.projectValue(e,t))),a=this.ticks.map(n.labelInterpolationFnc);r.forEach(((o,l)=>{const h=a[l],c={x:0,y:0};let u;u=r[l+1]?r[l+1]-o:Math.max(this.axisLength-o,this.axisLength/this.ticks.length),""!==h&&w(h)||("x"===this.units.pos?(o=this.chartRect.x1+o,c.x=s.axisX.labelOffset.x,"start"===s.axisX.position?c.y=this.chartRect.padding.top+s.axisX.labelOffset.y+5:c.y=this.chartRect.y1+s.axisX.labelOffset.y+5):(o=this.chartRect.y1-o,c.y=s.axisY.labelOffset.y-u,"start"===s.axisY.position?c.x=this.chartRect.padding.left+s.axisY.labelOffset.x:c.x=this.chartRect.x2+s.axisY.labelOffset.x+10),n.showGrid&&H(o,l,this,this.gridOffset,this.chartRect[this.counterUnits.len](),e,[s.classNames.grid,s.classNames[this.units.dir]],i),n.showLabel&&Q(o,u,l,h,this,n.offset,c,t,[s.classNames.label,s.classNames[this.units.dir],"start"===n.position?s.classNames[n.position]:s.classNames.end],i))}))}constructor(e,t,s){this.units=e,this.chartRect=t,this.ticks=s,this.counterUnits=e===re.x?re.y:re.x,this.axisLength=t[this.units.rectEnd]-t[this.units.rectStart],this.gridOffset=t[this.units.rectOffset]}}class oe extends ae{projectValue(e){const t=Number(L(e,this.units.pos));return this.axisLength*(t-this.bounds.min)/this.bounds.range}constructor(e,t,s,i){const n=i.highLow||S(t,i,e.pos),r=d(s[e.rectEnd]-s[e.rectStart],n,i.scaleMinSpace||20,i.onlyInteger),a={min:r.min,max:r.max};super(e,s,r.values),this.bounds=r,this.range=a}}class le extends ae{projectValue(e,t){return this.stepLength*t}constructor(e,t,s,i){const n=i.ticks||[];super(e,s,n);const r=Math.max(1,n.length-(i.stretch?1:0));this.stepLength=this.axisLength/r,this.stretch=Boolean(i.stretch)}}function he(e,t,s){var i;if(v(e,"name")&&e.name&&(null===(i=t.series)||void 0===i?void 0:i[e.name])){const i=(null==t?void 0:t.series[e.name])[s];return void 0===i?t[s]:i}return t[s]}const ce={axisX:{offset:30,position:"end",labelOffset:{x:0,y:0},showLabel:!0,showGrid:!0,labelInterpolationFnc:p,type:void 0},axisY:{offset:40,position:"start",labelOffset:{x:0,y:0},showLabel:!0,showGrid:!0,labelInterpolationFnc:p,type:void 0,scaleMinSpace:20,onlyInteger:!1},width:void 0,height:void 0,showLine:!0,showPoint:!0,showArea:!1,areaBase:0,lineSmooth:!0,showGridBackground:!1,low:void 0,high:void 0,chartPadding:{top:15,right:15,bottom:5,left:10},fullWidth:!1,reverseData:!1,classNames:{chart:"ct-chart-line",label:"ct-label",labelGroup:"ct-labels",series:"ct-series",line:"ct-line",point:"ct-point",area:"ct-area",grid:"ct-grid",gridGroup:"ct-grids",gridBackground:"ct-grid-background",vertical:"ct-vertical",horizontal:"ct-horizontal",start:"ct-start",end:"ct-end"}};const ue={axisX:{offset:30,position:"end",labelOffset:{x:0,y:0},showLabel:!0,showGrid:!0,labelInterpolationFnc:p,scaleMinSpace:30,onlyInteger:!1},axisY:{offset:40,position:"start",labelOffset:{x:0,y:0},showLabel:!0,showGrid:!0,labelInterpolationFnc:p,scaleMinSpace:20,onlyInteger:!1},width:void 0,height:void 0,high:void 0,low:void 0,referenceValue:0,chartPadding:{top:15,right:15,bottom:5,left:10},seriesBarDistance:15,stackBars:!1,stackMode:"accumulate",horizontalBars:!1,distributeSeries:!1,reverseData:!1,showGridBackground:!1,classNames:{chart:"ct-chart-bar",horizontalBars:"ct-horizontal-bars",label:"ct-label",labelGroup:"ct-labels",series:"ct-series",bar:"ct-bar",grid:"ct-grid",gridGroup:"ct-grids",gridBackground:"ct-grid-background",vertical:"ct-vertical",horizontal:"ct-horizontal",start:"ct-start",end:"ct-end"}};const de={width:void 0,height:void 0,chartPadding:5,classNames:{chartPie:"ct-chart-pie",chartDonut:"ct-chart-donut",series:"ct-series",slicePie:"ct-slice-pie",sliceDonut:"ct-slice-donut",label:"ct-label"},startAngle:0,total:void 0,donut:!1,donutWidth:60,showLabel:!0,labelOffset:0,labelPosition:"inside",labelInterpolationFnc:p,labelDirection:"neutral",ignoreEmptyValues:!1,preventOverlappingLabelOffset:0};function me(e,t,s){const i=t.x>e.x;return i&&"explode"===s||!i&&"implode"===s?"start":i&&"implode"===s||!i&&"explode"===s?"end":"middle"}e.AutoScaleAxis=oe,e.Axis=ae,e.BarChart=class extends ne{createChart(e){const{data:t}=this,s=B(t,e.reverseData,e.horizontalBars?"x":"y",!0),i=G(this.container,e.width,e.height,e.classNames.chart+(e.horizontalBars?" "+e.classNames.horizontalBars:""),e.viewBox),n=e.stackBars&&!0!==e.stackMode&&s.series.length?S([(a=s.series,x(a,(function(){for(var e=arguments.length,t=new Array(e),s=0;s({x:e.x+(v(t,"x")?t.x:0),y:e.y+(v(t,"y")?t.y:0)})),{x:0,y:0})})))],e,e.horizontalBars?"x":"y"):S(s.series,e,e.horizontalBars?"x":"y");var a;this.svg=i;const o=i.elem("g").addClass(e.classNames.gridGroup),l=i.elem("g"),h=i.elem("g").addClass(e.classNames.labelGroup);"number"==typeof e.high&&(n.high=e.high),"number"==typeof e.low&&(n.low=e.low);const c=U(i,e);let u;const d=e.distributeSeries&&e.stackBars?s.labels.slice(0,1):s.labels;let m,p,f;e.horizontalBars?(u=p=void 0===e.axisX.type?new oe(re.x,s.series,c,{...e.axisX,highLow:n,referenceValue:0}):new e.axisX.type(re.x,s.series,c,{...e.axisX,highLow:n,referenceValue:0}),m=f=void 0===e.axisY.type?new le(re.y,s.series,c,{ticks:d}):new e.axisY.type(re.y,s.series,c,e.axisY)):(m=p=void 0===e.axisX.type?new le(re.x,s.series,c,{ticks:d}):new e.axisX.type(re.x,s.series,c,e.axisX),u=f=void 0===e.axisY.type?new oe(re.y,s.series,c,{...e.axisY,highLow:n,referenceValue:0}):new e.axisY.type(re.y,s.series,c,{...e.axisY,highLow:n,referenceValue:0}));const g=e.horizontalBars?c.x1+u.projectValue(0):c.y1-u.projectValue(0),w="accumulate"===e.stackMode,b="accumulate-relative"===e.stackMode,E=[],N=[];let C=E;m.createGridAndLabels(o,h,e,this.eventEmitter),u.createGridAndLabels(o,h,e,this.eventEmitter),e.showGridBackground&&T(o,c,e.classNames.gridBackground,this.eventEmitter),A(t.series,((i,n)=>{const a=n-(t.series.length-1)/2;let o;o=e.distributeSeries&&!e.stackBars?m.axisLength/s.series.length/2:e.distributeSeries&&e.stackBars?m.axisLength/2:m.axisLength/s.series[n].length/2;const h=l.elem("g"),d=v(i,"name")&&i.name,x=v(i,"className")&&i.className,A=v(i,"meta")?i.meta:void 0;d&&h.attr({"ct:series-name":d}),A&&h.attr({"ct:meta":P(A)}),h.addClass([e.classNames.series,x||"".concat(e.classNames.series,"-").concat(r(n))].join(" ")),s.series[n].forEach(((t,r)=>{const l=v(t,"x")&&t.x,d=v(t,"y")&&t.y;let x,A;x=e.distributeSeries&&!e.stackBars?n:e.distributeSeries&&e.stackBars?0:r,A=e.horizontalBars?{x:c.x1+u.projectValue(l||0,r,s.series[n]),y:c.y1-m.projectValue(d||0,x,s.series[n])}:{x:c.x1+m.projectValue(l||0,x,s.series[n]),y:c.y1-u.projectValue(d||0,r,s.series[n])},m instanceof le&&(m.stretch||(A[m.units.pos]+=o*(e.horizontalBars?-1:1)),A[m.units.pos]+=e.stackBars||e.distributeSeries?0:a*e.seriesBarDistance*(e.horizontalBars?-1:1)),b&&(C=d>=0||l>=0?E:N);const O=C[r]||g;if(C[r]=O-(g-A[m.counterUnits.pos]),void 0===t)return;const L={["".concat(m.units.pos,"1")]:A[m.units.pos],["".concat(m.units.pos,"2")]:A[m.units.pos]};e.stackBars&&(w||b||!e.stackMode)?(L["".concat(m.counterUnits.pos,"1")]=O,L["".concat(m.counterUnits.pos,"2")]=C[r]):(L["".concat(m.counterUnits.pos,"1")]=g,L["".concat(m.counterUnits.pos,"2")]=A[m.counterUnits.pos]),L.x1=Math.min(Math.max(L.x1,c.x1),c.x2),L.x2=Math.min(Math.max(L.x2,c.x1),c.x2),L.y1=Math.min(Math.max(L.y1,c.y2),c.y1),L.y2=Math.min(Math.max(L.y2,c.y2),c.y1);const S=M(i,r),B=h.elem("line",L,e.classNames.bar).attr({"ct:value":[l,d].filter(y).join(","),"ct:meta":P(S)});this.eventEmitter.emit("draw",{type:"bar",value:t,index:r,meta:S,series:i,seriesIndex:n,axisX:p,axisY:f,chartRect:c,group:h,element:B,...L})}))}),e.reverseData),this.eventEmitter.emit("created",{chartRect:c,axisX:p,axisY:f,svg:i,options:e})}constructor(e,t,s,i){super(e,t,ue,m({},ue,s),i),this.data=t}},e.BaseChart=ne,e.EPSILON=a,e.EventEmitter=se,e.FixedScaleAxis=class extends ae{projectValue(e){const t=Number(L(e,this.units.pos));return this.axisLength*(t-this.range.min)/(this.range.max-this.range.min)}constructor(e,t,s,i){const n=i.highLow||S(t,i,e.pos),r=i.divisor||1,a=(i.ticks||f(r,(e=>n.low+(n.high-n.low)/r*e))).sort(((e,t)=>Number(e)-Number(t))),o={min:n.low,max:n.high};super(e,s,a),this.range=o}},e.Interpolation=te,e.LineChart=class extends ne{createChart(e){const{data:t}=this,s=B(t,e.reverseData,!0),i=G(this.container,e.width,e.height,e.classNames.chart,e.viewBox);this.svg=i;const n=i.elem("g").addClass(e.classNames.gridGroup),a=i.elem("g"),o=i.elem("g").addClass(e.classNames.labelGroup),l=U(i,e);let h,c;h=void 0===e.axisX.type?new le(re.x,s.series,l,{...e.axisX,ticks:s.labels,stretch:e.fullWidth}):new e.axisX.type(re.x,s.series,l,e.axisX),c=void 0===e.axisY.type?new oe(re.y,s.series,l,{...e.axisY,high:y(e.high)?e.high:e.axisY.high,low:y(e.low)?e.low:e.axisY.low}):new e.axisY.type(re.y,s.series,l,e.axisY),h.createGridAndLabels(n,o,e,this.eventEmitter),c.createGridAndLabels(n,o,e,this.eventEmitter),e.showGridBackground&&T(n,l,e.classNames.gridBackground,this.eventEmitter),A(t.series,((t,i)=>{const n=a.elem("g"),o=v(t,"name")&&t.name,u=v(t,"className")&&t.className,d=v(t,"meta")?t.meta:void 0;o&&n.attr({"ct:series-name":o}),d&&n.attr({"ct:meta":P(d)}),n.addClass([e.classNames.series,u||"".concat(e.classNames.series,"-").concat(r(i))].join(" "));const m=[],p=[];s.series[i].forEach(((e,n)=>{const r={x:l.x1+h.projectValue(e,n,s.series[i]),y:l.y1-c.projectValue(e,n,s.series[i])};m.push(r.x,r.y),p.push({value:e,valueIndex:n,meta:M(t,n)})}));const f={lineSmooth:he(t,e,"lineSmooth"),showPoint:he(t,e,"showPoint"),showLine:he(t,e,"showLine"),showArea:he(t,e,"showArea"),areaBase:he(t,e,"areaBase")};let g;g="function"==typeof f.lineSmooth?f.lineSmooth:f.lineSmooth?ee():K();const x=g(m,p);if(f.showPoint&&x.pathElements.forEach((s=>{const{data:r}=s,a=n.elem("line",{x1:s.x,y1:s.y,x2:s.x+.01,y2:s.y},e.classNames.point);if(r){let e,t;v(r.value,"x")&&(e=r.value.x),v(r.value,"y")&&(t=r.value.y),a.attr({"ct:value":[e,t].filter(y).join(","),"ct:meta":P(r.meta)})}this.eventEmitter.emit("draw",{type:"point",value:null==r?void 0:r.value,index:(null==r?void 0:r.valueIndex)||0,meta:null==r?void 0:r.meta,series:t,seriesIndex:i,axisX:h,axisY:c,group:n,element:a,x:s.x,y:s.y,chartRect:l})})),f.showLine){const r=n.elem("path",{d:x.stringify()},e.classNames.line,!0);this.eventEmitter.emit("draw",{type:"line",values:s.series[i],path:x.clone(),chartRect:l,index:i,series:t,seriesIndex:i,meta:d,axisX:h,axisY:c,group:n,element:r})}if(f.showArea&&c.range){const r=Math.max(Math.min(f.areaBase,c.range.max),c.range.min),a=l.y1-c.projectValue(r);x.splitByCommand("M").filter((e=>e.pathElements.length>1)).map((e=>{const t=e.pathElements[0],s=e.pathElements[e.pathElements.length-1];return e.clone(!0).position(0).remove(1).move(t.x,a).line(t.x,t.y).position(e.pathElements.length+1).line(s.x,a)})).forEach((r=>{const a=n.elem("path",{d:r.stringify()},e.classNames.area,!0);this.eventEmitter.emit("draw",{type:"area",values:s.series[i],path:r.clone(),series:t,seriesIndex:i,axisX:h,axisY:c,chartRect:l,index:i,group:n,element:a,meta:d})}))}}),e.reverseData),this.eventEmitter.emit("created",{chartRect:l,axisX:h,axisY:c,svg:i,options:e})}constructor(e,t,s,i){super(e,t,ce,m({},ce,s),i),this.data=t}},e.PieChart=class extends ne{moveLabel(e,t,s,i){e.y>t.y-s&&e.yt.x-i*s&&e.xv(e,"value")?0!==e.value:0!==e)).length;t.series.forEach(((e,t)=>i[t]=c.elem("g"))),e.showLabel&&(a=c.elem("g")),t.series.forEach(((n,c)=>{var g,b;if(0===s.series[c]&&e.ignoreEmptyValues)return;const E=v(n,"name")&&n.name,A=v(n,"className")&&n.className,M=v(n,"meta")?n.meta:void 0;E&&i[c].attr({"ct:series-name":E}),i[c].addClass([null===(g=e.classNames)||void 0===g?void 0:g.series,A||"".concat(null===(b=e.classNames)||void 0===b?void 0:b.series,"-").concat(r(c))].join(" "));let N=p>0?h+s.series[c]/p*360:0;const C=Math.max(0,h-(0===c||y?0:.2));N-C>=359.99&&(N=C+359.99);const O=u(x.x,x.y,m,C),L=u(x.x,x.y,m,N),S=new J(!e.donut).move(L.x,L.y).arc(m,m,0,Number(N-h>180),0,O.x,O.y);e.donut||S.line(x.x,x.y);const B=i[c].elem("path",{d:S.stringify()},e.donut?e.classNames.sliceDonut:e.classNames.slicePie);if(B.attr({"ct:value":s.series[c],"ct:meta":P(M)}),e.donut&&B.attr({style:"stroke-width: "+f.value+"px"}),this.eventEmitter.emit("draw",{type:"slice",value:s.series[c],totalDataSum:p,index:c,meta:M,series:n,group:i[c],element:B,path:S.clone(),center:x,radius:m,startAngle:h,endAngle:N,chartRect:d}),e.showLabel){let i,r;i=1===t.series.length?{x:x.x,y:x.y}:u(x.x,x.y,l,h+(N-h)/2),r=s.labels&&!w(s.labels[c])?s.labels[c]:s.series[c];const m=e.labelInterpolationFnc(r,c);if(m||0===m){if(e.preventOverlappingLabelOffset){const t=e.preventOverlappingLabelOffset,n=String(s.labels[c]).length;o.forEach((e=>{this.moveLabel(i,e,t,n)})),o.push(i)}const t=a.elem("text",{dx:i.x,dy:i.y,"text-anchor":me(x,i,e.labelDirection)},e.classNames.label).text(String(m));this.eventEmitter.emit("draw",{type:"label",index:c,group:a,element:t,text:""+m,chartRect:d,series:n,meta:M,...i})}}h=N})),this.eventEmitter.emit("created",{chartRect:d,svg:c,options:e})}constructor(e,t,s,i){super(e,t,de,m({},de,s),i),this.data=t}},e.StepAxis=le,e.Svg=R,e.SvgList=X,e.SvgPath=J,e.alphaNumerate=r,e.axisUnits=re,e.createChartRect=U,e.createGrid=H,e.createGridBackground=T,e.createLabel=Q,e.createSvg=G,e.deserialize=function(e){if("string"!=typeof e)return e;if("NaN"===e)return NaN;let t=e=Object.keys(s).reduce(((e,t)=>e.replaceAll(s[t],t)),e);if("string"==typeof e)try{t=JSON.parse(e),t=void 0!==t.data?t.data:t}catch(e){}return t},e.determineAnchorPosition=me,e.each=A,e.easings=V,e.ensureUnit=i,e.escapingMap=s,e.extend=m,e.getBounds=d,e.getHighLow=S,e.getMetaData=M,e.getMultiValue=L,e.getNumberOrUndefined=b,e.getSeriesOption=he,e.isArrayOfArrays=E,e.isArrayOfSeries=C,e.isDataHoleValue=N,e.isFalseyButZero=w,e.isMultiValue=O,e.isNumeric=y,e.namespaces=t,e.noop=p,e.normalizeData=B,e.normalizePadding=D,e.optionsProvider=F,e.orderOfMagnitude=o,e.polarToCartesian=u,e.precision=8,e.projectLength=l,e.quantity=n,e.rho=c,e.roundWithPrecision=h,e.safeHasProperty=v,e.serialMap=x,e.serialize=P,e.splitIntoSegments=I,e.sum=g,e.times=f,Object.defineProperty(e,"__esModule",{value:!0})})); +//# sourceMappingURL=index.umd.js.map diff --git a/jspwiki-plugins/jspwiki-plugins-chartist/src/main/resources/ini/jspwiki_module.xml b/jspwiki-plugins/jspwiki-plugins-chartist/src/main/resources/ini/jspwiki_module.xml new file mode 100644 index 0000000000..41d441a545 --- /dev/null +++ b/jspwiki-plugins/jspwiki-plugins-chartist/src/main/resources/ini/jspwiki_module.xml @@ -0,0 +1,6 @@ + + + ASF + 2.11 + + \ No newline at end of file diff --git a/jspwiki-plugins/pom.xml b/jspwiki-plugins/pom.xml new file mode 100644 index 0000000000..381a688375 --- /dev/null +++ b/jspwiki-plugins/pom.xml @@ -0,0 +1,41 @@ + + + + + + org.apache.jspwiki + jspwiki-builder + 3.0.0-SNAPSHOT + + + jspwiki-plugins + 4.0.0 + Optional plugins for JSP wiki + pom + + + jspwiki-plugins-chartist + + + + + + + diff --git a/jspwiki-portable/build.xml b/jspwiki-portable/build.xml index 1f1914992b..01a1d60afc 100644 --- a/jspwiki-portable/build.xml +++ b/jspwiki-portable/build.xml @@ -109,6 +109,11 @@ + + + + + diff --git a/jspwiki-portable/pom.xml b/jspwiki-portable/pom.xml index b675204d54..d8940e8432 100644 --- a/jspwiki-portable/pom.xml +++ b/jspwiki-portable/pom.xml @@ -269,6 +269,11 @@ tomcat-jsp-api ${tomcat.version} + + ${project.groupId} + jspwiki-plugins-chartist + ${project.version} + diff --git a/pom.xml b/pom.xml index f7ff23a703..f4fc5f93ee 100644 --- a/pom.xml +++ b/pom.xml @@ -153,6 +153,7 @@ jspwiki-war jspwiki-portable jspwiki-it-tests + jspwiki-plugins jspwiki-bom