From c47e9be244b3484066fc490da823a9926d2b09e2 Mon Sep 17 00:00:00 2001 From: tcharlss Date: Wed, 23 Sep 2020 16:19:30 +0200 Subject: [PATCH] =?UTF-8?q?M=C3=A0j=20de=20la=20lib=20en=203.0.0-beta=20+?= =?UTF-8?q?=20on=20renomme=20la=20page=20de=20d=C3=A9mo=20pour=20suivre=20?= =?UTF-8?q?la=20convention?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/{demo_chartjs.html => chartjs.html} | 428 ++--- lib/chartjs/chart.esm.js | 590 ++++--- lib/chartjs/chart.esm.min.js | 8 +- lib/chartjs/chart.js | 1479 +++++++++++------ lib/chartjs/chart.min.js | 10 +- lib/chartjs/samples/.eslintrc.yml | 15 + .../samples/charts/scatter/multi-axis.html | 15 +- modeles/chart.html | 5 +- 8 files changed, 1617 insertions(+), 933 deletions(-) rename demo/{demo_chartjs.html => chartjs.html} (97%) create mode 100644 lib/chartjs/samples/.eslintrc.yml diff --git a/demo/demo_chartjs.html b/demo/chartjs.html similarity index 97% rename from demo/demo_chartjs.html rename to demo/chartjs.html index 734db69..425bf13 100644 --- a/demo/demo_chartjs.html +++ b/demo/chartjs.html @@ -1,214 +1,214 @@ - - - - <:chartjs:demo_titre:> - #INSERT_HEAD - #INSERT_HEAD_CSS - - - - - - - - -

<:chartjs:demo_titre:>

- -
-

Types de graphiques

- -
- - -
-

<:chartjs:demo_bar:> <:chartjs:demo_type{type=bar}:>

- #SET{data,"40,32,50,35 next 20,25,45,42 next 40,43, 61,50 next 33,15,40,22"} - #SET{labels,"Salé,Sucré,Amer,Acide"} - #SET{datalabels,"poire,pomme,courgette,citron"} - [(#MODELE{chart}{id=barre,type=bar,datasets=#GET{data},labels=#GET{labels},dataLabels=#GET{datalabels},width=500,height=500})] -
<chart
-  |id=barre
-  |type=bar
-  |datasets=40,32,50,35 next 20,25,45,42 next 40,43, 61,50 next 33,15,40,22
-  |labels=Salé,Sucré,Amer,Acide
-  |dataLabels=poire,pomme,courgette,citron
-  |width=500
-  |height=500>
-			
-
- - -
-

<:chartjs:demo_line:> <:chartjs:demo_type{type=line}:>

- #SET{data,"40,43,61,50 next 33,15,40,22"} - #SET{labels,"Janvier, Février, Mars, Avril"} - #SET{datalabels,"patates,poireaux"} - [(#MODELE{chart}{id=ligne,type=line,datasets=#GET{data},labels=#GET{labels},dataLabels=#GET{datalabels},width=500,height=500})] -
<chart
-  |id=ligne
-  |type=line
-  |datasets=40,43,61,50 next 33,15,40,22
-  |labels=Janvier, Février, Mars, Avril0
-  |dataLabels=patates,poireaux
-  |width=500
-  |height=500>
-			
-
- - -
-

<:chartjs:demo_pie:> <:chartjs:demo_type{type=pie}:>

- #SET{data,"10,32,50,25,5"} - #SET{labels,"Tôkyô - 東京,Kyoto, Osaka,Chiba,Hiroshima"} - [(#MODELE{chart}{id=camembert1,type=pie,data=#GET{data},labels=#GET{labels}})] -
<chart
-  |id=camembert1
-  |type=pie
-  |labels=Tôkyô - 東京,Kyoto, Osaka,Chiba,Hiroshima
-  |data=10,32,50,25,5>
-			
-
- - -
-

<:chartjs:demo_doughnut:> <:chartjs:demo_type{type=doughnut}:>

- #SET{data,"30,10,55,25,15,8"} - #SET{colors,"#69D2E7,#E0E4CC,#F38630,#96CE7F,#CEBC17,#CE4264"} - [(#MODELE{chart}{id=anneau,type=doughnut,align=right,data=#GET{data},colors=#GET{colors},labels=#GET{labels}})] -
<chart
-  |id=anneau
-  |type=doughnut
-  |align=right
-  |data=30,10,55,25,15,8
-  |labels=Tôkyô - 東京,Kyoto, Osaka,Chiba,Hiroshima
-  |colors=#69D2E7,#E0E4CC,#F38630,#96CE7F,#CEBC17,#CE4264>
-			
-
- - -
-

<:chartjs:demo_polaire:> <:chartjs:demo_type{type=polarArea}:>

- #SET{data,"40,32,5,25,50,45"} - #SET{labels,"Noix,Amandes,Raisins,Autres sucreries,Salés,Six"} - [(#MODELE{chart}{id=polaire,type=polarArea,data=#GET{data},labels=#GET{labels}})] -
<chart
-  |id=polaire
-  |type=polarArea
-  |data=40,32,5,25,50,45
-  |labels=Noix,Amandes,Raisins,Autres sucreries,Salés,Six>
-			
-
- - -
-

<:chartjs:demo_radar:> <:chartjs:demo_type{type=radar}:>

- #SET{data,"20,22,40,25,55 next 15,20,30,40,35"} - #SET{labels,"Précis, Rapide, Joli, Complet, かわい"} - #SET{colors,"#CEBC17,#CE4264"} - [(#MODELE{chart}{id=radar,type=radar,datasets=#GET{data},labels=#GET{labels},colors=#GET{colors}})] -
<chart
-  |id=radar45
-  |type=radar
-  |datasets=40,43,61,50 next 33,15,40,22
-  |labels=Précis, Rapide, Joli, Complet, かわい
-  |colors=#CEBC17,#CE4264>
-			
-
- - -
-

<:chartjs:demo_bubble:> <:chartjs:demo_type{type=bubble}:>

- #SET{data,"2,5,10, 10,7,5 next 15,20,5, 10,12,15"} - #SET{datalabels,"poireaux, patates"} - [(#MODELE{chart}{id=bubble,type=bubble,datasets=#GET{data},dataLabels=#GET{datalabels}})] -
<chart
-  |id=bubble
-  |type=bubble
-  |datasets=2,5,10 10,7,5 next 15,20,5 ,10,12,15
-  |dataLabels=poireaux,patates>
-			
-
- - -
-

<:chartjs:demo_scatter:> <:chartjs:demo_type{type=scatter}:>

- #SET{data,"5,10, 10,0, 15,10 next 5,20, 6,25, 7,20 next 13,20, 14,25, 15,20"} - #SET{datalabels,"poireaux, patates, piments"} - [(#MODELE{chart}{id=scatter,type=scatter,datasets=#GET{data},dataLabels=#GET{datalabels}})] -
<chart
-  |id=scatter
-  |type=scatter
-  |datasets=5,10, 10,0, 15,10 next 5,20, 6,25, 7,20 next 13,20, 14,25, 15,20
-  |dataLabels=poireaux,patates,piments>
-			
-
- -
- -
-

Exemples avancés

- -
- - -
-

<:chartjs:demo_spip_data:>

- #SET{nb_article,0} - #SET{nb_article,#TOTAL_BOUCLE} - #SET{nb_auteur,0} - #SET{nb_auteur,#TOTAL_BOUCLE} - #SET{data,#GET{nb_article}|concat{",",#GET{nb_auteur}}} - #SET{labels,"Articles, Auteurs"} - [(#MODELE{chart}{id=barrespip,type=bar,datasets=#GET{data},labels=#GET{labels}})] -
#SET{nb_article,0}
-<BOUCLE_articles(ARTICLES)> </BOUCLE_articles>#SET{nb_article,#TOTAL_BOUCLE} </B_articles>
-#SET{nb_auteur,0}
-<BOUCLE_auteurs(AUTEURS)> </BOUCLE_auteurs>#SET{nb_auteur,#TOTAL_BOUCLE} </B_auteurs>
-#SET{data,#GET{nb_article}|concat{",",#GET{nb_auteur}}} 
-#SET{labels,"Articles, Auteurs"}
-[(#MODELE{chart}{id=barrespip,type=bar,datasets=#GET{data},labels=#GET{labels}})]
-			
-
- - - -
-

<:chartjs:demo_spip_bigdata:>

- #SET{data,''} - #SET{labels,''} - - #SET{labels, #GET{labels}|concat{",",#VALEUR{attributes/time}|affdate{d/m/y}}} - [ - (#VALEUR{attributes/currency}|=={JPY}|oui) - #SET{data,#GET{data}|concat{",",#VALEUR{attributes/rate}} - ] - - #SET{data,#GET{data}|substr{1}} - #SET{labels,#GET{labels}|substr{1}} - [(#MODELE{chart}{id=coursduyen,type=line,datasets=#GET{data},labels=#GET{labels}})] - <:chartjs:demo_spip_legend:> -
#SET{data,''}
-#SET{labels,''}
-<BOUCLE_cours(DATA){source simplexml,http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml?#ENV{date}}{datapath root/children/cube/0/children/cube}{0,30}>
-#SET{labels, #GET{labels}|concat{",",#VALEUR{attributes/time}|affdate{d/m/y}}} 
-<BOUCLE_yen(DATA){source tableau,#VALEUR{children/cube}}>[
-(#VALEUR{attributes/currency}|=={JPY}|oui)
- #SET{data,#GET{data}|concat{",",#VALEUR{attributes/rate}}
-]</BOUCLE_yen> 
-</BOUCLE_cours>
-#SET{data,#GET{data}|substr{1}}
-#SET{labels,#GET{labels}|substr{1}} 
-[(#MODELE{chart}{id=coursduyen,type=line,width=auto,height=auto,datasets=#GET{data},labels=#GET{labels}})]
-			
-
-
- - - - + + + + <:chartjs:demo_titre:> + #INSERT_HEAD + #INSERT_HEAD_CSS + + + + + + + + +

<:chartjs:demo_titre:>

+ +
+

Types de graphiques

+ +
+ + +
+

<:chartjs:demo_bar:> <:chartjs:demo_type{type=bar}:>

+ #SET{data,"40,32,50,35 next 20,25,45,42 next 40,43, 61,50 next 33,15,40,22"} + #SET{labels,"Salé,Sucré,Amer,Acide"} + #SET{datalabels,"poire,pomme,courgette,citron"} + [(#MODELE{chart}{id=barre,type=bar,datasets=#GET{data},labels=#GET{labels},dataLabels=#GET{datalabels},width=500,height=500})] +
<chart
+  |id=barre
+  |type=bar
+  |datasets=40,32,50,35 next 20,25,45,42 next 40,43, 61,50 next 33,15,40,22
+  |labels=Salé,Sucré,Amer,Acide
+  |dataLabels=poire,pomme,courgette,citron
+  |width=500
+  |height=500>
+			
+
+ + +
+

<:chartjs:demo_line:> <:chartjs:demo_type{type=line}:>

+ #SET{data,"40,43,61,50 next 33,15,40,22"} + #SET{labels,"Janvier, Février, Mars, Avril"} + #SET{datalabels,"patates,poireaux"} + [(#MODELE{chart}{id=ligne,type=line,datasets=#GET{data},labels=#GET{labels},dataLabels=#GET{datalabels},width=500,height=500})] +
<chart
+  |id=ligne
+  |type=line
+  |datasets=40,43,61,50 next 33,15,40,22
+  |labels=Janvier, Février, Mars, Avril0
+  |dataLabels=patates,poireaux
+  |width=500
+  |height=500>
+			
+
+ + +
+

<:chartjs:demo_pie:> <:chartjs:demo_type{type=pie}:>

+ #SET{data,"10,32,50,25,5"} + #SET{labels,"Tôkyô - 東京,Kyoto, Osaka,Chiba,Hiroshima"} + [(#MODELE{chart}{id=camembert1,type=pie,data=#GET{data},labels=#GET{labels}})] +
<chart
+  |id=camembert1
+  |type=pie
+  |labels=Tôkyô - 東京,Kyoto, Osaka,Chiba,Hiroshima
+  |data=10,32,50,25,5>
+			
+
+ + +
+

<:chartjs:demo_doughnut:> <:chartjs:demo_type{type=doughnut}:>

+ #SET{data,"30,10,55,25,15,8"} + #SET{colors,"#69D2E7,#E0E4CC,#F38630,#96CE7F,#CEBC17,#CE4264"} + [(#MODELE{chart}{id=anneau,type=doughnut,align=right,data=#GET{data},colors=#GET{colors},labels=#GET{labels}})] +
<chart
+  |id=anneau
+  |type=doughnut
+  |align=right
+  |data=30,10,55,25,15,8
+  |labels=Tôkyô - 東京,Kyoto, Osaka,Chiba,Hiroshima
+  |colors=#69D2E7,#E0E4CC,#F38630,#96CE7F,#CEBC17,#CE4264>
+			
+
+ + +
+

<:chartjs:demo_polaire:> <:chartjs:demo_type{type=polarArea}:>

+ #SET{data,"40,32,5,25,50,45"} + #SET{labels,"Noix,Amandes,Raisins,Autres sucreries,Salés,Six"} + [(#MODELE{chart}{id=polaire,type=polarArea,data=#GET{data},labels=#GET{labels}})] +
<chart
+  |id=polaire
+  |type=polarArea
+  |data=40,32,5,25,50,45
+  |labels=Noix,Amandes,Raisins,Autres sucreries,Salés,Six>
+			
+
+ + +
+

<:chartjs:demo_radar:> <:chartjs:demo_type{type=radar}:>

+ #SET{data,"20,22,40,25,55 next 15,20,30,40,35"} + #SET{labels,"Précis, Rapide, Joli, Complet, かわい"} + #SET{colors,"#CEBC17,#CE4264"} + [(#MODELE{chart}{id=radar,type=radar,datasets=#GET{data},labels=#GET{labels},colors=#GET{colors}})] +
<chart
+  |id=radar45
+  |type=radar
+  |datasets=40,43,61,50 next 33,15,40,22
+  |labels=Précis, Rapide, Joli, Complet, かわい
+  |colors=#CEBC17,#CE4264>
+			
+
+ + +
+

<:chartjs:demo_bubble:> <:chartjs:demo_type{type=bubble}:>

+ #SET{data,"2,5,10, 10,7,5 next 15,20,5, 10,12,15"} + #SET{datalabels,"poireaux, patates"} + [(#MODELE{chart}{id=bubble,type=bubble,datasets=#GET{data},dataLabels=#GET{datalabels}})] +
<chart
+  |id=bubble
+  |type=bubble
+  |datasets=2,5,10 10,7,5 next 15,20,5 ,10,12,15
+  |dataLabels=poireaux,patates>
+			
+
+ + +
+

<:chartjs:demo_scatter:> <:chartjs:demo_type{type=scatter}:>

+ #SET{data,"5,10, 10,0, 15,10 next 5,20, 6,25, 7,20 next 13,20, 14,25, 15,20"} + #SET{datalabels,"poireaux, patates, piments"} + [(#MODELE{chart}{id=scatter,type=scatter,datasets=#GET{data},dataLabels=#GET{datalabels}})] +
<chart
+  |id=scatter
+  |type=scatter
+  |datasets=5,10, 10,0, 15,10 next 5,20, 6,25, 7,20 next 13,20, 14,25, 15,20
+  |dataLabels=poireaux,patates,piments>
+			
+
+ +
+ +
+

Exemples avancés

+ +
+ + +
+

<:chartjs:demo_spip_data:>

+ #SET{nb_article,0} + #SET{nb_article,#TOTAL_BOUCLE} + #SET{nb_auteur,0} + #SET{nb_auteur,#TOTAL_BOUCLE} + #SET{data,#GET{nb_article}|concat{",",#GET{nb_auteur}}} + #SET{labels,"Articles, Auteurs"} + [(#MODELE{chart}{id=barrespip,type=bar,datasets=#GET{data},labels=#GET{labels}})] +
#SET{nb_article,0}
+<BOUCLE_articles(ARTICLES)> </BOUCLE_articles>#SET{nb_article,#TOTAL_BOUCLE} </B_articles>
+#SET{nb_auteur,0}
+<BOUCLE_auteurs(AUTEURS)> </BOUCLE_auteurs>#SET{nb_auteur,#TOTAL_BOUCLE} </B_auteurs>
+#SET{data,#GET{nb_article}|concat{",",#GET{nb_auteur}}} 
+#SET{labels,"Articles, Auteurs"}
+[(#MODELE{chart}{id=barrespip,type=bar,datasets=#GET{data},labels=#GET{labels}})]
+			
+
+ + + +
+

<:chartjs:demo_spip_bigdata:>

+ #SET{data,''} + #SET{labels,''} + + #SET{labels, #GET{labels}|concat{",",#VALEUR{attributes/time}|affdate{d/m/y}}} + [ + (#VALEUR{attributes/currency}|=={JPY}|oui) + #SET{data,#GET{data}|concat{",",#VALEUR{attributes/rate}} + ] + + #SET{data,#GET{data}|substr{1}} + #SET{labels,#GET{labels}|substr{1}} + [(#MODELE{chart}{id=coursduyen,type=line,datasets=#GET{data},labels=#GET{labels}})] + <:chartjs:demo_spip_legend:> +
#SET{data,''}
+#SET{labels,''}
+<BOUCLE_cours(DATA){source simplexml,http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml?#ENV{date}}{datapath root/children/cube/0/children/cube}{0,30}>
+#SET{labels, #GET{labels}|concat{",",#VALEUR{attributes/time}|affdate{d/m/y}}} 
+<BOUCLE_yen(DATA){source tableau,#VALEUR{children/cube}}>[
+(#VALEUR{attributes/currency}|=={JPY}|oui)
+ #SET{data,#GET{data}|concat{",",#VALEUR{attributes/rate}}
+]</BOUCLE_yen> 
+</BOUCLE_cours>
+#SET{data,#GET{data}|substr{1}}
+#SET{labels,#GET{labels}|substr{1}} 
+[(#MODELE{chart}{id=coursduyen,type=line,width=auto,height=auto,datasets=#GET{data},labels=#GET{labels}})]
+			
+
+
+ + + + diff --git a/lib/chartjs/chart.esm.js b/lib/chartjs/chart.esm.js index d9c5d77..f835d23 100644 --- a/lib/chartjs/chart.esm.js +++ b/lib/chartjs/chart.esm.js @@ -1,10 +1,10 @@ /*! - * Chart.js v3.0.0-alpha.2 + * Chart.js v3.0.0-beta * https://www.chartjs.org * (c) 2020 Chart.js Contributors * Released under the MIT License */ -import { requestAnimFrame } from '../helpers/extras.js'; +import { requestAnimFrame, throttled } from '../helpers/extras.js'; import effects from '../helpers/easing.js'; import { isObject, noop, valueOrDefault, merge, isArray, resolveObjectKey, _capitalize, mergeIf, _merger, isNullOrUndef, each, isFinite as isNumberFinite, callback, uid, _elementsEqual } from '../helpers/core.js'; import { r as resolve, d as defaults, t as toPadding, a as toFont } from '../helpers/chunks/helpers.options.js'; @@ -13,7 +13,7 @@ import { clipArea, unclipArea, _isPointInArea, _measureText, _alignPixel, clear, import { color, getHoverColor } from '../helpers/color.js'; import { unlistenArrayEvents, listenArrayEvents, _rlookupByKey, _lookupByKey, _filterBetween, _arrayUnique, _lookup } from '../helpers/collection.js'; import { sign, _limitValue, isNumber, toRadians, log10, toDegrees, _factorize, getAngleFromPoint, _angleBetween, _normalizeAngle, distanceBetweenPoints, _setMinAndMaxByKey, _decimalPlaces, almostEquals, almostWhole } from '../helpers/math.js'; -import { getRelativePosition as getRelativePosition$1, _getParentNode, getStyle, retinaScale, getMaximumWidth, getMaximumHeight } from '../helpers/dom.js'; +import { getRelativePosition as getRelativePosition$1, _getParentNode, readUsedSize, supportsEventListenerOptions, retinaScale, getMaximumWidth, getMaximumHeight } from '../helpers/dom.js'; import { _steppedInterpolation, _bezierInterpolation, _pointInLine } from '../helpers/interpolation.js'; import { _computeSegments, _boundSegments, _boundSegment } from '../helpers/segment.js'; import { _updateBezierControlPoints } from '../helpers/curve.js'; @@ -200,6 +200,7 @@ class Animation { this._prop = prop; this._from = from; this._to = to; + this._promises = undefined; } active() { return this._active; @@ -222,6 +223,7 @@ class Animation { if (me._active) { me.tick(Date.now()); me._active = false; + me._notify(false); } } tick(date) { @@ -236,6 +238,7 @@ class Animation { me._active = from !== to && (loop || (elapsed < duration)); if (!me._active) { me._target[prop] = to; + me._notify(true); return; } if (elapsed < 0) { @@ -247,6 +250,19 @@ class Animation { factor = me._easing(Math.min(1, Math.max(0, factor))); me._target[prop] = me._fn(from, to, factor); } + wait() { + const promises = this._promises || (this._promises = []); + return new Promise((res, rej) => { + promises.push({res, rej}); + }); + } + _notify(resolved) { + const method = resolved ? 'res' : 'rej'; + const promises = this._promises || []; + for (let i = 0; i < promises.length; i++) { + promises[i][method](); + } + } } const numbers = ['x', 'y', 'borderWidth', 'radius', 'tension']; @@ -296,10 +312,10 @@ defaults.set('animation', { function copyOptions(target, values) { const oldOpts = target.options; const newOpts = values.options; - if (!oldOpts || !newOpts || newOpts.$shared) { + if (!oldOpts || !newOpts) { return; } - if (oldOpts.$shared) { + if (oldOpts.$shared && !newOpts.$shared) { target.options = Object.assign({}, oldOpts, newOpts, {$shared: false}); } else { Object.assign(oldOpts, newOpts); @@ -337,25 +353,23 @@ class Animations { if (!animatedProps.has(prop)) { animatedProps.set(prop, Object.assign({}, animDefaults, cfg)); } else if (prop === key) { - animatedProps.set(prop, Object.assign({}, animatedProps.get(prop), cfg)); + const {properties, ...inherited} = animatedProps.get(prop); + animatedProps.set(prop, Object.assign({}, inherited, cfg)); } }); }); } _animateOptions(target, values) { const newOptions = values.options; - let animations = []; - if (!newOptions) { - return animations; - } - let options = target.options; - if (options) { - if (options.$shared) { - target.options = options = Object.assign({}, options, {$shared: false, $animations: {}}); - } - animations = this._createAnimations(options, newOptions); - } else { - target.options = newOptions; + const options = resolveTargetOptions(target, newOptions); + if (!options) { + return []; + } + const animations = this._createAnimations(options, newOptions); + if (newOptions.$shared && !options.$shared) { + awaitAll(target.$animations, newOptions).then(() => { + target.options = newOptions; + }); } return animations; } @@ -408,6 +422,31 @@ class Animations { } } } +function awaitAll(animations, properties) { + const running = []; + const keys = Object.keys(properties); + for (let i = 0; i < keys.length; i++) { + const anim = animations[keys[i]]; + if (anim && anim.active()) { + running.push(anim.wait()); + } + } + return Promise.all(running); +} +function resolveTargetOptions(target, newOptions) { + if (!newOptions) { + return; + } + let options = target.options; + if (!options) { + target.options = newOptions; + return; + } + if (options.$shared && !newOptions.$shared) { + target.options = options = Object.assign({}, options, {$shared: false, $animations: {}}); + } + return options; +} function scaleClip(scale, allowedOverflow) { const opts = scale && scale.options || {}; @@ -534,6 +573,9 @@ function optionKeys(optionNames) { function optionKey(key, active) { return active ? 'hover' + _capitalize(key) : key; } +function isDirectUpdateMode(mode) { + return mode === 'reset' || mode === 'none'; +} class DatasetController { constructor(chart, datasetIndex) { this.chart = chart; @@ -547,6 +589,8 @@ class DatasetController { this._parsing = false; this._data = undefined; this._objectData = undefined; + this._sharedOptions = undefined; + this.enableOptionSharing = false; this.initialize(); } initialize() { @@ -842,7 +886,7 @@ class DatasetController { me.configure(); me._cachedAnimations = {}; me._cachedDataOpts = {}; - me.update(mode); + me.update(mode || 'default'); meta._clip = toClip(valueOrDefault(me._config.clip, defaultClip(meta.xScale, meta.yScale, me.getMaxOverflow()))); } update(mode) {} @@ -913,9 +957,11 @@ class DatasetController { }); } resolveDataElementOptions(index, mode) { + mode = mode || 'default'; const me = this; const active = mode === 'active'; const cached = me._cachedDataOpts; + const sharing = me.enableOptionSharing; if (cached[mode]) { return cached[mode]; } @@ -927,8 +973,8 @@ class DatasetController { type: me.dataElementType.id }); if (info.cacheable) { - values.$shared = true; - cached[mode] = values; + values.$shared = sharing; + cached[mode] = sharing ? Object.freeze(values) : values; } return values; } @@ -976,35 +1022,31 @@ class DatasetController { } return animations; } - getSharedOptions(mode, el, options) { - if (!mode) { - this._sharedOptions = options && options.$shared; - } - if (mode !== 'reset' && options && options.$shared && el && el.options && el.options.$shared) { - return {target: el.options, options}; + getSharedOptions(options) { + if (!options.$shared) { + return; } + return this._sharedOptions || (this._sharedOptions = Object.assign({}, options)); } includeOptions(mode, sharedOptions) { - if (mode === 'hide' || mode === 'show') { - return true; - } - return mode !== 'resize' && !sharedOptions; + return !sharedOptions || isDirectUpdateMode(mode); } updateElement(element, index, properties, mode) { - if (mode === 'reset' || mode === 'none') { + if (isDirectUpdateMode(mode)) { Object.assign(element, properties); } else { this._resolveAnimations(index, mode).update(element, properties); } } - updateSharedOptions(sharedOptions, mode) { + updateSharedOptions(sharedOptions, mode, newOptions) { if (sharedOptions) { - this._resolveAnimations(undefined, mode).update(sharedOptions.target, sharedOptions.options); + this._resolveAnimations(undefined, mode).update({options: sharedOptions}, {options: newOptions}); } } _setStyle(element, index, mode, active) { element.active = active; - this._resolveAnimations(index, mode, active).update(element, {options: this.getStyle(index, active)}); + const options = this.getStyle(index, active); + this._resolveAnimations(index, mode, active).update(element, {options: this.getSharedOptions(options) || options}); } removeHoverStyle(element, datasetIndex, index) { this._setStyle(element, index, 'active', false); @@ -1241,6 +1283,7 @@ class BarController extends DatasetController { } initialize() { const me = this; + me.enableOptionSharing = true; super.initialize(); const meta = me._cachedMeta; meta.stack = me.getDataset().stack; @@ -1258,12 +1301,12 @@ class BarController extends DatasetController { const horizontal = vscale.isHorizontal(); const ruler = me._getRuler(); const firstOpts = me.resolveDataElementOptions(start, mode); - const sharedOptions = me.getSharedOptions(mode, rectangles[start], firstOpts); + const sharedOptions = me.getSharedOptions(firstOpts); const includeOptions = me.includeOptions(mode, sharedOptions); - let i; - for (i = 0; i < rectangles.length; i++) { + me.updateSharedOptions(sharedOptions, mode, firstOpts); + for (let i = 0; i < rectangles.length; i++) { const index = start + i; - const options = me.resolveDataElementOptions(index, mode); + const options = sharedOptions || me.resolveDataElementOptions(index, mode); const vpixels = me._calculateBarValuePixels(index, options); const ipixels = me._calculateBarIndexPixels(index, ruler, options); const properties = { @@ -1279,7 +1322,6 @@ class BarController extends DatasetController { } me.updateElement(rectangles[i], index, properties, mode); } - me.updateSharedOptions(sharedOptions, mode); } _getStacks(last) { const me = this; @@ -1456,6 +1498,10 @@ BarController.defaults = { }; class BubbleController extends DatasetController { + initialize() { + this.enableOptionSharing = true; + super.initialize(); + } parseObjectData(meta, data, start, count) { const {xScale, yScale} = meta; const {xAxisKey = 'x', yAxisKey = 'y'} = this._parsing; @@ -1504,7 +1550,7 @@ class BubbleController extends DatasetController { const reset = mode === 'reset'; const {xScale, yScale} = me._cachedMeta; const firstOpts = me.resolveDataElementOptions(start, mode); - const sharedOptions = me.getSharedOptions(mode, points[start], firstOpts); + const sharedOptions = me.getSharedOptions(firstOpts); const includeOptions = me.includeOptions(mode, sharedOptions); for (let i = 0; i < points.length; i++) { const point = points[i]; @@ -1525,7 +1571,7 @@ class BubbleController extends DatasetController { } me.updateElement(point, index, properties, mode); } - me.updateSharedOptions(sharedOptions, mode); + me.updateSharedOptions(sharedOptions, mode, firstOpts); } resolveDataElementOptions(index, mode) { const me = this; @@ -1623,6 +1669,7 @@ function getRatioAndOffset(rotation, circumference, cutout) { class DoughnutController extends DatasetController { constructor(chart, datasetIndex) { super(chart, datasetIndex); + this.enableOptionSharing = true; this.innerRadius = undefined; this.outerRadius = undefined; this.offsetX = undefined; @@ -1655,9 +1702,9 @@ class DoughnutController extends DatasetController { const cutout = options.cutoutPercentage / 100 || 0; const chartWeight = me._getRingWeight(me.index); const {ratioX, ratioY, offsetX, offsetY} = getRatioAndOffset(options.rotation, options.circumference, cutout); - const borderWidth = me.getMaxBorderWidth(); - const maxWidth = (chartArea.right - chartArea.left - borderWidth) / ratioX; - const maxHeight = (chartArea.bottom - chartArea.top - borderWidth) / ratioY; + const spacing = me.getMaxBorderWidth() + me.getMaxOffset(arcs); + const maxWidth = (chartArea.right - chartArea.left - spacing) / ratioX; + const maxHeight = (chartArea.bottom - chartArea.top - spacing) / ratioY; const outerRadius = Math.max(Math.min(maxWidth, maxHeight) / 2, 0); const innerRadius = Math.max(outerRadius * cutout, 0); const radiusLength = (outerRadius - innerRadius) / me._getVisibleDatasetWeightTotal(); @@ -1687,7 +1734,7 @@ class DoughnutController extends DatasetController { const innerRadius = animateScale ? 0 : me.innerRadius; const outerRadius = animateScale ? 0 : me.outerRadius; const firstOpts = me.resolveDataElementOptions(start, mode); - const sharedOptions = me.getSharedOptions(mode, arcs[start], firstOpts); + const sharedOptions = me.getSharedOptions(firstOpts); const includeOptions = me.includeOptions(mode, sharedOptions); let startAngle = opts.rotation; let i; @@ -1708,12 +1755,12 @@ class DoughnutController extends DatasetController { innerRadius }; if (includeOptions) { - properties.options = me.resolveDataElementOptions(index, mode); + properties.options = sharedOptions || me.resolveDataElementOptions(index, mode); } startAngle += circumference; me.updateElement(arc, index, properties, mode); } - me.updateSharedOptions(sharedOptions, mode); + me.updateSharedOptions(sharedOptions, mode, firstOpts); } calculateTotal() { const meta = this._cachedMeta; @@ -1735,6 +1782,16 @@ class DoughnutController extends DatasetController { } return 0; } + getLabelAndValue(index) { + const me = this; + const meta = me._cachedMeta; + const chart = me.chart; + const labels = chart.data.labels || []; + return { + label: labels[index] || '', + value: meta._parsed[index], + }; + } getMaxBorderWidth(arcs) { const me = this; let max = 0; @@ -1764,6 +1821,14 @@ class DoughnutController extends DatasetController { } return max; } + getMaxOffset(arcs) { + let max = 0; + for (let i = 0, ilen = arcs.length; i < ilen; ++i) { + const options = this.resolveDataElementOptions(i); + max = Math.max(max, options.offset || 0, options.hoverOffset || 0); + } + return max; + } _getRingWeightOffset(datasetIndex) { let ringWeightOffset = 0; for (let i = 0; i < datasetIndex; ++i) { @@ -1789,14 +1854,12 @@ DoughnutController.defaults = { 'borderColor', 'borderWidth', 'borderAlign', - 'hoverBackgroundColor', - 'hoverBorderColor', - 'hoverBorderWidth', + 'offset' ], animation: { numbers: { type: 'number', - properties: ['circumference', 'endAngle', 'innerRadius', 'outerRadius', 'startAngle', 'x', 'y'] + properties: ['circumference', 'endAngle', 'innerRadius', 'outerRadius', 'startAngle', 'x', 'y', 'offset', 'borderWidth'] }, animateRotate: true, animateScale: false @@ -1837,8 +1900,8 @@ DoughnutController.defaults = { return ''; }, label(tooltipItem) { - let dataLabel = tooltipItem.chart.data.labels[tooltipItem.dataIndex]; - const value = ': ' + tooltipItem.dataset.data[tooltipItem.dataIndex]; + let dataLabel = tooltipItem.label; + const value = ': ' + tooltipItem.formattedValue; if (isArray(dataLabel)) { dataLabel = dataLabel.slice(); dataLabel[0] += value; @@ -1852,6 +1915,10 @@ DoughnutController.defaults = { }; class LineController extends DatasetController { + initialize() { + this.enableOptionSharing = true; + super.initialize(); + } update(mode) { const me = this; const meta = me._cachedMeta; @@ -1871,7 +1938,7 @@ class LineController extends DatasetController { const reset = mode === 'reset'; const {xScale, yScale, _stacked} = me._cachedMeta; const firstOpts = me.resolveDataElementOptions(start, mode); - const sharedOptions = me.getSharedOptions(mode, points[start], firstOpts); + const sharedOptions = me.getSharedOptions(firstOpts); const includeOptions = me.includeOptions(mode, sharedOptions); const spanGaps = valueOrDefault(me._config.spanGaps, me.chart.options.spanGaps); const maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY; @@ -1889,12 +1956,12 @@ class LineController extends DatasetController { stop: i > 0 && (parsed.x - prevParsed.x) > maxGapLength }; if (includeOptions) { - properties.options = me.resolveDataElementOptions(index, mode); + properties.options = sharedOptions || me.resolveDataElementOptions(index, mode); } me.updateElement(point, index, properties, mode); prevParsed = parsed; } - me.updateSharedOptions(sharedOptions, mode); + me.updateSharedOptions(sharedOptions, mode, firstOpts); } resolveDatasetElementOptions(active) { const me = this; @@ -1923,6 +1990,10 @@ class LineController extends DatasetController { const lastPoint = data[data.length - 1].size(); return Math.max(border, firstPoint, lastPoint) / 2; } + draw() { + this._cachedMeta.dataset.updateControlPoints(this.chart.chartArea); + super.draw(); + } } LineController.id = 'line'; LineController.defaults = { @@ -2080,9 +2151,7 @@ PolarAreaController.defaults = { 'borderColor', 'borderWidth', 'borderAlign', - 'hoverBackgroundColor', - 'hoverBorderColor', - 'hoverBorderWidth' + 'offset' ], animation: { numbers: { @@ -2801,11 +2870,7 @@ const EVENT_TYPES = { pointerleave: 'mouseout', pointerout: 'mouseout' }; -function readUsedSize(element, property) { - const value = getStyle(element, property); - const matches = value && value.match(/^(\d+)(\.\d+)?px$/); - return matches ? +matches[1] : undefined; -} +const isNullOrEmpty = value => value === null || value === ''; function initCanvas(canvas, config) { const style = canvas.style; const renderHeight = canvas.getAttribute('height'); @@ -2823,13 +2888,13 @@ function initCanvas(canvas, config) { }; style.display = style.display || 'block'; style.boxSizing = style.boxSizing || 'border-box'; - if (renderWidth === null || renderWidth === '') { + if (isNullOrEmpty(renderWidth)) { const displayWidth = readUsedSize(canvas, 'width'); if (displayWidth !== undefined) { canvas.width = displayWidth; } } - if (renderHeight === null || renderHeight === '') { + if (isNullOrEmpty(renderHeight)) { if (canvas.style.height === '') { canvas.height = canvas.width / (config.options.aspectRatio || 2); } else { @@ -2841,27 +2906,12 @@ function initCanvas(canvas, config) { } return canvas; } -const supportsEventListenerOptions = (function() { - let passiveSupported = false; - try { - const options = { - get passive() { - passiveSupported = true; - return false; - } - }; - window.addEventListener('test', null, options); - window.removeEventListener('test', null, options); - } catch (e) { - } - return passiveSupported; -}()); const eventListenerOptions = supportsEventListenerOptions ? {passive: true} : false; function addListener(node, type, listener) { node.addEventListener(type, listener, eventListenerOptions); } -function removeListener(node, type, listener) { - node.removeEventListener(type, listener, eventListenerOptions); +function removeListener(chart, type, listener) { + chart.canvas.removeEventListener(type, listener, eventListenerOptions); } function createEvent(type, chart, x, y, nativeEvent) { return { @@ -2877,20 +2927,6 @@ function fromNativeEvent(event, chart) { const pos = getRelativePosition$1(event, chart); return createEvent(type, chart, pos.x, pos.y, event); } -function throttled(fn, thisArg) { - let ticking = false; - let args = []; - return function(...rest) { - args = Array.prototype.slice.call(rest); - if (!ticking) { - ticking = true; - requestAnimFrame.call(window, () => { - ticking = false; - fn.apply(thisArg, args); - }); - } - }; -} function createAttachObserver(chart, type, listener) { const canvas = chart.canvas; const container = canvas && _getParentNode(canvas); @@ -2928,6 +2964,32 @@ function createDetachObserver(chart, type, listener) { observer.observe(container, {childList: true}); return observer; } +const drpListeningCharts = new Map(); +let oldDevicePixelRatio = 0; +function onWindowResize() { + const dpr = window.devicePixelRatio; + if (dpr === oldDevicePixelRatio) { + return; + } + oldDevicePixelRatio = dpr; + drpListeningCharts.forEach((resize, chart) => { + if (chart.currentDevicePixelRatio !== dpr) { + resize(); + } + }); +} +function listenDevicePixelRatioChanges(chart, resize) { + if (!drpListeningCharts.size) { + window.addEventListener('resize', onWindowResize); + } + drpListeningCharts.set(chart, resize); +} +function unlistenDevicePixelRatioChanges(chart) { + drpListeningCharts.delete(chart); + if (!drpListeningCharts.size) { + window.removeEventListener('resize', onWindowResize); + } +} function createResizeObserver(chart, type, listener) { const canvas = chart.canvas; const container = canvas && _getParentNode(canvas); @@ -2951,12 +3013,16 @@ function createResizeObserver(chart, type, listener) { resize(width, height); }); observer.observe(container); + listenDevicePixelRatioChanges(chart, resize); return observer; } -function releaseObserver(canvas, type, observer) { +function releaseObserver(chart, type, observer) { if (observer) { observer.disconnect(); } + if (type === 'resize') { + unlistenDevicePixelRatioChanges(chart); + } } function createProxyAndListen(chart, type, listener) { const canvas = chart.canvas; @@ -3011,7 +3077,6 @@ class DomPlatform extends BasePlatform { proxies[type] = handler(chart, type, listener); } removeEventListener(chart, type) { - const canvas = chart.canvas; const proxies = chart.$proxies || (chart.$proxies = {}); const proxy = proxies[type]; if (!proxy) { @@ -3023,7 +3088,7 @@ class DomPlatform extends BasePlatform { resize: releaseObserver }; const handler = handlers[type] || removeListener; - handler(canvas, type, proxy); + handler(chart, type, proxy); proxies[type] = undefined; } getDevicePixelRatio() { @@ -3193,11 +3258,11 @@ function garbageCollect(caches, length) { function getTickMarkLength(options) { return options.drawTicks ? options.tickMarkLength : 0; } -function getScaleLabelHeight(options) { +function getScaleLabelHeight(options, fallback) { if (!options.display) { return 0; } - const font = toFont(options.font); + const font = toFont(options.font, fallback); const padding = toPadding(options.padding); return font.lineHeight + padding.height; } @@ -3517,7 +3582,7 @@ class Scale extends Element { if (maxLabelWidth + 6 > tickWidth) { tickWidth = maxWidth / (numTicks - (options.offset ? 0.5 : 1)); maxHeight = me.maxHeight - getTickMarkLength(options.gridLines) - - tickOpts.padding - getScaleLabelHeight(options.scaleLabel); + - tickOpts.padding - getScaleLabelHeight(options.scaleLabel, me.chart.options.font); maxLabelDiagonal = Math.sqrt(maxLabelWidth * maxLabelWidth + maxLabelHeight * maxLabelHeight); labelRotation = toDegrees(Math.min( Math.asin(Math.min((labelSizes.highest.height + 6) / tickWidth, 1)), @@ -3547,15 +3612,16 @@ class Scale extends Element { const display = me._isVisible(); const labelsBelowTicks = opts.position !== 'top' && me.axis === 'x'; const isHorizontal = me.isHorizontal(); + const scaleLabelHeight = display && getScaleLabelHeight(scaleLabelOpts, chart.options.font); if (isHorizontal) { minSize.width = me.maxWidth; } else if (display) { - minSize.width = getTickMarkLength(gridLineOpts) + getScaleLabelHeight(scaleLabelOpts); + minSize.width = getTickMarkLength(gridLineOpts) + scaleLabelHeight; } if (!isHorizontal) { minSize.height = me.maxHeight; } else if (display) { - minSize.height = getTickMarkLength(gridLineOpts) + getScaleLabelHeight(scaleLabelOpts); + minSize.height = getTickMarkLength(gridLineOpts) + scaleLabelHeight; } if (tickOpts.display && display && me.ticks.length) { const labelSizes = me._getLabelSizes(); @@ -4087,7 +4153,7 @@ class Scale extends Element { if (!scaleLabel.display) { return; } - const scaleLabelFont = toFont(scaleLabel.font); + const scaleLabelFont = toFont(scaleLabel.font, me.chart.options.font); const scaleLabelPadding = toPadding(scaleLabel.padding); const halfLineHeight = scaleLabelFont.lineHeight / 2; const scaleLabelAlign = scaleLabel.align; @@ -4194,15 +4260,16 @@ class Scale extends Element { } _resolveTickFontOptions(index) { const me = this; + const chart = me.chart; const options = me.options.ticks; const ticks = me.ticks || []; const context = { - chart: me.chart, + chart, scale: me, tick: ticks[index], index }; - return toFont(resolve([options.font], context)); + return toFont(resolve([options.font], context), chart.options.font); } } Scale.prototype._draw = Scale.prototype.draw; @@ -4232,6 +4299,9 @@ class TypedRegistry { if (id in items) { return scope; } + if (Object.keys(defaults.get(scope)).length) { + throw new Error('Can not register "' + id + '", because "defaults.' + scope + '" would collide with existing defaults'); + } items[id] = item; registerDefaults(item, scope, parentScope); return scope; @@ -4312,11 +4382,23 @@ class Registry { getScale(id) { return this._get(id, this.scales, 'scale'); } + removeControllers(...args) { + this._each('unregister', args, this.controllers); + } + removeElements(...args) { + this._each('unregister', args, this.elements); + } + removePlugins(...args) { + this._each('unregister', args, this.plugins); + } + removeScales(...args) { + this._each('unregister', args, this.scales); + } _each(method, args, typedRegistry) { const me = this; [...args].forEach(arg => { const reg = typedRegistry || me._getRegistryForType(arg); - if (reg.isForType(arg) || (reg === me.plugins && arg.id)) { + if (typedRegistry || reg.isForType(arg) || (reg === me.plugins && arg.id)) { me._exec(method, reg, arg); } else { each(arg, item => { @@ -4418,7 +4500,7 @@ function createDescriptors(plugins, options) { return result; } -var version = "3.0.0-alpha.2"; +var version = "3.0.0-beta"; function getIndexAxis(type, options) { const typeDefaults = defaults[type] || {}; @@ -4849,11 +4931,9 @@ class Chart { me.getDatasetMeta(i).controller.buildOrUpdateElements(); } me._updateLayout(); - if (me.options.animation) { - each(newControllers, (controller) => { - controller.reset(); - }); - } + each(newControllers, (controller) => { + controller.reset(); + }); me._updateDatasets(mode); me._plugins.notify(me, 'afterUpdate'); me._layers.sort(compare2Level('z', '_idx')); @@ -5214,9 +5294,10 @@ class Chart { return changed; } } -Chart.version = version; +Chart.defaults = defaults; Chart.instances = {}; Chart.registry = registry; +Chart.version = version; const invalidatePlugins = () => each(Chart.instances, (chart) => chart._plugins.invalidate()); Chart.register = (...items) => { registry.add(...items); @@ -5228,64 +5309,74 @@ Chart.unregister = (...items) => { }; const TAU = Math.PI * 2; -function clipArc(ctx, model) { - const {startAngle, endAngle, pixelMargin, x, y} = model; - let angleMargin = pixelMargin / model.outerRadius; +function clipArc(ctx, element) { + const {startAngle, endAngle, pixelMargin, x, y, outerRadius, innerRadius} = element; + let angleMargin = pixelMargin / outerRadius; ctx.beginPath(); - ctx.arc(x, y, model.outerRadius, startAngle - angleMargin, endAngle + angleMargin); - if (model.innerRadius > pixelMargin) { - angleMargin = pixelMargin / model.innerRadius; - ctx.arc(x, y, model.innerRadius - pixelMargin, endAngle + angleMargin, startAngle - angleMargin, true); + ctx.arc(x, y, outerRadius, startAngle - angleMargin, endAngle + angleMargin); + if (innerRadius > pixelMargin) { + angleMargin = pixelMargin / innerRadius; + ctx.arc(x, y, innerRadius, endAngle + angleMargin, startAngle - angleMargin, true); } else { ctx.arc(x, y, pixelMargin, endAngle + Math.PI / 2, startAngle - Math.PI / 2); } ctx.closePath(); ctx.clip(); } -function pathArc(ctx, model) { +function pathArc(ctx, element) { + const {x, y, startAngle, endAngle, pixelMargin} = element; + const outerRadius = Math.max(element.outerRadius - pixelMargin, 0); + const innerRadius = element.innerRadius + pixelMargin; ctx.beginPath(); - ctx.arc(model.x, model.y, model.outerRadius, model.startAngle, model.endAngle); - ctx.arc(model.x, model.y, model.innerRadius, model.endAngle, model.startAngle, true); + ctx.arc(x, y, outerRadius, startAngle, endAngle); + ctx.arc(x, y, innerRadius, endAngle, startAngle, true); ctx.closePath(); } -function drawArc(ctx, model, circumference) { - if (model.fullCircles) { - model.endAngle = model.startAngle + TAU; - pathArc(ctx, model); - for (let i = 0; i < model.fullCircles; ++i) { +function drawArc(ctx, element) { + if (element.fullCircles) { + element.endAngle = element.startAngle + TAU; + pathArc(ctx, element); + for (let i = 0; i < element.fullCircles; ++i) { ctx.fill(); } - model.endAngle = model.startAngle + circumference % TAU; + element.endAngle = element.startAngle + element.circumference % TAU; } - pathArc(ctx, model); + pathArc(ctx, element); ctx.fill(); } -function drawFullCircleBorders(ctx, element, model, inner) { - const endAngle = model.endAngle; +function drawFullCircleBorders(ctx, element, inner) { + const {x, y, startAngle, endAngle, pixelMargin} = element; + const outerRadius = Math.max(element.outerRadius - pixelMargin, 0); + const innerRadius = element.innerRadius + pixelMargin; let i; if (inner) { - model.endAngle = model.startAngle + TAU; - clipArc(ctx, model); - model.endAngle = endAngle; - if (model.endAngle === model.startAngle && model.fullCircles) { - model.endAngle += TAU; - model.fullCircles--; + element.endAngle = element.startAngle + TAU; + clipArc(ctx, element); + element.endAngle = endAngle; + if (element.endAngle === element.startAngle) { + element.endAngle += TAU; + element.fullCircles--; } } ctx.beginPath(); - ctx.arc(model.x, model.y, model.innerRadius, model.startAngle + TAU, model.startAngle, true); - for (i = 0; i < model.fullCircles; ++i) { + ctx.arc(x, y, innerRadius, startAngle + TAU, startAngle, true); + for (i = 0; i < element.fullCircles; ++i) { ctx.stroke(); } ctx.beginPath(); - ctx.arc(model.x, model.y, element.outerRadius, model.startAngle, model.startAngle + TAU); - for (i = 0; i < model.fullCircles; ++i) { + ctx.arc(x, y, outerRadius, startAngle, startAngle + TAU); + for (i = 0; i < element.fullCircles; ++i) { ctx.stroke(); } } -function drawBorder(ctx, element, model) { - const options = element.options; +function drawBorder(ctx, element) { + const {x, y, startAngle, endAngle, pixelMargin, options} = element; + const outerRadius = element.outerRadius; + const innerRadius = element.innerRadius + pixelMargin; const inner = options.borderAlign === 'inner'; + if (!options.borderWidth) { + return; + } if (inner) { ctx.lineWidth = options.borderWidth * 2; ctx.lineJoin = 'round'; @@ -5293,15 +5384,15 @@ function drawBorder(ctx, element, model) { ctx.lineWidth = options.borderWidth; ctx.lineJoin = 'bevel'; } - if (model.fullCircles) { - drawFullCircleBorders(ctx, element, model, inner); + if (element.fullCircles) { + drawFullCircleBorders(ctx, element, inner); } if (inner) { - clipArc(ctx, model); + clipArc(ctx, element); } ctx.beginPath(); - ctx.arc(model.x, model.y, element.outerRadius, model.startAngle, model.endAngle); - ctx.arc(model.x, model.y, model.innerRadius, model.endAngle, model.startAngle, true); + ctx.arc(x, y, outerRadius, startAngle, endAngle); + ctx.arc(x, y, innerRadius, endAngle, startAngle, true); ctx.closePath(); ctx.stroke(); } @@ -5314,6 +5405,8 @@ class Arc extends Element { this.endAngle = undefined; this.innerRadius = undefined; this.outerRadius = undefined; + this.pixelMargin = 0; + this.fullCircles = 0; if (cfg) { Object.assign(this, cfg); } @@ -5354,27 +5447,21 @@ class Arc extends Element { draw(ctx) { const me = this; const options = me.options; - const pixelMargin = (options.borderAlign === 'inner') ? 0.33 : 0; - const model = { - x: me.x, - y: me.y, - innerRadius: me.innerRadius, - outerRadius: Math.max(me.outerRadius - pixelMargin, 0), - pixelMargin, - startAngle: me.startAngle, - endAngle: me.endAngle, - fullCircles: Math.floor(me.circumference / TAU) - }; + const offset = options.offset || 0; + me.pixelMargin = (options.borderAlign === 'inner') ? 0.33 : 0; + me.fullCircles = Math.floor(me.circumference / TAU); if (me.circumference === 0) { return; } ctx.save(); + if (offset && me.circumference < TAU) { + const halfAngle = (me.startAngle + me.endAngle) / 2; + ctx.translate(Math.cos(halfAngle) * offset, Math.sin(halfAngle) * offset); + } ctx.fillStyle = options.backgroundColor; ctx.strokeStyle = options.borderColor; - drawArc(ctx, model, me.circumference); - if (options.borderWidth) { - drawBorder(ctx, me, model); - } + drawArc(ctx, me); + drawBorder(ctx, me); ctx.restore(); } } @@ -5382,7 +5469,8 @@ Arc.id = 'arc'; Arc.defaults = { borderAlign: 'center', borderColor: '#fff', - borderWidth: 2 + borderWidth: 2, + offset: 0 }; Arc.defaultRoutes = { backgroundColor: 'color' @@ -5504,6 +5592,7 @@ class Line extends Element { this._fullLoop = undefined; this._points = undefined; this._segments = undefined; + this._pointsUpdated = false; if (cfg) { Object.assign(this, cfg); } @@ -5511,9 +5600,10 @@ class Line extends Element { updateControlPoints(chartArea) { const me = this; const options = me.options; - if (options.tension && !options.stepped) { + if (options.tension && !options.stepped && !me._pointsUpdated) { const loop = options.spanGaps ? me._loop : me._fullLoop; _updateBezierControlPoints(me._points, options, chartArea, loop); + me._pointsUpdated = true; } } set points(points) { @@ -5593,6 +5683,7 @@ class Line extends Element { } ctx.stroke(); ctx.restore(); + this._pointsUpdated = false; } } Line.id = 'line'; @@ -5863,7 +5954,7 @@ function decodeFill(line, index, count) { } return target; } - return ['origin', 'start', 'end'].indexOf(fill) >= 0 ? fill : false; + return ['origin', 'start', 'end', 'stack'].indexOf(fill) >= 0 && fill; } function computeLinearBoundary(source) { const {scale = {}, fill} = source; @@ -5950,40 +6041,114 @@ function pointsFromSegments(boundary, line) { const first = linePoints[segment.start]; const last = linePoints[segment.end]; if (y !== null) { - points.push({x: first.x, y, _prop: 'x', _ref: first}); - points.push({x: last.x, y, _prop: 'x', _ref: last}); + points.push({x: first.x, y}); + points.push({x: last.x, y}); } else if (x !== null) { - points.push({x, y: first.y, _prop: 'y', _ref: first}); - points.push({x, y: last.y, _prop: 'y', _ref: last}); + points.push({x, y: first.y}); + points.push({x, y: last.y}); } }); return points; } +function buildStackLine(source) { + const {chart, scale, index, line} = source; + const points = []; + const segments = line.segments; + const sourcePoints = line.points; + const linesBelow = getLinesBelow(chart, index); + linesBelow.push(createBoundaryLine({x: null, y: scale.bottom}, line)); + for (let i = 0; i < segments.length; i++) { + const segment = segments[i]; + for (let j = segment.start; j <= segment.end; j++) { + addPointsBelow(points, sourcePoints[j], linesBelow); + } + } + return new Line({points, options: {}}); +} +const isLineAndNotInHideAnimation = (meta) => meta.type === 'line' && !meta.hidden; +function getLinesBelow(chart, index) { + const below = []; + const metas = chart.getSortedVisibleDatasetMetas(); + for (let i = 0; i < metas.length; i++) { + const meta = metas[i]; + if (meta.index === index) { + break; + } + if (isLineAndNotInHideAnimation(meta)) { + below.unshift(meta.dataset); + } + } + return below; +} +function addPointsBelow(points, sourcePoint, linesBelow) { + const postponed = []; + for (let j = 0; j < linesBelow.length; j++) { + const line = linesBelow[j]; + const {first, last, point} = findPoint(line, sourcePoint, 'x'); + if (!point || (first && last)) { + continue; + } + if (first) { + postponed.unshift(point); + } else { + points.push(point); + if (!last) { + break; + } + } + } + points.push(...postponed); +} +function findPoint(line, sourcePoint, property) { + const point = line.interpolate(sourcePoint, property); + if (!point) { + return {}; + } + const pointValue = point[property]; + const segments = line.segments; + const linePoints = line.points; + let first = false; + let last = false; + for (let i = 0; i < segments.length; i++) { + const segment = segments[i]; + const firstValue = linePoints[segment.start][property]; + const lastValue = linePoints[segment.end][property]; + if (pointValue >= firstValue && pointValue <= lastValue) { + first = pointValue === firstValue; + last = pointValue === lastValue; + break; + } + } + return {first, last, point}; +} function getTarget(source) { const {chart, fill, line} = source; if (isNumberFinite(fill)) { return getLineByIndex(chart, fill); } + if (fill === 'stack') { + return buildStackLine(source); + } const boundary = computeBoundary(source); - let points = []; - let _loop = false; - let _refPoints = false; if (boundary instanceof simpleArc) { return boundary; } + return createBoundaryLine(boundary, line); +} +function createBoundaryLine(boundary, line) { + let points = []; + let _loop = false; if (isArray(boundary)) { _loop = true; points = boundary; } else { points = pointsFromSegments(boundary, line); - _refPoints = true; } return points.length ? new Line({ points, options: {tension: 0}, _loop, - _fullLoop: _loop, - _refPoints + _fullLoop: _loop }) : null; } function resolveTarget(sources, index, propagate) { @@ -6041,15 +6206,6 @@ function _segments(line, target, property) { const points = line.points; const tpoints = target.points; const parts = []; - if (target._refPoints) { - for (let i = 0, ilen = tpoints.length; i < ilen; ++i) { - const point = tpoints[i]; - const prop = point._prop; - if (prop) { - point[prop] = point._ref[prop]; - } - } - } for (let i = 0; i < segments.length; i++) { const segment = segments[i]; const bounds = getBounds(property, points[segment.start], points[segment.end], segment.loop); @@ -6100,7 +6256,7 @@ function interpolatedLineTo(ctx, target, point, property) { } function _fill(ctx, cfg) { const {line, target, property, color, scale} = cfg; - const segments = _segments(cfg.line, cfg.target, property); + const segments = _segments(line, target, property); ctx.fillStyle = color; for (let i = 0, ilen = segments.length; i < ilen; ++i) { const {source: src, target: tgt, start, end} = segments[i]; @@ -6151,11 +6307,11 @@ var plugin_filler = { if (line && line.options && line instanceof Line) { source = { visible: chart.isDatasetVisible(i), + index: i, fill: decodeFill(line, i, count), chart, scale: meta.vScale, - line, - target: undefined + line }; } meta.$filler = source; @@ -6167,7 +6323,6 @@ var plugin_filler = { continue; } source.fill = resolveTarget(sources, i, propagate); - source.target = source.fill !== false && getTarget(source); } }, beforeDatasetsDraw(chart) { @@ -6184,11 +6339,12 @@ var plugin_filler = { beforeDatasetDraw(chart, args) { const area = chart.chartArea; const ctx = chart.ctx; - const meta = args.meta.$filler; - if (!meta || meta.fill === false) { + const source = args.meta.$filler; + if (!source || source.fill === false) { return; } - const {line, target, scale} = meta; + const target = getTarget(source); + const {line, scale} = source; const lineOpts = line.options; const fillOption = lineOpts.fill; const color = lineOpts.backgroundColor; @@ -6310,7 +6466,7 @@ class Legend extends Element { const labelOpts = opts.labels; const display = opts.display; const ctx = me.ctx; - const labelFont = toFont(labelOpts.font); + const labelFont = toFont(labelOpts.font, me.chart.options.font); const fontSize = labelFont.size; const boxWidth = getBoxWidth(labelOpts, fontSize); const boxHeight = getBoxHeight(labelOpts, fontSize); @@ -6394,7 +6550,6 @@ class Legend extends Element { const opts = me.options; const labelOpts = opts.labels; const defaultColor = defaults.color; - const lineDefault = defaults.elements.line; const legendHeight = me.height; const columnHeights = me.columnHeights; const legendWidth = me.width; @@ -6405,7 +6560,7 @@ class Legend extends Element { me.drawTitle(); const rtlHelper = getRtlAdapter(opts.rtl, me.left, me._minSize.width); const ctx = me.ctx; - const labelFont = toFont(labelOpts.font); + const labelFont = toFont(labelOpts.font, me.chart.options.font); const fontColor = labelFont.color; const fontSize = labelFont.size; let cursor; @@ -6424,15 +6579,15 @@ class Legend extends Element { return; } ctx.save(); - const lineWidth = valueOrDefault(legendItem.lineWidth, lineDefault.borderWidth); + const lineWidth = valueOrDefault(legendItem.lineWidth, 1); ctx.fillStyle = valueOrDefault(legendItem.fillStyle, defaultColor); - ctx.lineCap = valueOrDefault(legendItem.lineCap, lineDefault.borderCapStyle); - ctx.lineDashOffset = valueOrDefault(legendItem.lineDashOffset, lineDefault.borderDashOffset); - ctx.lineJoin = valueOrDefault(legendItem.lineJoin, lineDefault.borderJoinStyle); + ctx.lineCap = valueOrDefault(legendItem.lineCap, 'butt'); + ctx.lineDashOffset = valueOrDefault(legendItem.lineDashOffset, 0); + ctx.lineJoin = valueOrDefault(legendItem.lineJoin, 'miter'); ctx.lineWidth = lineWidth; ctx.strokeStyle = valueOrDefault(legendItem.strokeStyle, defaultColor); if (ctx.setLineDash) { - ctx.setLineDash(valueOrDefault(legendItem.lineDash, lineDefault.borderDash)); + ctx.setLineDash(valueOrDefault(legendItem.lineDash, [])); } if (labelOpts && labelOpts.usePointStyle) { const drawOptions = { @@ -6527,7 +6682,7 @@ class Legend extends Element { const me = this; const opts = me.options; const titleOpts = opts.title; - const titleFont = toFont(titleOpts.font); + const titleFont = toFont(titleOpts.font, me.chart.options.font); const titlePadding = toPadding(titleOpts.padding); if (!titleOpts.display) { return; @@ -6588,7 +6743,7 @@ class Legend extends Element { } _computeTitleHeight() { const titleOpts = this.options.title; - const titleFont = toFont(titleOpts.font); + const titleFont = toFont(titleOpts.font, this.chart.options.font); const titlePadding = toPadding(titleOpts.padding); return titleOpts.display ? titleFont.lineHeight + titlePadding.height : 0; } @@ -6810,7 +6965,7 @@ class Title extends Element { } const lineCount = isArray(opts.text) ? opts.text.length : 1; me._padding = toPadding(opts.padding); - const textSize = lineCount * toFont(opts.font).lineHeight + me._padding.height; + const textSize = lineCount * toFont(opts.font, me.chart.options.font).lineHeight + me._padding.height; me.width = minSize.width = isHorizontal ? me.maxWidth : textSize; me.height = minSize.height = isHorizontal ? textSize : me.maxHeight; } @@ -6826,7 +6981,7 @@ class Title extends Element { if (!opts.display) { return; } - const fontOpts = toFont(opts.font); + const fontOpts = toFont(opts.font, me.chart.options.font); const lineHeight = fontOpts.lineHeight; const offset = lineHeight / 2 + me._padding.top; let rotation = 0; @@ -7022,11 +7177,11 @@ function createTooltipItem(chart, item) { element }; } -function resolveOptions$1(options) { +function resolveOptions$1(options, fallbackFont) { options = merge({}, [defaults.plugins.tooltip, options]); - options.bodyFont = toFont(options.bodyFont); - options.titleFont = toFont(options.titleFont); - options.footerFont = toFont(options.footerFont); + options.bodyFont = toFont(options.bodyFont, fallbackFont); + options.titleFont = toFont(options.titleFont, fallbackFont); + options.footerFont = toFont(options.footerFont, fallbackFont); options.boxHeight = valueOrDefault(options.boxHeight, options.bodyFont.size); options.boxWidth = valueOrDefault(options.boxWidth, options.bodyFont.size); return options; @@ -7209,7 +7364,8 @@ class Tooltip extends Element { } initialize() { const me = this; - me.options = resolveOptions$1(me._chart.options.tooltips); + const chartOpts = me._chart.options; + me.options = resolveOptions$1(chartOpts.tooltips, chartOpts.font); } _resolveAnimations() { const me = this; @@ -7751,7 +7907,7 @@ var plugin_tooltip = { footer: noop, afterFooter: noop } - } + }, }; class CategoryScale extends Scale { @@ -8249,7 +8405,7 @@ function fitWithPointLabels(scale) { index: i, label: scale.pointLabels[i] }; - const plFont = toFont(resolve([scale.options.pointLabels.font], context, i)); + const plFont = toFont(resolve([scale.options.pointLabels.font], context, i), scale.chart.options.font); scale.ctx.font = plFont.string; textSize = measureLabelSize(scale.ctx, plFont.lineHeight, scale.pointLabels[i]); scale._pointLabelSizes[i] = textSize; @@ -8320,7 +8476,7 @@ function drawPointLabels(scale) { index: i, label: scale.pointLabels[i], }; - const plFont = toFont(resolve([pointLabelOpts.font], context, i)); + const plFont = toFont(resolve([pointLabelOpts.font], context, i), scale.chart.options.font); ctx.font = plFont.string; ctx.fillStyle = plFont.color; const angle = toDegrees(scale.getIndexAngle(i)); diff --git a/lib/chartjs/chart.esm.min.js b/lib/chartjs/chart.esm.min.js index 1959c5d..191a736 100644 --- a/lib/chartjs/chart.esm.min.js +++ b/lib/chartjs/chart.esm.min.js @@ -1,7 +1 @@ -/*! - * Chart.js v3.0.0-alpha.2 - * https://www.chartjs.org - * (c) 2020 Chart.js Contributors - * Released under the MIT License - */ -import{requestAnimFrame}from"../helpers/extras.js";import effects from"../helpers/easing.js";import{isObject,noop,valueOrDefault,merge,isArray,resolveObjectKey,_capitalize,mergeIf,_merger,isNullOrUndef,each,isFinite as isNumberFinite,callback,uid,_elementsEqual}from"../helpers/core.js";import{r as resolve,d as defaults,t as toPadding,a as toFont}from"../helpers/chunks/helpers.options.js";export{d as defaults}from"../helpers/chunks/helpers.options.js";import{clipArea,unclipArea,_isPointInArea,_measureText,_alignPixel,clear,_steppedLineTo,_bezierCurveTo,drawPoint,_longestText}from"../helpers/canvas.js";import{color,getHoverColor}from"../helpers/color.js";import{unlistenArrayEvents,listenArrayEvents,_rlookupByKey,_lookupByKey,_filterBetween,_arrayUnique,_lookup}from"../helpers/collection.js";import{sign,_limitValue,isNumber,toRadians,log10,toDegrees,_factorize,getAngleFromPoint,_angleBetween,_normalizeAngle,distanceBetweenPoints,_setMinAndMaxByKey,_decimalPlaces,almostEquals,almostWhole}from"../helpers/math.js";import{getRelativePosition as getRelativePosition$1,_getParentNode,getStyle,retinaScale,getMaximumWidth,getMaximumHeight}from"../helpers/dom.js";import{_steppedInterpolation,_bezierInterpolation,_pointInLine}from"../helpers/interpolation.js";import{_computeSegments,_boundSegments,_boundSegment}from"../helpers/segment.js";import{_updateBezierControlPoints}from"../helpers/curve.js";import{getRtlAdapter,overrideTextDirection,restoreTextDirection}from"../helpers/rtl.js";function drawFPS(t,e,i,a){const n=1e3/(i-a)|0,o=t.ctx;o.save(),o.clearRect(0,0,50,24),o.fillStyle="black",o.textAlign="right",e&&(o.fillText(e,50,8),o.fillText(n+" fps",50,18)),o.restore()}class Animator{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,a){const n=e.listeners[a]||[],o=e.duration;n.forEach(a=>a({chart:t,numSteps:o,currentStep:Math.min(i-e.start,o)}))}_refresh(){const t=this;t._request||(t._running=!0,t._request=requestAnimFrame.call(window,()=>{t._update(),t._request=null,t._running&&t._refresh()}))}_update(){const t=this,e=Date.now();let i=0;t._charts.forEach((a,n)=>{if(!a.running||!a.items.length)return;const o=a.items;let s,r=o.length-1,l=!1;for(;r>=0;--r)s=o[r],s._active?(s.tick(e),l=!0):(o[r]=o[o.length-1],o.pop());l&&(n.draw(),t._notify(n,a,e,"progress")),n.options.animation.debug&&drawFPS(n,o.length,e,t._lastDate),o.length||(a.running=!1,t._notify(n,a,e,"complete")),i+=o.length}),t._lastDate=e,0===i&&(t._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((t,e)=>Math.max(t,e._duration),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const i=e.items;let a=i.length-1;for(;a>=0;--a)i[a].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var animator=new Animator;const transparent="transparent",interpolators={boolean:(t,e,i)=>i>.5?e:t,color(t,e,i){const a=color(t||transparent),n=a.valid&&color(e||transparent);return n&&n.valid?n.mix(a,i).hexString():e},number:(t,e,i)=>t+(e-t)*i};class Animation{constructor(t,e,i,a){const n=e[i];a=resolve([t.to,a,n,t.from]);const o=resolve([t.from,n,a]);this._active=!0,this._fn=t.fn||interpolators[t.type||typeof o],this._easing=effects[t.easing||"linear"],this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=o,this._to=a}active(){return this._active}update(t,e,i){const a=this;if(a._active){const n=a._target[a._prop],o=i-a._start,s=a._duration-o;a._start=i,a._duration=Math.floor(Math.max(s,t.duration)),a._loop=!!t.loop,a._to=resolve([t.to,e,n,t.from]),a._from=resolve([t.from,n,e])}}cancel(){const t=this;t._active&&(t.tick(Date.now()),t._active=!1)}tick(t){const e=this,i=t-e._start,a=e._duration,n=e._prop,o=e._from,s=e._loop,r=e._to;let l;e._active=o!==r&&(s||i1?2-l:l,l=e._easing(Math.min(1,Math.max(0,l))),e._target[n]=e._fn(o,r,l)):e._target[n]=r}}const numbers=["x","y","borderWidth","radius","tension"],colors=["borderColor","backgroundColor"];function copyOptions(t,e){const i=t.options,a=e.options;i&&a&&!a.$shared&&(i.$shared?t.options=Object.assign({},i,a,{$shared:!1}):Object.assign(i,a),delete e.options)}function extensibleConfig(t){const e={};return Object.keys(t).forEach(i=>{const a=t[i];isObject(a)||(e[i]=a)}),e}defaults.set("animation",{duration:1e3,easing:"easeOutQuart",onProgress:noop,onComplete:noop,colors:{type:"color",properties:colors},numbers:{type:"number",properties:numbers},active:{duration:400},resize:{duration:0},show:{colors:{type:"color",properties:colors,from:"transparent"},visible:{type:"boolean",duration:0}},hide:{colors:{type:"color",properties:colors,to:"transparent"},visible:{type:"boolean",easing:"easeInExpo"}}});class Animations{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!isObject(t))return;const e=this._properties,i=extensibleConfig(t);Object.keys(t).forEach(a=>{const n=t[a];isObject(n)&&(n.properties||[a]).forEach(t=>{e.has(t)?t===a&&e.set(t,Object.assign({},e.get(t),n)):e.set(t,Object.assign({},i,n))})})}_animateOptions(t,e){const i=e.options;let a=[];if(!i)return a;let n=t.options;return n?(n.$shared&&(t.options=n=Object.assign({},n,{$shared:!1,$animations:{}})),a=this._createAnimations(n,i)):t.options=i,a}_createAnimations(t,e){const i=this._properties,a=[],n=t.$animations||(t.$animations={}),o=Object.keys(e),s=Date.now();let r;for(r=o.length-1;r>=0;--r){const l=o[r];if("$"===l.charAt(0))continue;if("options"===l){a.push(...this._animateOptions(t,e));continue}const c=e[l];let d=n[l];const h=i.get(l);if(d){if(h&&d.active()){d.update(h,c,s);continue}d.cancel()}h&&h.duration?(n[l]=d=new Animation(h,t,l,c),a.push(d)):t[l]=c}return a}update(t,e){if(0===this._properties.size)return copyOptions(t,e),void Object.assign(t,e);const i=this._createAnimations(t,e);return i.length?(animator.add(this._chart,i),!0):void 0}}function scaleClip(t,e){const i=t&&t.options||{},a=i.reverse,n=void 0===i.min?e:0,o=void 0===i.max?e:0;return{start:a?o:n,end:a?n:o}}function defaultClip(t,e,i){if(!1===i)return!1;const a=scaleClip(t,i),n=scaleClip(e,i);return{top:n.end,right:a.end,bottom:n.start,left:a.start}}function toClip(t){let e,i,a,n;return isObject(t)?(e=t.top,i=t.right,a=t.bottom,n=t.left):e=i=a=n=t,{top:e,right:i,bottom:a,left:n}}function getSortedDatasetIndices(t,e){const i=[],a=t._getSortedDatasetMetas(e);let n,o;for(n=0,o=a.length;ni[t].axis===e).shift()}function optionKeys(t){return isArray(t)?t:Object.keys(t)}function optionKey(t,e){return e?"hover"+_capitalize(t):t}class DatasetController{constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedAnimations={},this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this._config=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this.initialize()}initialize(){const t=this,e=t._cachedMeta;t.configure(),t.linkScales(),e._stacked=isStacked(e.vScale,e),t.addElements()}updateIndex(t){this.index=t}linkScales(){const t=this,e=t.chart,i=t._cachedMeta,a=t.getDataset(),n=(t,e,i,a)=>"x"===t?e:"r"===t?a:i,o=i.xAxisID=valueOrDefault(a.xAxisID,getFirstScaleId(e,"x")),s=i.yAxisID=valueOrDefault(a.yAxisID,getFirstScaleId(e,"y")),r=i.rAxisID=valueOrDefault(a.rAxisID,getFirstScaleId(e,"r")),l=i.indexAxis,c=i.iAxisID=n(l,o,s,r),d=i.vAxisID=n(l,s,o,r);i.xScale=t.getScaleForId(o),i.yScale=t.getScaleForId(s),i.rScale=t.getScaleForId(r),i.iScale=t.getScaleForId(c),i.vScale=t.getScaleForId(d)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){this._data&&unlistenArrayEvents(this._data,this)}_dataCheck(){const t=this,e=t.getDataset(),i=e.data||(e.data=[]);isObject(i)?t._data=convertObjectDataToArray(i):t._data!==i&&(t._data&&unlistenArrayEvents(t._data,t),i&&Object.isExtensible(i)&&listenArrayEvents(i,t),t._data=i)}addElements(){const t=this,e=t._cachedMeta;t._dataCheck();const i=t._data,a=e.data=new Array(i.length);for(let e=0,n=i.length;e{delete t._stacks[e.vScale.id][e.index]}),e.stack=i.stack),t._resyncElements(),a&&updateStacks(t,e._parsed)}configure(){const t=this;t._config=merge({},[t.chart.options[t._type].datasets,t.getDataset()],{merger(t,e,i){"data"!==t&&_merger(t,e,i)}}),t._parsing=resolve([t._config.parsing,t.chart.options.parsing,!0])}parse(t,e){const i=this,{_cachedMeta:a,_data:n}=i,{iScale:o,vScale:s,_stacked:r}=a,l=o.axis;let c,d,h,u,g=!0;if(t>0&&(g=a._sorted,u=a._parsed[t-1]),!1===i._parsing)a._parsed=n,a._sorted=!0;else{for(d=isArray(n[t])?i.parseArrayData(a,n,t,e):isObject(n[t])?i.parseObjectData(a,n,t,e):i.parsePrimitiveData(a,n,t,e),c=0;cf||h=0;--u)if(!m()){i.updateRangeFromParsed(c,t,p,l);break}return c}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let a,n,o;for(a=0,n=e.length;a-1!==t.indexOf("Color")&&!(t in e));let n,o=a.length-1;for(;o>=0;o--)n=a[o],e[n]=getHoverColor(i[n])}getStyle(t,e){const i=this,a=i._cachedMeta.dataset;i._config||i.configure();const n=a&&void 0===t?i.resolveDatasetElementOptions(e):i.resolveDataElementOptions(t||0,e&&"active");return e&&i._addAutomaticHoverColors(t,n),n}_getContext(t,e){return{chart:this.chart,dataPoint:this.getParsed(t),dataIndex:t,dataset:this.getDataset(),datasetIndex:this.index,active:e}}resolveDatasetElementOptions(t){return this._resolveOptions(this.datasetElementOptions,{active:t,type:this.datasetElementType.id})}resolveDataElementOptions(t,e){const i=this,a="active"===e,n=i._cachedDataOpts;if(n[e])return n[e];const o={cacheable:!a},s=i._resolveOptions(i.dataElementOptions,{index:t,active:a,info:o,type:i.dataElementType.id});return o.cacheable&&(s.$shared=!0,n[e]=s),s}_resolveOptions(t,e){const i=this,{index:a,active:n,type:o,info:s}=e,r=i._config,l=i.chart.options.elements[o]||{},c={},d=i._getContext(a,n),h=optionKeys(t);for(let e=0,i=h.length;ei?t._insertElements(i,a-i):a0?Math.min(s,Math.abs(a-i)):s,i=a;return s}function computeFitCategoryTraits(t,e,i){const a=i.barThickness,n=e.stackCount;let o,s;return isNullOrUndef(a)?(o=e.min*i.categoryPercentage,s=i.barPercentage):(o=a*n,s=1),{chunk:o/n,ratio:s,start:e.pixels[t]-o/2}}function computeFlexCategoryTraits(t,e,i){const a=e.pixels,n=a[t];let o=t>0?a[t-1]:null,s=tMath.abs(r)&&(l=r,c=s),e[i.axis]=c,e._custom={barStart:l,barEnd:c,start:n,end:o,min:s,max:r}}function parseValue(t,e,i,a){return isArray(t)?parseFloatBar(t,e,i,a):e[i.axis]=i.parse(t,a),e}function parseArrayOrPrimitive(t,e,i,a){const n=t.iScale,o=t.vScale,s=n.getLabels(),r=n===o,l=[];let c,d,h,u;for(c=i,d=i+a;c=0;--e)i=Math.max(i,t.getStyle(e,!0).radius);return i>0&&i}getLabelAndValue(t){const e=this._cachedMeta,{xScale:i,yScale:a}=e,n=this.getParsed(t),o=i.getLabelForValue(n.x),s=a.getLabelForValue(n.y),r=n._custom;return{label:e.label,value:"("+o+", "+s+(r?", "+r:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,t)}updateElements(t,e,i){const a=this,n="reset"===i,{xScale:o,yScale:s}=a._cachedMeta,r=a.resolveDataElementOptions(e,i),l=a.getSharedOptions(i,t[e],r),c=a.includeOptions(i,l);for(let r=0;r""}}};const PI=Math.PI,DOUBLE_PI=2*PI,HALF_PI=PI/2;function getRatioAndOffset(t,e,i){let a=1,n=1,o=0,s=0;if(e=PI?-DOUBLE_PI:r<-PI?DOUBLE_PI:0;const l=r+e,c=Math.cos(r),d=Math.sin(r),h=Math.cos(l),u=Math.sin(l),g=r<=0&&l>=0||l>=DOUBLE_PI,p=r<=HALF_PI&&l>=HALF_PI||l>=DOUBLE_PI+HALF_PI,f=r<=-HALF_PI&&l>=-HALF_PI||l>=PI+HALF_PI,m=r===-PI||l>=PI?-1:Math.min(c,c*i,h,h*i),x=f?-1:Math.min(d,d*i,u,u*i),b=g?1:Math.max(c,c*i,h,h*i),_=p?1:Math.max(d,d*i,u,u*i);a=(b-m)/2,n=(_-x)/2,o=-(b+m)/2,s=-(_+x)/2}return{ratioX:a,ratioY:n,offsetX:o,offsetY:s}}class DoughnutController extends DatasetController{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const i=this.getDataset().data,a=this._cachedMeta;let n,o;for(n=t,o=t+e;n0&&!isNaN(t)?DOUBLE_PI*(Math.abs(t)/e):0}getMaxBorderWidth(t){const e=this;let i=0;const a=e.chart;let n,o,s,r,l;if(!t)for(n=0,o=a.data.datasets.length;n{const a=t.getDatasetMeta(0).controller.getStyle(i);return{text:e,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,lineWidth:a.borderWidth,hidden:!t.getDataVisibility(i),index:i}}):[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},cutoutPercentage:50,rotation:-HALF_PI,circumference:DOUBLE_PI,tooltips:{callbacks:{title:()=>"",label(t){let e=t.chart.data.labels[t.dataIndex];const i=": "+t.dataset.data[t.dataIndex];return isArray(e)?(e=e.slice(),e[0]+=i):e+=i,e}}}};class LineController extends DatasetController{update(t){const e=this,i=e._cachedMeta,a=i.dataset,n=i.data||[];if("resize"!==t){const i={points:n,options:e.resolveDatasetElementOptions()};e.updateElement(a,void 0,i,t)}e.updateElements(n,0,t)}updateElements(t,e,i){const a=this,n="reset"===i,{xScale:o,yScale:s,_stacked:r}=a._cachedMeta,l=a.resolveDataElementOptions(e,i),c=a.getSharedOptions(i,t[e],l),d=a.includeOptions(i,c),h=valueOrDefault(a._config.spanGaps,a.chart.options.spanGaps),u=isNumber(h)?h:Number.POSITIVE_INFINITY;let g;for(let l=0;l0&&p.x-g.x>u};d&&(x.options=a.resolveDataElementOptions(c,i)),a.updateElement(h,c,x,i),g=p}a.updateSharedOptions(c,i)}resolveDatasetElementOptions(t){const e=this._config,i=this.chart.options,a=i.elements.line,n=super.resolveDatasetElementOptions(t),o=valueOrDefault(e.showLine,i.showLines);return n.spanGaps=valueOrDefault(e.spanGaps,i.spanGaps),n.tension=valueOrDefault(e.lineTension,a.tension),n.stepped=resolve([e.stepped,a.stepped]),o||(n.borderWidth=0),n}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset.options.borderWidth||0,i=t.data||[];if(!i.length)return e;const a=i[0].size(),n=i[i.length-1].size();return Math.max(e,a,n)/2}}function getStartAngleRadians(t){return toRadians(t)-.5*Math.PI}LineController.id="line",LineController.defaults={datasetElementType:"line",datasetElementOptions:["backgroundColor","borderCapStyle","borderColor","borderDash","borderDashOffset","borderJoinStyle","borderWidth","capBezierPoints","cubicInterpolationMode","fill"],dataElementType:"point",dataElementOptions:{backgroundColor:"pointBackgroundColor",borderColor:"pointBorderColor",borderWidth:"pointBorderWidth",hitRadius:"pointHitRadius",hoverHitRadius:"pointHitRadius",hoverBackgroundColor:"pointHoverBackgroundColor",hoverBorderColor:"pointHoverBorderColor",hoverBorderWidth:"pointHoverBorderWidth",hoverRadius:"pointHoverRadius",pointStyle:"pointStyle",radius:"pointRadius",rotation:"pointRotation"},showLines:!0,spanGaps:!1,hover:{mode:"index"},scales:{_index_:{type:"category"},_value_:{type:"linear"}}};class PolarAreaController extends DatasetController{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,t)}_updateRadius(){const t=this,e=t.chart,i=e.chartArea,a=e.options,n=Math.min(i.right-i.left,i.bottom-i.top),o=Math.max(n/2,0),s=(o-Math.max(a.cutoutPercentage?o/100*a.cutoutPercentage:1,0))/e.getVisibleDatasetCount();t.outerRadius=o-s*t.index,t.innerRadius=t.outerRadius-s}updateElements(t,e,i){const a=this,n="reset"===i,o=a.chart,s=a.getDataset(),r=o.options,l=r.animation,c=a._cachedMeta.rScale,d=c.xCenter,h=c.yCenter,u=getStartAngleRadians(r.startAngle);let g,p=u;for(a._cachedMeta.count=a.countVisibleElements(),g=0;g{!isNaN(t.data[a])&&this.chart.getDataVisibility(a)&&i++}),i}_computeAngle(t){const e=this,i=e._cachedMeta.count,a=e.getDataset();if(isNaN(a.data[t])||!this.chart.getDataVisibility(t))return 0;const n={chart:e.chart,dataPoint:this.getParsed(t),dataIndex:t,dataset:a,datasetIndex:e.index};return resolve([e.chart.options.elements.arc.angle,2*Math.PI/i],n,t)}}PolarAreaController.id="polarArea",PolarAreaController.defaults={dataElementType:"arc",dataElementOptions:["backgroundColor","borderColor","borderWidth","borderAlign","hoverBackgroundColor","hoverBorderColor","hoverBorderWidth"],animation:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]},animateRotate:!0,animateScale:!0},aspectRatio:1,datasets:{indexAxis:"r"},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,gridLines:{circular:!0},pointLabels:{display:!1}}},startAngle:0,legend:{labels:{generateLabels(t){const e=t.data;return e.labels.length&&e.datasets.length?e.labels.map((e,i)=>{const a=t.getDatasetMeta(0).controller.getStyle(i);return{text:e,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,lineWidth:a.borderWidth,hidden:!t.getDataVisibility(i),index:i}}):[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltips:{callbacks:{title:()=>"",label:t=>t.chart.data.labels[t.dataIndex]+": "+t.formattedValue}}};class PieController extends DoughnutController{}PieController.id="pie",PieController.defaults={cutoutPercentage:0};class RadarController extends DatasetController{getLabelAndValue(t){const e=this._cachedMeta.vScale,i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}update(t){const e=this,i=e._cachedMeta,a=i.dataset,n=i.data||[],o=i.iScale.getLabels();if("resize"!==t){const i={points:n,_loop:!0,_fullLoop:o.length===n.length,options:e.resolveDatasetElementOptions()};e.updateElement(a,void 0,i,t)}e.updateElements(n,0,t)}updateElements(t,e,i){const a=this,n=a.getDataset(),o=a._cachedMeta.rScale,s="reset"===i;let r;for(r=0;r"",label:t=>"("+t.label+", "+t.formattedValue+")"}}};class DateAdapter{constructor(t){this.options=t||{}}formats(){return abstract()}parse(t,e){return abstract()}format(t,e){return abstract()}add(t,e,i){return abstract()}diff(t,e,i){return abstract()}startOf(t,e,i){return abstract()}endOf(t,e){return abstract()}}DateAdapter.override=function(t){Object.assign(DateAdapter.prototype,t)};var adapters={_date:DateAdapter};function getRelativePosition(t,e){return"native"in t?{x:t.x,y:t.y}:getRelativePosition$1(t,e)}function evaluateAllVisibleItems(t,e){const i=t.getSortedVisibleDatasetMetas();let a,n,o;for(let t=0,s=i.length;t{const e=s[0].index,i=t.data[e];i&&!i.skip&&r.push({element:i,datasetIndex:t.index,index:e})}),r):[]},dataset(t,e,i,a){const n=getRelativePosition(e,t),o=i.axis||"xy";let s=i.intersect?getIntersectItems(t,n,o,a):getNearestItems(t,n,o,!1,a);if(s.length>0){const e=s[0].datasetIndex,i=t.getDatasetMeta(e).data;s=[];for(let t=0;tgetIntersectItems(t,getRelativePosition(e,t),i.axis||"xy",a),nearest:(t,e,i,a)=>getNearestItems(t,getRelativePosition(e,t),i.axis||"xy",i.intersect,a),x(t,e,i,a){const n=getRelativePosition(e,t),o=[];let s=!1;return evaluateAllVisibleItems(t,(t,e,i)=>{t.inXRange(n.x,a)&&o.push({element:t,datasetIndex:e,index:i}),t.inRange(n.x,n.y,a)&&(s=!0)}),i.intersect&&!s?[]:o},y(t,e,i,a){const n=getRelativePosition(e,t),o=[];let s=!1;return evaluateAllVisibleItems(t,(t,e,i)=>{t.inYRange(n.y,a)&&o.push({element:t,datasetIndex:e,index:i}),t.inRange(n.x,n.y,a)&&(s=!0)}),i.intersect&&!s?[]:o}}};const STATIC_POSITIONS=["left","top","right","bottom"];function filterByPosition(t,e){return t.filter(t=>t.pos===e)}function filterDynamicPositionByAxis(t,e){return t.filter(t=>-1===STATIC_POSITIONS.indexOf(t.pos)&&t.box.axis===e)}function sortByWeight(t,e){return t.sort((t,i)=>{const a=e?i:t,n=e?t:i;return a.weight===n.weight?a.index-n.index:a.weight-n.weight})}function wrapBoxes(t){const e=[];let i,a,n;for(i=0,a=(t||[]).length;i{a[t]=Math.max(e[t],i[t])}),a}return a(t?["left","right"]:["top","bottom"])}function fitBoxes(t,e,i){const a=[];let n,o,s,r,l,c;for(n=0,o=t.length;n{const i=e.box;Object.assign(i,t.chartArea),i.update(h.w,h.h)})}};class BasePlatform{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,i){}removeEventListener(t,e,i){}getDevicePixelRatio(){return 1}isAttached(t){return!0}}class BasicPlatform extends BasePlatform{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}}const EXPANDO_KEY="$chartjs",EVENT_TYPES={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"};function readUsedSize(t,e){const i=getStyle(t,e),a=i&&i.match(/^(\d+)(\.\d+)?px$/);return a?+a[1]:void 0}function initCanvas(t,e){const i=t.style,a=t.getAttribute("height"),n=t.getAttribute("width");if(t.$chartjs={initial:{height:a,width:n,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",i.boxSizing=i.boxSizing||"border-box",null===n||""===n){const e=readUsedSize(t,"width");void 0!==e&&(t.width=e)}if(null===a||""===a)if(""===t.style.height)t.height=t.width/(e.options.aspectRatio||2);else{const e=readUsedSize(t,"height");void 0!==e&&(t.height=e)}return t}const supportsEventListenerOptions=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t}(),eventListenerOptions=!!supportsEventListenerOptions&&{passive:!0};function addListener(t,e,i){t.addEventListener(e,i,eventListenerOptions)}function removeListener(t,e,i){t.removeEventListener(e,i,eventListenerOptions)}function createEvent(t,e,i,a,n){return{type:t,chart:e,native:n||null,x:void 0!==i?i:null,y:void 0!==a?a:null}}function fromNativeEvent(t,e){const i=EVENT_TYPES[t.type]||t.type,a=getRelativePosition$1(t,e);return createEvent(i,e,a.x,a.y,t)}function throttled(t,e){let i=!1,a=[];return function(...n){a=Array.prototype.slice.call(n),i||(i=!0,requestAnimFrame.call(window,()=>{i=!1,t.apply(e,a)}))}}function createAttachObserver(t,e,i){const a=t.canvas,n=a&&_getParentNode(a)||a,o=new MutationObserver(t=>{const e=_getParentNode(n);t.forEach(t=>{for(let a=0;a{t.forEach(t=>{for(let e=0;e{const a=n.clientWidth;i(t,e),a{const e=t[0],i=e.contentRect.width,a=e.contentRect.height;0===i&&0===a||o(i,a)});return s.observe(n),s}function releaseObserver(t,e,i){i&&i.disconnect()}function createProxyAndListen(t,e,i){const a=t.canvas,n=throttled(e=>{null!==t.ctx&&i(fromNativeEvent(e,t))},t);return addListener(a,e,n),n}class DomPlatform extends BasePlatform{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(initCanvas(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e.$chartjs)return!1;const i=e.$chartjs.initial;["height","width"].forEach(t=>{const a=i[t];isNullOrUndef(a)?e.removeAttribute(t):e.setAttribute(t,a)});const a=i.style||{};return Object.keys(a).forEach(t=>{e.style[t]=a[t]}),e.width=e.width,delete e.$chartjs,!0}addEventListener(t,e,i){this.removeEventListener(t,e);const a=t.$proxies||(t.$proxies={}),n={attach:createAttachObserver,detach:createDetachObserver,resize:createResizeObserver}[e]||createProxyAndListen;a[e]=n(t,e,i)}removeEventListener(t,e){const i=t.canvas,a=t.$proxies||(t.$proxies={}),n=a[e];if(!n)return;({attach:releaseObserver,detach:releaseObserver,resize:releaseObserver}[e]||removeListener)(i,e,n),a[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}isAttached(t){const e=_getParentNode(t);return!(!e||!_getParentNode(e))}}class Element{constructor(){this.x=void 0,this.y=void 0,this.active=!1,this.options=void 0,this.$animations=void 0}tooltipPosition(t){const{x:e,y:i}=this.getProps(["x","y"],t);return{x:e,y:i}}hasValue(){return isNumber(this.x)&&isNumber(this.y)}getProps(t,e){const i=this,a=this.$animations;if(!e||!a)return i;const n={};return t.forEach(t=>{n[t]=a[t]&&a[t].active?a[t]._to:i[t]}),n}}Element.defaults={},Element.defaultRoutes=void 0;const formatters={values:t=>isArray(t)?t:""+t,numeric(t,e,i){if(0===t)return"0";const a=this.chart.options.locale,n=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value));let o;(n<1e-4||n>1e15)&&(o="scientific");let s=i.length>3?i[2].value-i[1].value:i[1].value-i[0].value;Math.abs(s)>1&&t!==Math.floor(t)&&(s=t-Math.floor(t));const r=log10(Math.abs(s)),l=Math.max(Math.min(-1*Math.floor(r),20),0),c={notation:o,minimumFractionDigits:l,maximumFractionDigits:l};return Object.assign(c,this.options.ticks.format),new Intl.NumberFormat(a,c).format(t)},logarithmic:function(t,e,i){if(0===t)return"0";const a=t/Math.pow(10,Math.floor(log10(t)));return 1===a||2===a||5===a?formatters.numeric.call(this,t,e,i):""}};var Ticks={formatters:formatters};function sample(t,e){const i=[],a=t.length/e,n=t.length;let o=0;for(;os+r)))return c}function garbageCollect(t,e){each(t,t=>{const i=t.gc,a=i.length/2;let n;if(a>e){for(n=0;nn)return e}return Math.max(n,1)}function getMajorIndices(t){const e=[];let i,a;for(i=0,a=t.length;i=o||a<=1||!t.isHorizontal())return void(t.labelRotation=n);const d=t._getLabelSizes(),h=d.widest.width,u=d.highest.height-d.highest.offset,g=Math.min(t.maxWidth,t.chart.width-h);s=e.offset?t.maxWidth/a:g/(a-1),h+6>s&&(s=g/(a-(e.offset?.5:1)),r=t.maxHeight-getTickMarkLength(e.gridLines)-i.padding-getScaleLabelHeight(e.scaleLabel),l=Math.sqrt(h*h+u*u),c=toDegrees(Math.min(Math.asin(Math.min((d.highest.height+6)/s,1)),Math.asin(Math.min(r/l,1))-Math.asin(u/l))),c=Math.max(n,Math.min(o,c))),t.labelRotation=c}afterCalculateLabelRotation(){callback(this.options.afterCalculateLabelRotation,[this])}beforeFit(){callback(this.options.beforeFit,[this])}fit(){const t=this,e={width:0,height:0},i=t.chart,a=t.options,n=a.ticks,o=a.scaleLabel,s=a.gridLines,r=t._isVisible(),l="top"!==a.position&&"x"===t.axis,c=t.isHorizontal();if(c?e.width=t.maxWidth:r&&(e.width=getTickMarkLength(s)+getScaleLabelHeight(o)),c?r&&(e.height=getTickMarkLength(s)+getScaleLabelHeight(o)):e.height=t.maxHeight,n.display&&r&&t.ticks.length){const i=t._getLabelSizes(),a=i.first,o=i.last,s=i.widest,r=i.highest,d=.8*r.offset,h=n.padding;if(c){const i=0!==t.labelRotation,n=toRadians(t.labelRotation),c=Math.cos(n),u=Math.sin(n),g=u*s.width+c*(r.height-(i?r.offset:0))+(i?0:d);e.height=Math.min(t.maxHeight,e.height+g+h);const p=t.getPixelForTick(0)-t.left,f=t.right-t.getPixelForTick(t.ticks.length-1);let m,x;i?(m=l?c*a.width+u*a.offset:u*(a.height-a.offset),x=l?u*(o.height-o.offset):c*o.width+u*o.offset):(m=a.width/2,x=o.width/2),t.paddingLeft=Math.max((m-p)*t.width/(t.width-p),0)+3,t.paddingRight=Math.max((x-f)*t.width/(t.width-f),0)+3}else{const i=n.mirror?0:s.width+h+d;e.width=Math.min(t.maxWidth,e.width+i),t.paddingTop=o.height/2,t.paddingBottom=a.height/2}}t._handleMargins(),c?(t.width=t._length=i.width-t._margins.left-t._margins.right,t.height=e.height):(t.width=e.width,t.height=t._length=i.height-t._margins.top-t._margins.bottom)}_handleMargins(){const t=this;t._margins&&(t._margins.left=Math.max(t.paddingLeft,t._margins.left),t._margins.top=Math.max(t.paddingTop,t._margins.top),t._margins.right=Math.max(t.paddingRight,t._margins.right),t._margins.bottom=Math.max(t.paddingBottom,t._margins.bottom))}afterFit(){callback(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullWidth(){return this.options.fullWidth}_convertTicksToLabels(t){const e=this;e.beforeTickToLabelConversion(),e.generateTickLabels(t),e.afterTickToLabelConversion()}_getLabelSizes(){const t=this;let e=t._labelSizes;return e||(t._labelSizes=e=t._computeLabelSizes()),e}_computeLabelSizes(){const t=this,e=t.ctx,i=t._longestTextCache,a=t.options.ticks.sampleSize,n=[],o=[],s=[];let r=t.ticks;ae.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){const e=this;return e._reversePixels&&(t=1-t),e._startPixel+t*e._length}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}_autoSkip(t){const e=this,i=e.options.ticks,a=i.maxTicksLimit||e._length/e._tickSize(),n=i.major.enabled?getMajorIndices(t):[],o=n.length,s=n[0],r=n[o-1],l=[];if(o>a)return skipMajors(t,l,n,o/a),l;const c=calculateSpacing(n,t,a);if(o>0){let e,i;const a=o>1?Math.round((r-s)/(o-1)):null;for(skip(t,l,c,isNullOrUndef(a)?0:s-a,s),e=0,i=o-1;er*n?r/a:l/n:l*n0}_computeGridLineItems(t){const e=this,i=e.axis,a=e.chart,n=e.options,{gridLines:o,position:s}=n,r=o.offsetGridLines,l=e.isHorizontal(),c=e.ticks,d=c.length+(r?1:0),h=getTickMarkLength(o),u=[];let g={chart:a,scale:e,tick:c[0],index:0};const p=o.drawBorder?resolve([o.borderWidth,o.lineWidth,0],g,0):0,f=p/2,m=function(t){return _alignPixel(a,t,p)};let x,b,_,y,v,k,M,S,A,w,D,P;if("top"===s)x=m(e.bottom),k=e.bottom-h,S=x-f,w=m(t.top)+f,P=t.bottom;else if("bottom"===s)x=m(e.top),w=t.top,P=m(t.bottom)-f,k=x+f,S=e.top+h;else if("left"===s)x=m(e.right),v=e.right-h,M=x-f,A=m(t.left)+f,D=t.right;else if("right"===s)x=m(e.left),A=t.left,D=m(t.right)-f,v=x+f,M=e.left+h;else if("x"===i){if("center"===s)x=m((t.top+t.bottom)/2);else if(isObject(s)){const t=Object.keys(s)[0],i=s[t];x=m(e.chart.scales[t].getPixelForValue(i))}w=t.top,P=t.bottom,k=x+f,S=k+h}else if("y"===i){if("center"===s)x=m((t.left+t.right)/2);else if(isObject(s)){const t=Object.keys(s)[0],i=s[t];x=m(e.chart.scales[t].getPixelForValue(i))}v=x-f,M=v-h,A=t.left,D=t.right}for(b=0;b0&&""!==e.strokeStyle;i.save(),i.translate(t.x,t.y),i.rotate(t.rotation),i.font=e.string,i.fillStyle=e.color,i.textBaseline="middle",i.textAlign=t.textAlign,s&&(i.strokeStyle=e.strokeStyle,i.lineWidth=e.lineWidth);const l=t.label;let c=t.textOffset;if(isArray(l))for(o=0,r=l.length;o{const a=e[i].split("."),n=a.pop(),o=a.join(".");defaults.route(t,i,o,n)})}function isIChartComponent(t){return"id"in t&&"defaults"in t}class Registry{constructor(){this.controllers=new TypedRegistry(DatasetController,""),this.elements=new TypedRegistry(Element,"elements"),this.plugins=new TypedRegistry(Object,"plugins"),this.scales=new TypedRegistry(Scale,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}_each(t,e,i){const a=this;[...e].forEach(e=>{const n=i||a._getRegistryForType(e);n.isForType(e)||n===a.plugins&&e.id?a._exec(t,n,e):each(e,e=>{const n=i||a._getRegistryForType(e);a._exec(t,n,e)})})}_exec(t,e,i){const a=_capitalize(t);callback(i["before"+a],[],i),e[t](i),callback(i["after"+a],[],i)}_getRegistryForType(t){for(let e=0;e{const e=a[t],r=determineAxis(t,e),l=getDefaultScaleIDFromAxis(r,n);o[r]=o[r]||t,s[t]=mergeIf({axis:r},[e,i.scales[r],i.scales[l]])}),e.scale&&(s[e.scale.id||"r"]=mergeIf({axis:"r"},[e.scale,i.scales.r]),o.r=o.r||e.scale.id||"r"),t.data.datasets.forEach(i=>{const n=i.type||t.type,r=i.indexAxis||getIndexAxis(n,e),l=(defaults[n]||{}).scales||{};Object.keys(l).forEach(t=>{const e=getAxisFromDefaultScaleID(t,r),n=i[e+"AxisID"]||o[e]||e;s[n]=s[n]||{},mergeIf(s[n],[{axis:e},a[n],l[t]])})}),Object.keys(s).forEach(t=>{const e=s[t];mergeIf(e,[defaults.scales[e.type],defaults.scale])}),s}function mergeConfig(...t){return merge({},t,{merger(t,e,i,a){"scales"!==t&&"scale"!==t&&_merger(t,e,i,a)}})}function initConfig(t){const e=(t=t||{}).data=t.data||{datasets:[],labels:[]};e.datasets=e.datasets||[],e.labels=e.labels||[];const i=mergeScaleConfig(t,t.options),a=t.options=mergeConfig(defaults,defaults[t.type],t.options||{});return a.scales=i,a.title=!1!==a.title&&merge({},[defaults.plugins.title,a.title]),a.tooltips=!1!==a.tooltips&&merge({},[defaults.plugins.tooltip,a.tooltips]),t}function isAnimationDisabled(t){return!t.animation}function updateConfig(t){let e=t.options;each(t.scales,e=>{layouts.removeBox(t,e)});const i=mergeScaleConfig(t.config,e);e=mergeConfig(defaults,defaults[t.config.type],e),t.options=t.config.options=e,t.options.scales=i,t._animationsDisabled=isAnimationDisabled(e)}const KNOWN_POSITIONS=["top","bottom","left","right","chartArea"];function positionIsHorizontal(t,e){return"top"===t||"bottom"===t||-1===KNOWN_POSITIONS.indexOf(t)&&"x"===e}function axisFromPosition(t){return"top"===t||"bottom"===t?"x":"left"===t||"right"===t?"y":void 0}function determineAxis(t,e){return"x"===t||"y"===t||"r"===t?t:e.axis||axisFromPosition(e.position)||t.charAt(0).toLowerCase()}function compare2Level(t,e){return function(i,a){return i[t]===a[t]?i[e]-a[e]:i[t]-a[t]}}function onAnimationsComplete(t){const e=t.chart,i=e.options.animation;e._plugins.notify(e,"afterRender"),callback(i&&i.onComplete,[t],e)}function onAnimationProgress(t){const e=t.chart,i=e.options.animation;callback(i&&i.onProgress,[t],e)}function isDomSupported(){return"undefined"!=typeof window&&"undefined"!=typeof document}function getCanvas(t){return isDomSupported()&&"string"==typeof t?t=document.getElementById(t):t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}function computeNewSize(t,e,i,a){return void 0!==e&&void 0!==i||(e=getMaximumWidth(t),i=getMaximumHeight(t)),{width:e=Math.max(0,Math.floor(e)),height:Math.max(0,Math.floor(a?e/a:i))}}class Chart{constructor(t,e){const i=this;e=initConfig(e);const a=getCanvas(t);this.platform=i._initializePlatform(a,e);const n=i.platform.acquireContext(a,e),o=n&&n.canvas,s=o&&o.height,r=o&&o.width;this.id=uid(),this.ctx=n,this.canvas=o,this.config=e,this.width=r,this.height=s,this.aspectRatio=s?r/s:null,this.options=e.options,this._bufferedRender=!1,this._layers=[],this._metasets=[],this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this.data=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._sortedMetasets=[],this._updating=!1,this.scales={},this.scale=void 0,this._plugins=new PluginService,this.$proxies={},this._hiddenIndices={},this.attached=!1,Chart.instances[i.id]=i,Object.defineProperty(i,"data",{get:()=>i.config.data,set(t){i.config.data=t}}),n&&o?(animator.listen(i,"complete",onAnimationsComplete),animator.listen(i,"progress",onAnimationProgress),i._initialize(),i.attached&&i.update()):console.error("Failed to create chart: can't acquire context from the given item")}_initialize(){const t=this;return t._plugins.notify(t,"beforeInit"),t.options.responsive?t.resize(!0):retinaScale(t,t.options.devicePixelRatio),t.bindEvents(),t._plugins.notify(t,"afterInit"),t}_initializePlatform(t,e){return e.platform?new e.platform:!isDomSupported()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?new BasicPlatform:new DomPlatform}clear(){return clear(this),this}stop(){return animator.stop(this),this}resize(t,e,i){const a=this,n=a.options,o=a.canvas,s=computeNewSize(o,e,i,n.maintainAspectRatio&&a.aspectRatio),r=a.currentDevicePixelRatio,l=n.devicePixelRatio||a.platform.getDevicePixelRatio();a.width===s.width&&a.height===s.height&&r===l||(o.width=a.width=s.width,o.height=a.height=s.height,o.style&&(o.style.width=s.width+"px",o.style.height=s.height+"px"),retinaScale(a,l),t||(a._plugins.notify(a,"resize",[s]),callback(n.onResize,[s],a),a.attached&&a.update("resize")))}ensureScalesHaveIDs(){const t=this.options,e=t.scales||{},i=t.scale;each(e,(t,e)=>{t.id=e}),i&&(i.id=i.id||"scale")}buildOrUpdateScales(){const t=this,e=t.options,i=e.scales,a=t.scales||{},n=Object.keys(a).reduce((t,e)=>(t[e]=!1,t),{});let o=[];i&&(o=o.concat(Object.keys(i).map(t=>{const e=i[t],a=determineAxis(t,e),n="r"===a,o="x"===a;return{options:e,dposition:n?"chartArea":o?"bottom":"left",dtype:n?"radialLinear":o?"category":"linear"}}))),each(o,i=>{const o=i.options,s=o.id,r=determineAxis(s,o),l=valueOrDefault(o.type,i.dtype);void 0!==o.position&&positionIsHorizontal(o.position,r)===positionIsHorizontal(i.dposition)||(o.position=i.dposition),n[s]=!0;let c=null;if(s in a&&a[s].type===l)c=a[s];else{c=new(registry.getScale(l))({id:s,type:l,ctx:t.ctx,chart:t}),a[c.id]=c}c.init(o,e),i.isDefault&&(t.scale=c)}),each(n,(t,e)=>{t||delete a[e]}),t.scales=a,each(a,e=>{e.fullWidth=e.options.fullWidth,e.position=e.options.position,e.weight=e.options.weight,layouts.addBox(t,e)})}_updateMetasetIndex(t,e){const i=this._metasets,a=t.index;a!==e&&(i[a]=i[e],i[e]=t,t.index=e)}_updateMetasets(){const t=this,e=t._metasets,i=t.data.datasets.length,a=e.length;if(a>i){for(let e=i;e{t.getDatasetMeta(i).controller.reset()},t)}reset(){this._resetElements(),this._plugins.notify(this,"reset")}update(t){const e=this;let i,a;if(e._updating=!0,updateConfig(e),e.ensureScalesHaveIDs(),e.buildOrUpdateScales(),e._plugins.invalidate(),!1===e._plugins.notify(e,"beforeUpdate"))return;const n=e.buildOrUpdateControllers();for(i=0,a=e.data.datasets.length;i{t.reset()}),e._updateDatasets(t),e._plugins.notify(e,"afterUpdate"),e._layers.sort(compare2Level("z","_idx")),e._lastEvent&&e._eventHandler(e._lastEvent,!0),e.render(),e._updating=!1}_updateLayout(){const t=this;!1!==t._plugins.notify(t,"beforeLayout")&&(layouts.update(t,t.width,t.height),t._layers=[],each(t.boxes,e=>{e.configure&&e.configure(),t._layers.push(...e._layers())},t),t._layers.forEach((t,e)=>{t._idx=e}),t._plugins.notify(t,"afterLayout"))}_updateDatasets(t){const e=this,i="function"==typeof t;if(!1!==e._plugins.notify(e,"beforeDatasetsUpdate")){for(let a=0,n=e.data.datasets.length;a=0;--i)t._drawDataset(e[i]);t._plugins.notify(t,"afterDatasetsDraw")}_drawDataset(t){const e=this,i=e.ctx,a=t._clip,n=e.chartArea,o={meta:t,index:t.index};!1!==e._plugins.notify(e,"beforeDatasetDraw",[o])&&(clipArea(i,{left:!1===a.left?0:n.left-a.left,right:!1===a.right?e.width:n.right+a.right,top:!1===a.top?0:n.top-a.top,bottom:!1===a.bottom?e.height:n.bottom+a.bottom}),t.controller.draw(),unclipArea(i),e._plugins.notify(e,"afterDatasetDraw",[o]))}getElementAtEvent(t){return Interaction.modes.nearest(this,t,{intersect:!0})}getElementsAtEvent(t){return Interaction.modes.index(this,t,{intersect:!0})}getElementsAtXAxis(t){return Interaction.modes.index(this,t,{intersect:!1})}getElementsAtEventForMode(t,e,i,a){const n=Interaction.modes[e];return"function"==typeof n?n(this,t,i,a):[]}getDatasetAtEvent(t){return Interaction.modes.dataset(this,t,{intersect:!0})}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let a=i.filter(t=>t._dataset===e).pop();return a||(a=i[t]={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1}),a}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.getDatasetMeta(t);return"boolean"==typeof e.hidden?!e.hidden:!this.data.datasets[t].hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateDatasetVisibility(t,e){const i=this,a=e?"show":"hide",n=i.getDatasetMeta(t),o=n.controller._resolveAnimations(void 0,a);i.setDatasetVisibility(t,e),o.update(n,{visible:e}),i.update(e=>e.datasetIndex===t?a:void 0)}hide(t){this._updateDatasetVisibility(t,!1)}show(t){this._updateDatasetVisibility(t,!0)}_destroyDatasetMeta(t){const e=this,i=e._metasets&&e._metasets[t];i&&(i.controller._destroy(),delete e._metasets[t])}destroy(){const t=this,e=t.canvas;let i,a;for(t.stop(),animator.remove(t),i=0,a=t.data.datasets.length;i{i.addEventListener(t,a,n),e[a]=n},n=(a,n)=>{e[a]&&(i.removeEventListener(t,a,n),delete e[a])};let o=function(e){t._eventHandler(e)};if(each(t.options.events,t=>a(t,o)),t.options.responsive){let e;o=(e,i)=>{t.canvas&&t.resize(!1,e,i)};const s=()=>{n("attach",s),t.resize(),t.attached=!0,a("resize",o),a("detach",e)};e=()=>{t.attached=!1,n("resize",o),a("attach",s)},i.isAttached(t.canvas)?s():e()}else t.attached=!0}unbindEvents(){const t=this,e=t._listeners;e&&(delete t._listeners,each(e,(e,i)=>{t.platform.removeEventListener(t,i,e)}))}updateHoverStyle(t,e,i){const a=i?"set":"remove";let n,o,s,r;for("dataset"===e&&(n=this.getDatasetMeta(t[0].datasetIndex),n.controller["_"+a+"DatasetHoverStyle"]()),s=0,r=t.length;seach(Chart.instances,t=>t._plugins.invalidate());Chart.register=(...t)=>{registry.add(...t),invalidatePlugins()},Chart.unregister=(...t)=>{registry.remove(...t),invalidatePlugins()};const TAU=2*Math.PI;function clipArc(t,e){const{startAngle:i,endAngle:a,pixelMargin:n,x:o,y:s}=e;let r=n/e.outerRadius;t.beginPath(),t.arc(o,s,e.outerRadius,i-r,a+r),e.innerRadius>n?(r=n/e.innerRadius,t.arc(o,s,e.innerRadius-n,a+r,i-r,!0)):t.arc(o,s,n,a+Math.PI/2,i-Math.PI/2),t.closePath(),t.clip()}function pathArc(t,e){t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath()}function drawArc(t,e,i){if(e.fullCircles){e.endAngle=e.startAngle+TAU,pathArc(t,e);for(let i=0;i=TAU||_angleBetween(n,s,r))&&(o>=l&&o<=c)}getCenterPoint(t){const{x:e,y:i,startAngle:a,endAngle:n,innerRadius:o,outerRadius:s}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),r=(a+n)/2,l=(o+s)/2;return{x:e+Math.cos(r)*l,y:i+Math.sin(r)*l}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const e=this,i=e.options,a="inner"===i.borderAlign?.33:0,n={x:e.x,y:e.y,innerRadius:e.innerRadius,outerRadius:Math.max(e.outerRadius-a,0),pixelMargin:a,startAngle:e.startAngle,endAngle:e.endAngle,fullCircles:Math.floor(e.circumference/TAU)};0!==e.circumference&&(t.save(),t.fillStyle=i.backgroundColor,t.strokeStyle=i.borderColor,drawArc(t,n,e.circumference),i.borderWidth&&drawBorder(t,e,n),t.restore())}}function setStyle(t,e){t.lineCap=e.borderCapStyle,t.setLineDash(e.borderDash),t.lineDashOffset=e.borderDashOffset,t.lineJoin=e.borderJoinStyle,t.lineWidth=e.borderWidth,t.strokeStyle=e.borderColor}function lineTo(t,e,i){t.lineTo(i.x,i.y)}function getLineMethod(t){return t.stepped?_steppedLineTo:t.tension?_bezierCurveTo:lineTo}function pathSegment(t,e,i,a){const{start:n,end:o,loop:s}=i,{points:r,options:l}=e,c=getLineMethod(l),d=r.length;let{move:h=!0,reverse:u}=a||{};const g=o(s+(c?d-t:t))%o,y=()=>{p!==f&&(t.lineTo(x,f),t.lineTo(x,p),t.lineTo(x,m))};for(l&&(u=n[_(0)],t.moveTo(u.x,u.y)),h=0;h<=d;++h){if(u=n[_(h)],u.skip)continue;const e=u.x,i=u.y,a=0|e;a===g?(if&&(f=i),x=(b*x+e)/++b):(y(),t.lineTo(e,i),g=a,b=0,p=f=i),m=i}y()}function _getSegmentMethod(t){const e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._loop||e.tension||e.stepped||i)?fastPathSegment:pathSegment}function _getInterpolationMethod(t){return t.stepped?_steppedInterpolation:t.tension?_bezierInterpolation:_pointInLine}Arc.id="arc",Arc.defaults={borderAlign:"center",borderColor:"#fff",borderWidth:2},Arc.defaultRoutes={backgroundColor:"color"};class Line extends Element{constructor(t){super(),this.options=void 0,this._loop=void 0,this._fullLoop=void 0,this._points=void 0,this._segments=void 0,t&&Object.assign(this,t)}updateControlPoints(t){const e=this,i=e.options;if(i.tension&&!i.stepped){const a=i.spanGaps?e._loop:e._fullLoop;_updateBezierControlPoints(e._points,i,t,a)}}set points(t){this._points=t,delete this._segments}get points(){return this._points}get segments(){return this._segments||(this._segments=_computeSegments(this))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this,a=i.options,n=t[e],o=i.points,s=_boundSegments(i,{property:e,start:n,end:n});if(!s.length)return;const r=[],l=_getInterpolationMethod(a);let c,d;for(c=0,d=s.length;ct.x):parseEdge(e,"bottom","top",t.base=s.left&&e<=s.right)&&(o||i>=s.top&&i<=s.bottom)}Point.id="point",Point.defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3},Point.defaultRoutes={backgroundColor:"color",borderColor:"color"};class Rectangle extends Element{constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,t&&Object.assign(this,t)}draw(t){const e=this.options,{inner:i,outer:a}=boundingRects(this);t.save(),a.w===i.w&&a.h===i.h||(t.beginPath(),t.rect(a.x,a.y,a.w,a.h),t.clip(),t.rect(i.x,i.y,i.w,i.h),t.fillStyle=e.borderColor,t.fill("evenodd")),t.fillStyle=e.backgroundColor,t.fillRect(i.x,i.y,i.w,i.h),t.restore()}inRange(t,e,i){return inRange(this,t,e,i)}inXRange(t,e){return inRange(this,t,null,e)}inYRange(t,e){return inRange(this,null,t,e)}getCenterPoint(t){const{x:e,y:i,base:a,horizontal:n}=this.getProps(["x","y","base","horizontal"],t);return{x:n?(e+a)/2:e,y:n?i:(i+a)/2}}getRange(t){return"x"===t?this.width/2:this.height/2}}function getLineByIndex(t,e){const i=t.getDatasetMeta(e);return i&&t.isDatasetVisible(e)?i.dataset:null}function parseFillOption(t){const e=t.options,i=e.fill;let a=valueOrDefault(i&&i.target,i);return void 0===a&&(a=!!e.backgroundColor),!1!==a&&null!==a&&(!0===a?"origin":a)}function decodeFill(t,e,i){const a=parseFillOption(t);let n=parseFloat(a);return isNumberFinite(n)&&Math.floor(n)===n?("-"!==a[0]&&"+"!==a[0]||(n=e+n),!(n===e||n<0||n>=i)&&n):["origin","start","end"].indexOf(a)>=0&&a}function computeLinearBoundary(t){const{scale:e={},fill:i}=t;let a,n=null;return"start"===i?n=e.bottom:"end"===i?n=e.top:e.getBasePixel&&(n=e.getBasePixel()),isNumberFinite(n)?(a=e.isHorizontal(),{x:a?n:null,y:a?null:n}):null}Rectangle.id="rectangle",Rectangle.defaults={borderSkipped:"start",borderWidth:0},Rectangle.defaultRoutes={backgroundColor:"color",borderColor:"color"};class simpleArc{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,i){const{x:a,y:n,radius:o}=this;return e=e||{start:0,end:2*Math.PI},i.reverse?t.arc(a,n,o,e.end,e.start,!0):t.arc(a,n,o,e.start,e.end),!i.bounds}interpolate(t,e){const{x:i,y:a,radius:n}=this,o=t.angle;if("angle"===e)return{x:i+Math.cos(o)*n,y:a+Math.sin(o)*n,angle:o}}}function computeCircularBoundary(t){const{scale:e,fill:i}=t,a=e.options,n=e.getLabels().length,o=[],s=a.reverse?e.max:e.min,r=a.reverse?e.min:e.max,l="start"===i?s:"end"===i?r:e.getBaseValue();let c,d;if(a.gridLines.circular)return d=e.getPointPositionForValue(0,s),new simpleArc({x:d.x,y:d.y,radius:e.getDistanceFromCenterForValue(l)});for(c=0;c{const e=n[t.start],s=n[t.end];null!==a?(o.push({x:e.x,y:a,_prop:"x",_ref:e}),o.push({x:s.x,y:a,_prop:"x",_ref:s})):null!==i&&(o.push({x:i,y:e.y,_prop:"y",_ref:e}),o.push({x:i,y:s.y,_prop:"y",_ref:s}))}),o}function getTarget(t){const{chart:e,fill:i,line:a}=t;if(isNumberFinite(i))return getLineByIndex(e,i);const n=computeBoundary(t);let o=[],s=!1,r=!1;return n instanceof simpleArc?n:(isArray(n)?(s=!0,o=n):(o=pointsFromSegments(n,a),r=!0),o.length?new Line({points:o,options:{tension:0},_loop:s,_fullLoop:s,_refPoints:r}):null)}function resolveTarget(t,e,i){let a=t[e].fill;const n=[e];let o;if(!i)return a;for(;!1!==a&&-1===n.indexOf(a);){if(!isNumberFinite(a))return a;if(o=t[a],!o)return!1;if(o.visible)return a;n.push(a),a=o.fill}return!1}function _clip(t,e,i){t.beginPath(),e.path(t),t.lineTo(e.last().x,i),t.lineTo(e.first().x,i),t.closePath(),t.clip()}function getBounds(t,e,i,a){if(a)return;let n=e[t],o=i[t];return"angle"===t&&(n=_normalizeAngle(n),o=_normalizeAngle(o)),{property:t,start:n,end:o}}function _getEdge(t,e,i,a){return t&&e?a(t[i],e[i]):t?t[i]:e?e[i]:0}function _segments(t,e,i){const a=t.segments,n=t.points,o=e.points,s=[];if(e._refPoints)for(let t=0,e=o.length;t=0;--a)n=e[a].$filler,n&&n.line.updateControlPoints(i)},beforeDatasetDraw(t,e){const i=t.chartArea,a=t.ctx,n=e.meta.$filler;if(!n||!1===n.fill)return;const{line:o,target:s,scale:r}=n,l=o.options,c=l.fill,d=l.backgroundColor,{above:h=d,below:u=d}=c||{};s&&o.points.length&&(clipArea(a,i),doFill(a,{line:o,target:s,above:h,below:u,area:i,scale:r}),unclipArea(a))},defaults:{propagate:!0}};function getBoxWidth(t,e){const{boxWidth:i}=t;return t.usePointStyle&&i>e||isNullOrUndef(i)?e:i}function getBoxHeight(t,e){const{boxHeight:i}=t;return t.usePointStyle&&i>e||isNullOrUndef(i)?e:i}class Legend extends Element{constructor(t){super(),Object.assign(this,t),this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnWidths=void 0,this.columnHeights=void 0,this.lineWidths=void 0,this._minSize=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.position=void 0,this.weight=void 0,this.fullWidth=void 0}beforeUpdate(){}update(t,e,i){const a=this;a.beforeUpdate(),a.maxWidth=t,a.maxHeight=e,a._margins=i,a.beforeSetDimensions(),a.setDimensions(),a.afterSetDimensions(),a.beforeBuildLabels(),a.buildLabels(),a.afterBuildLabels(),a.beforeFit(),a.fit(),a.afterFit(),a.afterUpdate()}afterUpdate(){}beforeSetDimensions(){}setDimensions(){const t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t._minSize={width:0,height:0}}afterSetDimensions(){}beforeBuildLabels(){}buildLabels(){const t=this,e=t.options.labels||{};let i=callback(e.generateLabels,[t.chart],t)||[];e.filter&&(i=i.filter(i=>e.filter(i,t.chart.data))),t.options.reverse&&i.reverse(),t.legendItems=i}afterBuildLabels(){}beforeFit(){}fit(){const t=this,e=t.options,i=e.labels,a=e.display,n=t.ctx,o=toFont(i.font),s=o.size,r=getBoxWidth(i,s),l=getBoxHeight(i,s),c=Math.max(l,s),d=t.legendHitBoxes=[],h=t._minSize,u=t.isHorizontal(),g=t._computeTitleHeight();if(u?(h.width=t.maxWidth,h.height=a?10:0):(h.width=a?10:0,h.height=t.maxHeight),a){if(n.font=o.string,u){const e=t.lineWidths=[0];let a=g;n.textAlign="left",n.textBaseline="middle",t.legendItems.forEach((t,o)=>{const l=r+s/2+n.measureText(t.text).width;(0===o||e[e.length-1]+l+2*i.padding>h.width)&&(a+=c+i.padding,e[e.length-(o>0?0:1)]=0),d[o]={left:0,top:0,width:l,height:c},e[e.length-1]+=l+i.padding}),h.height+=a}else{const e=i.padding,a=t.columnWidths=[],o=t.columnHeights=[];let l=i.padding,u=0,p=0;const f=h.height-g;t.legendItems.forEach((t,h)=>{const g=r+s/2+n.measureText(t.text).width;h>0&&p+s+2*e>f&&(l+=u+i.padding,a.push(u),o.push(p),u=0,p=0),u=Math.max(u,g),p+=s+e,d[h]={left:0,top:0,width:g,height:c}}),l+=u,a.push(u),o.push(p),h.width+=l}t.width=h.width,t.height=h.height}else t.width=h.width=t.height=h.height=0}afterFit(){}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){const t=this,e=t.options,i=e.labels,a=defaults.color,n=defaults.elements.line,o=t.height,s=t.columnHeights,r=t.width,l=t.lineWidths;if(!e.display)return;t.drawTitle();const c=getRtlAdapter(e.rtl,t.left,t._minSize.width),d=t.ctx,h=toFont(i.font),u=h.color,g=h.size;let p;d.textAlign=c.textAlign("left"),d.textBaseline="middle",d.lineWidth=.5,d.strokeStyle=u,d.fillStyle=u,d.font=h.string;const f=getBoxWidth(i,g),m=getBoxHeight(i,g),x=Math.max(g,m),b=t.legendHitBoxes,_=function(t,a){switch(e.align){case"start":return i.padding;case"end":return t-a;default:return(t-a+i.padding)/2}},y=t.isHorizontal(),v=this._computeTitleHeight();p=y?{x:t.left+_(r,l[0]),y:t.top+i.padding+v,line:0}:{x:t.left+i.padding,y:t.top+_(o,s[0])+v,line:0},overrideTextDirection(t.ctx,e.textDirection);const k=x+i.padding;t.legendItems.forEach((e,h)=>{const u=d.measureText(e.text).width,v=f+g/2+u;let M=p.x,S=p.y;c.setWidth(t._minSize.width),y?h>0&&M+v+i.padding>t.left+t._minSize.width&&(S=p.y+=k,p.line++,M=p.x=t.left+_(r,l[p.line])):h>0&&S+k>t.top+t._minSize.height&&(M=p.x=M+t.columnWidths[p.line]+i.padding,p.line++,S=p.y=t.top+_(o,s[p.line]));const A=c.x(M);!function(t,e,o){if(isNaN(f)||f<=0||isNaN(m)||m<0)return;d.save();const s=valueOrDefault(o.lineWidth,n.borderWidth);if(d.fillStyle=valueOrDefault(o.fillStyle,a),d.lineCap=valueOrDefault(o.lineCap,n.borderCapStyle),d.lineDashOffset=valueOrDefault(o.lineDashOffset,n.borderDashOffset),d.lineJoin=valueOrDefault(o.lineJoin,n.borderJoinStyle),d.lineWidth=s,d.strokeStyle=valueOrDefault(o.strokeStyle,a),d.setLineDash&&d.setLineDash(valueOrDefault(o.lineDash,n.borderDash)),i&&i.usePointStyle){const i={radius:f*Math.SQRT2/2,pointStyle:o.pointStyle,rotation:o.rotation,borderWidth:s},a=c.xPlus(t,f/2);drawPoint(d,i,a,e+g/2)}else{const i=e+Math.max((g-m)/2,0);d.fillRect(c.leftForLtr(t,f),i,f,m),0!==s&&d.strokeRect(c.leftForLtr(t,f),i,f,m)}d.restore()}(A,S,e),b[h].left=c.leftForLtr(A,b[h].width),b[h].top=S,function(t,e,i,a){const n=g/2,o=c.xPlus(t,f+n),s=e+x/2;d.fillText(i.text,o,s),i.hidden&&(d.beginPath(),d.lineWidth=2,d.moveTo(o,s),d.lineTo(c.xPlus(o,a),s),d.stroke())}(A,S,e,u),y?p.x+=v+i.padding:p.y+=k}),restoreTextDirection(t.ctx,e.textDirection)}drawTitle(){const t=this,e=t.options,i=e.title,a=toFont(i.font),n=toPadding(i.padding);if(!i.display)return;const o=getRtlAdapter(e.rtl,t.left,t._minSize.width),s=t.ctx,r=i.position;let l,c;const d=a.size/2;let h=t.top+n.top+d,u=t.left,g=t.width;if(this.isHorizontal())switch(g=Math.max(...t.lineWidths),e.align){case"start":break;case"end":u=t.right-g;break;default:u=(t.left+t.right)/2-g/2}else{const i=Math.max(...t.columnHeights);switch(e.align){case"start":break;case"end":h+=t.height-i;break;default:h+=(t.height-i)/2}}switch(r){case"start":l=u,c="left";break;case"end":l=u+g,c="right";break;default:l=u+g/2,c="center"}s.textAlign=o.textAlign(c),s.textBaseline="middle",s.strokeStyle=a.color,s.fillStyle=a.color,s.font=a.string,s.fillText(i.text,l,h)}_computeTitleHeight(){const t=this.options.title,e=toFont(t.font),i=toPadding(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){const i=this;let a,n,o;if(t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom)for(o=i.legendHitBoxes,a=0;a=n.left&&t<=n.left+n.width&&e>=n.top&&e<=n.top+n.height)return i.legendItems[a];return null}handleEvent(t){const e=this,i=e.options,a="mouseup"===t.type?"click":t.type;if("mousemove"===a){if(!i.onHover&&!i.onLeave)return}else{if("click"!==a)return;if(!i.onClick)return}const n=e._getLegendItemAt(t.x,t.y);"click"===a?n&&callback(i.onClick,[t,n,e],e):(i.onLeave&&n!==e._hoveredItem&&(e._hoveredItem&&callback(i.onLeave,[t,e._hoveredItem,e],e),e._hoveredItem=n),n&&callback(i.onHover,[t,n,e],e))}}function resolveOptions(t){return!1!==t&&merge({},[defaults.plugins.legend,t])}function createNewLegendAndAttach(t,e){const i=new Legend({ctx:t.ctx,options:e,chart:t});layouts.configure(t,i,e),layouts.addBox(t,i),t.legend=i}var plugin_legend={id:"legend",_element:Legend,beforeInit(t){const e=resolveOptions(t.options.legend);e&&createNewLegendAndAttach(t,e)},beforeUpdate(t){const e=resolveOptions(t.options.legend),i=t.legend;e?i?(layouts.configure(t,i,e),i.options=e):createNewLegendAndAttach(t,e):i&&(layouts.removeBox(t,i),delete t.legend)},afterUpdate(t){t.legend&&t.legend.buildLabels()},afterEvent(t,e){const i=t.legend;i&&i.handleEvent(e)},defaults:{display:!0,position:"top",align:"center",fullWidth:!0,reverse:!1,weight:1e3,onClick(t,e,i){const a=e.datasetIndex,n=i.chart;n.isDatasetVisible(a)?(n.hide(a),e.hidden=!0):(n.show(a),e.hidden=!1)},onHover:null,onLeave:null,labels:{boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,i=t.options.legend||{},a=i.labels&&i.labels.usePointStyle;return t._getSortedDatasetMetas().map(t=>{const i=t.controller.getStyle(a?0:void 0);return{text:e[t.index].label,fillStyle:i.backgroundColor,hidden:!t.visible,lineCap:i.borderCapStyle,lineDash:i.borderDash,lineDashOffset:i.borderDashOffset,lineJoin:i.borderJoinStyle,lineWidth:i.borderWidth,strokeStyle:i.borderColor,pointStyle:i.pointStyle,rotation:i.rotation,datasetIndex:t.index}},this)}},title:{display:!1,position:"center",text:""}}};class Title extends Element{constructor(t){super(),Object.assign(this,t),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._margins=void 0,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.maxWidth=void 0,this.maxHeight=void 0,this.position=void 0,this.weight=void 0,this.fullWidth=void 0}beforeUpdate(){}update(t,e,i){const a=this;a.beforeUpdate(),a.maxWidth=t,a.maxHeight=e,a._margins=i,a.beforeSetDimensions(),a.setDimensions(),a.afterSetDimensions(),a.beforeBuildLabels(),a.buildLabels(),a.afterBuildLabels(),a.beforeFit(),a.fit(),a.afterFit(),a.afterUpdate()}afterUpdate(){}beforeSetDimensions(){}setDimensions(){const t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height)}afterSetDimensions(){}beforeBuildLabels(){}buildLabels(){}afterBuildLabels(){}beforeFit(){}fit(){const t=this,e=t.options,i={},a=t.isHorizontal();if(!e.display)return void(t.width=i.width=t.height=i.height=0);const n=isArray(e.text)?e.text.length:1;t._padding=toPadding(e.padding);const o=n*toFont(e.font).lineHeight+t._padding.height;t.width=i.width=a?t.maxWidth:o,t.height=i.height=a?o:t.maxHeight}afterFit(){}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}draw(){const t=this,e=t.ctx,i=t.options;if(!i.display)return;const a=toFont(i.font),n=a.lineHeight,o=n/2+t._padding.top;let s=0;const r=t.top,l=t.left,c=t.bottom,d=t.right;let h,u,g,p;if(t.isHorizontal()){switch(i.align){case"start":u=l,p="left";break;case"end":u=d,p="right";break;default:u=l+(d-l)/2,p="center"}g=r+o,h=d-l}else{switch(u="left"===i.position?l+o:d-o,i.align){case"start":g="left"===i.position?c:r,p="left";break;case"end":g="left"===i.position?r:c,p="right";break;default:g=r+(c-r)/2,p="center"}h=c-r,s=Math.PI*("left"===i.position?-.5:.5)}e.save(),e.fillStyle=a.color,e.font=a.string,e.translate(u,g),e.rotate(s),e.textAlign=p,e.textBaseline="middle";const f=i.text;if(isArray(f)){let t=0;for(let i=0;i-1?t.split("\n"):t}function createTooltipItem(t,e){const{element:i,datasetIndex:a,index:n}=e,o=t.getDatasetMeta(a).controller,{label:s,value:r}=o.getLabelAndValue(n);return{chart:t,label:s,dataPoint:o.getParsed(n),formattedValue:r,dataset:o.getDataset(),dataIndex:n,datasetIndex:a,element:i}}function resolveOptions$1(t){return(t=merge({},[defaults.plugins.tooltip,t])).bodyFont=toFont(t.bodyFont),t.titleFont=toFont(t.titleFont),t.footerFont=toFont(t.footerFont),t.boxHeight=valueOrDefault(t.boxHeight,t.bodyFont.size),t.boxWidth=valueOrDefault(t.boxWidth,t.bodyFont.size),t}function getTooltipSize(t){const e=t._chart.ctx,{body:i,footer:a,options:n,title:o}=t,{bodyFont:s,footerFont:r,titleFont:l,boxWidth:c,boxHeight:d}=n,h=o.length,u=a.length,g=i.length;let p=2*n.yPadding,f=0,m=i.reduce((t,e)=>t+e.before.length+e.lines.length+e.after.length,0);if(m+=t.beforeBody.length+t.afterBody.length,h&&(p+=h*l.size+(h-1)*n.titleSpacing+n.titleMarginBottom),m){p+=g*(n.displayColors?Math.max(d,s.size):s.size)+(m-g)*s.size+(m-1)*n.bodySpacing}u&&(p+=n.footerMarginTop+u*r.size+(u-1)*n.footerSpacing);let x=0;const b=function(t){f=Math.max(f,e.measureText(t).width+x)};return e.save(),e.font=l.string,each(t.title,b),e.font=s.string,each(t.beforeBody.concat(t.afterBody),b),x=n.displayColors?c+2:0,each(i,t=>{each(t.before,b),each(t.lines,b),each(t.after,b)}),x=0,e.font=r.string,each(t.footer,b),e.restore(),f+=2*n.xPadding,{width:f,height:p}}function determineAlignment(t,e,i){const{x:a,y:n,width:o,height:s}=i,r=t.chartArea;let l,c,d="center",h="center";nt.height-s&&(h="bottom");const u=(r.left+r.right)/2,g=(r.top+r.bottom)/2;"center"===h?(l=t=>t<=u,c=t=>t>u):(l=t=>t<=o/2,c=e=>e>=t.width-o/2);const p=t=>t<=g?"top":"bottom";return l(a)?(d="left",a+o+e.caretSize+e.caretPadding>t.width&&(d="center",h=p(n))):c(a)&&(d="right",(t=>t-o-e.caretSize-e.caretPadding<0)(a)&&(d="center",h=p(n))),{xAlign:e.xAlign?e.xAlign:d,yAlign:e.yAlign?e.yAlign:h}}function alignX(t,e,i){let{x:a,width:n}=t;return"right"===e?a-=n:"center"===e&&(a-=n/2,a+n>i&&(a=i-n),a<0&&(a=0)),a}function alignY(t,e,i){let{y:a,height:n}=t;return"top"===e?a+=i:a-="bottom"===e?n+i:n/2,a}function getBackgroundPoint(t,e,i,a){const{caretSize:n,caretPadding:o,cornerRadius:s}=t,{xAlign:r,yAlign:l}=i,c=n+o,d=s+o;let h=alignX(e,r,a.width);return"center"===l?"left"===r?h+=c:"right"===r&&(h-=c):"left"===r?h-=d:"right"===r&&(h+=d),{x:h,y:alignY(e,l,c)}}function getAlignedX(t,e){const i=t.options;return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-i.xPadding:t.x+i.xPadding}function getBeforeAfterBodyLines(t){return pushOrConcat([],splitNewlines(t))}class Tooltip extends Element{constructor(t){super(),this.opacity=0,this._active=[],this._chart=t._chart,this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this.$animations=void 0,this.options=void 0,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelTextColors=void 0,this.initialize()}initialize(){this.options=resolveOptions$1(this._chart.options.tooltips)}_resolveAnimations(){const t=this,e=t._cachedAnimations;if(e)return e;const i=t._chart,a=t.options,n=a.enabled&&i.options.animation&&a.animation,o=new Animations(t._chart,n);return t._cachedAnimations=Object.freeze(o),o}getTitle(t){const e=this,i=e.options.callbacks,a=i.beforeTitle.apply(e,[t]),n=i.title.apply(e,[t]),o=i.afterTitle.apply(e,[t]);let s=[];return s=pushOrConcat(s,splitNewlines(a)),s=pushOrConcat(s,splitNewlines(n)),s=pushOrConcat(s,splitNewlines(o)),s}getBeforeBody(t){return getBeforeAfterBodyLines(this.options.callbacks.beforeBody.apply(this,[t]))}getBody(t){const e=this,i=e.options.callbacks,a=[];return each(t,t=>{const n={before:[],lines:[],after:[]};pushOrConcat(n.before,splitNewlines(i.beforeLabel.call(e,t))),pushOrConcat(n.lines,i.label.call(e,t)),pushOrConcat(n.after,splitNewlines(i.afterLabel.call(e,t))),a.push(n)}),a}getAfterBody(t){return getBeforeAfterBodyLines(this.options.callbacks.afterBody.apply(this,[t]))}getFooter(t){const e=this,i=e.options.callbacks,a=i.beforeFooter.apply(e,[t]),n=i.footer.apply(e,[t]),o=i.afterFooter.apply(e,[t]);let s=[];return s=pushOrConcat(s,splitNewlines(a)),s=pushOrConcat(s,splitNewlines(n)),s=pushOrConcat(s,splitNewlines(o)),s}_createItems(){const t=this,e=t._active,i=t.options,a=t._chart.data,n=[],o=[];let s,r,l=[];for(s=0,r=e.length;si.filter(t,e,n,a))),i.itemSort&&(l=l.sort((t,e)=>i.itemSort(t,e,a))),each(l,e=>{n.push(i.callbacks.labelColor.call(t,e)),o.push(i.callbacks.labelTextColor.call(t,e))}),t.labelColors=n,t.labelTextColors=o,t.dataPoints=l,l}update(t){const e=this,i=e.options,a=e._active;let n;if(a.length){const t=positioners[i.position].call(e,a,e._eventPosition),o=e._createItems();e.title=e.getTitle(o),e.beforeBody=e.getBeforeBody(o),e.body=e.getBody(o),e.afterBody=e.getAfterBody(o),e.footer=e.getFooter(o);const s=e._size=getTooltipSize(e),r=Object.assign({},t,s),l=determineAlignment(e._chart,i,r),c=getBackgroundPoint(i,r,l,e._chart);e.xAlign=l.xAlign,e.yAlign=l.yAlign,n={opacity:1,x:c.x,y:c.y,width:s.width,height:s.height,caretX:t.x,caretY:t.y}}else 0!==e.opacity&&(n={opacity:0});n&&e._resolveAnimations().update(e,n),t&&i.custom&&i.custom.call(e,{chart:e._chart,tooltip:e})}drawCaret(t,e,i){const a=this.getCaretPosition(t,i);e.lineTo(a.x1,a.y1),e.lineTo(a.x2,a.y2),e.lineTo(a.x3,a.y3)}getCaretPosition(t,e){const{xAlign:i,yAlign:a,options:n}=this,{cornerRadius:o,caretSize:s}=n,{x:r,y:l}=t,{width:c,height:d}=e;let h,u,g,p,f,m;return"center"===a?(f=l+d/2,"left"===i?(h=r,u=h-s,p=f+s,m=f-s):(h=r+c,u=h+s,p=f-s,m=f+s),g=h):(u="left"===i?r+o+s:"right"===i?r+c-o-s:this.caretX,"top"===a?(p=l,f=p-s,h=u-s,g=u+s):(p=l+d,f=p+s,h=u+s,g=u-s),m=p),{x1:h,x2:u,x3:g,y1:p,y2:f,y3:m}}drawTitle(t,e){const i=this,a=i.options,n=i.title,o=n.length;let s,r,l;if(o){const c=getRtlAdapter(a.rtl,i.x,i.width);for(t.x=getAlignedX(i,a.titleAlign),e.textAlign=c.textAlign(a.titleAlign),e.textBaseline="middle",s=a.titleFont,r=a.titleSpacing,e.fillStyle=a.titleFont.color,e.font=s.string,l=0;l0&&e.stroke()}_updateAnimationTarget(){const t=this,e=t._chart,i=t.options,a=t.$animations,n=a&&a.x,o=a&&a.y;if(n||o){const a=positioners[i.position].call(t,t._active,t._eventPosition);if(!a)return;const s=t._size=getTooltipSize(t),r=Object.assign({},a,t._size),l=determineAlignment(e,i,r),c=getBackgroundPoint(i,r,l,e);n._to===c.x&&o._to===c.y||(t.xAlign=l.xAlign,t.yAlign=l.yAlign,t.width=s.width,t.height=s.height,t.caretX=a.x,t.caretY=a.y,t._resolveAnimations().update(t,c))}}draw(t){const e=this,i=e.options;let a=e.opacity;if(!a)return;e._updateAnimationTarget();const n={width:e.width,height:e.height},o={x:e.x,y:e.y};a=Math.abs(a)<.001?0:a;const s=e.title.length||e.beforeBody.length||e.body.length||e.afterBody.length||e.footer.length;i.enabled&&s&&(t.save(),t.globalAlpha=a,e.drawBackground(o,t,n),overrideTextDirection(t,i.textDirection),o.y+=i.yPadding,e.drawTitle(o,t),e.drawBody(o,t),e.drawFooter(o,t),restoreTextDirection(t,i.textDirection),t.restore())}handleEvent(t,e){const i=this,a=i.options,n=i._active||[];let o=!1,s=[];"mouseout"!==t.type&&(s=i._chart.getElementsAtEventForMode(t,a.mode,a,e),a.reverse&&s.reverse());const r=positioners[a.position].call(i,s,t),l=this.caretX!==r.x||this.caretY!==r.y;return o=e||!_elementsEqual(s,n)||l,o&&(i._active=s,(a.enabled||a.custom)&&(i._eventPosition={x:t.x,y:t.y},i.update(!0))),o}}Tooltip.positioners=positioners;var plugin_tooltip={id:"tooltip",_element:Tooltip,positioners:positioners,afterInit(t){t.options.tooltips&&(t.tooltip=new Tooltip({_chart:t}))},beforeUpdate(t){t.tooltip&&t.tooltip.initialize()},reset(t){t.tooltip&&t.tooltip.initialize()},afterDraw(t){const e=t.tooltip,i={tooltip:e};!1!==t._plugins.notify(t,"beforeTooltipDraw",[i])&&(e&&e.draw(t.ctx),t._plugins.notify(t,"afterTooltipDraw",[i]))},afterEvent(t,e,i){if(t.tooltip){const a=i;t.tooltip.handleEvent(e,a)}},defaults:{enabled:!0,custom:null,mode:"nearest",position:"average",intersect:!0,backgroundColor:"rgba(0,0,0,0.8)",titleFont:{style:"bold",color:"#fff"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodySpacing:2,bodyFont:{color:"#fff"},bodyAlign:"left",footerSpacing:2,footerMarginTop:6,footerFont:{color:"#fff",style:"bold"},footerAlign:"left",yPadding:6,xPadding:6,caretPadding:2,caretSize:5,cornerRadius:6,multiKeyBackground:"#fff",displayColors:!0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart",numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:{beforeTitle:noop,title(t){if(t.length>0){const e=t[0],i=e.chart.data.labels,a=i?i.length:0;if(e.label)return e.label;if(a>0&&e.dataIndex=0&&te.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){const e=this,i=Math.round(e._startValue+e.getDecimalForPixel(t)*e._valueRange);return Math.min(Math.max(i,0),e.ticks.length-1)}getBasePixel(){return this.bottom}}function niceNum(t){const e=Math.floor(log10(t)),i=t/Math.pow(10,e);let a;return a=i<=1?1:i<=2?2:i<=5?5:10,a*Math.pow(10,e)}function generateTicks(t,e){const i=[],{stepSize:a,min:n,max:o,precision:s}=t,r=a||1,l=t.maxTicks-1,{min:c,max:d}=e;let h,u,g,p,f=niceNum((d-c)/l/r)*r;if(f<1e-14&&isNullOrUndef(n)&&isNullOrUndef(o))return[{value:c},{value:d}];p=Math.ceil(d/f)-Math.floor(c/f),p>l&&(f=niceNum(p*f/l/r)*r),a||isNullOrUndef(s)?h=Math.pow(10,_decimalPlaces(f)):(h=Math.pow(10,s),f=Math.ceil(f*h)/h),u=Math.floor(c/f)*f,g=Math.ceil(d/f)*f,!a||isNullOrUndef(n)||isNullOrUndef(o)||almostWhole((o-n)/a,f/1e3)&&(u=n,g=o),p=(g-u)/f,p=almostEquals(p,Math.round(p),f/1e3)?Math.round(p):Math.ceil(p),u=Math.round(u*h)/h,g=Math.round(g*h)/h,i.push({value:isNullOrUndef(n)?u:n});for(let t=1;t0&&i>0&&(t.min=0)}const i=void 0!==e.min||void 0!==e.suggestedMin,a=void 0!==e.max||void 0!==e.suggestedMax;void 0!==e.min?t.min=e.min:void 0!==e.suggestedMin&&(null===t.min?t.min=e.suggestedMin:t.min=Math.min(t.min,e.suggestedMin)),void 0!==e.max?t.max=e.max:void 0!==e.suggestedMax&&(null===t.max?t.max=e.suggestedMax:t.max=Math.max(t.max,e.suggestedMax)),i!==a&&t.min>=t.max&&(i?t.max=t.min+1:t.min=t.max-1),t.min===t.max&&(t.max++,e.beginAtZero||t.min--)}getTickLimit(){const t=this,e=t.options.ticks;let i,{maxTicksLimit:a,stepSize:n}=e;return n?i=Math.ceil(t.max/n)-Math.floor(t.min/n)+1:(i=t.computeTickLimit(),a=a||11),a&&(i=Math.min(a,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this,e=t.options,i=e.ticks;let a=t.getTickLimit();a=Math.max(2,a);const n=generateTicks({maxTicks:a,min:e.min,max:e.max,precision:i.precision,stepSize:valueOrDefault(i.fixedStepSize,i.stepSize)},t);return _setMinAndMaxByKey(n,t,"value"),e.reverse?(n.reverse(),t.start=t.max,t.end=t.min):(t.start=t.min,t.end=t.max),n}configure(){const t=this,e=t.ticks;let i=t.min,a=t.max;if(super.configure(),t.options.offset&&e.length){const t=(a-i)/Math.max(e.length-1,1)/2;i-=t,a+=t}t._startValue=i,t._endValue=a,t._valueRange=a-i}getLabelForValue(t){return new Intl.NumberFormat(this.options.locale).format(t)}}class LinearScale extends LinearScaleBase{determineDataLimits(){const t=this,e=t.options,{min:i,max:a}=t.getMinMax(!0);t.min=isNumberFinite(i)?i:valueOrDefault(e.suggestedMin,0),t.max=isNumberFinite(a)?a:valueOrDefault(e.suggestedMax,1),e.stacked&&i>0&&(t.min=0),t.handleTickRangeOptions()}computeTickLimit(){const t=this;if(t.isHorizontal())return Math.ceil(t.width/40);const e=t._resolveTickFontOptions(0);return Math.ceil(t.height/e.lineHeight)}getPixelForValue(t){const e=this;return e.getPixelForDecimal((t-e._startValue)/e._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}function isMajor(t){return 1===t/Math.pow(10,Math.floor(log10(t)))}function finiteOrDefault(t,e){return isNumberFinite(t)?t:e}function generateTicks$1(t,e){const i=Math.floor(log10(e.max)),a=Math.ceil(e.max/Math.pow(10,i)),n=[];let o=finiteOrDefault(t.min,Math.pow(10,Math.floor(log10(e.min)))),s=Math.floor(log10(o)),r=Math.floor(o/Math.pow(10,s)),l=s<0?Math.pow(10,Math.abs(s)):1;do{n.push({value:o,major:isMajor(o)}),++r,10===r&&(r=1,++s,l=s>=0?1:l),o=Math.round(r*Math.pow(10,s)*l)/l}while(s0?i:NaN}determineDataLimits(){const t=this,{min:e,max:i}=t.getMinMax(!0);t.min=isNumberFinite(e)?Math.max(0,e):null,t.max=isNumberFinite(i)?Math.max(0,i):null,t.handleTickRangeOptions()}handleTickRangeOptions(){const t=this;let e=t.min,i=t.max;e===i&&(e<=0?(e=1,i=10):(e=Math.pow(10,Math.floor(log10(e))-1),i=Math.pow(10,Math.floor(log10(i))+1))),e<=0&&(e=Math.pow(10,Math.floor(log10(i))-1)),i<=0&&(i=Math.pow(10,Math.floor(log10(e))+1)),t.min=e,t.max=i}buildTicks(){const t=this,e=t.options,i=generateTicks$1({min:t._userMin,max:t._userMax},t);let a=!t.isHorizontal();return _setMinAndMaxByKey(i,t,"value"),e.reverse?(a=!a,t.start=t.max,t.end=t.min):(t.start=t.min,t.end=t.max),a&&i.reverse(),i}getLabelForValue(t){return void 0===t?"0":new Intl.NumberFormat(this.options.locale).format(t)}configure(){const t=this,e=t.min;super.configure(),t._startValue=log10(e),t._valueRange=log10(t.max)-log10(e)}getPixelForValue(t){const e=this;return void 0!==t&&0!==t||(t=e.min),e.getPixelForDecimal(t===e.min?0:(log10(t)-e._startValue)/e._valueRange)}getValueForPixel(t){const e=this,i=e.getDecimalForPixel(t);return Math.pow(10,e._startValue+i*e._valueRange)}}function getTickBackdropHeight(t){const e=t.ticks;return e.display&&t.display?valueOrDefault(e.font&&e.font.size,defaults.font.size)+2*e.backdropPaddingY:0}function measureLabelSize(t,e,i){return isArray(i)?{w:_longestText(t,t.font,i),h:i.length*e}:{w:t.measureText(i).width,h:e}}function determineLimits(t,e,i,a,n){return t===a||t===n?{start:e-i/2,end:e+i/2}:tn?{start:e-i,end:e}:{start:e,end:e+i}}function fitWithPointLabels(t){const e={l:0,r:t.width,t:0,b:t.height-t.paddingTop},i={};let a,n,o;t._pointLabelSizes=[];const s=t.chart.data.labels.length;for(a=0;ae.r&&(e.r=d.end,i.r=l),h.starte.b&&(e.b=h.end,i.b=l)}t._setReductions(t.drawingArea,e,i)}function getTextAlignForAngle(t){return 0===t||180===t?"center":t<180?"left":"right"}function fillText(t,e,i,a){let n,o,s=i.y+a/2;if(isArray(e))for(n=0,o=e.length;n270||t<90)&&(i.y-=e.h)}function drawPointLabels(t){const e=t.ctx,i=t.options,a=i.pointLabels,n=getTickBackdropHeight(i),o=t.getDistanceFromCenterForValue(i.ticks.reverse?t.min:t.max);e.save(),e.textBaseline="middle";for(let i=t.chart.data.labels.length-1;i>=0;i--){const s=0===i?n/2:0,r=t.getPointPosition(i,o+s+5),l={chart:t.chart,scale:t,index:i,label:t.pointLabels[i]},c=toFont(resolve([a.font],l,i));e.font=c.string,e.fillStyle=c.color;const d=toDegrees(t.getIndexAngle(i));e.textAlign=getTextAlignForAngle(d),adjustPointPositionForLabelHeight(d,t._pointLabelSizes[i],r),fillText(e,t.pointLabels[i],r,c.lineHeight)}e.restore()}function drawRadiusLine(t,e,i,a){const n=t.ctx,o=e.circular,s=t.chart.data.labels.length,r={chart:t.chart,scale:t,index:a,tick:t.ticks[a]},l=resolve([e.color],r,a-1),c=resolve([e.lineWidth],r,a-1);let d;if((o||s)&&l&&c){if(n.save(),n.strokeStyle=l,n.lineWidth=c,n.setLineDash&&(n.setLineDash(resolve([e.borderDash,[]],r)),n.lineDashOffset=resolve([e.borderDashOffset],r,a-1)),n.beginPath(),o)n.arc(t.xCenter,t.yCenter,i,0,2*Math.PI);else{d=t.getPointPosition(0,i),n.moveTo(d.x,d.y);for(let e=1;e{const a=callback(e.options.pointLabels.callback,[t,i],e);return a||0===a?a:""})}fit(){const t=this,e=t.options;e.display&&e.pointLabels.display?fitWithPointLabels(t):t.setCenterPoint(0,0,0,0)}_setReductions(t,e,i){const a=this;let n=e.l/Math.sin(i.l),o=Math.max(e.r-a.width,0)/Math.sin(i.r),s=-e.t/Math.cos(i.t),r=-Math.max(e.b-(a.height-a.paddingTop),0)/Math.cos(i.b);n=numberOrZero(n),o=numberOrZero(o),s=numberOrZero(s),r=numberOrZero(r),a.drawingArea=Math.min(Math.floor(t-(n+o)/2),Math.floor(t-(s+r)/2)),a.setCenterPoint(n,o,s,r)}setCenterPoint(t,e,i,a){const n=this,o=n.width-e-n.drawingArea,s=t+n.drawingArea,r=i+n.drawingArea,l=n.height-n.paddingTop-a-n.drawingArea;n.xCenter=Math.floor((s+o)/2+n.left),n.yCenter=Math.floor((r+l)/2+n.top+n.paddingTop)}getIndexAngle(t){const e=this.chart,i=2*Math.PI/e.data.labels.length,a=(e.options||{}).startAngle||0;return _normalizeAngle(t*i+toRadians(a))}getDistanceFromCenterForValue(t){const e=this;if(isNullOrUndef(t))return NaN;const i=e.drawingArea/(e.max-e.min);return e.options.reverse?(e.max-t)*i:(t-e.min)*i}getValueForDistanceFromCenter(t){if(isNullOrUndef(t))return NaN;const e=this,i=t/(e.drawingArea/(e.max-e.min));return e.options.reverse?e.max-i:e.min+i}getPointPosition(t,e){const i=this,a=i.getIndexAngle(t)-Math.PI/2;return{x:Math.cos(a)*e+i.xCenter,y:Math.sin(a)*e+i.yCenter,angle:a}}getPointPositionForValue(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))}getBasePosition(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}drawGrid(){const t=this,e=t.ctx,i=t.options,a=i.gridLines,n=i.angleLines;let o,s,r;if(i.pointLabels.display&&drawPointLabels(t),a.display&&t.ticks.forEach((e,i)=>{0!==i&&(s=t.getDistanceFromCenterForValue(t.ticks[i].value),drawRadiusLine(t,a,s,i))}),n.display){for(e.save(),o=t.chart.data.labels.length-1;o>=0;o--){const l={chart:t.chart,scale:t,index:o,label:t.pointLabels[o]},c=resolve([n.lineWidth,a.lineWidth],l,o),d=resolve([n.color,a.color],l,o);c&&d&&(e.lineWidth=c,e.strokeStyle=d,e.setLineDash&&(e.setLineDash(resolve([n.borderDash,a.borderDash,[]],l)),e.lineDashOffset=resolve([n.borderDashOffset,a.borderDashOffset,0],l,o)),s=t.getDistanceFromCenterForValue(i.ticks.reverse?t.min:t.max),r=t.getPointPosition(o,s),e.beginPath(),e.moveTo(t.xCenter,t.yCenter),e.lineTo(r.x,r.y),e.stroke())}e.restore()}}drawLabels(){const t=this,e=t.ctx,i=t.options,a=i.ticks;if(!a.display)return;const n=t.getIndexAngle(0);let o,s;e.save(),e.translate(t.xCenter,t.yCenter),e.rotate(n),e.textAlign="center",e.textBaseline="middle",t.ticks.forEach((n,r)=>{const l={chart:t.chart,scale:t,index:r,tick:n};if(0===r&&!i.reverse)return;const c=t._resolveTickFontOptions(r);e.font=c.string,o=t.getDistanceFromCenterForValue(t.ticks[r].value);resolve([a.showLabelBackdrop],l,r)&&(s=e.measureText(n.label).width,e.fillStyle=resolve([a.backdropColor],l,r),e.fillRect(-s/2-a.backdropPaddingX,-o-c.size/2-a.backdropPaddingY,s+2*a.backdropPaddingX,c.size+2*a.backdropPaddingY)),e.fillStyle=c.color,e.fillText(n.label,0,-o)}),e.restore()}drawTitle(){}}RadialLinearScale.id="radialLinear",RadialLinearScale.defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,color:"rgba(0,0,0,0.1)",lineWidth:1,borderDash:[],borderDashOffset:0},gridLines:{circular:!1},ticks:{showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2,callback:Ticks.formatters.numeric},pointLabels:{display:!0,font:{size:10},callback:t=>t}};const MAX_INTEGER=Number.MAX_SAFE_INTEGER||9007199254740991,INTERVALS={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},UNITS=Object.keys(INTERVALS);function sorter(t,e){return t-e}function parse(t,e){if(isNullOrUndef(e))return null;const i=t._adapter,a=t.options.time,{parser:n,round:o,isoWeekday:s}=a;let r=e;return"function"==typeof n&&(r=n(r)),isNumberFinite(r)||(r="string"==typeof n?i.parse(r,n):i.parse(r)),null===r?r:(o&&(r="week"===o&&s?t._adapter.startOf(r,"isoWeek",s):t._adapter.startOf(r,o)),+r)}function determineUnitForAutoTicks(t,e,i,a){const n=UNITS.length;for(let o=UNITS.indexOf(t);o=UNITS.indexOf(i);o--){const i=UNITS[o];if(INTERVALS[i].common&&t._adapter.diff(n,a,i)>=e-1)return i}return UNITS[i?UNITS.indexOf(i):0]}function determineMajorUnit(t){for(let e=UNITS.indexOf(t)+1,i=UNITS.length;e=i?t[a]:t[n]]=!0}function setMajorTicks(t,e,i,a){const n=t._adapter,o=+n.startOf(e[0].value,a),s=e[e.length-1].value;let r,l;for(r=o;r<=s;r=+n.add(r,1,a))l=i[r],l>=0&&(e[l].major=!0);return e}function ticksFromTimestamps(t,e,i){const a=[],n={},o=e.length;let s,r;for(s=0;s1e5*r)throw new Error(i+" and "+a+" are too far apart with stepSize of "+r+" "+s);if("data"===t.options.ticks.source){const i=t.getDataTimestamps();for(d=h;d+t)}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}_tickFormatFunction(t,e,i,a){const n=this,o=n.options,s=o.time.displayFormats,r=n._unit,l=n._majorUnit,c=r&&s[r],d=l&&s[l],h=i[e],u=l&&d&&h&&h.major,g=n._adapter.format(t,a||(u?d:c)),p=o.ticks.callback;return p?p(g,e,i):g}generateTickLabels(t){let e,i,a;for(e=0,i=t.length;e0?r:1}getDataTimestamps(){const t=this;let e,i,a=t._cache.data||[];if(a.length)return a;const n=t.getMatchingVisibleMetas();if(t._normalized&&n.length)return t._cache.data=n[0].controller.getAllParsedValues(t);for(e=0,i=n.length;ee&&s0&&!isNullOrUndef(e)?e/i._maxIndex:i.getDecimalForValue(t);return i.getPixelForDecimal((a.start+n)*a.factor)}getDecimalForValue(t){return interpolate(this._table,t)/this._maxIndex}getValueForPixel(t){const e=this,i=e._offsets,a=e.getDecimalForPixel(t)/i.factor-i.end;return interpolate(e._table,a*this._maxIndex,!0)}}TimeSeriesScale.id="timeseries",TimeSeriesScale.defaults=TimeScale.defaults;export{Animation,Animations,Arc,BarController,BasePlatform,BasicPlatform,BubbleController,CategoryScale,Chart,DatasetController,DomPlatform,DoughnutController,Element,plugin_filler as Filler,Interaction,plugin_legend as Legend,Line,LineController,LinearScale,LogarithmicScale,PieController,Point,PolarAreaController,RadarController,RadialLinearScale,Rectangle,Scale,ScatterController,Ticks,TimeScale,TimeSeriesScale,plugin_title as Title,plugin_tooltip as Tooltip,adapters as _adapters,animator,layouts,PluginService as plugins,registry}; +import{requestAnimFrame,throttled}from '../helpers/extras.js';import effects from '../helpers/easing.js';import{isObject,noop,valueOrDefault,merge,isArray,resolveObjectKey,_capitalize,mergeIf,_merger,isNullOrUndef,each,isFinite as isNumberFinite,callback,uid,_elementsEqual}from '../helpers/core.js';import{r as resolve,d as defaults,t as toPadding,a as toFont}from '../helpers/chunks/helpers.options.js';export{d as defaults}from '../helpers/chunks/helpers.options.js';import{clipArea,unclipArea,_isPointInArea,_measureText,_alignPixel,clear,_steppedLineTo,_bezierCurveTo,drawPoint,_longestText}from '../helpers/canvas.js';import{color,getHoverColor}from '../helpers/color.js';import{unlistenArrayEvents,listenArrayEvents,_rlookupByKey,_lookupByKey,_filterBetween,_arrayUnique,_lookup}from '../helpers/collection.js';import{sign,_limitValue,isNumber,toRadians,log10,toDegrees,_factorize,getAngleFromPoint,_angleBetween,_normalizeAngle,distanceBetweenPoints,_setMinAndMaxByKey,_decimalPlaces,almostEquals,almostWhole}from '../helpers/math.js';import{getRelativePosition as getRelativePosition$1,_getParentNode,readUsedSize,supportsEventListenerOptions,retinaScale,getMaximumWidth,getMaximumHeight}from '../helpers/dom.js';import{_steppedInterpolation,_bezierInterpolation,_pointInLine}from '../helpers/interpolation.js';import{_computeSegments,_boundSegments,_boundSegment}from '../helpers/segment.js';import{_updateBezierControlPoints}from '../helpers/curve.js';import{getRtlAdapter,overrideTextDirection,restoreTextDirection}from '../helpers/rtl.js';function drawFPS(chart,count,date,lastDate){const fps=(1000/(date-lastDate))|0;const ctx=chart.ctx;ctx.save();ctx.clearRect(0,0,50,24);ctx.fillStyle='black';ctx.textAlign='right';if(count){ctx.fillText(count,50,8);ctx.fillText(fps+' fps',50,18)}ctx.restore()}class Animator{constructor(){this._request=null;this._charts=new Map();this._running=false;this._lastDate=undefined}_notify(chart,anims,date,type){const callbacks=anims.listeners[type]||[];const numSteps=anims.duration;callbacks.forEach(fn=>fn({chart,numSteps,currentStep:Math.min(date-anims.start,numSteps)}))}_refresh(){const me=this;if(me._request){return}me._running=true;me._request=requestAnimFrame.call(window,()=>{me._update();me._request=null;if(me._running){me._refresh()}})}_update(){const me=this;const date=Date.now();let remaining=0;me._charts.forEach((anims,chart)=>{if(!anims.running||!anims.items.length){return}const items=anims.items;let i=items.length-1;let draw=false;let item;for(;i>=0;i-=1){item=items[i];if(item._active){item.tick(date);draw=true}else{items[i]=items[items.length-1];items.pop()}}if(draw){chart.draw();me._notify(chart,anims,date,'progress')}if(chart.options.animation.debug){drawFPS(chart,items.length,date,me._lastDate)}if(!items.length){anims.running=false;me._notify(chart,anims,date,'complete')}remaining+=items.length});me._lastDate=date;if(remaining===0){me._running=false}}_getAnims(chart){const charts=this._charts;let anims=charts.get(chart);if(!anims){anims={running:false,items:[],listeners:{complete:[],progress:[]}};charts.set(chart,anims)}return anims}listen(chart,event,cb){this._getAnims(chart).listeners[event].push(cb)}add(chart,items){if(!items||!items.length){return}this._getAnims(chart).items.push(...items)}has(chart){return this._getAnims(chart).items.length>0}start(chart){const anims=this._charts.get(chart);if(!anims){return}anims.running=true;anims.start=Date.now();anims.duration=anims.items.reduce((acc,cur)=>Math.max(acc,cur._duration),0);this._refresh()}running(chart){if(!this._running){return false}const anims=this._charts.get(chart);if(!anims||!anims.running||!anims.items.length){return false}return true}stop(chart){const anims=this._charts.get(chart);if(!anims||!anims.items.length){return}const items=anims.items;let i=items.length-1;for(;i>=0;i-=1){items[i].cancel()}anims.items=[];this._notify(chart,anims,Date.now(),'complete')}remove(chart){return this._charts.delete(chart)}}var animator=new Animator();const transparent='transparent';const interpolators={boolean(from,to,factor){return factor>0.5?to:from},color(from,to,factor){const c0=color(from||transparent);const c1=c0.valid&&color(to||transparent);return c1&&c1.valid?c1.mix(c0,factor).hexString():to},number(from,to,factor){return from+(to-from)*factor}};class Animation{constructor(cfg,target,prop,to){const currentValue=target[prop];to=resolve([cfg.to,to,currentValue,cfg.from]);const from=resolve([cfg.from,currentValue,to]);this._active=true;this._fn=cfg.fn||interpolators[cfg.type||typeof from];this._easing=effects[cfg.easing||'linear'];this._start=Math.floor(Date.now()+(cfg.delay||0));this._duration=Math.floor(cfg.duration);this._loop=!!cfg.loop;this._target=target;this._prop=prop;this._from=from;this._to=to;this._promises=undefined}active(){return this._active}update(cfg,to,date){const me=this;if(me._active){const currentValue=me._target[me._prop];const elapsed=date-me._start;const remain=me._duration-elapsed;me._start=date;me._duration=Math.floor(Math.max(remain,cfg.duration));me._loop=!!cfg.loop;me._to=resolve([cfg.to,to,currentValue,cfg.from]);me._from=resolve([cfg.from,currentValue,to])}}cancel(){const me=this;if(me._active){me.tick(Date.now());me._active=false;me._notify(false)}}tick(date){const me=this;const elapsed=date-me._start;const duration=me._duration;const prop=me._prop;const from=me._from;const loop=me._loop;const to=me._to;let factor;me._active=from!==to&&(loop||(elapsed1?2-factor:factor;factor=me._easing(Math.min(1,Math.max(0,factor)));me._target[prop]=me._fn(from,to,factor)}wait(){const promises=this._promises||(this._promises=[]);return new Promise((res,rej)=>{promises.push({res,rej})})}_notify(resolved){const method=resolved?'res':'rej';const promises=this._promises||[];for(let i=0;i{const value=animations[key];if(!isObject(value)){result[key]=value}});return result}class Animations{constructor(chart,animations){this._chart=chart;this._properties=new Map();this.configure(animations)}configure(animations){if(!isObject(animations)){return}const animatedProps=this._properties;const animDefaults=extensibleConfig(animations);Object.keys(animations).forEach(key=>{const cfg=animations[key];if(!isObject(cfg)){return}(cfg.properties||[key]).forEach((prop)=>{if(!animatedProps.has(prop)){animatedProps.set(prop,Object.assign({},animDefaults,cfg))}else if(prop===key){const{properties,...inherited}=animatedProps.get(prop);animatedProps.set(prop,Object.assign({},inherited,cfg))}})})}_animateOptions(target,values){const newOptions=values.options;const options=resolveTargetOptions(target,newOptions);if(!options){return[]}const animations=this._createAnimations(options,newOptions);if(newOptions.$shared&&!options.$shared){awaitAll(target.$animations,newOptions).then(()=>{target.options=newOptions})}return animations}_createAnimations(target,values){const animatedProps=this._properties;const animations=[];const running=target.$animations||(target.$animations={});const props=Object.keys(values);const date=Date.now();let i;for(i=props.length-1;i>=0;i-=1){const prop=props[i];if(prop.charAt(0)==='$'){continue}if(prop==='options'){animations.push(...this._animateOptions(target,values));continue}const value=values[prop];let animation=running[prop];const cfg=animatedProps.get(prop);if(animation){if(cfg&&animation.active()){animation.update(cfg,value,date);continue}else{animation.cancel()}}if(!cfg||!cfg.duration){target[prop]=value;continue}running[prop]=animation=new Animation(cfg,target,prop,value);animations.push(animation)}return animations}update(target,values){if(this._properties.size===0){copyOptions(target,values);Object.assign(target,values);return}const animations=this._createAnimations(target,values);if(animations.length){animator.add(this._chart,animations);return true}}}function awaitAll(animations,properties){const running=[];const keys=Object.keys(properties);for(let i=0;iscales[key].axis===axis).shift()}function optionKeys(optionNames){return isArray(optionNames)?optionNames:Object.keys(optionNames)}function optionKey(key,active){return active?'hover'+_capitalize(key):key}function isDirectUpdateMode(mode){return mode==='reset'||mode==='none'}class DatasetController{constructor(chart,datasetIndex){this.chart=chart;this._ctx=chart.ctx;this.index=datasetIndex;this._cachedAnimations={};this._cachedDataOpts={};this._cachedMeta=this.getMeta();this._type=this._cachedMeta.type;this._config=undefined;this._parsing=false;this._data=undefined;this._objectData=undefined;this._sharedOptions=undefined;this.enableOptionSharing=false;this.initialize()}initialize(){const me=this;const meta=me._cachedMeta;me.configure();me.linkScales();meta._stacked=isStacked(meta.vScale,meta);me.addElements()}updateIndex(datasetIndex){this.index=datasetIndex}linkScales(){const me=this;const chart=me.chart;const meta=me._cachedMeta;const dataset=me.getDataset();const chooseId=(axis,x,y,r)=>axis==='x'?x:axis==='r'?r:y;const xid=meta.xAxisID=valueOrDefault(dataset.xAxisID,getFirstScaleId(chart,'x'));const yid=meta.yAxisID=valueOrDefault(dataset.yAxisID,getFirstScaleId(chart,'y'));const rid=meta.rAxisID=valueOrDefault(dataset.rAxisID,getFirstScaleId(chart,'r'));const indexAxis=meta.indexAxis;const iid=meta.iAxisID=chooseId(indexAxis,xid,yid,rid);const vid=meta.vAxisID=chooseId(indexAxis,yid,xid,rid);meta.xScale=me.getScaleForId(xid);meta.yScale=me.getScaleForId(yid);meta.rScale=me.getScaleForId(rid);meta.iScale=me.getScaleForId(iid);meta.vScale=me.getScaleForId(vid)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(scaleID){return this.chart.scales[scaleID]}_getOtherScale(scale){const meta=this._cachedMeta;return scale===meta.iScale?meta.vScale:meta.iScale}reset(){this._update('reset')}_destroy(){if(this._data){unlistenArrayEvents(this._data,this)}}_dataCheck(){const me=this;const dataset=me.getDataset();const data=dataset.data||(dataset.data=[]);if(isObject(data)){me._data=convertObjectDataToArray(data)}else if(me._data!==data){if(me._data){unlistenArrayEvents(me._data,me)}if(data&&Object.isExtensible(data)){listenArrayEvents(data,me)}me._data=data}}addElements(){const me=this;const meta=me._cachedMeta;me._dataCheck();const data=me._data;const metaData=meta.data=[data.length];for(let i=0,ilen=data.length;i{delete parsed._stacks[meta.vScale.id][meta.index]});meta.stack=dataset.stack}me._resyncElements();if(stackChanged){updateStacks(me,meta._parsed)}}configure(){const me=this;me._config=merge({},[me.chart.options[me._type].datasets,me.getDataset()],{merger(key,target,source){if(key!=='data'){_merger(key,target,source)}}});me._parsing=resolve([me._config.parsing,me.chart.options.parsing,true])}parse(start,count){const me=this;const{_cachedMeta:meta,_data:data}=me;const{iScale,vScale,_stacked}=meta;const iAxis=iScale.axis;let sorted=true;let i,parsed,cur,prev;if(start>0){sorted=meta._sorted;prev=meta._parsed[start-1]}if(me._parsing===false){meta._parsed=data;meta._sorted=true}else{if(isArray(data[start])){parsed=me.parseArrayData(meta,data,start,count)}else if(isObject(data[start])){parsed=me.parseObjectData(meta,data,start,count)}else{parsed=me.parsePrimitiveData(meta,data,start,count)}for(i=0;iotherValue||otherMax=0;i-=1){if(_skip()){continue}me.updateRangeFromParsed(range,scale,parsed,stack);break}}return range}getAllParsedValues(scale){const parsed=this._cachedMeta._parsed;const values=[];let i,ilen,value;for(i=0,ilen=parsed.length;ikey.indexOf('Color')!==-1&&!(key in options));let i=missingColors.length-1;let color;for(;i>=0;i-=1){color=missingColors[i];options[color]=getHoverColor(normalOptions[color])}}getStyle(index,active){const me=this;const meta=me._cachedMeta;const dataset=meta.dataset;if(!me._config){me.configure()}const options=dataset&&index===undefined?me.resolveDatasetElementOptions(active):me.resolveDataElementOptions(index||0,active&&'active');if(active){me._addAutomaticHoverColors(index,options)}return options}_getContext(index,active){return{chart:this.chart,dataPoint:this.getParsed(index),dataIndex:index,dataset:this.getDataset(),datasetIndex:this.index,active}}resolveDatasetElementOptions(active){return this._resolveOptions(this.datasetElementOptions,{active,type:this.datasetElementType.id})}resolveDataElementOptions(index,mode){mode=mode||'default';const me=this;const active=mode==='active';const cached=me._cachedDataOpts;const sharing=me.enableOptionSharing;if(cached[mode]){return cached[mode]}const info={cacheable:!active};const values=me._resolveOptions(me.dataElementOptions,{index,active,info,type:me.dataElementType.id});if(info.cacheable){values.$shared=sharing;cached[mode]=sharing?Object.freeze(values):values}return values}_resolveOptions(optionNames,args){const me=this;const{index,active,type,info}=args;const datasetOpts=me._config;const options=me.chart.options.elements[type]||{};const values={};const context=me._getContext(index,active);const keys=optionKeys(optionNames);for(let i=0,ilen=keys.length;inumMeta){me._insertElements(numMeta,numData-numMeta)}else if(numData0?Math.min(min,Math.abs(curr-prev)):min;prev=curr}return min}function computeFitCategoryTraits(index,ruler,options){const thickness=options.barThickness;const count=ruler.stackCount;let size,ratio;if(isNullOrUndef(thickness)){size=ruler.min*options.categoryPercentage;ratio=options.barPercentage}else{size=thickness*count;ratio=1}return{chunk:size/count,ratio,start:ruler.pixels[index]-(size/2)}}function computeFlexCategoryTraits(index,ruler,options){const pixels=ruler.pixels;const curr=pixels[index];let prev=index>0?pixels[index-1]:null;let next=indexMath.abs(max)){barStart=max;barEnd=min}item[vScale.axis]=barEnd;item._custom={barStart,barEnd,start:startValue,end:endValue,min,max}}function parseValue(entry,item,vScale,i){if(isArray(entry)){parseFloatBar(entry,item,vScale,i)}else{item[vScale.axis]=vScale.parse(entry,i)}return item}function parseArrayOrPrimitive(meta,data,start,count){const iScale=meta.iScale;const vScale=meta.vScale;const labels=iScale.getLabels();const singleScale=iScale===vScale;const parsed=[];let i,ilen,item,entry;for(i=start,ilen=start+count;i=0;i-=1){max=Math.max(max,me.getStyle(i,true).radius)}return max>0&&max}getLabelAndValue(index){const me=this;const meta=me._cachedMeta;const{xScale,yScale}=meta;const parsed=me.getParsed(index);const x=xScale.getLabelForValue(parsed.x);const y=yScale.getLabelForValue(parsed.y);const r=parsed._custom;return{label:meta.label,value:'('+x+', '+y+(r?', '+r:'')+')'}}update(mode){const me=this;const points=me._cachedMeta.data;me.updateElements(points,0,mode)}updateElements(points,start,mode){const me=this;const reset=mode==='reset';const{xScale,yScale}=me._cachedMeta;const firstOpts=me.resolveDataElementOptions(start,mode);const sharedOptions=me.getSharedOptions(firstOpts);const includeOptions=me.includeOptions(mode,sharedOptions);for(let i=0;i=PI? -DOUBLE_PI:startAngle< -PI?DOUBLE_PI:0;const endAngle=startAngle+circumference;const startX=Math.cos(startAngle);const startY=Math.sin(startAngle);const endX=Math.cos(endAngle);const endY=Math.sin(endAngle);const contains0=(startAngle<=0&&endAngle>=0)||endAngle>=DOUBLE_PI;const contains90=(startAngle<=HALF_PI&&endAngle>=HALF_PI)||endAngle>=DOUBLE_PI+HALF_PI;const contains180=startAngle=== -PI||endAngle>=PI;const contains270=(startAngle<= -HALF_PI&&endAngle>= -HALF_PI)||endAngle>=PI+HALF_PI;const minX=contains180?-1:Math.min(startX,startX*cutout,endX,endX*cutout);const minY=contains270?-1:Math.min(startY,startY*cutout,endY,endY*cutout);const maxX=contains0?1:Math.max(startX,startX*cutout,endX,endX*cutout);const maxY=contains90?1:Math.max(startY,startY*cutout,endY,endY*cutout);ratioX=(maxX-minX)/2;ratioY=(maxY-minY)/2;offsetX= -(maxX+minX)/2;offsetY= -(maxY+minY)/2}return{ratioX,ratioY,offsetX,offsetY}}class DoughnutController extends DatasetController{constructor(chart,datasetIndex){super(chart,datasetIndex);this.enableOptionSharing=true;this.innerRadius=undefined;this.outerRadius=undefined;this.offsetX=undefined;this.offsetY=undefined}linkScales(){}parse(start,count){const data=this.getDataset().data;const meta=this._cachedMeta;let i,ilen;for(i=start,ilen=start+count;i0&&!isNaN(value)){return DOUBLE_PI*(Math.abs(value)/total)}return 0}getLabelAndValue(index){const me=this;const meta=me._cachedMeta;const chart=me.chart;const labels=chart.data.labels||[];return{label:labels[index]||'',value:meta._parsed[index]}}getMaxBorderWidth(arcs){const me=this;let max=0;const chart=me.chart;let i,ilen,meta,controller,options;if(!arcs){for(i=0,ilen=chart.data.datasets.length;i{const meta=chart.getDatasetMeta(0);const style=meta.controller.getStyle(i);return{text:label,fillStyle:style.backgroundColor,strokeStyle:style.borderColor,lineWidth:style.borderWidth,hidden:!chart.getDataVisibility(i),index:i}})}return[]}},onClick(e,legendItem,legend){legend.chart.toggleDataVisibility(legendItem.index);legend.chart.update()}},cutoutPercentage:50,rotation: -HALF_PI,circumference:DOUBLE_PI,tooltips:{callbacks:{title(){return ''},label(tooltipItem){let dataLabel=tooltipItem.label;const value=': '+tooltipItem.formattedValue;if(isArray(dataLabel)){dataLabel=dataLabel.slice();dataLabel[0]+=value}else{dataLabel+=value}return dataLabel}}}};class LineController extends DatasetController{initialize(){this.enableOptionSharing=true;super.initialize()}update(mode){const me=this;const meta=me._cachedMeta;const line=meta.dataset;const points=meta.data||[];if(mode!=='resize'){const properties={points,options:me.resolveDatasetElementOptions()};me.updateElement(line,undefined,properties,mode)}me.updateElements(points,0,mode)}updateElements(points,start,mode){const me=this;const reset=mode==='reset';const{xScale,yScale,_stacked}=me._cachedMeta;const firstOpts=me.resolveDataElementOptions(start,mode);const sharedOptions=me.getSharedOptions(firstOpts);const includeOptions=me.includeOptions(mode,sharedOptions);const spanGaps=valueOrDefault(me._config.spanGaps,me.chart.options.spanGaps);const maxGapLength=isNumber(spanGaps)?spanGaps:Number.POSITIVE_INFINITY;let prevParsed;for(let i=0;i0&&(parsed.x-prevParsed.x)>maxGapLength};if(includeOptions){properties.options=sharedOptions||me.resolveDataElementOptions(index,mode)}me.updateElement(point,index,properties,mode);prevParsed=parsed}me.updateSharedOptions(sharedOptions,mode,firstOpts)}resolveDatasetElementOptions(active){const me=this;const config=me._config;const options=me.chart.options;const lineOptions=options.elements.line;const values=super.resolveDatasetElementOptions(active);const showLine=valueOrDefault(config.showLine,options.showLines);values.spanGaps=valueOrDefault(config.spanGaps,options.spanGaps);values.tension=valueOrDefault(config.lineTension,lineOptions.tension);values.stepped=resolve([config.stepped,lineOptions.stepped]);if(!showLine){values.borderWidth=0}return values}getMaxOverflow(){const me=this;const meta=me._cachedMeta;const border=meta.dataset.options.borderWidth||0;const data=meta.data||[];if(!data.length){return border}const firstPoint=data[0].size();const lastPoint=data[data.length-1].size();return Math.max(border,firstPoint,lastPoint)/2}draw(){this._cachedMeta.dataset.updateControlPoints(this.chart.chartArea);super.draw()}}LineController.id='line';LineController.defaults={datasetElementType:'line',datasetElementOptions:['backgroundColor','borderCapStyle','borderColor','borderDash','borderDashOffset','borderJoinStyle','borderWidth','capBezierPoints','cubicInterpolationMode','fill'],dataElementType:'point',dataElementOptions:{backgroundColor:'pointBackgroundColor',borderColor:'pointBorderColor',borderWidth:'pointBorderWidth',hitRadius:'pointHitRadius',hoverHitRadius:'pointHitRadius',hoverBackgroundColor:'pointHoverBackgroundColor',hoverBorderColor:'pointHoverBorderColor',hoverBorderWidth:'pointHoverBorderWidth',hoverRadius:'pointHoverRadius',pointStyle:'pointStyle',radius:'pointRadius',rotation:'pointRotation'},showLines:true,spanGaps:false,hover:{mode:'index'},scales:{_index_:{type:'category'},_value_:{type:'linear'}}};function getStartAngleRadians(deg){return toRadians(deg)-0.5*Math.PI}class PolarAreaController extends DatasetController{constructor(chart,datasetIndex){super(chart,datasetIndex);this.innerRadius=undefined;this.outerRadius=undefined}update(mode){const arcs=this._cachedMeta.data;this._updateRadius();this.updateElements(arcs,0,mode)}_updateRadius(){const me=this;const chart=me.chart;const chartArea=chart.chartArea;const opts=chart.options;const minSize=Math.min(chartArea.right-chartArea.left,chartArea.bottom-chartArea.top);const outerRadius=Math.max(minSize/2,0);const innerRadius=Math.max(opts.cutoutPercentage?(outerRadius/100)*(opts.cutoutPercentage):1,0);const radiusLength=(outerRadius-innerRadius)/chart.getVisibleDatasetCount();me.outerRadius=outerRadius-(radiusLength*me.index);me.innerRadius=me.outerRadius-radiusLength}updateElements(arcs,start,mode){const me=this;const reset=mode==='reset';const chart=me.chart;const dataset=me.getDataset();const opts=chart.options;const animationOpts=opts.animation;const scale=me._cachedMeta.rScale;const centerX=scale.xCenter;const centerY=scale.yCenter;const datasetStartAngle=getStartAngleRadians(opts.startAngle);let angle=datasetStartAngle;let i;me._cachedMeta.count=me.countVisibleElements();for(i=0;i{if(!isNaN(dataset.data[index])&&this.chart.getDataVisibility(index)){count+=1}});return count}_computeAngle(index){const me=this;const meta=me._cachedMeta;const count=meta.count;const dataset=me.getDataset();if(isNaN(dataset.data[index])||!this.chart.getDataVisibility(index)){return 0}const context={chart:me.chart,dataPoint:this.getParsed(index),dataIndex:index,dataset,datasetIndex:me.index};return resolve([me.chart.options.elements.arc.angle,(2*Math.PI)/count],context,index)}}PolarAreaController.id='polarArea';PolarAreaController.defaults={dataElementType:'arc',dataElementOptions:['backgroundColor','borderColor','borderWidth','borderAlign','offset'],animation:{numbers:{type:'number',properties:['x','y','startAngle','endAngle','innerRadius','outerRadius']},animateRotate:true,animateScale:true},aspectRatio:1,datasets:{indexAxis:'r'},scales:{r:{type:'radialLinear',angleLines:{display:false},beginAtZero:true,gridLines:{circular:true},pointLabels:{display:false}}},startAngle:0,legend:{labels:{generateLabels(chart){const data=chart.data;if(data.labels.length&&data.datasets.length){return data.labels.map((label,i)=>{const meta=chart.getDatasetMeta(0);const style=meta.controller.getStyle(i);return{text:label,fillStyle:style.backgroundColor,strokeStyle:style.borderColor,lineWidth:style.borderWidth,hidden:!chart.getDataVisibility(i),index:i}})}return[]}},onClick(e,legendItem,legend){legend.chart.toggleDataVisibility(legendItem.index);legend.chart.update()}},tooltips:{callbacks:{title(){return ''},label(context){return context.chart.data.labels[context.dataIndex]+': '+context.formattedValue}}}};class PieController extends DoughnutController{}PieController.id='pie';PieController.defaults={cutoutPercentage:0};class RadarController extends DatasetController{getLabelAndValue(index){const me=this;const vScale=me._cachedMeta.vScale;const parsed=me.getParsed(index);return{label:vScale.getLabels()[index],value:''+vScale.getLabelForValue(parsed[vScale.axis])}}update(mode){const me=this;const meta=me._cachedMeta;const line=meta.dataset;const points=meta.data||[];const labels=meta.iScale.getLabels();if(mode!=='resize'){const properties={points,_loop:true,_fullLoop:labels.length===points.length,options:me.resolveDatasetElementOptions()};me.updateElement(line,undefined,properties,mode)}me.updateElements(points,0,mode)}updateElements(points,start,mode){const me=this;const dataset=me.getDataset();const scale=me._cachedMeta.rScale;const reset=mode==='reset';let i;for(i=0;i{const index=items[0].index;const element=meta.data[index];if(element&&!element.skip){elements.push({element,datasetIndex:meta.index,index})}});return elements},dataset(chart,e,options,useFinalPosition){const position=getRelativePosition(e,chart);const axis=options.axis||'xy';let items=options.intersect?getIntersectItems(chart,position,axis,useFinalPosition):getNearestItems(chart,position,axis,false,useFinalPosition);if(items.length>0){const datasetIndex=items[0].datasetIndex;const data=chart.getDatasetMeta(datasetIndex).data;items=[];for(let i=0;i{if(element.inXRange(position.x,useFinalPosition)){items.push({element,datasetIndex,index})}if(element.inRange(position.x,position.y,useFinalPosition)){intersectsItem=true}});if(options.intersect&&!intersectsItem){return[]}return items},y(chart,e,options,useFinalPosition){const position=getRelativePosition(e,chart);const items=[];let intersectsItem=false;evaluateAllVisibleItems(chart,(element,datasetIndex,index)=>{if(element.inYRange(position.y,useFinalPosition)){items.push({element,datasetIndex,index})}if(element.inRange(position.x,position.y,useFinalPosition)){intersectsItem=true}});if(options.intersect&&!intersectsItem){return[]}return items}}};const STATIC_POSITIONS=['left','top','right','bottom'];function filterByPosition(array,position){return array.filter(v=>v.pos===position)}function filterDynamicPositionByAxis(array,axis){return array.filter(v=>STATIC_POSITIONS.indexOf(v.pos)===-1&&v.box.axis===axis)}function sortByWeight(array,reverse){return array.sort((a,b)=>{const v0=reverse?b:a;const v1=reverse?a:b;return v0.weight===v1.weight?v0.index-v1.index:v0.weight-v1.weight})}function wrapBoxes(boxes){const layoutBoxes=[];let i,ilen,box;for(i=0,ilen=(boxes||[]).length;i{margin[pos]=Math.max(chartArea[pos],maxPadding[pos])});return margin}return horizontal?marginForPositions(['left','right']):marginForPositions(['top','bottom'])}function fitBoxes(boxes,chartArea,params){const refitBoxes=[];let i,ilen,layout,box,refit,changed;for(i=0,ilen=boxes.length;i{const box=layout.box;Object.assign(box,chart.chartArea);box.update(chartArea.w,chartArea.h)})}};class BasePlatform{acquireContext(canvas,options){}releaseContext(context){return false}addEventListener(chart,type,listener){}removeEventListener(chart,type,listener){}getDevicePixelRatio(){return 1}isAttached(canvas){return true}}class BasicPlatform extends BasePlatform{acquireContext(item){return item&&item.getContext&&item.getContext('2d')||null}}const EXPANDO_KEY='$chartjs';const EVENT_TYPES={touchstart:'mousedown',touchmove:'mousemove',touchend:'mouseup',pointerenter:'mouseenter',pointerdown:'mousedown',pointermove:'mousemove',pointerup:'mouseup',pointerleave:'mouseout',pointerout:'mouseout'};const isNullOrEmpty=value=>value===null||value==='';function initCanvas(canvas,config){const style=canvas.style;const renderHeight=canvas.getAttribute('height');const renderWidth=canvas.getAttribute('width');canvas[EXPANDO_KEY]={initial:{height:renderHeight,width:renderWidth,style:{display:style.display,height:style.height,width:style.width}}};style.display=style.display||'block';style.boxSizing=style.boxSizing||'border-box';if(isNullOrEmpty(renderWidth)){const displayWidth=readUsedSize(canvas,'width');if(displayWidth!==undefined){canvas.width=displayWidth}}if(isNullOrEmpty(renderHeight)){if(canvas.style.height===''){canvas.height=canvas.width/(config.options.aspectRatio||2)}else{const displayHeight=readUsedSize(canvas,'height');if(displayHeight!==undefined){canvas.height=displayHeight}}}return canvas}const eventListenerOptions=supportsEventListenerOptions?{passive:true}:false;function addListener(node,type,listener){node.addEventListener(type,listener,eventListenerOptions)}function removeListener(chart,type,listener){chart.canvas.removeEventListener(type,listener,eventListenerOptions)}function createEvent(type,chart,x,y,nativeEvent){return{type,chart,native:nativeEvent||null,x:x!==undefined?x:null,y:y!==undefined?y:null}}function fromNativeEvent(event,chart){const type=EVENT_TYPES[event.type]||event.type;const pos=getRelativePosition$1(event,chart);return createEvent(type,chart,pos.x,pos.y,event)}function createAttachObserver(chart,type,listener){const canvas=chart.canvas;const container=canvas&&_getParentNode(canvas);const element=container||canvas;const observer=new MutationObserver(entries=>{const parent=_getParentNode(element);entries.forEach(entry=>{for(let i=0;i{entries.forEach(entry=>{for(let i=0;i{if(chart.currentDevicePixelRatio!==dpr){resize()}})}function listenDevicePixelRatioChanges(chart,resize){if(!drpListeningCharts.size){window.addEventListener('resize',onWindowResize)}drpListeningCharts.set(chart,resize)}function unlistenDevicePixelRatioChanges(chart){drpListeningCharts.delete(chart);if(!drpListeningCharts.size){window.removeEventListener('resize',onWindowResize)}}function createResizeObserver(chart,type,listener){const canvas=chart.canvas;const container=canvas&&_getParentNode(canvas);if(!container){return}const resize=throttled((width,height)=>{const w=container.clientWidth;listener(width,height);if(w{const entry=entries[0];const width=entry.contentRect.width;const height=entry.contentRect.height;if(width===0&&height===0){return}resize(width,height)});observer.observe(container);listenDevicePixelRatioChanges(chart,resize);return observer}function releaseObserver(chart,type,observer){if(observer){observer.disconnect()}if(type==='resize'){unlistenDevicePixelRatioChanges(chart)}}function createProxyAndListen(chart,type,listener){const canvas=chart.canvas;const proxy=throttled((event)=>{if(chart.ctx!==null){listener(fromNativeEvent(event,chart))}},chart);addListener(canvas,type,proxy);return proxy}class DomPlatform extends BasePlatform{acquireContext(canvas,config){const context=canvas&&canvas.getContext&&canvas.getContext('2d');if(context&&context.canvas===canvas){initCanvas(canvas,config);return context}return null}releaseContext(context){const canvas=context.canvas;if(!canvas[EXPANDO_KEY]){return false}const initial=canvas[EXPANDO_KEY].initial;['height','width'].forEach((prop)=>{const value=initial[prop];if(isNullOrUndef(value)){canvas.removeAttribute(prop)}else{canvas.setAttribute(prop,value)}});const style=initial.style||{};Object.keys(style).forEach((key)=>{canvas.style[key]=style[key]});canvas.width=canvas.width;delete canvas[EXPANDO_KEY];return true}addEventListener(chart,type,listener){this.removeEventListener(chart,type);const proxies=chart.$proxies||(chart.$proxies={});const handlers={attach:createAttachObserver,detach:createDetachObserver,resize:createResizeObserver};const handler=handlers[type]||createProxyAndListen;proxies[type]=handler(chart,type,listener)}removeEventListener(chart,type){const proxies=chart.$proxies||(chart.$proxies={});const proxy=proxies[type];if(!proxy){return}const handlers={attach:releaseObserver,detach:releaseObserver,resize:releaseObserver};const handler=handlers[type]||removeListener;handler(chart,type,proxy);proxies[type]=undefined}getDevicePixelRatio(){return window.devicePixelRatio}isAttached(canvas){const container=_getParentNode(canvas);return!!(container&&_getParentNode(container))}}class Element{constructor(){this.x=undefined;this.y=undefined;this.active=false;this.options=undefined;this.$animations=undefined}tooltipPosition(useFinalPosition){const{x,y}=this.getProps(['x','y'],useFinalPosition);return{x,y}}hasValue(){return isNumber(this.x)&&isNumber(this.y)}getProps(props,final){const me=this;const anims=this.$animations;if(!final||!anims){return me}const ret={};props.forEach(prop=>{ret[prop]=anims[prop]&&anims[prop].active?anims[prop]._to:me[prop]});return ret}}Element.defaults={};Element.defaultRoutes=undefined;const formatters={values(value){return isArray(value)?value:''+value},numeric(tickValue,index,ticks){if(tickValue===0){return '0'}const locale=this.chart.options.locale;const maxTick=Math.max(Math.abs(ticks[0].value),Math.abs(ticks[ticks.length-1].value));let notation;if(maxTick<1e-4||maxTick>1e+15){notation='scientific'}let delta=ticks.length>3?ticks[2].value-ticks[1].value:ticks[1].value-ticks[0].value;if(Math.abs(delta)>1&&tickValue!==Math.floor(tickValue)){delta=tickValue-Math.floor(tickValue)}const logDelta=log10(Math.abs(delta));const numDecimal=Math.max(Math.min(-1*Math.floor(logDelta),20),0);const options={notation,minimumFractionDigits:numDecimal,maximumFractionDigits:numDecimal};Object.assign(options,this.options.ticks.format);return new Intl.NumberFormat(locale,options).format(tickValue)}};formatters.logarithmic=function(tickValue,index,ticks){if(tickValue===0){return '0'}const remain=tickValue/(Math.pow(10,Math.floor(log10(tickValue))));if(remain===1||remain===2||remain===5){return formatters.numeric.call(this,tickValue,index,ticks)}return ''};var Ticks={formatters};defaults.set('scale',{display:true,offset:false,reverse:false,beginAtZero:false,gridLines:{display:true,color:'rgba(0,0,0,0.1)',lineWidth:1,drawBorder:true,drawOnChartArea:true,drawTicks:true,tickMarkLength:10,offsetGridLines:false,borderDash:[],borderDashOffset:0.0},scaleLabel:{display:false,labelString:'',padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:false,lineWidth:0,strokeStyle:'',padding:0,display:true,autoSkip:true,autoSkipPadding:0,labelOffset:0,callback:Ticks.formatters.values,minor:{},major:{}}});function sample(arr,numItems){const result=[];const increment=arr.length/numItems;const len=arr.length;let i=0;for(;iend+epsilon){return}}return lineValue}function garbageCollect(caches,length){each(caches,(cache)=>{const gc=cache.gc;const gcLen=gc.length/2;let i;if(gcLen>length){for(i=0;ispacing){return factor}}return Math.max(spacing,1)}function getMajorIndices(ticks){const result=[];let i,ilen;for(i=0,ilen=ticks.length;i=maxRotation||numTicks<=1||!me.isHorizontal()){me.labelRotation=minRotation;return}const labelSizes=me._getLabelSizes();const maxLabelWidth=labelSizes.widest.width;const maxLabelHeight=labelSizes.highest.height-labelSizes.highest.offset;const maxWidth=Math.min(me.maxWidth,me.chart.width-maxLabelWidth);tickWidth=options.offset?me.maxWidth/numTicks:maxWidth/(numTicks-1);if(maxLabelWidth+6>tickWidth){tickWidth=maxWidth/(numTicks-(options.offset?0.5:1));maxHeight=me.maxHeight-getTickMarkLength(options.gridLines)-tickOpts.padding-getScaleLabelHeight(options.scaleLabel,me.chart.options.font);maxLabelDiagonal=Math.sqrt(maxLabelWidth*maxLabelWidth+maxLabelHeight*maxLabelHeight);labelRotation=toDegrees(Math.min(Math.asin(Math.min((labelSizes.highest.height+6)/tickWidth,1)),Math.asin(Math.min(maxHeight/maxLabelDiagonal,1))-Math.asin(maxLabelHeight/maxLabelDiagonal)));labelRotation=Math.max(minRotation,Math.min(maxRotation,labelRotation))}me.labelRotation=labelRotation}afterCalculateLabelRotation(){callback(this.options.afterCalculateLabelRotation,[this])}beforeFit(){callback(this.options.beforeFit,[this])}fit(){const me=this;const minSize={width:0,height:0};const chart=me.chart;const opts=me.options;const tickOpts=opts.ticks;const scaleLabelOpts=opts.scaleLabel;const gridLineOpts=opts.gridLines;const display=me._isVisible();const labelsBelowTicks=opts.position!=='top'&&me.axis==='x';const isHorizontal=me.isHorizontal();const scaleLabelHeight=display&&getScaleLabelHeight(scaleLabelOpts,chart.options.font);if(isHorizontal){minSize.width=me.maxWidth}else if(display){minSize.width=getTickMarkLength(gridLineOpts)+scaleLabelHeight}if(!isHorizontal){minSize.height=me.maxHeight}else if(display){minSize.height=getTickMarkLength(gridLineOpts)+scaleLabelHeight}if(tickOpts.display&&display&&me.ticks.length){const labelSizes=me._getLabelSizes();const firstLabelSize=labelSizes.first;const lastLabelSize=labelSizes.last;const widestLabelSize=labelSizes.widest;const highestLabelSize=labelSizes.highest;const lineSpace=highestLabelSize.offset*0.8;const tickPadding=tickOpts.padding;if(isHorizontal){const isRotated=me.labelRotation!==0;const angleRadians=toRadians(me.labelRotation);const cosRotation=Math.cos(angleRadians);const sinRotation=Math.sin(angleRadians);const labelHeight=sinRotation*widestLabelSize.width+cosRotation*(highestLabelSize.height-(isRotated?highestLabelSize.offset:0))+(isRotated?0:lineSpace);minSize.height=Math.min(me.maxHeight,minSize.height+labelHeight+tickPadding);const offsetLeft=me.getPixelForTick(0)-me.left;const offsetRight=me.right-me.getPixelForTick(me.ticks.length-1);let paddingLeft,paddingRight;if(isRotated){paddingLeft=labelsBelowTicks?cosRotation*firstLabelSize.width+sinRotation*firstLabelSize.offset:sinRotation*(firstLabelSize.height-firstLabelSize.offset);paddingRight=labelsBelowTicks?sinRotation*(lastLabelSize.height-lastLabelSize.offset):cosRotation*lastLabelSize.width+sinRotation*lastLabelSize.offset}else{paddingLeft=firstLabelSize.width/2;paddingRight=lastLabelSize.width/2}me.paddingLeft=Math.max((paddingLeft-offsetLeft)*me.width/(me.width-offsetLeft),0)+3;me.paddingRight=Math.max((paddingRight-offsetRight)*me.width/(me.width-offsetRight),0)+3}else{const labelWidth=tickOpts.mirror?0:widestLabelSize.width+tickPadding+lineSpace;minSize.width=Math.min(me.maxWidth,minSize.width+labelWidth);me.paddingTop=lastLabelSize.height/2;me.paddingBottom=firstLabelSize.height/2}}me._handleMargins();if(isHorizontal){me.width=me._length=chart.width-me._margins.left-me._margins.right;me.height=minSize.height}else{me.width=minSize.width;me.height=me._length=chart.height-me._margins.top-me._margins.bottom}}_handleMargins(){const me=this;if(me._margins){me._margins.left=Math.max(me.paddingLeft,me._margins.left);me._margins.top=Math.max(me.paddingTop,me._margins.top);me._margins.right=Math.max(me.paddingRight,me._margins.right);me._margins.bottom=Math.max(me.paddingBottom,me._margins.bottom)}}afterFit(){callback(this.options.afterFit,[this])}isHorizontal(){const{axis,position}=this.options;return position==='top'||position==='bottom'||axis==='x'}isFullWidth(){return this.options.fullWidth}_convertTicksToLabels(ticks){const me=this;me.beforeTickToLabelConversion();me.generateTickLabels(ticks);me.afterTickToLabelConversion()}_getLabelSizes(){const me=this;let labelSizes=me._labelSizes;if(!labelSizes){me._labelSizes=labelSizes=me._computeLabelSizes()}return labelSizes}_computeLabelSizes(){const me=this;const ctx=me.ctx;const caches=me._longestTextCache;const sampleSize=me.options.ticks.sampleSize;const widths=[];const heights=[];const offsets=[];let ticks=me.ticks;if(sampleSizeticks.length-1){return null}return this.getPixelForValue(ticks[index].value)}getPixelForDecimal(decimal){const me=this;if(me._reversePixels){decimal=1-decimal}return me._startPixel+decimal*me._length}getDecimalForPixel(pixel){const decimal=(pixel-this._startPixel)/this._length;return this._reversePixels?1-decimal:decimal}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min,max}=this;return min<0&&max<0?max:min>0&&max>0?min:0}_autoSkip(ticks){const me=this;const tickOpts=me.options.ticks;const ticksLimit=tickOpts.maxTicksLimit||me._length/me._tickSize();const majorIndices=tickOpts.major.enabled?getMajorIndices(ticks):[];const numMajorIndices=majorIndices.length;const first=majorIndices[0];const last=majorIndices[numMajorIndices-1];const newTicks=[];if(numMajorIndices>ticksLimit){skipMajors(ticks,newTicks,majorIndices,numMajorIndices/ticksLimit);return newTicks}const spacing=calculateSpacing(majorIndices,ticks,ticksLimit);if(numMajorIndices>0){let i,ilen;const avgMajorSpacing=numMajorIndices>1?Math.round((last-first)/(numMajorIndices-1)):null;skip(ticks,newTicks,spacing,isNullOrUndef(avgMajorSpacing)?0:first-avgMajorSpacing,first);for(i=0,ilen=numMajorIndices-1;iw*sin?w/cos:h/sin:h*sin0}_computeGridLineItems(chartArea){const me=this;const axis=me.axis;const chart=me.chart;const options=me.options;const{gridLines,position}=options;const offsetGridLines=gridLines.offsetGridLines;const isHorizontal=me.isHorizontal();const ticks=me.ticks;const ticksLength=ticks.length+(offsetGridLines?1:0);const tl=getTickMarkLength(gridLines);const items=[];let context={chart,scale:me,tick:ticks[0],index:0};const axisWidth=gridLines.drawBorder?resolve([gridLines.borderWidth,gridLines.lineWidth,0],context,0):0;const axisHalfWidth=axisWidth/2;const alignBorderValue=function(pixel){return _alignPixel(chart,pixel,axisWidth)};let borderValue,i,lineValue,alignedLineValue;let tx1,ty1,tx2,ty2,x1,y1,x2,y2;if(position==='top'){borderValue=alignBorderValue(me.bottom);ty1=me.bottom-tl;ty2=borderValue-axisHalfWidth;y1=alignBorderValue(chartArea.top)+axisHalfWidth;y2=chartArea.bottom}else if(position==='bottom'){borderValue=alignBorderValue(me.top);y1=chartArea.top;y2=alignBorderValue(chartArea.bottom)-axisHalfWidth;ty1=borderValue+axisHalfWidth;ty2=me.top+tl}else if(position==='left'){borderValue=alignBorderValue(me.right);tx1=me.right-tl;tx2=borderValue-axisHalfWidth;x1=alignBorderValue(chartArea.left)+axisHalfWidth;x2=chartArea.right}else if(position==='right'){borderValue=alignBorderValue(me.left);x1=chartArea.left;x2=alignBorderValue(chartArea.right)-axisHalfWidth;tx1=borderValue+axisHalfWidth;tx2=me.left+tl}else if(axis==='x'){if(position==='center'){borderValue=alignBorderValue((chartArea.top+chartArea.bottom)/2)}else if(isObject(position)){const positionAxisID=Object.keys(position)[0];const value=position[positionAxisID];borderValue=alignBorderValue(me.chart.scales[positionAxisID].getPixelForValue(value))}y1=chartArea.top;y2=chartArea.bottom;ty1=borderValue+axisHalfWidth;ty2=ty1+tl}else if(axis==='y'){if(position==='center'){borderValue=alignBorderValue((chartArea.left+chartArea.right)/2)}else if(isObject(position)){const positionAxisID=Object.keys(position)[0];const value=position[positionAxisID];borderValue=alignBorderValue(me.chart.scales[positionAxisID].getPixelForValue(value))}tx1=borderValue-axisHalfWidth;tx2=tx1-tl;x1=chartArea.left;x2=chartArea.right}for(i=0;i0&&tickFont.strokeStyle!=='';ctx.save();ctx.translate(item.x,item.y);ctx.rotate(item.rotation);ctx.font=tickFont.string;ctx.fillStyle=tickFont.color;ctx.textBaseline='middle';ctx.textAlign=item.textAlign;if(useStroke){ctx.strokeStyle=tickFont.strokeStyle;ctx.lineWidth=tickFont.lineWidth}const label=item.label;let y=item.textOffset;if(isArray(label)){for(j=0,jlen=label.length;j{const parts=routes[property].split('.');const targetName=parts.pop();const targetScope=parts.join('.');defaults.route(scope,property,targetScope,targetName)})}function isIChartComponent(proto){return 'id'in proto&&'defaults'in proto}class Registry{constructor(){this.controllers=new TypedRegistry(DatasetController,'');this.elements=new TypedRegistry(Element,'elements');this.plugins=new TypedRegistry(Object,'plugins');this.scales=new TypedRegistry(Scale,'scales');this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...args){this._each('register',args)}remove(...args){this._each('unregister',args)}addControllers(...args){this._each('register',args,this.controllers)}addElements(...args){this._each('register',args,this.elements)}addPlugins(...args){this._each('register',args,this.plugins)}addScales(...args){this._each('register',args,this.scales)}getController(id){return this._get(id,this.controllers,'controller')}getElement(id){return this._get(id,this.elements,'element')}getPlugin(id){return this._get(id,this.plugins,'plugin')}getScale(id){return this._get(id,this.scales,'scale')}removeControllers(...args){this._each('unregister',args,this.controllers)}removeElements(...args){this._each('unregister',args,this.elements)}removePlugins(...args){this._each('unregister',args,this.plugins)}removeScales(...args){this._each('unregister',args,this.scales)}_each(method,args,typedRegistry){const me=this;[...args].forEach(arg=>{const reg=typedRegistry||me._getRegistryForType(arg);if(typedRegistry||reg.isForType(arg)||(reg===me.plugins&&arg.id)){me._exec(method,reg,arg)}else{each(arg,item=>{const itemReg=typedRegistry||me._getRegistryForType(item);me._exec(method,itemReg,item)})}})}_exec(method,registry,component){const camelMethod=_capitalize(method);callback(component['before'+camelMethod],[],component);registry[method](component);callback(component['after'+camelMethod],[],component)}_getRegistryForType(type){for(let i=0;i{const scaleConf=configScales[id];const axis=determineAxis(id,scaleConf);const defaultId=getDefaultScaleIDFromAxis(axis,chartIndexAxis);firstIDs[axis]=firstIDs[axis]||id;scales[id]=mergeIf({axis},[scaleConf,chartDefaults.scales[axis],chartDefaults.scales[defaultId]])});if(options.scale){scales[options.scale.id||'r']=mergeIf({axis:'r'},[options.scale,chartDefaults.scales.r]);firstIDs.r=firstIDs.r||options.scale.id||'r'}config.data.datasets.forEach(dataset=>{const type=dataset.type||config.type;const indexAxis=dataset.indexAxis||getIndexAxis(type,options);const datasetDefaults=defaults[type]||{};const defaultScaleOptions=datasetDefaults.scales||{};Object.keys(defaultScaleOptions).forEach(defaultID=>{const axis=getAxisFromDefaultScaleID(defaultID,indexAxis);const id=dataset[axis+'AxisID']||firstIDs[axis]||axis;scales[id]=scales[id]||{};mergeIf(scales[id],[{axis},configScales[id],defaultScaleOptions[defaultID]])})});Object.keys(scales).forEach(key=>{const scale=scales[key];mergeIf(scale,[defaults.scales[scale.type],defaults.scale])});return scales}function mergeConfig(...args){return merge({},args,{merger(key,target,source,options){if(key!=='scales'&&key!=='scale'){_merger(key,target,source,options)}}})}function initConfig(config){config=config||{};const data=config.data=config.data||{datasets:[],labels:[]};data.datasets=data.datasets||[];data.labels=data.labels||[];const scaleConfig=mergeScaleConfig(config,config.options);const options=config.options=mergeConfig(defaults,defaults[config.type],config.options||{});options.scales=scaleConfig;options.title=(options.title!==false)&&merge({},[defaults.plugins.title,options.title]);options.tooltips=(options.tooltips!==false)&&merge({},[defaults.plugins.tooltip,options.tooltips]);return config}function isAnimationDisabled(config){return!config.animation}function updateConfig(chart){let newOptions=chart.options;each(chart.scales,(scale)=>{layouts.removeBox(chart,scale)});const scaleConfig=mergeScaleConfig(chart.config,newOptions);newOptions=mergeConfig(defaults,defaults[chart.config.type],newOptions);chart.options=chart.config.options=newOptions;chart.options.scales=scaleConfig;chart._animationsDisabled=isAnimationDisabled(newOptions)}const KNOWN_POSITIONS=['top','bottom','left','right','chartArea'];function positionIsHorizontal(position,axis){return position==='top'||position==='bottom'||(KNOWN_POSITIONS.indexOf(position)===-1&&axis==='x')}function axisFromPosition(position){if(position==='top'||position==='bottom'){return 'x'}if(position==='left'||position==='right'){return 'y'}}function determineAxis(id,scaleOptions){if(id==='x'||id==='y'||id==='r'){return id}return scaleOptions.axis||axisFromPosition(scaleOptions.position)||id.charAt(0).toLowerCase()}function compare2Level(l1,l2){return function(a,b){return a[l1]===b[l1]?a[l2]-b[l2]:a[l1]-b[l1]}}function onAnimationsComplete(ctx){const chart=ctx.chart;const animationOptions=chart.options.animation;chart._plugins.notify(chart,'afterRender');callback(animationOptions&&animationOptions.onComplete,[ctx],chart)}function onAnimationProgress(ctx){const chart=ctx.chart;const animationOptions=chart.options.animation;callback(animationOptions&&animationOptions.onProgress,[ctx],chart)}function isDomSupported(){return typeof window!=='undefined'&&typeof document!=='undefined'}function getCanvas(item){if(isDomSupported()&&typeof item==='string'){item=document.getElementById(item)}else if(item.length){item=item[0]}if(item&&item.canvas){item=item.canvas}return item}function computeNewSize(canvas,width,height,aspectRatio){if(width===undefined||height===undefined){width=getMaximumWidth(canvas);height=getMaximumHeight(canvas)}width=Math.max(0,Math.floor(width));return{width,height:Math.max(0,Math.floor(aspectRatio?width/aspectRatio:height))}}class Chart{constructor(item,config){const me=this;config=initConfig(config);const initialCanvas=getCanvas(item);this.platform=me._initializePlatform(initialCanvas,config);const context=me.platform.acquireContext(initialCanvas,config);const canvas=context&&context.canvas;const height=canvas&&canvas.height;const width=canvas&&canvas.width;this.id=uid();this.ctx=context;this.canvas=canvas;this.config=config;this.width=width;this.height=height;this.aspectRatio=height?width/height:null;this.options=config.options;this._bufferedRender=false;this._layers=[];this._metasets=[];this.boxes=[];this.currentDevicePixelRatio=undefined;this.chartArea=undefined;this.data=undefined;this._active=[];this._lastEvent=undefined;this._listeners={};this._sortedMetasets=[];this._updating=false;this.scales={};this.scale=undefined;this._plugins=new PluginService();this.$proxies={};this._hiddenIndices={};this.attached=false;Chart.instances[me.id]=me;Object.defineProperty(me,'data',{get(){return me.config.data},set(value){me.config.data=value}});if(!context||!canvas){console.error("Failed to create chart: can't acquire context from the given item");return}animator.listen(me,'complete',onAnimationsComplete);animator.listen(me,'progress',onAnimationProgress);me._initialize();if(me.attached){me.update()}}_initialize(){const me=this;me._plugins.notify(me,'beforeInit');if(me.options.responsive){me.resize(true)}else{retinaScale(me,me.options.devicePixelRatio)}me.bindEvents();me._plugins.notify(me,'afterInit');return me}_initializePlatform(canvas,config){if(config.platform){return new config.platform()}else if(!isDomSupported()||(typeof OffscreenCanvas!=='undefined'&&canvas instanceof OffscreenCanvas)){return new BasicPlatform()}return new DomPlatform()}clear(){clear(this);return this}stop(){animator.stop(this);return this}resize(silent,width,height){const me=this;const options=me.options;const canvas=me.canvas;const aspectRatio=options.maintainAspectRatio&&me.aspectRatio;const newSize=computeNewSize(canvas,width,height,aspectRatio);const oldRatio=me.currentDevicePixelRatio;const newRatio=options.devicePixelRatio||me.platform.getDevicePixelRatio();if(me.width===newSize.width&&me.height===newSize.height&&oldRatio===newRatio){return}canvas.width=me.width=newSize.width;canvas.height=me.height=newSize.height;if(canvas.style){canvas.style.width=newSize.width+'px';canvas.style.height=newSize.height+'px'}retinaScale(me,newRatio);if(!silent){me._plugins.notify(me,'resize',[newSize]);callback(options.onResize,[newSize],me);if(me.attached){me.update('resize')}}}ensureScalesHaveIDs(){const options=this.options;const scalesOptions=options.scales||{};const scaleOptions=options.scale;each(scalesOptions,(axisOptions,axisID)=>{axisOptions.id=axisID});if(scaleOptions){scaleOptions.id=scaleOptions.id||'scale'}}buildOrUpdateScales(){const me=this;const options=me.options;const scaleOpts=options.scales;const scales=me.scales||{};const updated=Object.keys(scales).reduce((obj,id)=>{obj[id]=false;return obj},{});let items=[];if(scaleOpts){items=items.concat(Object.keys(scaleOpts).map((id)=>{const scaleOptions=scaleOpts[id];const axis=determineAxis(id,scaleOptions);const isRadial=axis==='r';const isHorizontal=axis==='x';return{options:scaleOptions,dposition:isRadial?'chartArea':isHorizontal?'bottom':'left',dtype:isRadial?'radialLinear':isHorizontal?'category':'linear'}}))}each(items,(item)=>{const scaleOptions=item.options;const id=scaleOptions.id;const axis=determineAxis(id,scaleOptions);const scaleType=valueOrDefault(scaleOptions.type,item.dtype);if(scaleOptions.position===undefined||positionIsHorizontal(scaleOptions.position,axis)!==positionIsHorizontal(item.dposition)){scaleOptions.position=item.dposition}updated[id]=true;let scale=null;if(id in scales&&scales[id].type===scaleType){scale=scales[id]}else{const scaleClass=registry.getScale(scaleType);scale=new scaleClass({id,type:scaleType,ctx:me.ctx,chart:me});scales[scale.id]=scale}scale.init(scaleOptions,options);if(item.isDefault){me.scale=scale}});each(updated,(hasUpdated,id)=>{if(!hasUpdated){delete scales[id]}});me.scales=scales;each(scales,(scale)=>{scale.fullWidth=scale.options.fullWidth;scale.position=scale.options.position;scale.weight=scale.options.weight;layouts.addBox(me,scale)})}_updateMetasetIndex(meta,index){const metasets=this._metasets;const oldIndex=meta.index;if(oldIndex!==index){metasets[oldIndex]=metasets[index];metasets[index]=meta;meta.index=index}}_updateMetasets(){const me=this;const metasets=me._metasets;const numData=me.data.datasets.length;const numMeta=metasets.length;if(numMeta>numData){for(let i=numData;i{me.getDatasetMeta(datasetIndex).controller.reset()},me)}reset(){this._resetElements();this._plugins.notify(this,'reset')}update(mode){const me=this;let i,ilen;me._updating=true;updateConfig(me);me.ensureScalesHaveIDs();me.buildOrUpdateScales();me._plugins.invalidate();if(me._plugins.notify(me,'beforeUpdate')===false){return}const newControllers=me.buildOrUpdateControllers();for(i=0,ilen=me.data.datasets.length;i{controller.reset()});me._updateDatasets(mode);me._plugins.notify(me,'afterUpdate');me._layers.sort(compare2Level('z','_idx'));if(me._lastEvent){me._eventHandler(me._lastEvent,true)}me.render();me._updating=false}_updateLayout(){const me=this;if(me._plugins.notify(me,'beforeLayout')===false){return}layouts.update(me,me.width,me.height);me._layers=[];each(me.boxes,(box)=>{if(box.configure){box.configure()}me._layers.push(...box._layers())},me);me._layers.forEach((item,index)=>{item._idx=index});me._plugins.notify(me,'afterLayout')}_updateDatasets(mode){const me=this;const isFunction=typeof mode==='function';if(me._plugins.notify(me,'beforeDatasetsUpdate')===false){return}for(let i=0,ilen=me.data.datasets.length;i=0;i-=1){me._drawDataset(metasets[i])}me._plugins.notify(me,'afterDatasetsDraw')}_drawDataset(meta){const me=this;const ctx=me.ctx;const clip=meta._clip;const area=me.chartArea;const args={meta,index:meta.index};if(me._plugins.notify(me,'beforeDatasetDraw',[args])===false){return}clipArea(ctx,{left:clip.left===false?0:area.left-clip.left,right:clip.right===false?me.width:area.right+clip.right,top:clip.top===false?0:area.top-clip.top,bottom:clip.bottom===false?me.height:area.bottom+clip.bottom});meta.controller.draw();unclipArea(ctx);me._plugins.notify(me,'afterDatasetDraw',[args])}getElementAtEvent(e){return Interaction.modes.nearest(this,e,{intersect:true})}getElementsAtEvent(e){return Interaction.modes.index(this,e,{intersect:true})}getElementsAtXAxis(e){return Interaction.modes.index(this,e,{intersect:false})}getElementsAtEventForMode(e,mode,options,useFinalPosition){const method=Interaction.modes[mode];if(typeof method==='function'){return method(this,e,options,useFinalPosition)}return[]}getDatasetAtEvent(e){return Interaction.modes.dataset(this,e,{intersect:true})}getDatasetMeta(datasetIndex){const me=this;const dataset=me.data.datasets[datasetIndex];const metasets=me._metasets;let meta=metasets.filter(x=>x._dataset===dataset).pop();if(!meta){meta=metasets[datasetIndex]={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:dataset.order||0,index:datasetIndex,_dataset:dataset,_parsed:[],_sorted:false}}return meta}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(datasetIndex){const meta=this.getDatasetMeta(datasetIndex);return typeof meta.hidden==='boolean'?!meta.hidden:!this.data.datasets[datasetIndex].hidden}setDatasetVisibility(datasetIndex,visible){const meta=this.getDatasetMeta(datasetIndex);meta.hidden=!visible}toggleDataVisibility(index){this._hiddenIndices[index]=!this._hiddenIndices[index]}getDataVisibility(index){return!this._hiddenIndices[index]}_updateDatasetVisibility(datasetIndex,visible){const me=this;const mode=visible?'show':'hide';const meta=me.getDatasetMeta(datasetIndex);const anims=meta.controller._resolveAnimations(undefined,mode);me.setDatasetVisibility(datasetIndex,visible);anims.update(meta,{visible});me.update((ctx)=>ctx.datasetIndex===datasetIndex?mode:undefined)}hide(datasetIndex){this._updateDatasetVisibility(datasetIndex,false)}show(datasetIndex){this._updateDatasetVisibility(datasetIndex,true)}_destroyDatasetMeta(datasetIndex){const me=this;const meta=me._metasets&&me._metasets[datasetIndex];if(meta){meta.controller._destroy();delete me._metasets[datasetIndex]}}destroy(){const me=this;const canvas=me.canvas;let i,ilen;me.stop();animator.remove(me);for(i=0,ilen=me.data.datasets.length;i{platform.addEventListener(me,type,listener);listeners[type]=listener};const _remove=(type,listener)=>{if(listeners[type]){platform.removeEventListener(me,type,listener);delete listeners[type]}};let listener=function(e){me._eventHandler(e)};each(me.options.events,(type)=>_add(type,listener));if(me.options.responsive){listener=(width,height)=>{if(me.canvas){me.resize(false,width,height)}};let detached;const attached=()=>{_remove('attach',attached);me.resize();me.attached=true;_add('resize',listener);_add('detach',detached)};detached=()=>{me.attached=false;_remove('resize',listener);_add('attach',attached)};if(platform.isAttached(me.canvas)){attached()}else{detached()}}else{me.attached=true}}unbindEvents(){const me=this;const listeners=me._listeners;if(!listeners){return}delete me._listeners;each(listeners,(listener,type)=>{me.platform.removeEventListener(me,type,listener)})}updateHoverStyle(items,mode,enabled){const prefix=enabled?'set':'remove';let meta,item,i,ilen;if(mode==='dataset'){meta=this.getDatasetMeta(items[0].datasetIndex);meta.controller['_'+prefix+'DatasetHoverStyle']()}for(i=0,ilen=items.length;ieach(Chart.instances,(chart)=>chart._plugins.invalidate());Chart.register=(...items)=>{registry.add(...items);invalidatePlugins()};Chart.unregister=(...items)=>{registry.remove(...items);invalidatePlugins()};const TAU=Math.PI*2;function clipArc(ctx,element){const{startAngle,endAngle,pixelMargin,x,y,outerRadius,innerRadius}=element;let angleMargin=pixelMargin/outerRadius;ctx.beginPath();ctx.arc(x,y,outerRadius,startAngle-angleMargin,endAngle+angleMargin);if(innerRadius>pixelMargin){angleMargin=pixelMargin/innerRadius;ctx.arc(x,y,innerRadius,endAngle+angleMargin,startAngle-angleMargin,true)}else{ctx.arc(x,y,pixelMargin,endAngle+Math.PI/2,startAngle-Math.PI/2)}ctx.closePath();ctx.clip()}function pathArc(ctx,element){const{x,y,startAngle,endAngle,pixelMargin}=element;const outerRadius=Math.max(element.outerRadius-pixelMargin,0);const innerRadius=element.innerRadius+pixelMargin;ctx.beginPath();ctx.arc(x,y,outerRadius,startAngle,endAngle);ctx.arc(x,y,innerRadius,endAngle,startAngle,true);ctx.closePath()}function drawArc(ctx,element){if(element.fullCircles){element.endAngle=element.startAngle+TAU;pathArc(ctx,element);for(let i=0;i=TAU||_angleBetween(angle,startAngle,endAngle);const withinRadius=(distance>=innerRadius&&distance<=outerRadius);return(betweenAngles&&withinRadius)}getCenterPoint(useFinalPosition){const{x,y,startAngle,endAngle,innerRadius,outerRadius}=this.getProps(['x','y','startAngle','endAngle','innerRadius','outerRadius'],useFinalPosition);const halfAngle=(startAngle+endAngle)/2;const halfRadius=(innerRadius+outerRadius)/2;return{x:x+Math.cos(halfAngle)*halfRadius,y:y+Math.sin(halfAngle)*halfRadius}}tooltipPosition(useFinalPosition){return this.getCenterPoint(useFinalPosition)}draw(ctx){const me=this;const options=me.options;const offset=options.offset||0;me.pixelMargin=(options.borderAlign==='inner')?0.33:0;me.fullCircles=Math.floor(me.circumference/TAU);if(me.circumference===0){return}ctx.save();if(offset&&me.circumference(start+(reverse?ilen-index:index))%count;const drawX=()=>{if(minY!==maxY){ctx.lineTo(avgX,maxY);ctx.lineTo(avgX,minY);ctx.lineTo(avgX,lastY)}};if(move){point=points[pointIndex(0)];ctx.moveTo(point.x,point.y)}for(i=0;i<=ilen;i+=1){point=points[pointIndex(i)];if(point.skip){continue}const x=point.x;const y=point.y;const truncX=x|0;if(truncX===prevX){if(ymaxY){maxY=y}avgX=(countX*avgX+x)/ ++countX}else{drawX();ctx.lineTo(x,y);prevX=truncX;countX=0;minY=maxY=y}lastY=y}drawX()}function _getSegmentMethod(line){const opts=line.options;const borderDash=opts.borderDash&&opts.borderDash.length;const useFastPath=!line._loop&&!opts.tension&&!opts.stepped&&!borderDash;return useFastPath?fastPathSegment:pathSegment}function _getInterpolationMethod(options){if(options.stepped){return _steppedInterpolation}if(options.tension){return _bezierInterpolation}return _pointInLine}class Line extends Element{constructor(cfg){super();this.options=undefined;this._loop=undefined;this._fullLoop=undefined;this._points=undefined;this._segments=undefined;this._pointsUpdated=false;if(cfg){Object.assign(this,cfg)}}updateControlPoints(chartArea){const me=this;const options=me.options;if(options.tension&&!options.stepped&&!me._pointsUpdated){const loop=options.spanGaps?me._loop:me._fullLoop;_updateBezierControlPoints(me._points,options,chartArea,loop);me._pointsUpdated=true}}set points(points){this._points=points;delete this._segments}get points(){return this._points}get segments(){return this._segments||(this._segments=_computeSegments(this))}first(){const segments=this.segments;const points=this.points;return segments.length&&points[segments[0].start]}last(){const segments=this.segments;const points=this.points;const count=segments.length;return count&&points[segments[count-1].end]}interpolate(point,property){const me=this;const options=me.options;const value=point[property];const points=me.points;const segments=_boundSegments(me,{property,start:value,end:value});if(!segments.length){return}const result=[];const _interpolate=_getInterpolationMethod(options);let i,ilen;for(i=0,ilen=segments.length;ibar.x):parseEdge(edge,'bottom','top',bar.base=bounds.left&&x<=bounds.right)&&(skipY||y>=bounds.top&&y<=bounds.bottom)}class Rectangle extends Element{constructor(cfg){super();this.options=undefined;this.horizontal=undefined;this.base=undefined;this.width=undefined;this.height=undefined;if(cfg){Object.assign(this,cfg)}}draw(ctx){const options=this.options;const{inner,outer}=boundingRects(this);ctx.save();if(outer.w!==inner.w||outer.h!==inner.h){ctx.beginPath();ctx.rect(outer.x,outer.y,outer.w,outer.h);ctx.clip();ctx.rect(inner.x,inner.y,inner.w,inner.h);ctx.fillStyle=options.borderColor;ctx.fill('evenodd')}ctx.fillStyle=options.backgroundColor;ctx.fillRect(inner.x,inner.y,inner.w,inner.h);ctx.restore()}inRange(mouseX,mouseY,useFinalPosition){return inRange(this,mouseX,mouseY,useFinalPosition)}inXRange(mouseX,useFinalPosition){return inRange(this,mouseX,null,useFinalPosition)}inYRange(mouseY,useFinalPosition){return inRange(this,null,mouseY,useFinalPosition)}getCenterPoint(useFinalPosition){const{x,y,base,horizontal}=this.getProps(['x','y','base','horizontal'],useFinalPosition);return{x:horizontal?(x+base)/2:x,y:horizontal?y:(y+base)/2}}getRange(axis){return axis==='x'?this.width/2:this.height/2}}Rectangle.id='rectangle';Rectangle.defaults={borderSkipped:'start',borderWidth:0};Rectangle.defaultRoutes={backgroundColor:'color',borderColor:'color'};function getLineByIndex(chart,index){const meta=chart.getDatasetMeta(index);const visible=meta&&chart.isDatasetVisible(index);return visible?meta.dataset:null}function parseFillOption(line){const options=line.options;const fillOption=options.fill;let fill=valueOrDefault(fillOption&&fillOption.target,fillOption);if(fill===undefined){fill=!!options.backgroundColor}if(fill===false||fill===null){return false}if(fill===true){return 'origin'}return fill}function decodeFill(line,index,count){const fill=parseFillOption(line);let target=parseFloat(fill);if(isNumberFinite(target)&&Math.floor(target)===target){if(fill[0]==='-'||fill[0]==='+'){target=index+target}if(target===index||target<0||target>=count){return false}return target}return['origin','start','end','stack'].indexOf(fill)>=0&&fill}function computeLinearBoundary(source){const{scale={},fill}=source;let target=null;let horizontal;if(fill==='start'){target=scale.bottom}else if(fill==='end'){target=scale.top}else if(scale.getBasePixel){target=scale.getBasePixel()}if(isNumberFinite(target)){horizontal=scale.isHorizontal();return{x:horizontal?target:null,y:horizontal?null:target}}return null}class simpleArc{constructor(opts){this.x=opts.x;this.y=opts.y;this.radius=opts.radius}pathSegment(ctx,bounds,opts){const{x,y,radius}=this;bounds=bounds||{start:0,end:Math.PI*2};if(opts.reverse){ctx.arc(x,y,radius,bounds.end,bounds.start,true)}else{ctx.arc(x,y,radius,bounds.start,bounds.end)}return!opts.bounds}interpolate(point,property){const{x,y,radius}=this;const angle=point.angle;if(property==='angle'){return{x:x+Math.cos(angle)*radius,y:y+Math.sin(angle)*radius,angle}}}}function computeCircularBoundary(source){const{scale,fill}=source;const options=scale.options;const length=scale.getLabels().length;const target=[];const start=options.reverse?scale.max:scale.min;const end=options.reverse?scale.min:scale.max;const value=fill==='start'?start:fill==='end'?end:scale.getBaseValue();let i,center;if(options.gridLines.circular){center=scale.getPointPositionForValue(0,start);return new simpleArc({x:center.x,y:center.y,radius:scale.getDistanceFromCenterForValue(value)})}for(i=0;i{const first=linePoints[segment.start];const last=linePoints[segment.end];if(y!==null){points.push({x:first.x,y});points.push({x:last.x,y})}else if(x!==null){points.push({x,y:first.y});points.push({x,y:last.y})}});return points}function buildStackLine(source){const{chart,scale,index,line}=source;const points=[];const segments=line.segments;const sourcePoints=line.points;const linesBelow=getLinesBelow(chart,index);linesBelow.push(createBoundaryLine({x:null,y:scale.bottom},line));for(let i=0;imeta.type==='line'&&!meta.hidden;function getLinesBelow(chart,index){const below=[];const metas=chart.getSortedVisibleDatasetMetas();for(let i=0;i=firstValue&&pointValue<=lastValue){first=pointValue===firstValue;last=pointValue===lastValue;break}}return{first,last,point}}function getTarget(source){const{chart,fill,line}=source;if(isNumberFinite(fill)){return getLineByIndex(chart,fill)}if(fill==='stack'){return buildStackLine(source)}const boundary=computeBoundary(source);if(boundary instanceof simpleArc){return boundary}return createBoundaryLine(boundary,line)}function createBoundaryLine(boundary,line){let points=[];let _loop=false;if(isArray(boundary)){_loop=true;points=boundary}else{points=pointsFromSegments(boundary,line)}return points.length?new Line({points,options:{tension:0},_loop,_fullLoop:_loop}):null}function resolveTarget(sources,index,propagate){const source=sources[index];let fill=source.fill;const visited=[index];let target;if(!propagate){return fill}while(fill!==false&&visited.indexOf(fill)===-1){if(!isNumberFinite(fill)){return fill}target=sources[fill];if(!target){return false}if(target.visible){return fill}visited.push(fill);fill=target.fill}return false}function _clip(ctx,target,clipY){ctx.beginPath();target.path(ctx);ctx.lineTo(target.last().x,clipY);ctx.lineTo(target.first().x,clipY);ctx.closePath();ctx.clip()}function getBounds(property,first,last,loop){if(loop){return}let start=first[property];let end=last[property];if(property==='angle'){start=_normalizeAngle(start);end=_normalizeAngle(end)}return{property,start,end}}function _getEdge(a,b,prop,fn){if(a&&b){return fn(a[prop],b[prop])}return a?a[prop]:b?b[prop]:0}function _segments(line,target,property){const segments=line.segments;const points=line.points;const tpoints=target.points;const parts=[];for(let i=0;i=0;i-=1){meta=metasets[i].$filler;if(meta){meta.line.updateControlPoints(area)}}},beforeDatasetDraw(chart,args){const area=chart.chartArea;const ctx=chart.ctx;const source=args.meta.$filler;if(!source||source.fill===false){return}const target=getTarget(source);const{line,scale}=source;const lineOpts=line.options;const fillOption=lineOpts.fill;const color=lineOpts.backgroundColor;const{above=color,below=color}=fillOption||{};if(target&&line.points.length){clipArea(ctx,area);doFill(ctx,{line,target,above,below,area,scale});unclipArea(ctx)}},defaults:{propagate:true}};function getBoxWidth(labelOpts,fontSize){const{boxWidth}=labelOpts;return(labelOpts.usePointStyle&&boxWidth>fontSize)||isNullOrUndef(boxWidth)?fontSize:boxWidth}function getBoxHeight(labelOpts,fontSize){const{boxHeight}=labelOpts;return(labelOpts.usePointStyle&&boxHeight>fontSize)||isNullOrUndef(boxHeight)?fontSize:boxHeight}class Legend extends Element{constructor(config){super();Object.assign(this,config);this.legendHitBoxes=[];this._hoveredItem=null;this.doughnutMode=false;this.chart=config.chart;this.options=config.options;this.ctx=config.ctx;this.legendItems=undefined;this.columnWidths=undefined;this.columnHeights=undefined;this.lineWidths=undefined;this._minSize=undefined;this.maxHeight=undefined;this.maxWidth=undefined;this.top=undefined;this.bottom=undefined;this.left=undefined;this.right=undefined;this.height=undefined;this.width=undefined;this._margins=undefined;this.paddingTop=undefined;this.paddingBottom=undefined;this.paddingLeft=undefined;this.paddingRight=undefined;this.position=undefined;this.weight=undefined;this.fullWidth=undefined}beforeUpdate(){}update(maxWidth,maxHeight,margins){const me=this;me.beforeUpdate();me.maxWidth=maxWidth;me.maxHeight=maxHeight;me._margins=margins;me.beforeSetDimensions();me.setDimensions();me.afterSetDimensions();me.beforeBuildLabels();me.buildLabels();me.afterBuildLabels();me.beforeFit();me.fit();me.afterFit();me.afterUpdate()}afterUpdate(){}beforeSetDimensions(){}setDimensions(){const me=this;if(me.isHorizontal()){me.width=me.maxWidth;me.left=0;me.right=me.width}else{me.height=me.maxHeight;me.top=0;me.bottom=me.height}me.paddingLeft=0;me.paddingTop=0;me.paddingRight=0;me.paddingBottom=0;me._minSize={width:0,height:0}}afterSetDimensions(){}beforeBuildLabels(){}buildLabels(){const me=this;const labelOpts=me.options.labels||{};let legendItems=callback(labelOpts.generateLabels,[me.chart],me)||[];if(labelOpts.filter){legendItems=legendItems.filter((item)=>labelOpts.filter(item,me.chart.data))}if(me.options.reverse){legendItems.reverse()}me.legendItems=legendItems}afterBuildLabels(){}beforeFit(){}fit(){const me=this;const opts=me.options;const labelOpts=opts.labels;const display=opts.display;const ctx=me.ctx;const labelFont=toFont(labelOpts.font,me.chart.options.font);const fontSize=labelFont.size;const boxWidth=getBoxWidth(labelOpts,fontSize);const boxHeight=getBoxHeight(labelOpts,fontSize);const itemHeight=Math.max(boxHeight,fontSize);const hitboxes=me.legendHitBoxes=[];const minSize=me._minSize;const isHorizontal=me.isHorizontal();const titleHeight=me._computeTitleHeight();if(isHorizontal){minSize.width=me.maxWidth;minSize.height=display?10:0}else{minSize.width=display?10:0;minSize.height=me.maxHeight}if(!display){me.width=minSize.width=me.height=minSize.height=0;return}ctx.font=labelFont.string;if(isHorizontal){const lineWidths=me.lineWidths=[0];let totalHeight=titleHeight;ctx.textAlign='left';ctx.textBaseline='middle';me.legendItems.forEach((legendItem,i)=>{const width=boxWidth+(fontSize/2)+ctx.measureText(legendItem.text).width;if(i===0||lineWidths[lineWidths.length-1]+width+2*labelOpts.padding>minSize.width){totalHeight+=itemHeight+labelOpts.padding;lineWidths[lineWidths.length-(i>0?0:1)]=0}hitboxes[i]={left:0,top:0,width,height:itemHeight};lineWidths[lineWidths.length-1]+=width+labelOpts.padding});minSize.height+=totalHeight}else{const vPadding=labelOpts.padding;const columnWidths=me.columnWidths=[];const columnHeights=me.columnHeights=[];let totalWidth=labelOpts.padding;let currentColWidth=0;let currentColHeight=0;const heightLimit=minSize.height-titleHeight;me.legendItems.forEach((legendItem,i)=>{const itemWidth=boxWidth+(fontSize/2)+ctx.measureText(legendItem.text).width;if(i>0&¤tColHeight+fontSize+2*vPadding>heightLimit){totalWidth+=currentColWidth+labelOpts.padding;columnWidths.push(currentColWidth);columnHeights.push(currentColHeight);currentColWidth=0;currentColHeight=0}currentColWidth=Math.max(currentColWidth,itemWidth);currentColHeight+=fontSize+vPadding;hitboxes[i]={left:0,top:0,width:itemWidth,height:itemHeight}});totalWidth+=currentColWidth;columnWidths.push(currentColWidth);columnHeights.push(currentColHeight);minSize.width+=totalWidth}me.width=minSize.width;me.height=minSize.height}afterFit(){}isHorizontal(){return this.options.position==='top'||this.options.position==='bottom'}draw(){const me=this;const opts=me.options;const labelOpts=opts.labels;const defaultColor=defaults.color;const legendHeight=me.height;const columnHeights=me.columnHeights;const legendWidth=me.width;const lineWidths=me.lineWidths;if(!opts.display){return}me.drawTitle();const rtlHelper=getRtlAdapter(opts.rtl,me.left,me._minSize.width);const ctx=me.ctx;const labelFont=toFont(labelOpts.font,me.chart.options.font);const fontColor=labelFont.color;const fontSize=labelFont.size;let cursor;ctx.textAlign=rtlHelper.textAlign('left');ctx.textBaseline='middle';ctx.lineWidth=0.5;ctx.strokeStyle=fontColor;ctx.fillStyle=fontColor;ctx.font=labelFont.string;const boxWidth=getBoxWidth(labelOpts,fontSize);const boxHeight=getBoxHeight(labelOpts,fontSize);const height=Math.max(fontSize,boxHeight);const hitboxes=me.legendHitBoxes;const drawLegendBox=function(x,y,legendItem){if(isNaN(boxWidth)||boxWidth<=0||isNaN(boxHeight)||boxHeight<0){return}ctx.save();const lineWidth=valueOrDefault(legendItem.lineWidth,1);ctx.fillStyle=valueOrDefault(legendItem.fillStyle,defaultColor);ctx.lineCap=valueOrDefault(legendItem.lineCap,'butt');ctx.lineDashOffset=valueOrDefault(legendItem.lineDashOffset,0);ctx.lineJoin=valueOrDefault(legendItem.lineJoin,'miter');ctx.lineWidth=lineWidth;ctx.strokeStyle=valueOrDefault(legendItem.strokeStyle,defaultColor);if(ctx.setLineDash){ctx.setLineDash(valueOrDefault(legendItem.lineDash,[]))}if(labelOpts&&labelOpts.usePointStyle){const drawOptions={radius:boxWidth*Math.SQRT2/2,pointStyle:legendItem.pointStyle,rotation:legendItem.rotation,borderWidth:lineWidth};const centerX=rtlHelper.xPlus(x,boxWidth/2);const centerY=y+fontSize/2;drawPoint(ctx,drawOptions,centerX,centerY)}else{const yBoxTop=y+Math.max((fontSize-boxHeight)/2,0);ctx.fillRect(rtlHelper.leftForLtr(x,boxWidth),yBoxTop,boxWidth,boxHeight);if(lineWidth!==0){ctx.strokeRect(rtlHelper.leftForLtr(x,boxWidth),yBoxTop,boxWidth,boxHeight)}}ctx.restore()};const fillText=function(x,y,legendItem,textWidth){const halfFontSize=fontSize/2;const xLeft=rtlHelper.xPlus(x,boxWidth+halfFontSize);const yMiddle=y+(height/2);ctx.fillText(legendItem.text,xLeft,yMiddle);if(legendItem.hidden){ctx.beginPath();ctx.lineWidth=2;ctx.moveTo(xLeft,yMiddle);ctx.lineTo(rtlHelper.xPlus(xLeft,textWidth),yMiddle);ctx.stroke()}};const alignmentOffset=function(dimension,blockSize){switch(opts.align){case 'start':return labelOpts.padding;case 'end':return dimension-blockSize;default:return(dimension-blockSize+labelOpts.padding)/2}};const isHorizontal=me.isHorizontal();const titleHeight=this._computeTitleHeight();if(isHorizontal){cursor={x:me.left+alignmentOffset(legendWidth,lineWidths[0]),y:me.top+labelOpts.padding+titleHeight,line:0}}else{cursor={x:me.left+labelOpts.padding,y:me.top+alignmentOffset(legendHeight,columnHeights[0])+titleHeight,line:0}}overrideTextDirection(me.ctx,opts.textDirection);const itemHeight=height+labelOpts.padding;me.legendItems.forEach((legendItem,i)=>{const textWidth=ctx.measureText(legendItem.text).width;const width=boxWidth+(fontSize/2)+textWidth;let x=cursor.x;let y=cursor.y;rtlHelper.setWidth(me._minSize.width);if(isHorizontal){if(i>0&&x+width+labelOpts.padding>me.left+me._minSize.width){y=cursor.y+=itemHeight;cursor.line+=1;x=cursor.x=me.left+alignmentOffset(legendWidth,lineWidths[cursor.line])}}else if(i>0&&y+itemHeight>me.top+me._minSize.height){x=cursor.x=x+me.columnWidths[cursor.line]+labelOpts.padding;cursor.line+=1;y=cursor.y=me.top+alignmentOffset(legendHeight,columnHeights[cursor.line])}const realX=rtlHelper.x(x);drawLegendBox(realX,y,legendItem);hitboxes[i].left=rtlHelper.leftForLtr(realX,hitboxes[i].width);hitboxes[i].top=y;fillText(realX,y,legendItem,textWidth);if(isHorizontal){cursor.x+=width+labelOpts.padding}else{cursor.y+=itemHeight}});restoreTextDirection(me.ctx,opts.textDirection)}drawTitle(){const me=this;const opts=me.options;const titleOpts=opts.title;const titleFont=toFont(titleOpts.font,me.chart.options.font);const titlePadding=toPadding(titleOpts.padding);if(!titleOpts.display){return}const rtlHelper=getRtlAdapter(opts.rtl,me.left,me._minSize.width);const ctx=me.ctx;const position=titleOpts.position;let x,textAlign;const halfFontSize=titleFont.size/2;let y=me.top+titlePadding.top+halfFontSize;let left=me.left;let maxWidth=me.width;if(this.isHorizontal()){maxWidth=Math.max(...me.lineWidths);switch(opts.align){case 'start':break;case 'end':left=me.right-maxWidth;break;default:left=((me.left+me.right)/2)-(maxWidth/2);break}}else{const maxHeight=Math.max(...me.columnHeights);switch(opts.align){case 'start':break;case 'end':y+=me.height-maxHeight;break;default:y+=(me.height-maxHeight)/2;break}}switch(position){case 'start':x=left;textAlign='left';break;case 'end':x=left+maxWidth;textAlign='right';break;default:x=left+(maxWidth/2);textAlign='center';break}ctx.textAlign=rtlHelper.textAlign(textAlign);ctx.textBaseline='middle';ctx.strokeStyle=titleFont.color;ctx.fillStyle=titleFont.color;ctx.font=titleFont.string;ctx.fillText(titleOpts.text,x,y)}_computeTitleHeight(){const titleOpts=this.options.title;const titleFont=toFont(titleOpts.font,this.chart.options.font);const titlePadding=toPadding(titleOpts.padding);return titleOpts.display?titleFont.lineHeight+titlePadding.height:0}_getLegendItemAt(x,y){const me=this;let i,hitBox,lh;if(x>=me.left&&x<=me.right&&y>=me.top&&y<=me.bottom){lh=me.legendHitBoxes;for(i=0;i=hitBox.left&&x<=hitBox.left+hitBox.width&&y>=hitBox.top&&y<=hitBox.top+hitBox.height){return me.legendItems[i]}}}return null}handleEvent(e){const me=this;const opts=me.options;const type=e.type==='mouseup'?'click':e.type;if(type==='mousemove'){if(!opts.onHover&&!opts.onLeave){return}}else if(type==='click'){if(!opts.onClick){return}}else{return}const hoveredItem=me._getLegendItemAt(e.x,e.y);if(type==='click'){if(hoveredItem){callback(opts.onClick,[e,hoveredItem,me],me)}}else{if(opts.onLeave&&hoveredItem!==me._hoveredItem){if(me._hoveredItem){callback(opts.onLeave,[e,me._hoveredItem,me],me)}me._hoveredItem=hoveredItem}if(hoveredItem){callback(opts.onHover,[e,hoveredItem,me],me)}}}}function resolveOptions(options){return options!==false&&merge({},[defaults.plugins.legend,options])}function createNewLegendAndAttach(chart,legendOpts){const legend=new Legend({ctx:chart.ctx,options:legendOpts,chart});layouts.configure(chart,legend,legendOpts);layouts.addBox(chart,legend);chart.legend=legend}var plugin_legend={id:'legend',_element:Legend,beforeInit(chart){const legendOpts=resolveOptions(chart.options.legend);if(legendOpts){createNewLegendAndAttach(chart,legendOpts)}},beforeUpdate(chart){const legendOpts=resolveOptions(chart.options.legend);const legend=chart.legend;if(legendOpts){if(legend){layouts.configure(chart,legend,legendOpts);legend.options=legendOpts}else{createNewLegendAndAttach(chart,legendOpts)}}else if(legend){layouts.removeBox(chart,legend);delete chart.legend}},afterUpdate(chart){if(chart.legend){chart.legend.buildLabels()}},afterEvent(chart,e){const legend=chart.legend;if(legend){legend.handleEvent(e)}},defaults:{display:true,position:'top',align:'center',fullWidth:true,reverse:false,weight:1000,onClick(e,legendItem,legend){const index=legendItem.datasetIndex;const ci=legend.chart;if(ci.isDatasetVisible(index)){ci.hide(index);legendItem.hidden=true}else{ci.show(index);legendItem.hidden=false}},onHover:null,onLeave:null,labels:{boxWidth:40,padding:10,generateLabels(chart){const datasets=chart.data.datasets;const options=chart.options.legend||{};const usePointStyle=options.labels&&options.labels.usePointStyle;return chart._getSortedDatasetMetas().map((meta)=>{const style=meta.controller.getStyle(usePointStyle?0:undefined);return{text:datasets[meta.index].label,fillStyle:style.backgroundColor,hidden:!meta.visible,lineCap:style.borderCapStyle,lineDash:style.borderDash,lineDashOffset:style.borderDashOffset,lineJoin:style.borderJoinStyle,lineWidth:style.borderWidth,strokeStyle:style.borderColor,pointStyle:style.pointStyle,rotation:style.rotation,datasetIndex:meta.index}},this)}},title:{display:false,position:'center',text:''}}};class Title extends Element{constructor(config){super();Object.assign(this,config);this.chart=config.chart;this.options=config.options;this.ctx=config.ctx;this._margins=undefined;this._padding=undefined;this.top=undefined;this.bottom=undefined;this.left=undefined;this.right=undefined;this.width=undefined;this.height=undefined;this.maxWidth=undefined;this.maxHeight=undefined;this.position=undefined;this.weight=undefined;this.fullWidth=undefined}beforeUpdate(){}update(maxWidth,maxHeight,margins){const me=this;me.beforeUpdate();me.maxWidth=maxWidth;me.maxHeight=maxHeight;me._margins=margins;me.beforeSetDimensions();me.setDimensions();me.afterSetDimensions();me.beforeBuildLabels();me.buildLabels();me.afterBuildLabels();me.beforeFit();me.fit();me.afterFit();me.afterUpdate()}afterUpdate(){}beforeSetDimensions(){}setDimensions(){const me=this;if(me.isHorizontal()){me.width=me.maxWidth;me.left=0;me.right=me.width}else{me.height=me.maxHeight;me.top=0;me.bottom=me.height}}afterSetDimensions(){}beforeBuildLabels(){}buildLabels(){}afterBuildLabels(){}beforeFit(){}fit(){const me=this;const opts=me.options;const minSize={};const isHorizontal=me.isHorizontal();if(!opts.display){me.width=minSize.width=me.height=minSize.height=0;return}const lineCount=isArray(opts.text)?opts.text.length:1;me._padding=toPadding(opts.padding);const textSize=lineCount*toFont(opts.font,me.chart.options.font).lineHeight+me._padding.height;me.width=minSize.width=isHorizontal?me.maxWidth:textSize;me.height=minSize.height=isHorizontal?textSize:me.maxHeight}afterFit(){}isHorizontal(){const pos=this.options.position;return pos==='top'||pos==='bottom'}draw(){const me=this;const ctx=me.ctx;const opts=me.options;if(!opts.display){return}const fontOpts=toFont(opts.font,me.chart.options.font);const lineHeight=fontOpts.lineHeight;const offset=lineHeight/2+me._padding.top;let rotation=0;const top=me.top;const left=me.left;const bottom=me.bottom;const right=me.right;let maxWidth,titleX,titleY;let align;if(me.isHorizontal()){switch(opts.align){case 'start':titleX=left;align='left';break;case 'end':titleX=right;align='right';break;default:titleX=left+((right-left)/2);align='center';break}titleY=top+offset;maxWidth=right-left}else{titleX=opts.position==='left'?left+offset:right-offset;switch(opts.align){case 'start':titleY=opts.position==='left'?bottom:top;align='left';break;case 'end':titleY=opts.position==='left'?top:bottom;align='right';break;default:titleY=top+((bottom-top)/2);align='center';break}maxWidth=bottom-top;rotation=Math.PI*(opts.position==='left'?-0.5:0.5)}ctx.save();ctx.fillStyle=fontOpts.color;ctx.font=fontOpts.string;ctx.translate(titleX,titleY);ctx.rotate(rotation);ctx.textAlign=align;ctx.textBaseline='middle';const text=opts.text;if(isArray(text)){let y=0;for(let i=0;i-1){return str.split('\n')}return str}function createTooltipItem(chart,item){const{element,datasetIndex,index}=item;const controller=chart.getDatasetMeta(datasetIndex).controller;const{label,value}=controller.getLabelAndValue(index);return{chart,label,dataPoint:controller.getParsed(index),formattedValue:value,dataset:controller.getDataset(),dataIndex:index,datasetIndex,element}}function resolveOptions$1(options,fallbackFont){options=merge({},[defaults.plugins.tooltip,options]);options.bodyFont=toFont(options.bodyFont,fallbackFont);options.titleFont=toFont(options.titleFont,fallbackFont);options.footerFont=toFont(options.footerFont,fallbackFont);options.boxHeight=valueOrDefault(options.boxHeight,options.bodyFont.size);options.boxWidth=valueOrDefault(options.boxWidth,options.bodyFont.size);return options}function getTooltipSize(tooltip){const ctx=tooltip._chart.ctx;const{body,footer,options,title}=tooltip;const{bodyFont,footerFont,titleFont,boxWidth,boxHeight}=options;const titleLineCount=title.length;const footerLineCount=footer.length;const bodyLineItemCount=body.length;let height=options.yPadding*2;let width=0;let combinedBodyLength=body.reduce((count,bodyItem)=>count+bodyItem.before.length+bodyItem.lines.length+bodyItem.after.length,0);combinedBodyLength+=tooltip.beforeBody.length+tooltip.afterBody.length;if(titleLineCount){height+=titleLineCount*titleFont.size+(titleLineCount-1)*options.titleSpacing+options.titleMarginBottom}if(combinedBodyLength){const bodyLineHeight=options.displayColors?Math.max(boxHeight,bodyFont.size):bodyFont.size;height+=bodyLineItemCount*bodyLineHeight+(combinedBodyLength-bodyLineItemCount)*bodyFont.size+(combinedBodyLength-1)*options.bodySpacing}if(footerLineCount){height+=options.footerMarginTop+footerLineCount*footerFont.size+(footerLineCount-1)*options.footerSpacing}let widthPadding=0;const maxLineWidth=function(line){width=Math.max(width,ctx.measureText(line).width+widthPadding)};ctx.save();ctx.font=titleFont.string;each(tooltip.title,maxLineWidth);ctx.font=bodyFont.string;each(tooltip.beforeBody.concat(tooltip.afterBody),maxLineWidth);widthPadding=options.displayColors?(boxWidth+2):0;each(body,(bodyItem)=>{each(bodyItem.before,maxLineWidth);each(bodyItem.lines,maxLineWidth);each(bodyItem.after,maxLineWidth)});widthPadding=0;ctx.font=footerFont.string;each(tooltip.footer,maxLineWidth);ctx.restore();width+=2*options.xPadding;return{width,height}}function determineAlignment(chart,options,size){const{x,y,width,height}=size;const chartArea=chart.chartArea;let xAlign='center';let yAlign='center';if(y(chart.height-height)){yAlign='bottom'}let lf,rf;const midX=(chartArea.left+chartArea.right)/2;const midY=(chartArea.top+chartArea.bottom)/2;if(yAlign==='center'){lf=(value)=>value<=midX;rf=(value)=>value>midX}else{lf=(value)=>value<=(width/2);rf=(value)=>value>=(chart.width-(width/2))}const olf=(value)=>value+width+options.caretSize+options.caretPadding>chart.width;const orf=(value)=>value-width-options.caretSize-options.caretPadding<0;const yf=(value)=>value<=midY?'top':'bottom';if(lf(x)){xAlign='left';if(olf(x)){xAlign='center';yAlign=yf(y)}}else if(rf(x)){xAlign='right';if(orf(x)){xAlign='center';yAlign=yf(y)}}return{xAlign:options.xAlign?options.xAlign:xAlign,yAlign:options.yAlign?options.yAlign:yAlign}}function alignX(size,xAlign,chartWidth){let{x,width}=size;if(xAlign==='right'){x-=width}else if(xAlign==='center'){x-=(width/2);if(x+width>chartWidth){x=chartWidth-width}if(x<0){x=0}}return x}function alignY(size,yAlign,paddingAndSize){let{y,height}=size;if(yAlign==='top'){y+=paddingAndSize}else if(yAlign==='bottom'){y-=height+paddingAndSize}else{y-=(height/2)}return y}function getBackgroundPoint(options,size,alignment,chart){const{caretSize,caretPadding,cornerRadius}=options;const{xAlign,yAlign}=alignment;const paddingAndSize=caretSize+caretPadding;const radiusAndPadding=cornerRadius+caretPadding;let x=alignX(size,xAlign,chart.width);const y=alignY(size,yAlign,paddingAndSize);if(yAlign==='center'){if(xAlign==='left'){x+=paddingAndSize}else if(xAlign==='right'){x-=paddingAndSize}}else if(xAlign==='left'){x-=radiusAndPadding}else if(xAlign==='right'){x+=radiusAndPadding}return{x,y}}function getAlignedX(tooltip,align){const options=tooltip.options;return align==='center'?tooltip.x+tooltip.width/2:align==='right'?tooltip.x+tooltip.width-options.xPadding:tooltip.x+options.xPadding}function getBeforeAfterBodyLines(callback){return pushOrConcat([],splitNewlines(callback))}class Tooltip extends Element{constructor(config){super();this.opacity=0;this._active=[];this._chart=config._chart;this._eventPosition=undefined;this._size=undefined;this._cachedAnimations=undefined;this.$animations=undefined;this.options=undefined;this.dataPoints=undefined;this.title=undefined;this.beforeBody=undefined;this.body=undefined;this.afterBody=undefined;this.footer=undefined;this.xAlign=undefined;this.yAlign=undefined;this.x=undefined;this.y=undefined;this.height=undefined;this.width=undefined;this.caretX=undefined;this.caretY=undefined;this.labelColors=undefined;this.labelTextColors=undefined;this.initialize()}initialize(){const me=this;const chartOpts=me._chart.options;me.options=resolveOptions$1(chartOpts.tooltips,chartOpts.font)}_resolveAnimations(){const me=this;const cached=me._cachedAnimations;if(cached){return cached}const chart=me._chart;const options=me.options;const opts=options.enabled&&chart.options.animation&&options.animation;const animations=new Animations(me._chart,opts);me._cachedAnimations=Object.freeze(animations);return animations}getTitle(context){const me=this;const opts=me.options;const callbacks=opts.callbacks;const beforeTitle=callbacks.beforeTitle.apply(me,[context]);const title=callbacks.title.apply(me,[context]);const afterTitle=callbacks.afterTitle.apply(me,[context]);let lines=[];lines=pushOrConcat(lines,splitNewlines(beforeTitle));lines=pushOrConcat(lines,splitNewlines(title));lines=pushOrConcat(lines,splitNewlines(afterTitle));return lines}getBeforeBody(tooltipItems){return getBeforeAfterBodyLines(this.options.callbacks.beforeBody.apply(this,[tooltipItems]))}getBody(tooltipItems){const me=this;const callbacks=me.options.callbacks;const bodyItems=[];each(tooltipItems,(context)=>{const bodyItem={before:[],lines:[],after:[]};pushOrConcat(bodyItem.before,splitNewlines(callbacks.beforeLabel.call(me,context)));pushOrConcat(bodyItem.lines,callbacks.label.call(me,context));pushOrConcat(bodyItem.after,splitNewlines(callbacks.afterLabel.call(me,context)));bodyItems.push(bodyItem)});return bodyItems}getAfterBody(tooltipItems){return getBeforeAfterBodyLines(this.options.callbacks.afterBody.apply(this,[tooltipItems]))}getFooter(tooltipItems){const me=this;const callbacks=me.options.callbacks;const beforeFooter=callbacks.beforeFooter.apply(me,[tooltipItems]);const footer=callbacks.footer.apply(me,[tooltipItems]);const afterFooter=callbacks.afterFooter.apply(me,[tooltipItems]);let lines=[];lines=pushOrConcat(lines,splitNewlines(beforeFooter));lines=pushOrConcat(lines,splitNewlines(footer));lines=pushOrConcat(lines,splitNewlines(afterFooter));return lines}_createItems(){const me=this;const active=me._active;const options=me.options;const data=me._chart.data;const labelColors=[];const labelTextColors=[];let tooltipItems=[];let i,len;for(i=0,len=active.length;ioptions.filter(element,index,array,data))}if(options.itemSort){tooltipItems=tooltipItems.sort((a,b)=>options.itemSort(a,b,data))}each(tooltipItems,(context)=>{labelColors.push(options.callbacks.labelColor.call(me,context));labelTextColors.push(options.callbacks.labelTextColor.call(me,context))});me.labelColors=labelColors;me.labelTextColors=labelTextColors;me.dataPoints=tooltipItems;return tooltipItems}update(changed){const me=this;const options=me.options;const active=me._active;let properties;if(!active.length){if(me.opacity!==0){properties={opacity:0}}}else{const position=positioners[options.position].call(me,active,me._eventPosition);const tooltipItems=me._createItems();me.title=me.getTitle(tooltipItems);me.beforeBody=me.getBeforeBody(tooltipItems);me.body=me.getBody(tooltipItems);me.afterBody=me.getAfterBody(tooltipItems);me.footer=me.getFooter(tooltipItems);const size=me._size=getTooltipSize(me);const positionAndSize=Object.assign({},position,size);const alignment=determineAlignment(me._chart,options,positionAndSize);const backgroundPoint=getBackgroundPoint(options,positionAndSize,alignment,me._chart);me.xAlign=alignment.xAlign;me.yAlign=alignment.yAlign;properties={opacity:1,x:backgroundPoint.x,y:backgroundPoint.y,width:size.width,height:size.height,caretX:position.x,caretY:position.y}}if(properties){me._resolveAnimations().update(me,properties)}if(changed&&options.custom){options.custom.call(me,{chart:me._chart,tooltip:me})}}drawCaret(tooltipPoint,ctx,size){const caretPosition=this.getCaretPosition(tooltipPoint,size);ctx.lineTo(caretPosition.x1,caretPosition.y1);ctx.lineTo(caretPosition.x2,caretPosition.y2);ctx.lineTo(caretPosition.x3,caretPosition.y3)}getCaretPosition(tooltipPoint,size){const{xAlign,yAlign,options}=this;const{cornerRadius,caretSize}=options;const{x:ptX,y:ptY}=tooltipPoint;const{width,height}=size;let x1,x2,x3,y1,y2,y3;if(yAlign==='center'){y2=ptY+(height/2);if(xAlign==='left'){x1=ptX;x2=x1-caretSize;y1=y2+caretSize;y3=y2-caretSize}else{x1=ptX+width;x2=x1+caretSize;y1=y2-caretSize;y3=y2+caretSize}x3=x1}else{if(xAlign==='left'){x2=ptX+cornerRadius+(caretSize)}else if(xAlign==='right'){x2=ptX+width-cornerRadius-caretSize}else{x2=this.caretX}if(yAlign==='top'){y1=ptY;y2=y1-caretSize;x1=x2-caretSize;x3=x2+caretSize}else{y1=ptY+height;y2=y1+caretSize;x1=x2+caretSize;x3=x2-caretSize}y3=y1}return{x1,x2,x3,y1,y2,y3}}drawTitle(pt,ctx){const me=this;const options=me.options;const title=me.title;const length=title.length;let titleFont,titleSpacing,i;if(length){const rtlHelper=getRtlAdapter(options.rtl,me.x,me.width);pt.x=getAlignedX(me,options.titleAlign);ctx.textAlign=rtlHelper.textAlign(options.titleAlign);ctx.textBaseline='middle';titleFont=options.titleFont;titleSpacing=options.titleSpacing;ctx.fillStyle=options.titleFont.color;ctx.font=titleFont.string;for(i=0;i0){ctx.stroke()}}_updateAnimationTarget(){const me=this;const chart=me._chart;const options=me.options;const anims=me.$animations;const animX=anims&&anims.x;const animY=anims&&anims.y;if(animX||animY){const position=positioners[options.position].call(me,me._active,me._eventPosition);if(!position){return}const size=me._size=getTooltipSize(me);const positionAndSize=Object.assign({},position,me._size);const alignment=determineAlignment(chart,options,positionAndSize);const point=getBackgroundPoint(options,positionAndSize,alignment,chart);if(animX._to!==point.x||animY._to!==point.y){me.xAlign=alignment.xAlign;me.yAlign=alignment.yAlign;me.width=size.width;me.height=size.height;me.caretX=position.x;me.caretY=position.y;me._resolveAnimations().update(me,point)}}}draw(ctx){const me=this;const options=me.options;let opacity=me.opacity;if(!opacity){return}me._updateAnimationTarget();const tooltipSize={width:me.width,height:me.height};const pt={x:me.x,y:me.y};opacity=Math.abs(opacity)<1e-3?0:opacity;const hasTooltipContent=me.title.length||me.beforeBody.length||me.body.length||me.afterBody.length||me.footer.length;if(options.enabled&&hasTooltipContent){ctx.save();ctx.globalAlpha=opacity;me.drawBackground(pt,ctx,tooltipSize);overrideTextDirection(ctx,options.textDirection);pt.y+=options.yPadding;me.drawTitle(pt,ctx);me.drawBody(pt,ctx);me.drawFooter(pt,ctx);restoreTextDirection(ctx,options.textDirection);ctx.restore()}}handleEvent(e,replay){const me=this;const options=me.options;const lastActive=me._active||[];let changed=false;let active=[];if(e.type!=='mouseout'){active=me._chart.getElementsAtEventForMode(e,options.mode,options,replay);if(options.reverse){active.reverse()}}const position=positioners[options.position].call(me,active,e);const positionChanged=this.caretX!==position.x||this.caretY!==position.y;changed=replay||!_elementsEqual(active,lastActive)||positionChanged;if(changed){me._active=active;if(options.enabled||options.custom){me._eventPosition={x:e.x,y:e.y};me.update(true)}}return changed}}Tooltip.positioners=positioners;var plugin_tooltip={id:'tooltip',_element:Tooltip,positioners,afterInit(chart){const tooltipOpts=chart.options.tooltips;if(tooltipOpts){chart.tooltip=new Tooltip({_chart:chart})}},beforeUpdate(chart){if(chart.tooltip){chart.tooltip.initialize()}},reset(chart){if(chart.tooltip){chart.tooltip.initialize()}},afterDraw(chart){const tooltip=chart.tooltip;const args={tooltip};if(chart._plugins.notify(chart,'beforeTooltipDraw',[args])===false){return}if(tooltip){tooltip.draw(chart.ctx)}chart._plugins.notify(chart,'afterTooltipDraw',[args])},afterEvent(chart,e,replay){if(chart.tooltip){const useFinalPosition=replay;chart.tooltip.handleEvent(e,useFinalPosition)}},defaults:{enabled:true,custom:null,mode:'nearest',position:'average',intersect:true,backgroundColor:'rgba(0,0,0,0.8)',titleFont:{style:'bold',color:'#fff'},titleSpacing:2,titleMarginBottom:6,titleAlign:'left',bodySpacing:2,bodyFont:{color:'#fff'},bodyAlign:'left',footerSpacing:2,footerMarginTop:6,footerFont:{color:'#fff',style:'bold'},footerAlign:'left',yPadding:6,xPadding:6,caretPadding:2,caretSize:5,cornerRadius:6,multiKeyBackground:'#fff',displayColors:true,borderColor:'rgba(0,0,0,0)',borderWidth:0,animation:{duration:400,easing:'easeOutQuart',numbers:{type:'number',properties:['x','y','width','height','caretX','caretY']},opacity:{easing:'linear',duration:200}},callbacks:{beforeTitle:noop,title(tooltipItems){if(tooltipItems.length>0){const item=tooltipItems[0];const labels=item.chart.data.labels;const labelCount=labels?labels.length:0;if(item.label){return item.label}else if(labelCount>0&&item.dataIndex=0&&valueticks.length-1){return null}return me.getPixelForValue(ticks[index].value)}getValueForPixel(pixel){const me=this;const value=Math.round(me._startValue+me.getDecimalForPixel(pixel)*me._valueRange);return Math.min(Math.max(value,0),me.ticks.length-1)}getBasePixel(){return this.bottom}}CategoryScale.id='category';CategoryScale.defaults={ticks:{callback:CategoryScale.prototype.getLabelForValue}};function niceNum(range){const exponent=Math.floor(log10(range));const fraction=range/Math.pow(10,exponent);let niceFraction;if(fraction<=1.0){niceFraction=1}else if(fraction<=2){niceFraction=2}else if(fraction<=5){niceFraction=5}else{niceFraction=10}return niceFraction*Math.pow(10,exponent)}function generateTicks(generationOptions,dataRange){const ticks=[];const MIN_SPACING=1e-14;const{stepSize,min,max,precision}=generationOptions;const unit=stepSize||1;const maxNumSpaces=generationOptions.maxTicks-1;const{min:rmin,max:rmax}=dataRange;let spacing=niceNum((rmax-rmin)/maxNumSpaces/unit)*unit;let factor,niceMin,niceMax,numSpaces;if(spacingmaxNumSpaces){spacing=niceNum(numSpaces*spacing/maxNumSpaces/unit)*unit}if(stepSize||isNullOrUndef(precision)){factor=Math.pow(10,_decimalPlaces(spacing))}else{factor=Math.pow(10,precision);spacing=Math.ceil(spacing*factor)/factor}niceMin=Math.floor(rmin/spacing)*spacing;niceMax=Math.ceil(rmax/spacing)*spacing;if(stepSize&&!isNullOrUndef(min)&&!isNullOrUndef(max)){if(almostWhole((max-min)/stepSize,spacing/1000)){niceMin=min;niceMax=max}}numSpaces=(niceMax-niceMin)/spacing;if(almostEquals(numSpaces,Math.round(numSpaces),spacing/1000)){numSpaces=Math.round(numSpaces)}else{numSpaces=Math.ceil(numSpaces)}niceMin=Math.round(niceMin*factor)/factor;niceMax=Math.round(niceMax*factor)/factor;ticks.push({value:isNullOrUndef(min)?niceMin:min});for(let j=1;j0&&maxSign>0){me.min=0}}const setMin=opts.min!==undefined||opts.suggestedMin!==undefined;const setMax=opts.max!==undefined||opts.suggestedMax!==undefined;if(opts.min!==undefined){me.min=opts.min}else if(opts.suggestedMin!==undefined){if(me.min===null){me.min=opts.suggestedMin}else{me.min=Math.min(me.min,opts.suggestedMin)}}if(opts.max!==undefined){me.max=opts.max}else if(opts.suggestedMax!==undefined){if(me.max===null){me.max=opts.suggestedMax}else{me.max=Math.max(me.max,opts.suggestedMax)}}if(setMin!==setMax){if(me.min>=me.max){if(setMin){me.max=me.min+1}else{me.min=me.max-1}}}if(me.min===me.max){me.max+=1;if(!opts.beginAtZero){me.min-=1}}}getTickLimit(){const me=this;const tickOpts=me.options.ticks;let{maxTicksLimit,stepSize}=tickOpts;let maxTicks;if(stepSize){maxTicks=Math.ceil(me.max/stepSize)-Math.floor(me.min/stepSize)+1}else{maxTicks=me.computeTickLimit();maxTicksLimit=maxTicksLimit||11}if(maxTicksLimit){maxTicks=Math.min(maxTicksLimit,maxTicks)}return maxTicks}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const me=this;const opts=me.options;const tickOpts=opts.ticks;let maxTicks=me.getTickLimit();maxTicks=Math.max(2,maxTicks);const numericGeneratorOptions={maxTicks,min:opts.min,max:opts.max,precision:tickOpts.precision,stepSize:valueOrDefault(tickOpts.fixedStepSize,tickOpts.stepSize)};const ticks=generateTicks(numericGeneratorOptions,me);_setMinAndMaxByKey(ticks,me,'value');if(opts.reverse){ticks.reverse();me.start=me.max;me.end=me.min}else{me.start=me.min;me.end=me.max}return ticks}configure(){const me=this;const ticks=me.ticks;let start=me.min;let end=me.max;super.configure();if(me.options.offset&&ticks.length){const offset=(end-start)/Math.max(ticks.length-1,1)/2;start-=offset;end+=offset}me._startValue=start;me._endValue=end;me._valueRange=end-start}getLabelForValue(value){return new Intl.NumberFormat(this.options.locale).format(value)}}class LinearScale extends LinearScaleBase{determineDataLimits(){const me=this;const options=me.options;const{min,max}=me.getMinMax(true);me.min=isNumberFinite(min)?min:valueOrDefault(options.suggestedMin,0);me.max=isNumberFinite(max)?max:valueOrDefault(options.suggestedMax,1);if(options.stacked&&min>0){me.min=0}me.handleTickRangeOptions()}computeTickLimit(){const me=this;if(me.isHorizontal()){return Math.ceil(me.width/40)}const tickFont=me._resolveTickFontOptions(0);return Math.ceil(me.height/tickFont.lineHeight)}getPixelForValue(value){const me=this;return me.getPixelForDecimal((value-me._startValue)/me._valueRange)}getValueForPixel(pixel){return this._startValue+this.getDecimalForPixel(pixel)*this._valueRange}}LinearScale.id='linear';LinearScale.defaults={ticks:{callback:Ticks.formatters.numeric}};function isMajor(tickVal){const remain=tickVal/(Math.pow(10,Math.floor(log10(tickVal))));return remain===1}function finiteOrDefault(value,def){return isNumberFinite(value)?value:def}function generateTicks$1(generationOptions,dataRange){const endExp=Math.floor(log10(dataRange.max));const endSignificand=Math.ceil(dataRange.max/Math.pow(10,endExp));const ticks=[];let tickVal=finiteOrDefault(generationOptions.min,Math.pow(10,Math.floor(log10(dataRange.min))));let exp=Math.floor(log10(tickVal));let significand=Math.floor(tickVal/Math.pow(10,exp));let precision=exp<0?Math.pow(10,Math.abs(exp)):1;do{ticks.push({value:tickVal,major:isMajor(tickVal)});significand+=1;if(significand===10){significand=1;exp+=1;precision=exp>=0?1:precision}tickVal=Math.round(significand*Math.pow(10,exp)*precision)/precision}while(exp0?value:NaN}determineDataLimits(){const me=this;const{min,max}=me.getMinMax(true);me.min=isNumberFinite(min)?Math.max(0,min):null;me.max=isNumberFinite(max)?Math.max(0,max):null;me.handleTickRangeOptions()}handleTickRangeOptions(){const me=this;const DEFAULT_MIN=1;const DEFAULT_MAX=10;let min=me.min;let max=me.max;if(min===max){if(min<=0){min=DEFAULT_MIN;max=DEFAULT_MAX}else{min=Math.pow(10,Math.floor(log10(min))-1);max=Math.pow(10,Math.floor(log10(max))+1)}}if(min<=0){min=Math.pow(10,Math.floor(log10(max))-1)}if(max<=0){max=Math.pow(10,Math.floor(log10(min))+1)}me.min=min;me.max=max}buildTicks(){const me=this;const opts=me.options;const generationOptions={min:me._userMin,max:me._userMax};const ticks=generateTicks$1(generationOptions,me);let reverse=!me.isHorizontal();_setMinAndMaxByKey(ticks,me,'value');if(opts.reverse){reverse=!reverse;me.start=me.max;me.end=me.min}else{me.start=me.min;me.end=me.max}if(reverse){ticks.reverse()}return ticks}getLabelForValue(value){return value===undefined?'0':new Intl.NumberFormat(this.options.locale).format(value)}configure(){const me=this;const start=me.min;super.configure();me._startValue=log10(start);me._valueRange=log10(me.max)-log10(start)}getPixelForValue(value){const me=this;if(value===undefined||value===0){value=me.min}return me.getPixelForDecimal(value===me.min?0:(log10(value)-me._startValue)/me._valueRange)}getValueForPixel(pixel){const me=this;const decimal=me.getDecimalForPixel(pixel);return Math.pow(10,me._startValue+decimal*me._valueRange)}}LogarithmicScale.id='logarithmic';LogarithmicScale.defaults={ticks:{callback:Ticks.formatters.logarithmic,major:{enabled:true}}};function getTickBackdropHeight(opts){const tickOpts=opts.ticks;if(tickOpts.display&&opts.display){return valueOrDefault(tickOpts.font&&tickOpts.font.size,defaults.font.size)+tickOpts.backdropPaddingY*2}return 0}function measureLabelSize(ctx,lineHeight,label){if(isArray(label)){return{w:_longestText(ctx,ctx.font,label),h:label.length*lineHeight}}return{w:ctx.measureText(label).width,h:lineHeight}}function determineLimits(angle,pos,size,min,max){if(angle===min||angle===max){return{start:pos-(size/2),end:pos+(size/2)}}else if(anglemax){return{start:pos-size,end:pos}}return{start:pos,end:pos+size}}function fitWithPointLabels(scale){const furthestLimits={l:0,r:scale.width,t:0,b:scale.height-scale.paddingTop};const furthestAngles={};let i,textSize,pointPosition;scale._pointLabelSizes=[];const valueCount=scale.chart.data.labels.length;for(i=0;ifurthestLimits.r){furthestLimits.r=hLimits.end;furthestAngles.r=angleRadians}if(vLimits.startfurthestLimits.b){furthestLimits.b=vLimits.end;furthestAngles.b=angleRadians}}scale._setReductions(scale.drawingArea,furthestLimits,furthestAngles)}function getTextAlignForAngle(angle){if(angle===0||angle===180){return 'center'}else if(angle<180){return 'left'}return 'right'}function fillText(ctx,text,position,lineHeight){let y=position.y+lineHeight/2;let i,ilen;if(isArray(text)){for(i=0,ilen=text.length;i270||angle<90){position.y-=textSize.h}}function drawPointLabels(scale){const ctx=scale.ctx;const opts=scale.options;const pointLabelOpts=opts.pointLabels;const tickBackdropHeight=getTickBackdropHeight(opts);const outerDistance=scale.getDistanceFromCenterForValue(opts.ticks.reverse?scale.min:scale.max);ctx.save();ctx.textBaseline='middle';for(let i=scale.chart.data.labels.length-1;i>=0;i-=1){const extra=(i===0?tickBackdropHeight/2:0);const pointLabelPosition=scale.getPointPosition(i,outerDistance+extra+5);const context={chart:scale.chart,scale,index:i,label:scale.pointLabels[i]};const plFont=toFont(resolve([pointLabelOpts.font],context,i),scale.chart.options.font);ctx.font=plFont.string;ctx.fillStyle=plFont.color;const angle=toDegrees(scale.getIndexAngle(i));ctx.textAlign=getTextAlignForAngle(angle);adjustPointPositionForLabelHeight(angle,scale._pointLabelSizes[i],pointLabelPosition);fillText(ctx,scale.pointLabels[i],pointLabelPosition,plFont.lineHeight)}ctx.restore()}function drawRadiusLine(scale,gridLineOpts,radius,index){const ctx=scale.ctx;const circular=gridLineOpts.circular;const valueCount=scale.chart.data.labels.length;const context={chart:scale.chart,scale,index,tick:scale.ticks[index]};const lineColor=resolve([gridLineOpts.color],context,index-1);const lineWidth=resolve([gridLineOpts.lineWidth],context,index-1);let pointPosition;if((!circular&&!valueCount)||!lineColor||!lineWidth){return}ctx.save();ctx.strokeStyle=lineColor;ctx.lineWidth=lineWidth;if(ctx.setLineDash){ctx.setLineDash(resolve([gridLineOpts.borderDash,[]],context));ctx.lineDashOffset=resolve([gridLineOpts.borderDashOffset],context,index-1)}ctx.beginPath();if(circular){ctx.arc(scale.xCenter,scale.yCenter,radius,0,Math.PI*2)}else{pointPosition=scale.getPointPosition(0,radius);ctx.moveTo(pointPosition.x,pointPosition.y);for(let i=1;i{const label=callback(me.options.pointLabels.callback,[value,index],me);return label||label===0?label:''})}fit(){const me=this;const opts=me.options;if(opts.display&&opts.pointLabels.display){fitWithPointLabels(me)}else{me.setCenterPoint(0,0,0,0)}}_setReductions(largestPossibleRadius,furthestLimits,furthestAngles){const me=this;let radiusReductionLeft=furthestLimits.l/Math.sin(furthestAngles.l);let radiusReductionRight=Math.max(furthestLimits.r-me.width,0)/Math.sin(furthestAngles.r);let radiusReductionTop= -furthestLimits.t/Math.cos(furthestAngles.t);let radiusReductionBottom= -Math.max(furthestLimits.b-(me.height-me.paddingTop),0)/Math.cos(furthestAngles.b);radiusReductionLeft=numberOrZero(radiusReductionLeft);radiusReductionRight=numberOrZero(radiusReductionRight);radiusReductionTop=numberOrZero(radiusReductionTop);radiusReductionBottom=numberOrZero(radiusReductionBottom);me.drawingArea=Math.min(Math.floor(largestPossibleRadius-(radiusReductionLeft+radiusReductionRight)/2),Math.floor(largestPossibleRadius-(radiusReductionTop+radiusReductionBottom)/2));me.setCenterPoint(radiusReductionLeft,radiusReductionRight,radiusReductionTop,radiusReductionBottom)}setCenterPoint(leftMovement,rightMovement,topMovement,bottomMovement){const me=this;const maxRight=me.width-rightMovement-me.drawingArea;const maxLeft=leftMovement+me.drawingArea;const maxTop=topMovement+me.drawingArea;const maxBottom=(me.height-me.paddingTop)-bottomMovement-me.drawingArea;me.xCenter=Math.floor(((maxLeft+maxRight)/2)+me.left);me.yCenter=Math.floor(((maxTop+maxBottom)/2)+me.top+me.paddingTop)}getIndexAngle(index){const chart=this.chart;const angleMultiplier=Math.PI*2/chart.data.labels.length;const options=chart.options||{};const startAngle=options.startAngle||0;return _normalizeAngle(index*angleMultiplier+toRadians(startAngle))}getDistanceFromCenterForValue(value){const me=this;if(isNullOrUndef(value)){return NaN}const scalingFactor=me.drawingArea/(me.max-me.min);if(me.options.reverse){return(me.max-value)*scalingFactor}return(value-me.min)*scalingFactor}getValueForDistanceFromCenter(distance){if(isNullOrUndef(distance)){return NaN}const me=this;const scaledDistance=distance/(me.drawingArea/(me.max-me.min));return me.options.reverse?me.max-scaledDistance:me.min+scaledDistance}getPointPosition(index,distanceFromCenter){const me=this;const angle=me.getIndexAngle(index)-(Math.PI/2);return{x:Math.cos(angle)*distanceFromCenter+me.xCenter,y:Math.sin(angle)*distanceFromCenter+me.yCenter,angle}}getPointPositionForValue(index,value){return this.getPointPosition(index,this.getDistanceFromCenterForValue(value))}getBasePosition(index){return this.getPointPositionForValue(index||0,this.getBaseValue())}drawGrid(){const me=this;const ctx=me.ctx;const opts=me.options;const gridLineOpts=opts.gridLines;const angleLineOpts=opts.angleLines;let i,offset,position;if(opts.pointLabels.display){drawPointLabels(me)}if(gridLineOpts.display){me.ticks.forEach((tick,index)=>{if(index!==0){offset=me.getDistanceFromCenterForValue(me.ticks[index].value);drawRadiusLine(me,gridLineOpts,offset,index)}})}if(angleLineOpts.display){ctx.save();for(i=me.chart.data.labels.length-1;i>=0;i-=1){const context={chart:me.chart,scale:me,index:i,label:me.pointLabels[i]};const lineWidth=resolve([angleLineOpts.lineWidth,gridLineOpts.lineWidth],context,i);const color=resolve([angleLineOpts.color,gridLineOpts.color],context,i);if(!lineWidth||!color){continue}ctx.lineWidth=lineWidth;ctx.strokeStyle=color;if(ctx.setLineDash){ctx.setLineDash(resolve([angleLineOpts.borderDash,gridLineOpts.borderDash,[]],context));ctx.lineDashOffset=resolve([angleLineOpts.borderDashOffset,gridLineOpts.borderDashOffset,0.0],context,i)}offset=me.getDistanceFromCenterForValue(opts.ticks.reverse?me.min:me.max);position=me.getPointPosition(i,offset);ctx.beginPath();ctx.moveTo(me.xCenter,me.yCenter);ctx.lineTo(position.x,position.y);ctx.stroke()}ctx.restore()}}drawLabels(){const me=this;const ctx=me.ctx;const opts=me.options;const tickOpts=opts.ticks;if(!tickOpts.display){return}const startAngle=me.getIndexAngle(0);let offset,width;ctx.save();ctx.translate(me.xCenter,me.yCenter);ctx.rotate(startAngle);ctx.textAlign='center';ctx.textBaseline='middle';me.ticks.forEach((tick,index)=>{const context={chart:me.chart,scale:me,index,tick};if(index===0&&!opts.reverse){return}const tickFont=me._resolveTickFontOptions(index);ctx.font=tickFont.string;offset=me.getDistanceFromCenterForValue(me.ticks[index].value);const showLabelBackdrop=resolve([tickOpts.showLabelBackdrop],context,index);if(showLabelBackdrop){width=ctx.measureText(tick.label).width;ctx.fillStyle=resolve([tickOpts.backdropColor],context,index);ctx.fillRect(-width/2-tickOpts.backdropPaddingX,-offset-tickFont.size/2-tickOpts.backdropPaddingY,width+tickOpts.backdropPaddingX*2,tickFont.size+tickOpts.backdropPaddingY*2)}ctx.fillStyle=tickFont.color;ctx.fillText(tick.label,0,-offset)});ctx.restore()}drawTitle(){}}RadialLinearScale.id='radialLinear';RadialLinearScale.defaults={display:true,animate:true,position:'chartArea',angleLines:{display:true,color:'rgba(0,0,0,0.1)',lineWidth:1,borderDash:[],borderDashOffset:0.0},gridLines:{circular:false},ticks:{showLabelBackdrop:true,backdropColor:'rgba(255,255,255,0.75)',backdropPaddingY:2,backdropPaddingX:2,callback:Ticks.formatters.numeric},pointLabels:{display:true,font:{size:10},callback(label){return label}}};const MAX_INTEGER=Number.MAX_SAFE_INTEGER||9007199254740991;const INTERVALS={millisecond:{common:true,size:1,steps:1000},second:{common:true,size:1000,steps:60},minute:{common:true,size:60000,steps:60},hour:{common:true,size:3600000,steps:24},day:{common:true,size:86400000,steps:30},week:{common:false,size:604800000,steps:4},month:{common:true,size:2.628e9,steps:12},quarter:{common:false,size:7.884e9,steps:4},year:{common:true,size:3.154e10}};const UNITS=(Object.keys(INTERVALS));function sorter(a,b){return a-b}function parse(scale,input){if(isNullOrUndef(input)){return null}const adapter=scale._adapter;const options=scale.options.time;const{parser,round,isoWeekday}=options;let value=input;if(typeof parser==='function'){value=parser(value)}if(!isNumberFinite(value)){value=typeof parser==='string'?adapter.parse(value,parser):adapter.parse(value)}if(value===null){return value}if(round){value=round==='week'&&isoWeekday?scale._adapter.startOf(value,'isoWeek',isoWeekday):scale._adapter.startOf(value,round)}return+value}function determineUnitForAutoTicks(minUnit,min,max,capacity){const ilen=UNITS.length;for(let i=UNITS.indexOf(minUnit);i=UNITS.indexOf(minUnit);i-=1){const unit=UNITS[i];if(INTERVALS[unit].common&&scale._adapter.diff(max,min,unit)>=numTicks-1){return unit}}return UNITS[minUnit?UNITS.indexOf(minUnit):0]}function determineMajorUnit(unit){for(let i=UNITS.indexOf(unit)+1,ilen=UNITS.length;i=time?timestamps[lo]:timestamps[hi];ticks[timestamp]=true}function setMajorTicks(scale,ticks,map,majorUnit){const adapter=scale._adapter;const first= +adapter.startOf(ticks[0].value,majorUnit);const last=ticks[ticks.length-1].value;let major,index;for(major=first;major<=last;major= +adapter.add(major,1,majorUnit)){index=map[major];if(index>=0){ticks[index].major=true}}return ticks}function ticksFromTimestamps(scale,values,majorUnit){const ticks=[];const map={};const ilen=values.length;let i,value;for(i=0;i100000*stepSize){throw new Error(min+' and '+max+' are too far apart with stepSize of '+stepSize+' '+minor)}if(me.options.ticks.source==='data'){const timestamps=me.getDataTimestamps();for(time=first;time +x)}getLabelForValue(value){const me=this;const adapter=me._adapter;const timeOpts=me.options.time;if(timeOpts.tooltipFormat){return adapter.format(value,timeOpts.tooltipFormat)}return adapter.format(value,timeOpts.displayFormats.datetime)}_tickFormatFunction(time,index,ticks,format){const me=this;const options=me.options;const formats=options.time.displayFormats;const unit=me._unit;const majorUnit=me._majorUnit;const minorFormat=unit&&formats[unit];const majorFormat=majorUnit&&formats[majorUnit];const tick=ticks[index];const major=majorUnit&&majorFormat&&tick&&tick.major;const label=me._adapter.format(time,format||(major?majorFormat:minorFormat));const formatter=options.ticks.callback;return formatter?formatter(label,index,ticks):label}generateTickLabels(ticks){let i,ilen,tick;for(i=0,ilen=ticks.length;i0?capacity:1}getDataTimestamps(){const me=this;let timestamps=me._cache.data||[];let i,ilen;if(timestamps.length){return timestamps}const metas=me.getMatchingVisibleMetas();if(me._normalized&&metas.length){return(me._cache.data=metas[0].controller.getAllParsedValues(me))}for(i=0,ilen=metas.length;imin&&curr0&&!isNullOrUndef(index)?index/me._maxIndex:me.getDecimalForValue(value);return me.getPixelForDecimal((offsets.start+pos)*offsets.factor)}getDecimalForValue(value){return interpolate(this._table,value)/this._maxIndex}getValueForPixel(pixel){const me=this;const offsets=me._offsets;const decimal=me.getDecimalForPixel(pixel)/offsets.factor-offsets.end;return interpolate(me._table,decimal*this._maxIndex,true)}}TimeSeriesScale.id='timeseries';TimeSeriesScale.defaults=TimeScale.defaults;export{Animation,Animations,Arc,BarController,BasePlatform,BasicPlatform,BubbleController,CategoryScale,Chart,DatasetController,DomPlatform,DoughnutController,Element,plugin_filler as Filler,Interaction,plugin_legend as Legend,Line,LineController,LinearScale,LogarithmicScale,PieController,Point,PolarAreaController,RadarController,RadialLinearScale,Rectangle,Scale,ScatterController,Ticks,TimeScale,TimeSeriesScale,plugin_title as Title,plugin_tooltip as Tooltip,adapters as _adapters,animator,layouts,PluginService as plugins,registry}; diff --git a/lib/chartjs/chart.js b/lib/chartjs/chart.js index 39c2d2c..3b835d2 100644 --- a/lib/chartjs/chart.js +++ b/lib/chartjs/chart.js @@ -1,5 +1,5 @@ /*! - * Chart.js v3.0.0-alpha.2 + * Chart.js v3.0.0-beta * https://www.chartjs.org * (c) 2020 Chart.js Contributors * Released under the MIT License @@ -7,7 +7,7 @@ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : -(global = global || self, global.Chart = factory()); +(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Chart = factory()); }(this, (function () { 'use strict'; function _defineProperties(target, props) { @@ -50,6 +50,21 @@ function _inheritsLoose(subClass, superClass) { subClass.__proto__ = superClass; } +function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; +} + function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); @@ -69,6 +84,23 @@ var requestAnimFrame = function () { } return window.requestAnimationFrame; }(); +function throttled(fn, thisArg) { + var ticking = false; + var args = []; + return function () { + for (var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++) { + rest[_key] = arguments[_key]; + } + args = Array.prototype.slice.call(rest); + if (!ticking) { + ticking = true; + requestAnimFrame.call(window, function () { + ticking = false; + fn.apply(thisArg, args); + }); + } + }; +} function drawFPS(chart, count, date, lastDate) { var fps = 1000 / (date - lastDate) | 0; @@ -310,7 +342,7 @@ function clone(source) { return source.map(clone); } if (isObject(source)) { - var target = Object.create(source); + var target = {}; var keys = Object.keys(source); var klen = keys.length; var k = 0; @@ -830,6 +862,17 @@ function _arrayUnique(items) { return result; } +var collection = /*#__PURE__*/Object.freeze({ +__proto__: null, +_lookup: _lookup, +_lookupByKey: _lookupByKey, +_rlookupByKey: _rlookupByKey, +_filterBetween: _filterBetween, +listenArrayEvents: listenArrayEvents, +unlistenArrayEvents: unlistenArrayEvents, +_arrayUnique: _arrayUnique +}); + function isConstrainedValue(value) { return value !== undefined && value !== null && value !== 'none'; } @@ -881,29 +924,31 @@ function _calculatePadding(container, padding, parentDimension) { return padding.indexOf('%') > -1 ? parentDimension * parseInt(padding, 10) / 100 : parseInt(padding, 10); } function getRelativePosition(evt, chart) { - var mouseX, mouseY; var e = evt.originalEvent || evt; - var canvasElement = chart.canvas; - var boundingRect = canvasElement.getBoundingClientRect(); var touches = e.touches; - if (touches && touches.length > 0) { - mouseX = touches[0].clientX; - mouseY = touches[0].clientY; - } else { - mouseX = e.clientX; - mouseY = e.clientY; + var source = touches && touches.length ? touches[0] : e; + var clientX = source.clientX; + var clientY = source.clientY; + var x = source.offsetX || source.layerX || clientX; + var y = source.offsetY || source.layerY || clientY; + if (x !== clientX && y !== clientY) { + return { + x: x, + y: y + }; } + var canvasElement = chart.canvas; + var devicePixelRatio = chart.currentDevicePixelRatio; + var boundingRect = canvasElement.getBoundingClientRect(); var paddingLeft = parseFloat(getStyle(canvasElement, 'padding-left')); var paddingTop = parseFloat(getStyle(canvasElement, 'padding-top')); var paddingRight = parseFloat(getStyle(canvasElement, 'padding-right')); var paddingBottom = parseFloat(getStyle(canvasElement, 'padding-bottom')); var width = boundingRect.right - boundingRect.left - paddingLeft - paddingRight; var height = boundingRect.bottom - boundingRect.top - paddingTop - paddingBottom; - mouseX = Math.round((mouseX - boundingRect.left - paddingLeft) / width * canvasElement.width / chart.currentDevicePixelRatio); - mouseY = Math.round((mouseY - boundingRect.top - paddingTop) / height * canvasElement.height / chart.currentDevicePixelRatio); return { - x: mouseX, - y: mouseY + x: Math.round((x - boundingRect.left - paddingLeft) / width * canvasElement.width / devicePixelRatio), + y: Math.round((y - boundingRect.top - paddingTop) / height * canvasElement.height / devicePixelRatio) }; } function fallbackIfNotValid(measure, fallback) { @@ -946,6 +991,26 @@ function retinaScale(chart, forceRatio) { canvas.style.width = width + 'px'; } } +var supportsEventListenerOptions = function () { + var passiveSupported = false; + try { + var options = { + get passive() { + passiveSupported = true; + return false; + } + }; + window.addEventListener('test', null, options); + window.removeEventListener('test', null, options); + } catch (e) { + } + return passiveSupported; +}(); +function readUsedSize(element, property) { + var value = getStyle(element, property); + var matches = value && value.match(/^(\d+)(\.\d+)?px$/); + return matches ? +matches[1] : undefined; +} var dom = /*#__PURE__*/Object.freeze({ __proto__: null, @@ -954,7 +1019,9 @@ getStyle: getStyle, getRelativePosition: getRelativePosition, getMaximumWidth: getMaximumWidth, getMaximumHeight: getMaximumHeight, -retinaScale: retinaScale +retinaScale: retinaScale, +supportsEventListenerOptions: supportsEventListenerOptions, +readUsedSize: readUsedSize }); function getRelativePosition$1(e, chart) { @@ -1213,22 +1280,22 @@ function toPadding(value) { width: l + r }; } -function toFont(options) { - var defaultFont = defaults.font; +function toFont(options, fallback) { options = options || {}; - var size = valueOrDefault(options.size, defaultFont.size); + fallback = fallback || defaults.font; + var size = valueOrDefault(options.size, fallback.size); if (typeof size === 'string') { size = parseInt(size, 10); } var font = { - color: valueOrDefault(options.color, defaultFont.color), - family: valueOrDefault(options.family, defaultFont.family), - lineHeight: toLineHeight(valueOrDefault(options.lineHeight, defaultFont.lineHeight), size), - lineWidth: valueOrDefault(options.lineWidth, defaultFont.lineWidth), + color: valueOrDefault(options.color, fallback.color), + family: valueOrDefault(options.family, fallback.family), + lineHeight: toLineHeight(valueOrDefault(options.lineHeight, fallback.lineHeight), size), + lineWidth: valueOrDefault(options.lineWidth, fallback.lineWidth), size: size, - style: valueOrDefault(options.style, defaultFont.style), - weight: valueOrDefault(options.weight, defaultFont.weight), - strokeStyle: valueOrDefault(options.strokeStyle, defaultFont.strokeStyle), + style: valueOrDefault(options.style, fallback.style), + weight: valueOrDefault(options.weight, fallback.weight), + strokeStyle: valueOrDefault(options.strokeStyle, fallback.strokeStyle), string: '' }; font.string = toFontString(font); @@ -2058,11 +2125,9 @@ var EVENT_TYPES = { pointerleave: 'mouseout', pointerout: 'mouseout' }; -function readUsedSize(element, property) { - var value = getStyle(element, property); - var matches = value && value.match(/^(\d+)(\.\d+)?px$/); - return matches ? +matches[1] : undefined; -} +var isNullOrEmpty = function isNullOrEmpty(value) { + return value === null || value === ''; +}; function initCanvas(canvas, config) { var style = canvas.style; var renderHeight = canvas.getAttribute('height'); @@ -2080,13 +2145,13 @@ function initCanvas(canvas, config) { }; style.display = style.display || 'block'; style.boxSizing = style.boxSizing || 'border-box'; - if (renderWidth === null || renderWidth === '') { + if (isNullOrEmpty(renderWidth)) { var displayWidth = readUsedSize(canvas, 'width'); if (displayWidth !== undefined) { canvas.width = displayWidth; } } - if (renderHeight === null || renderHeight === '') { + if (isNullOrEmpty(renderHeight)) { if (canvas.style.height === '') { canvas.height = canvas.width / (config.options.aspectRatio || 2); } else { @@ -2098,29 +2163,14 @@ function initCanvas(canvas, config) { } return canvas; } -var supportsEventListenerOptions = function () { - var passiveSupported = false; - try { - var options = { - get passive() { - passiveSupported = true; - return false; - } - }; - window.addEventListener('test', null, options); - window.removeEventListener('test', null, options); - } catch (e) { - } - return passiveSupported; -}(); var eventListenerOptions = supportsEventListenerOptions ? { passive: true } : false; function addListener(node, type, listener) { node.addEventListener(type, listener, eventListenerOptions); } -function removeListener(node, type, listener) { - node.removeEventListener(type, listener, eventListenerOptions); +function removeListener(chart, type, listener) { + chart.canvas.removeEventListener(type, listener, eventListenerOptions); } function createEvent(type, chart, x, y, nativeEvent) { return { @@ -2136,23 +2186,6 @@ function fromNativeEvent(event, chart) { var pos = getRelativePosition(event, chart); return createEvent(type, chart, pos.x, pos.y, event); } -function throttled(fn, thisArg) { - var ticking = false; - var args = []; - return function () { - for (var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++) { - rest[_key] = arguments[_key]; - } - args = Array.prototype.slice.call(rest); - if (!ticking) { - ticking = true; - requestAnimFrame.call(window, function () { - ticking = false; - fn.apply(thisArg, args); - }); - } - }; -} function createAttachObserver(chart, type, listener) { var canvas = chart.canvas; var container = canvas && _getParentNode(canvas); @@ -2195,6 +2228,32 @@ function createDetachObserver(chart, type, listener) { }); return observer; } +var drpListeningCharts = new Map(); +var oldDevicePixelRatio = 0; +function onWindowResize() { + var dpr = window.devicePixelRatio; + if (dpr === oldDevicePixelRatio) { + return; + } + oldDevicePixelRatio = dpr; + drpListeningCharts.forEach(function (resize, chart) { + if (chart.currentDevicePixelRatio !== dpr) { + resize(); + } + }); +} +function listenDevicePixelRatioChanges(chart, resize) { + if (!drpListeningCharts.size) { + window.addEventListener('resize', onWindowResize); + } + drpListeningCharts.set(chart, resize); +} +function unlistenDevicePixelRatioChanges(chart) { + drpListeningCharts["delete"](chart); + if (!drpListeningCharts.size) { + window.removeEventListener('resize', onWindowResize); + } +} function createResizeObserver(chart, type, listener) { var canvas = chart.canvas; var container = canvas && _getParentNode(canvas); @@ -2218,12 +2277,16 @@ function createResizeObserver(chart, type, listener) { resize(width, height); }); observer.observe(container); + listenDevicePixelRatioChanges(chart, resize); return observer; } -function releaseObserver(canvas, type, observer) { +function releaseObserver(chart, type, observer) { if (observer) { observer.disconnect(); } + if (type === 'resize') { + unlistenDevicePixelRatioChanges(chart); + } } function createProxyAndListen(chart, type, listener) { var canvas = chart.canvas; @@ -2286,7 +2349,6 @@ var DomPlatform = function (_BasePlatform) { } ; _proto.removeEventListener = function removeEventListener(chart, type) { - var canvas = chart.canvas; var proxies = chart.$proxies || (chart.$proxies = {}); var proxy = proxies[type]; if (!proxy) { @@ -2298,7 +2360,7 @@ var DomPlatform = function (_BasePlatform) { resize: releaseObserver }; var handler = handlers[type] || removeListener; - handler(canvas, type, proxy); + handler(chart, type, proxy); proxies[type] = undefined; }; _proto.getDevicePixelRatio = function getDevicePixelRatio() { @@ -2319,6 +2381,202 @@ BasicPlatform: BasicPlatform, DomPlatform: DomPlatform }); +function finallyConstructor(callback) { + var constructor = this.constructor; + return this.then(function (value) { + return constructor.resolve(callback()).then(function () { + return value; + }); + }, function (reason) { + return constructor.resolve(callback()).then(function () { + return constructor.reject(reason); + }); + }); +} + +var setTimeoutFunc = setTimeout; +function isArray$1(x) { + return Boolean(x && typeof x.length !== 'undefined'); +} +function noop$1() {} +function bind(fn, thisArg) { + return function () { + fn.apply(thisArg, arguments); + }; +} +function Promise(fn) { + if (!(this instanceof Promise)) throw new TypeError('Promises must be constructed via new'); + if (typeof fn !== 'function') throw new TypeError('not a function'); + this._state = 0; + this._handled = false; + this._value = undefined; + this._deferreds = []; + doResolve(fn, this); +} +function handle(self, deferred) { + while (self._state === 3) { + self = self._value; + } + if (self._state === 0) { + self._deferreds.push(deferred); + return; + } + self._handled = true; + Promise._immediateFn(function () { + var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected; + if (cb === null) { + (self._state === 1 ? resolve$1 : reject)(deferred.promise, self._value); + return; + } + var ret; + try { + ret = cb(self._value); + } catch (e) { + reject(deferred.promise, e); + return; + } + resolve$1(deferred.promise, ret); + }); +} +function resolve$1(self, newValue) { + try { + if (newValue === self) throw new TypeError('A promise cannot be resolved with itself.'); + if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) { + var then = newValue.then; + if (newValue instanceof Promise) { + self._state = 3; + self._value = newValue; + finale(self); + return; + } else if (typeof then === 'function') { + doResolve(bind(then, newValue), self); + return; + } + } + self._state = 1; + self._value = newValue; + finale(self); + } catch (e) { + reject(self, e); + } +} +function reject(self, newValue) { + self._state = 2; + self._value = newValue; + finale(self); +} +function finale(self) { + if (self._state === 2 && self._deferreds.length === 0) { + Promise._immediateFn(function () { + if (!self._handled) { + Promise._unhandledRejectionFn(self._value); + } + }); + } + for (var i = 0, len = self._deferreds.length; i < len; i++) { + handle(self, self._deferreds[i]); + } + self._deferreds = null; +} +function Handler(onFulfilled, onRejected, promise) { + this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; + this.onRejected = typeof onRejected === 'function' ? onRejected : null; + this.promise = promise; +} +function doResolve(fn, self) { + var done = false; + try { + fn(function (value) { + if (done) return; + done = true; + resolve$1(self, value); + }, function (reason) { + if (done) return; + done = true; + reject(self, reason); + }); + } catch (ex) { + if (done) return; + done = true; + reject(self, ex); + } +} +Promise.prototype['catch'] = function (onRejected) { + return this.then(null, onRejected); +}; +Promise.prototype.then = function (onFulfilled, onRejected) { + var prom = new this.constructor(noop$1); + handle(this, new Handler(onFulfilled, onRejected, prom)); + return prom; +}; +Promise.prototype['finally'] = finallyConstructor; +Promise.all = function (arr) { + return new Promise(function (resolve, reject) { + if (!isArray$1(arr)) { + return reject(new TypeError('Promise.all accepts an array')); + } + var args = Array.prototype.slice.call(arr); + if (args.length === 0) return resolve([]); + var remaining = args.length; + function res(i, val) { + try { + if (val && (typeof val === 'object' || typeof val === 'function')) { + var then = val.then; + if (typeof then === 'function') { + then.call(val, function (val) { + res(i, val); + }, reject); + return; + } + } + args[i] = val; + if (--remaining === 0) { + resolve(args); + } + } catch (ex) { + reject(ex); + } + } + for (var i = 0; i < args.length; i++) { + res(i, args[i]); + } + }); +}; +Promise.resolve = function (value) { + if (value && typeof value === 'object' && value.constructor === Promise) { + return value; + } + return new Promise(function (resolve) { + resolve(value); + }); +}; +Promise.reject = function (value) { + return new Promise(function (resolve, reject) { + reject(value); + }); +}; +Promise.race = function (arr) { + return new Promise(function (resolve, reject) { + if (!isArray$1(arr)) { + return reject(new TypeError('Promise.race accepts an array')); + } + for (var i = 0, len = arr.length; i < len; i++) { + Promise.resolve(arr[i]).then(resolve, reject); + } + }); +}; +Promise._immediateFn = +typeof setImmediate === 'function' && function (fn) { + setImmediate(fn); +} || function (fn) { + setTimeoutFunc(fn, 0); +}; +Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) { + if (typeof console !== 'undefined' && console) { + console.warn('Possible Unhandled Promise Rejection:', err); + } +}; + var effects = { linear: function linear(t) { return t; @@ -3149,6 +3407,7 @@ var Animation = function () { this._prop = prop; this._from = from; this._to = to; + this._promises = undefined; } var _proto = Animation.prototype; _proto.active = function active() { @@ -3172,6 +3431,7 @@ var Animation = function () { if (me._active) { me.tick(Date.now()); me._active = false; + me._notify(false); } }; _proto.tick = function tick(date) { @@ -3186,6 +3446,7 @@ var Animation = function () { me._active = from !== to && (loop || elapsed < duration); if (!me._active) { me._target[prop] = to; + me._notify(true); return; } if (elapsed < 0) { @@ -3197,6 +3458,22 @@ var Animation = function () { factor = me._easing(Math.min(1, Math.max(0, factor))); me._target[prop] = me._fn(from, to, factor); }; + _proto.wait = function wait() { + var promises = this._promises || (this._promises = []); + return new Promise(function (res, rej) { + promises.push({ + res: res, + rej: rej + }); + }); + }; + _proto._notify = function _notify(resolved) { + var method = resolved ? 'res' : 'rej'; + var promises = this._promises || []; + for (var i = 0; i < promises.length; i++) { + promises[i][method](); + } + }; return Animation; }(); @@ -3247,10 +3524,10 @@ defaults.set('animation', { function copyOptions(target, values) { var oldOpts = target.options; var newOpts = values.options; - if (!oldOpts || !newOpts || newOpts.$shared) { + if (!oldOpts || !newOpts) { return; } - if (oldOpts.$shared) { + if (oldOpts.$shared && !newOpts.$shared) { target.options = _extends({}, oldOpts, newOpts, { $shared: false }); @@ -3291,7 +3568,10 @@ var Animations = function () { if (!animatedProps.has(prop)) { animatedProps.set(prop, _extends({}, animDefaults, cfg)); } else if (prop === key) { - animatedProps.set(prop, _extends({}, animatedProps.get(prop), cfg)); + var _animatedProps$get = animatedProps.get(prop), + properties = _animatedProps$get.properties, + inherited = _objectWithoutPropertiesLoose(_animatedProps$get, ["properties"]); + animatedProps.set(prop, _extends({}, inherited, cfg)); } }); }); @@ -3299,21 +3579,15 @@ var Animations = function () { ; _proto._animateOptions = function _animateOptions(target, values) { var newOptions = values.options; - var animations = []; - if (!newOptions) { - return animations; - } - var options = target.options; - if (options) { - if (options.$shared) { - target.options = options = _extends({}, options, { - $shared: false, - $animations: {} - }); - } - animations = this._createAnimations(options, newOptions); - } else { - target.options = newOptions; + var options = resolveTargetOptions(target, newOptions); + if (!options) { + return []; + } + var animations = this._createAnimations(options, newOptions); + if (newOptions.$shared && !options.$shared) { + awaitAll(target.$animations, newOptions).then(function () { + target.options = newOptions; + }); } return animations; } @@ -3369,6 +3643,34 @@ var Animations = function () { }; return Animations; }(); +function awaitAll(animations, properties) { + var running = []; + var keys = Object.keys(properties); + for (var i = 0; i < keys.length; i++) { + var anim = animations[keys[i]]; + if (anim && anim.active()) { + running.push(anim.wait()); + } + } + return Promise.all(running); +} +function resolveTargetOptions(target, newOptions) { + if (!newOptions) { + return; + } + var options = target.options; + if (!options) { + target.options = newOptions; + return; + } + if (options.$shared && !newOptions.$shared) { + target.options = options = _extends({}, options, { + $shared: false, + $animations: {} + }); + } + return options; +} var PI$1 = Math.PI; var TAU = 2 * PI$1; @@ -3635,6 +3937,9 @@ function optionKeys(optionNames) { function optionKey(key, active) { return active ? 'hover' + _capitalize(key) : key; } +function isDirectUpdateMode(mode) { + return mode === 'reset' || mode === 'none'; +} var DatasetController = function () { function DatasetController(chart, datasetIndex) { this.chart = chart; @@ -3648,6 +3953,8 @@ var DatasetController = function () { this._parsing = false; this._data = undefined; this._objectData = undefined; + this._sharedOptions = undefined; + this.enableOptionSharing = false; this.initialize(); } var _proto = DatasetController.prototype; @@ -3973,7 +4280,7 @@ var DatasetController = function () { me.configure(); me._cachedAnimations = {}; me._cachedDataOpts = {}; - me.update(mode); + me.update(mode || 'default'); meta._clip = toClip(valueOrDefault(me._config.clip, defaultClip(meta.xScale, meta.yScale, me.getMaxOverflow()))); } ; @@ -4051,9 +4358,11 @@ var DatasetController = function () { } ; _proto.resolveDataElementOptions = function resolveDataElementOptions(index, mode) { + mode = mode || 'default'; var me = this; var active = mode === 'active'; var cached = me._cachedDataOpts; + var sharing = me.enableOptionSharing; if (cached[mode]) { return cached[mode]; } @@ -4067,8 +4376,8 @@ var DatasetController = function () { type: me.dataElementType.id }); if (info.cacheable) { - values.$shared = true; - cached[mode] = values; + values.$shared = sharing; + cached[mode] = sharing ? Object.freeze(values) : values; } return values; } @@ -4120,43 +4429,40 @@ var DatasetController = function () { return animations; } ; - _proto.getSharedOptions = function getSharedOptions(mode, el, options) { - if (!mode) { - this._sharedOptions = options && options.$shared; - } - if (mode !== 'reset' && options && options.$shared && el && el.options && el.options.$shared) { - return { - target: el.options, - options: options - }; + _proto.getSharedOptions = function getSharedOptions(options) { + if (!options.$shared) { + return; } + return this._sharedOptions || (this._sharedOptions = _extends({}, options)); } ; _proto.includeOptions = function includeOptions(mode, sharedOptions) { - if (mode === 'hide' || mode === 'show') { - return true; - } - return mode !== 'resize' && !sharedOptions; + return !sharedOptions || isDirectUpdateMode(mode); } ; _proto.updateElement = function updateElement(element, index, properties, mode) { - if (mode === 'reset' || mode === 'none') { + if (isDirectUpdateMode(mode)) { _extends(element, properties); } else { this._resolveAnimations(index, mode).update(element, properties); } } ; - _proto.updateSharedOptions = function updateSharedOptions(sharedOptions, mode) { + _proto.updateSharedOptions = function updateSharedOptions(sharedOptions, mode, newOptions) { if (sharedOptions) { - this._resolveAnimations(undefined, mode).update(sharedOptions.target, sharedOptions.options); + this._resolveAnimations(undefined, mode).update({ + options: sharedOptions + }, { + options: newOptions + }); } } ; _proto._setStyle = function _setStyle(element, index, mode, active) { element.active = active; + var options = this.getStyle(index, active); this._resolveAnimations(index, mode, active).update(element, { - options: this.getStyle(index, active) + options: this.getSharedOptions(options) || options }); }; _proto.removeHoverStyle = function removeHoverStyle(element, datasetIndex, index) { @@ -4422,11 +4728,11 @@ function garbageCollect(caches, length) { function getTickMarkLength(options) { return options.drawTicks ? options.tickMarkLength : 0; } -function getScaleLabelHeight(options) { +function getScaleLabelHeight(options, fallback) { if (!options.display) { return 0; } - var font = toFont(options.font); + var font = toFont(options.font, fallback); var padding = toPadding(options.padding); return font.lineHeight + padding.height; } @@ -4779,7 +5085,7 @@ var Scale = function (_Element) { tickWidth = options.offset ? me.maxWidth / numTicks : maxWidth / (numTicks - 1); if (maxLabelWidth + 6 > tickWidth) { tickWidth = maxWidth / (numTicks - (options.offset ? 0.5 : 1)); - maxHeight = me.maxHeight - getTickMarkLength(options.gridLines) - tickOpts.padding - getScaleLabelHeight(options.scaleLabel); + maxHeight = me.maxHeight - getTickMarkLength(options.gridLines) - tickOpts.padding - getScaleLabelHeight(options.scaleLabel, me.chart.options.font); maxLabelDiagonal = Math.sqrt(maxLabelWidth * maxLabelWidth + maxLabelHeight * maxLabelHeight); labelRotation = toDegrees(Math.min(Math.asin(Math.min((labelSizes.highest.height + 6) / tickWidth, 1)), Math.asin(Math.min(maxHeight / maxLabelDiagonal, 1)) - Math.asin(maxLabelHeight / maxLabelDiagonal))); labelRotation = Math.max(minRotation, Math.min(maxRotation, labelRotation)); @@ -4807,15 +5113,16 @@ var Scale = function (_Element) { var display = me._isVisible(); var labelsBelowTicks = opts.position !== 'top' && me.axis === 'x'; var isHorizontal = me.isHorizontal(); + var scaleLabelHeight = display && getScaleLabelHeight(scaleLabelOpts, chart.options.font); if (isHorizontal) { minSize.width = me.maxWidth; } else if (display) { - minSize.width = getTickMarkLength(gridLineOpts) + getScaleLabelHeight(scaleLabelOpts); + minSize.width = getTickMarkLength(gridLineOpts) + scaleLabelHeight; } if (!isHorizontal) { minSize.height = me.maxHeight; } else if (display) { - minSize.height = getTickMarkLength(gridLineOpts) + getScaleLabelHeight(scaleLabelOpts); + minSize.height = getTickMarkLength(gridLineOpts) + scaleLabelHeight; } if (tickOpts.display && display && me.ticks.length) { var labelSizes = me._getLabelSizes(); @@ -5367,7 +5674,7 @@ var Scale = function (_Element) { if (!scaleLabel.display) { return; } - var scaleLabelFont = toFont(scaleLabel.font); + var scaleLabelFont = toFont(scaleLabel.font, me.chart.options.font); var scaleLabelPadding = toPadding(scaleLabel.padding); var halfLineHeight = scaleLabelFont.lineHeight / 2; var scaleLabelAlign = scaleLabel.align; @@ -5473,15 +5780,16 @@ var Scale = function (_Element) { ; _proto._resolveTickFontOptions = function _resolveTickFontOptions(index) { var me = this; + var chart = me.chart; var options = me.options.ticks; var ticks = me.ticks || []; var context = { - chart: me.chart, + chart: chart, scale: me, tick: ticks[index], index: index }; - return toFont(resolve([options.font], context)); + return toFont(resolve([options.font], context), chart.options.font); }; return Scale; }(Element$1); @@ -5514,6 +5822,9 @@ var TypedRegistry = function () { if (id in items) { return scope; } + if (Object.keys(defaults.get(scope)).length) { + throw new Error('Can not register "' + id + '", because "defaults.' + scope + '" would collide with existing defaults'); + } items[id] = item; registerDefaults(item, scope, parentScope); return scope; @@ -5623,11 +5934,39 @@ var Registry = function () { return this._get(id, this.scales, 'scale'); } ; + _proto.removeControllers = function removeControllers() { + for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) { + args[_key7] = arguments[_key7]; + } + this._each('unregister', args, this.controllers); + } + ; + _proto.removeElements = function removeElements() { + for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) { + args[_key8] = arguments[_key8]; + } + this._each('unregister', args, this.elements); + } + ; + _proto.removePlugins = function removePlugins() { + for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) { + args[_key9] = arguments[_key9]; + } + this._each('unregister', args, this.plugins); + } + ; + _proto.removeScales = function removeScales() { + for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) { + args[_key10] = arguments[_key10]; + } + this._each('unregister', args, this.scales); + } + ; _proto._each = function _each(method, args, typedRegistry) { var me = this; [].concat(args).forEach(function (arg) { var reg = typedRegistry || me._getRegistryForType(arg); - if (reg.isForType(arg) || reg === me.plugins && arg.id) { + if (typedRegistry || reg.isForType(arg) || reg === me.plugins && arg.id) { me._exec(method, reg, arg); } else { each(arg, function (item) { @@ -5737,7 +6076,7 @@ function createDescriptors(plugins, options) { return result; } -var version = "3.0.0-alpha.2"; +var version = "3.0.0-beta"; function getIndexAxis(type, options) { var typeDefaults = defaults[type] || {}; @@ -6180,11 +6519,9 @@ var Chart = function () { me.getDatasetMeta(i).controller.buildOrUpdateElements(); } me._updateLayout(); - if (me.options.animation) { - each(newControllers, function (controller) { - controller.reset(); - }); - } + each(newControllers, function (controller) { + controller.reset(); + }); me._updateDatasets(mode); me._plugins.notify(me, 'afterUpdate'); me._layers.sort(compare2Level('z', '_idx')); @@ -6585,9 +6922,10 @@ var Chart = function () { }; return Chart; }(); -Chart.version = version; +Chart.defaults = defaults; Chart.instances = {}; Chart.registry = registry; +Chart.version = version; var invalidatePlugins = function invalidatePlugins() { return each(Chart.instances, function (chart) { return chart._plugins.invalidate(); @@ -6751,6 +7089,42 @@ splineCurveMonotone: splineCurveMonotone, _updateBezierControlPoints: _updateBezierControlPoints }); +function _pointInLine(p1, p2, t, mode) { + return { + x: p1.x + t * (p2.x - p1.x), + y: p1.y + t * (p2.y - p1.y) + }; +} +function _steppedInterpolation(p1, p2, t, mode) { + return { + x: p1.x + t * (p2.x - p1.x), + y: mode === 'middle' ? t < 0.5 ? p1.y : p2.y : mode === 'after' ? t < 1 ? p1.y : p2.y : t > 0 ? p2.y : p1.y + }; +} +function _bezierInterpolation(p1, p2, t, mode) { + var cp1 = { + x: p1.controlPointNextX, + y: p1.controlPointNextY + }; + var cp2 = { + x: p2.controlPointPreviousX, + y: p2.controlPointPreviousY + }; + var a = _pointInLine(p1, cp1, t); + var b = _pointInLine(cp1, cp2, t); + var c = _pointInLine(cp2, p2, t); + var d = _pointInLine(a, b, t); + var e = _pointInLine(b, c, t); + return _pointInLine(d, e, t); +} + +var interpolation = /*#__PURE__*/Object.freeze({ +__proto__: null, +_pointInLine: _pointInLine, +_steppedInterpolation: _steppedInterpolation, +_bezierInterpolation: _bezierInterpolation +}); + var getRightToLeftAdapter = function getRightToLeftAdapter(rectX, width) { return { x: function x(_x) { @@ -6817,16 +7191,234 @@ overrideTextDirection: overrideTextDirection, restoreTextDirection: restoreTextDirection }); -var helpers = _extends({}, coreHelpers, { - canvas: canvas, +function propertyFn(property) { + if (property === 'angle') { + return { + between: _angleBetween, + compare: _angleDiff, + normalize: _normalizeAngle + }; + } + return { + between: function between(n, s, e) { + return n >= s && n <= e; + }, + compare: function compare(a, b) { + return a - b; + }, + normalize: function normalize(x) { + return x; + } + }; +} +function makeSubSegment(start, end, loop, count) { + return { + start: start % count, + end: end % count, + loop: loop && (end - start + 1) % count === 0 + }; +} +function getSegment(segment, points, bounds) { + var property = bounds.property, + startBound = bounds.start, + endBound = bounds.end; + var _propertyFn = propertyFn(property), + between = _propertyFn.between, + normalize = _propertyFn.normalize; + var count = points.length; + var start = segment.start, + end = segment.end, + loop = segment.loop; + var i, ilen; + if (loop) { + start += count; + end += count; + for (i = 0, ilen = count; i < ilen; ++i) { + if (!between(normalize(points[start % count][property]), startBound, endBound)) { + break; + } + start--; + end--; + } + start %= count; + end %= count; + } + if (end < start) { + end += count; + } + return { + start: start, + end: end, + loop: loop + }; +} +function _boundSegment(segment, points, bounds) { + if (!bounds) { + return [segment]; + } + var property = bounds.property, + startBound = bounds.start, + endBound = bounds.end; + var count = points.length; + var _propertyFn2 = propertyFn(property), + compare = _propertyFn2.compare, + between = _propertyFn2.between, + normalize = _propertyFn2.normalize; + var _getSegment = getSegment(segment, points, bounds), + start = _getSegment.start, + end = _getSegment.end, + loop = _getSegment.loop; + var result = []; + var inside = false; + var subStart = null; + var value, point, prevValue; + var startIsBefore = function startIsBefore() { + return between(startBound, prevValue, value) && compare(startBound, prevValue) !== 0; + }; + var endIsBefore = function endIsBefore() { + return compare(endBound, value) === 0 || between(endBound, prevValue, value); + }; + var shouldStart = function shouldStart() { + return inside || startIsBefore(); + }; + var shouldStop = function shouldStop() { + return !inside || endIsBefore(); + }; + for (var i = start, prev = start; i <= end; ++i) { + point = points[i % count]; + if (point.skip) { + continue; + } + value = normalize(point[property]); + inside = between(value, startBound, endBound); + if (subStart === null && shouldStart()) { + subStart = compare(value, startBound) === 0 ? i : prev; + } + if (subStart !== null && shouldStop()) { + result.push(makeSubSegment(subStart, i, loop, count)); + subStart = null; + } + prev = i; + prevValue = value; + } + if (subStart !== null) { + result.push(makeSubSegment(subStart, end, loop, count)); + } + return result; +} +function _boundSegments(line, bounds) { + var result = []; + var segments = line.segments; + for (var i = 0; i < segments.length; i++) { + var sub = _boundSegment(segments[i], line.points, bounds); + if (sub.length) { + result.push.apply(result, sub); + } + } + return result; +} +function findStartAndEnd(points, count, loop, spanGaps) { + var start = 0; + var end = count - 1; + if (loop && !spanGaps) { + while (start < count && !points[start].skip) { + start++; + } + } + while (start < count && points[start].skip) { + start++; + } + start %= count; + if (loop) { + end += start; + } + while (end > start && points[end % count].skip) { + end--; + } + end %= count; + return { + start: start, + end: end + }; +} +function solidSegments(points, start, max, loop) { + var count = points.length; + var result = []; + var last = start; + var prev = points[start]; + var end; + for (end = start + 1; end <= max; ++end) { + var cur = points[end % count]; + if (cur.skip || cur.stop) { + if (!prev.skip) { + loop = false; + result.push({ + start: start % count, + end: (end - 1) % count, + loop: loop + }); + start = last = cur.stop ? end : null; + } + } else { + last = end; + if (prev.skip) { + start = end; + } + } + prev = cur; + } + if (last !== null) { + result.push({ + start: start % count, + end: last % count, + loop: loop + }); + } + return result; +} +function _computeSegments(line) { + var points = line.points; + var spanGaps = line.options.spanGaps; + var count = points.length; + if (!count) { + return []; + } + var loop = !!line._loop; + var _findStartAndEnd = findStartAndEnd(points, count, loop, spanGaps), + start = _findStartAndEnd.start, + end = _findStartAndEnd.end; + if (spanGaps === true) { + return [{ + start: start, + end: end, + loop: loop + }]; + } + var max = end < start ? end + count : end; + var completeLoop = !!line._fullLoop && start === 0 && end === count - 1; + return solidSegments(points, start, max, completeLoop); +} + +var segment = /*#__PURE__*/Object.freeze({ +__proto__: null, +_boundSegment: _boundSegment, +_boundSegments: _boundSegments, +_computeSegments: _computeSegments +}); + +var helpers = _extends({}, coreHelpers, { + canvas: canvas, + collection: collection, curve: curve, dom: dom, easing: { effects: effects }, + interpolation: interpolation, options: options, math: math, rtl: rtl, + segment: segment, requestAnimFrame: requestAnimFrame, fontString: fontString, color: color, @@ -7033,6 +7625,7 @@ var BarController = function (_DatasetController) { }; _proto.initialize = function initialize() { var me = this; + me.enableOptionSharing = true; _DatasetController.prototype.initialize.call(this); var meta = me._cachedMeta; meta.stack = me.getDataset().stack; @@ -7050,12 +7643,12 @@ var BarController = function (_DatasetController) { var horizontal = vscale.isHorizontal(); var ruler = me._getRuler(); var firstOpts = me.resolveDataElementOptions(start, mode); - var sharedOptions = me.getSharedOptions(mode, rectangles[start], firstOpts); + var sharedOptions = me.getSharedOptions(firstOpts); var includeOptions = me.includeOptions(mode, sharedOptions); - var i; - for (i = 0; i < rectangles.length; i++) { + me.updateSharedOptions(sharedOptions, mode, firstOpts); + for (var i = 0; i < rectangles.length; i++) { var index = start + i; - var options = me.resolveDataElementOptions(index, mode); + var options = sharedOptions || me.resolveDataElementOptions(index, mode); var vpixels = me._calculateBarValuePixels(index, options); var ipixels = me._calculateBarIndexPixels(index, ruler, options); var properties = { @@ -7071,7 +7664,6 @@ var BarController = function (_DatasetController) { } me.updateElement(rectangles[i], index, properties, mode); } - me.updateSharedOptions(sharedOptions, mode); } ; _proto._getStacks = function _getStacks(last) { @@ -7239,6 +7831,11 @@ var BubbleController = function (_DatasetController) { return _DatasetController.apply(this, arguments) || this; } var _proto = BubbleController.prototype; + _proto.initialize = function initialize() { + this.enableOptionSharing = true; + _DatasetController.prototype.initialize.call(this); + } + ; _proto.parseObjectData = function parseObjectData(meta, data, start, count) { var xScale = meta.xScale, yScale = meta.yScale; @@ -7297,7 +7894,7 @@ var BubbleController = function (_DatasetController) { xScale = _me$_cachedMeta.xScale, yScale = _me$_cachedMeta.yScale; var firstOpts = me.resolveDataElementOptions(start, mode); - var sharedOptions = me.getSharedOptions(mode, points[start], firstOpts); + var sharedOptions = me.getSharedOptions(firstOpts); var includeOptions = me.includeOptions(mode, sharedOptions); for (var i = 0; i < points.length; i++) { var point = points[i]; @@ -7318,7 +7915,7 @@ var BubbleController = function (_DatasetController) { } me.updateElement(point, index, properties, mode); } - me.updateSharedOptions(sharedOptions, mode); + me.updateSharedOptions(sharedOptions, mode, firstOpts); } ; _proto.resolveDataElementOptions = function resolveDataElementOptions(index, mode) { @@ -7415,6 +8012,7 @@ var DoughnutController = function (_DatasetController) { function DoughnutController(chart, datasetIndex) { var _this; _this = _DatasetController.call(this, chart, datasetIndex) || this; + _this.enableOptionSharing = true; _this.innerRadius = undefined; _this.outerRadius = undefined; _this.offsetX = undefined; @@ -7457,9 +8055,9 @@ var DoughnutController = function (_DatasetController) { ratioY = _getRatioAndOffset.ratioY, offsetX = _getRatioAndOffset.offsetX, offsetY = _getRatioAndOffset.offsetY; - var borderWidth = me.getMaxBorderWidth(); - var maxWidth = (chartArea.right - chartArea.left - borderWidth) / ratioX; - var maxHeight = (chartArea.bottom - chartArea.top - borderWidth) / ratioY; + var spacing = me.getMaxBorderWidth() + me.getMaxOffset(arcs); + var maxWidth = (chartArea.right - chartArea.left - spacing) / ratioX; + var maxHeight = (chartArea.bottom - chartArea.top - spacing) / ratioY; var outerRadius = Math.max(Math.min(maxWidth, maxHeight) / 2, 0); var innerRadius = Math.max(outerRadius * cutout, 0); var radiusLength = (outerRadius - innerRadius) / me._getVisibleDatasetWeightTotal(); @@ -7490,7 +8088,7 @@ var DoughnutController = function (_DatasetController) { var innerRadius = animateScale ? 0 : me.innerRadius; var outerRadius = animateScale ? 0 : me.outerRadius; var firstOpts = me.resolveDataElementOptions(start, mode); - var sharedOptions = me.getSharedOptions(mode, arcs[start], firstOpts); + var sharedOptions = me.getSharedOptions(firstOpts); var includeOptions = me.includeOptions(mode, sharedOptions); var startAngle = opts.rotation; var i; @@ -7511,12 +8109,12 @@ var DoughnutController = function (_DatasetController) { innerRadius: innerRadius }; if (includeOptions) { - properties.options = me.resolveDataElementOptions(index, mode); + properties.options = sharedOptions || me.resolveDataElementOptions(index, mode); } startAngle += circumference; me.updateElement(arc, index, properties, mode); } - me.updateSharedOptions(sharedOptions, mode); + me.updateSharedOptions(sharedOptions, mode, firstOpts); }; _proto.calculateTotal = function calculateTotal() { var meta = this._cachedMeta; @@ -7538,6 +8136,16 @@ var DoughnutController = function (_DatasetController) { } return 0; }; + _proto.getLabelAndValue = function getLabelAndValue(index) { + var me = this; + var meta = me._cachedMeta; + var chart = me.chart; + var labels = chart.data.labels || []; + return { + label: labels[index] || '', + value: meta._parsed[index] + }; + }; _proto.getMaxBorderWidth = function getMaxBorderWidth(arcs) { var me = this; var max = 0; @@ -7566,6 +8174,14 @@ var DoughnutController = function (_DatasetController) { } } return max; + }; + _proto.getMaxOffset = function getMaxOffset(arcs) { + var max = 0; + for (var i = 0, ilen = arcs.length; i < ilen; ++i) { + var options = this.resolveDataElementOptions(i); + max = Math.max(max, options.offset || 0, options.hoverOffset || 0); + } + return max; } ; _proto._getRingWeightOffset = function _getRingWeightOffset(datasetIndex) { @@ -7591,11 +8207,11 @@ DoughnutController.id = 'doughnut'; DoughnutController.defaults = { datasetElementType: false, dataElementType: 'arc', - dataElementOptions: ['backgroundColor', 'borderColor', 'borderWidth', 'borderAlign', 'hoverBackgroundColor', 'hoverBorderColor', 'hoverBorderWidth'], + dataElementOptions: ['backgroundColor', 'borderColor', 'borderWidth', 'borderAlign', 'offset'], animation: { numbers: { type: 'number', - properties: ['circumference', 'endAngle', 'innerRadius', 'outerRadius', 'startAngle', 'x', 'y'] + properties: ['circumference', 'endAngle', 'innerRadius', 'outerRadius', 'startAngle', 'x', 'y', 'offset', 'borderWidth'] }, animateRotate: true, animateScale: false @@ -7636,8 +8252,8 @@ DoughnutController.defaults = { return ''; }, label: function label(tooltipItem) { - var dataLabel = tooltipItem.chart.data.labels[tooltipItem.dataIndex]; - var value = ': ' + tooltipItem.dataset.data[tooltipItem.dataIndex]; + var dataLabel = tooltipItem.label; + var value = ': ' + tooltipItem.formattedValue; if (isArray(dataLabel)) { dataLabel = dataLabel.slice(); dataLabel[0] += value; @@ -7656,6 +8272,10 @@ var LineController = function (_DatasetController) { return _DatasetController.apply(this, arguments) || this; } var _proto = LineController.prototype; + _proto.initialize = function initialize() { + this.enableOptionSharing = true; + _DatasetController.prototype.initialize.call(this); + }; _proto.update = function update(mode) { var me = this; var meta = me._cachedMeta; @@ -7678,7 +8298,7 @@ var LineController = function (_DatasetController) { yScale = _me$_cachedMeta.yScale, _stacked = _me$_cachedMeta._stacked; var firstOpts = me.resolveDataElementOptions(start, mode); - var sharedOptions = me.getSharedOptions(mode, points[start], firstOpts); + var sharedOptions = me.getSharedOptions(firstOpts); var includeOptions = me.includeOptions(mode, sharedOptions); var spanGaps = valueOrDefault(me._config.spanGaps, me.chart.options.spanGaps); var maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY; @@ -7696,12 +8316,12 @@ var LineController = function (_DatasetController) { stop: i > 0 && parsed.x - prevParsed.x > maxGapLength }; if (includeOptions) { - properties.options = me.resolveDataElementOptions(index, mode); + properties.options = sharedOptions || me.resolveDataElementOptions(index, mode); } me.updateElement(point, index, properties, mode); prevParsed = parsed; } - me.updateSharedOptions(sharedOptions, mode); + me.updateSharedOptions(sharedOptions, mode, firstOpts); } ; _proto.resolveDatasetElementOptions = function resolveDatasetElementOptions(active) { @@ -7732,6 +8352,10 @@ var LineController = function (_DatasetController) { var lastPoint = data[data.length - 1].size(); return Math.max(border, firstPoint, lastPoint) / 2; }; + _proto.draw = function draw() { + this._cachedMeta.dataset.updateControlPoints(this.chart.chartArea); + _DatasetController.prototype.draw.call(this); + }; return LineController; }(DatasetController); LineController.id = 'line'; @@ -7879,7 +8503,7 @@ var PolarAreaController = function (_DatasetController) { PolarAreaController.id = 'polarArea'; PolarAreaController.defaults = { dataElementType: 'arc', - dataElementOptions: ['backgroundColor', 'borderColor', 'borderWidth', 'borderAlign', 'hoverBackgroundColor', 'hoverBorderColor', 'hoverBorderWidth'], + dataElementOptions: ['backgroundColor', 'borderColor', 'borderWidth', 'borderAlign', 'offset'], animation: { numbers: { type: 'number', @@ -8111,68 +8735,93 @@ ScatterController: ScatterController }); var TAU$1 = Math.PI * 2; -function clipArc(ctx, model) { - var startAngle = model.startAngle, - endAngle = model.endAngle, - pixelMargin = model.pixelMargin, - x = model.x, - y = model.y; - var angleMargin = pixelMargin / model.outerRadius; +function clipArc(ctx, element) { + var startAngle = element.startAngle, + endAngle = element.endAngle, + pixelMargin = element.pixelMargin, + x = element.x, + y = element.y, + outerRadius = element.outerRadius, + innerRadius = element.innerRadius; + var angleMargin = pixelMargin / outerRadius; ctx.beginPath(); - ctx.arc(x, y, model.outerRadius, startAngle - angleMargin, endAngle + angleMargin); - if (model.innerRadius > pixelMargin) { - angleMargin = pixelMargin / model.innerRadius; - ctx.arc(x, y, model.innerRadius - pixelMargin, endAngle + angleMargin, startAngle - angleMargin, true); + ctx.arc(x, y, outerRadius, startAngle - angleMargin, endAngle + angleMargin); + if (innerRadius > pixelMargin) { + angleMargin = pixelMargin / innerRadius; + ctx.arc(x, y, innerRadius, endAngle + angleMargin, startAngle - angleMargin, true); } else { ctx.arc(x, y, pixelMargin, endAngle + Math.PI / 2, startAngle - Math.PI / 2); } ctx.closePath(); ctx.clip(); } -function pathArc(ctx, model) { +function pathArc(ctx, element) { + var x = element.x, + y = element.y, + startAngle = element.startAngle, + endAngle = element.endAngle, + pixelMargin = element.pixelMargin; + var outerRadius = Math.max(element.outerRadius - pixelMargin, 0); + var innerRadius = element.innerRadius + pixelMargin; ctx.beginPath(); - ctx.arc(model.x, model.y, model.outerRadius, model.startAngle, model.endAngle); - ctx.arc(model.x, model.y, model.innerRadius, model.endAngle, model.startAngle, true); + ctx.arc(x, y, outerRadius, startAngle, endAngle); + ctx.arc(x, y, innerRadius, endAngle, startAngle, true); ctx.closePath(); } -function drawArc(ctx, model, circumference) { - if (model.fullCircles) { - model.endAngle = model.startAngle + TAU$1; - pathArc(ctx, model); - for (var i = 0; i < model.fullCircles; ++i) { +function drawArc(ctx, element) { + if (element.fullCircles) { + element.endAngle = element.startAngle + TAU$1; + pathArc(ctx, element); + for (var i = 0; i < element.fullCircles; ++i) { ctx.fill(); } - model.endAngle = model.startAngle + circumference % TAU$1; + element.endAngle = element.startAngle + element.circumference % TAU$1; } - pathArc(ctx, model); + pathArc(ctx, element); ctx.fill(); } -function drawFullCircleBorders(ctx, element, model, inner) { - var endAngle = model.endAngle; +function drawFullCircleBorders(ctx, element, inner) { + var x = element.x, + y = element.y, + startAngle = element.startAngle, + endAngle = element.endAngle, + pixelMargin = element.pixelMargin; + var outerRadius = Math.max(element.outerRadius - pixelMargin, 0); + var innerRadius = element.innerRadius + pixelMargin; var i; if (inner) { - model.endAngle = model.startAngle + TAU$1; - clipArc(ctx, model); - model.endAngle = endAngle; - if (model.endAngle === model.startAngle && model.fullCircles) { - model.endAngle += TAU$1; - model.fullCircles--; + element.endAngle = element.startAngle + TAU$1; + clipArc(ctx, element); + element.endAngle = endAngle; + if (element.endAngle === element.startAngle) { + element.endAngle += TAU$1; + element.fullCircles--; } } ctx.beginPath(); - ctx.arc(model.x, model.y, model.innerRadius, model.startAngle + TAU$1, model.startAngle, true); - for (i = 0; i < model.fullCircles; ++i) { + ctx.arc(x, y, innerRadius, startAngle + TAU$1, startAngle, true); + for (i = 0; i < element.fullCircles; ++i) { ctx.stroke(); } ctx.beginPath(); - ctx.arc(model.x, model.y, element.outerRadius, model.startAngle, model.startAngle + TAU$1); - for (i = 0; i < model.fullCircles; ++i) { + ctx.arc(x, y, outerRadius, startAngle, startAngle + TAU$1); + for (i = 0; i < element.fullCircles; ++i) { ctx.stroke(); } } -function drawBorder(ctx, element, model) { - var options = element.options; +function drawBorder(ctx, element) { + var x = element.x, + y = element.y, + startAngle = element.startAngle, + endAngle = element.endAngle, + pixelMargin = element.pixelMargin, + options = element.options; + var outerRadius = element.outerRadius; + var innerRadius = element.innerRadius + pixelMargin; var inner = options.borderAlign === 'inner'; + if (!options.borderWidth) { + return; + } if (inner) { ctx.lineWidth = options.borderWidth * 2; ctx.lineJoin = 'round'; @@ -8180,15 +8829,15 @@ function drawBorder(ctx, element, model) { ctx.lineWidth = options.borderWidth; ctx.lineJoin = 'bevel'; } - if (model.fullCircles) { - drawFullCircleBorders(ctx, element, model, inner); + if (element.fullCircles) { + drawFullCircleBorders(ctx, element, inner); } if (inner) { - clipArc(ctx, model); + clipArc(ctx, element); } ctx.beginPath(); - ctx.arc(model.x, model.y, element.outerRadius, model.startAngle, model.endAngle); - ctx.arc(model.x, model.y, model.innerRadius, model.endAngle, model.startAngle, true); + ctx.arc(x, y, outerRadius, startAngle, endAngle); + ctx.arc(x, y, innerRadius, endAngle, startAngle, true); ctx.closePath(); ctx.stroke(); } @@ -8203,6 +8852,8 @@ var Arc = function (_Element) { _this.endAngle = undefined; _this.innerRadius = undefined; _this.outerRadius = undefined; + _this.pixelMargin = 0; + _this.fullCircles = 0; if (cfg) { _extends(_assertThisInitialized(_this), cfg); } @@ -8250,27 +8901,21 @@ var Arc = function (_Element) { _proto.draw = function draw(ctx) { var me = this; var options = me.options; - var pixelMargin = options.borderAlign === 'inner' ? 0.33 : 0; - var model = { - x: me.x, - y: me.y, - innerRadius: me.innerRadius, - outerRadius: Math.max(me.outerRadius - pixelMargin, 0), - pixelMargin: pixelMargin, - startAngle: me.startAngle, - endAngle: me.endAngle, - fullCircles: Math.floor(me.circumference / TAU$1) - }; + var offset = options.offset || 0; + me.pixelMargin = options.borderAlign === 'inner' ? 0.33 : 0; + me.fullCircles = Math.floor(me.circumference / TAU$1); if (me.circumference === 0) { return; } ctx.save(); + if (offset && me.circumference < TAU$1) { + var halfAngle = (me.startAngle + me.endAngle) / 2; + ctx.translate(Math.cos(halfAngle) * offset, Math.sin(halfAngle) * offset); + } ctx.fillStyle = options.backgroundColor; ctx.strokeStyle = options.borderColor; - drawArc(ctx, model, me.circumference); - if (options.borderWidth) { - drawBorder(ctx, me, model); - } + drawArc(ctx, me); + drawBorder(ctx, me); ctx.restore(); }; return Arc; @@ -8279,236 +8924,13 @@ Arc.id = 'arc'; Arc.defaults = { borderAlign: 'center', borderColor: '#fff', - borderWidth: 2 + borderWidth: 2, + offset: 0 }; Arc.defaultRoutes = { backgroundColor: 'color' }; -function _pointInLine(p1, p2, t, mode) { - return { - x: p1.x + t * (p2.x - p1.x), - y: p1.y + t * (p2.y - p1.y) - }; -} -function _steppedInterpolation(p1, p2, t, mode) { - return { - x: p1.x + t * (p2.x - p1.x), - y: mode === 'middle' ? t < 0.5 ? p1.y : p2.y : mode === 'after' ? t < 1 ? p1.y : p2.y : t > 0 ? p2.y : p1.y - }; -} -function _bezierInterpolation(p1, p2, t, mode) { - var cp1 = { - x: p1.controlPointNextX, - y: p1.controlPointNextY - }; - var cp2 = { - x: p2.controlPointPreviousX, - y: p2.controlPointPreviousY - }; - var a = _pointInLine(p1, cp1, t); - var b = _pointInLine(cp1, cp2, t); - var c = _pointInLine(cp2, p2, t); - var d = _pointInLine(a, b, t); - var e = _pointInLine(b, c, t); - return _pointInLine(d, e, t); -} - -function propertyFn(property) { - if (property === 'angle') { - return { - between: _angleBetween, - compare: _angleDiff, - normalize: _normalizeAngle - }; - } - return { - between: function between(n, s, e) { - return n >= s && n <= e; - }, - compare: function compare(a, b) { - return a - b; - }, - normalize: function normalize(x) { - return x; - } - }; -} -function makeSubSegment(start, end, loop, count) { - return { - start: start % count, - end: end % count, - loop: loop && (end - start + 1) % count === 0 - }; -} -function getSegment(segment, points, bounds) { - var property = bounds.property, - startBound = bounds.start, - endBound = bounds.end; - var _propertyFn = propertyFn(property), - between = _propertyFn.between, - normalize = _propertyFn.normalize; - var count = points.length; - var start = segment.start, - end = segment.end, - loop = segment.loop; - var i, ilen; - if (loop) { - start += count; - end += count; - for (i = 0, ilen = count; i < ilen; ++i) { - if (!between(normalize(points[start % count][property]), startBound, endBound)) { - break; - } - start--; - end--; - } - start %= count; - end %= count; - } - if (end < start) { - end += count; - } - return { - start: start, - end: end, - loop: loop - }; -} -function _boundSegment(segment, points, bounds) { - if (!bounds) { - return [segment]; - } - var property = bounds.property, - startBound = bounds.start, - endBound = bounds.end; - var count = points.length; - var _propertyFn2 = propertyFn(property), - compare = _propertyFn2.compare, - between = _propertyFn2.between, - normalize = _propertyFn2.normalize; - var _getSegment = getSegment(segment, points, bounds), - start = _getSegment.start, - end = _getSegment.end, - loop = _getSegment.loop; - var result = []; - var inside = false; - var subStart = null; - var i, value, point, prev; - for (i = start; i <= end; ++i) { - point = points[i % count]; - if (point.skip) { - continue; - } - value = normalize(point[property]); - inside = between(value, startBound, endBound); - if (subStart === null && inside) { - subStart = i > start && compare(value, startBound) > 0 ? prev : i; - } - if (subStart !== null && (!inside || compare(value, endBound) === 0)) { - result.push(makeSubSegment(subStart, i, loop, count)); - subStart = null; - } - prev = i; - } - if (subStart !== null) { - result.push(makeSubSegment(subStart, end, loop, count)); - } - return result; -} -function _boundSegments(line, bounds) { - var result = []; - var segments = line.segments; - for (var i = 0; i < segments.length; i++) { - var sub = _boundSegment(segments[i], line.points, bounds); - if (sub.length) { - result.push.apply(result, sub); - } - } - return result; -} -function findStartAndEnd(points, count, loop, spanGaps) { - var start = 0; - var end = count - 1; - if (loop && !spanGaps) { - while (start < count && !points[start].skip) { - start++; - } - } - while (start < count && points[start].skip) { - start++; - } - start %= count; - if (loop) { - end += start; - } - while (end > start && points[end % count].skip) { - end--; - } - end %= count; - return { - start: start, - end: end - }; -} -function solidSegments(points, start, max, loop) { - var count = points.length; - var result = []; - var last = start; - var prev = points[start]; - var end; - for (end = start + 1; end <= max; ++end) { - var cur = points[end % count]; - if (cur.skip || cur.stop) { - if (!prev.skip) { - loop = false; - result.push({ - start: start % count, - end: (end - 1) % count, - loop: loop - }); - start = last = cur.stop ? end : null; - } - } else { - last = end; - if (prev.skip) { - start = end; - } - } - prev = cur; - } - if (last !== null) { - result.push({ - start: start % count, - end: last % count, - loop: loop - }); - } - return result; -} -function _computeSegments(line) { - var points = line.points; - var spanGaps = line.options.spanGaps; - var count = points.length; - if (!count) { - return []; - } - var loop = !!line._loop; - var _findStartAndEnd = findStartAndEnd(points, count, loop, spanGaps), - start = _findStartAndEnd.start, - end = _findStartAndEnd.end; - if (spanGaps === true) { - return [{ - start: start, - end: end, - loop: loop - }]; - } - var max = end < start ? end + count : end; - var completeLoop = !!line._fullLoop && start === 0 && end === count - 1; - return solidSegments(points, start, max, completeLoop); -} - function setStyle(ctx, vm) { ctx.lineCap = vm.borderCapStyle; ctx.setLineDash(vm.borderDash); @@ -8639,6 +9061,7 @@ var Line = function (_Element) { _this._fullLoop = undefined; _this._points = undefined; _this._segments = undefined; + _this._pointsUpdated = false; if (cfg) { _extends(_assertThisInitialized(_this), cfg); } @@ -8648,9 +9071,10 @@ var Line = function (_Element) { _proto.updateControlPoints = function updateControlPoints(chartArea) { var me = this; var options = me.options; - if (options.tension && !options.stepped) { + if (options.tension && !options.stepped && !me._pointsUpdated) { var loop = options.spanGaps ? me._loop : me._fullLoop; _updateBezierControlPoints(me._points, options, chartArea, loop); + me._pointsUpdated = true; } }; _proto.first = function first() { @@ -8731,6 +9155,7 @@ var Line = function (_Element) { } ctx.stroke(); ctx.restore(); + this._pointsUpdated = false; }; _createClass(Line, [{ key: "points", @@ -9056,7 +9481,7 @@ function decodeFill(line, index, count) { } return target; } - return ['origin', 'start', 'end'].indexOf(fill) >= 0 ? fill : false; + return ['origin', 'start', 'end', 'stack'].indexOf(fill) >= 0 && fill; } function computeLinearBoundary(source) { var _source$scale = source.scale, @@ -9161,33 +9586,114 @@ function pointsFromSegments(boundary, line) { if (y !== null) { points.push({ x: first.x, - y: y, - _prop: 'x', - _ref: first + y: y }); points.push({ x: last.x, - y: y, - _prop: 'x', - _ref: last + y: y }); } else if (x !== null) { points.push({ x: x, - y: first.y, - _prop: 'y', - _ref: first + y: first.y }); points.push({ x: x, - y: last.y, - _prop: 'y', - _ref: last + y: last.y }); } }); return points; } +function buildStackLine(source) { + var chart = source.chart, + scale = source.scale, + index = source.index, + line = source.line; + var points = []; + var segments = line.segments; + var sourcePoints = line.points; + var linesBelow = getLinesBelow(chart, index); + linesBelow.push(createBoundaryLine({ + x: null, + y: scale.bottom + }, line)); + for (var i = 0; i < segments.length; i++) { + var segment = segments[i]; + for (var j = segment.start; j <= segment.end; j++) { + addPointsBelow(points, sourcePoints[j], linesBelow); + } + } + return new Line({ + points: points, + options: {} + }); +} +var isLineAndNotInHideAnimation = function isLineAndNotInHideAnimation(meta) { + return meta.type === 'line' && !meta.hidden; +}; +function getLinesBelow(chart, index) { + var below = []; + var metas = chart.getSortedVisibleDatasetMetas(); + for (var i = 0; i < metas.length; i++) { + var meta = metas[i]; + if (meta.index === index) { + break; + } + if (isLineAndNotInHideAnimation(meta)) { + below.unshift(meta.dataset); + } + } + return below; +} +function addPointsBelow(points, sourcePoint, linesBelow) { + var postponed = []; + for (var j = 0; j < linesBelow.length; j++) { + var line = linesBelow[j]; + var _findPoint = findPoint(line, sourcePoint, 'x'), + first = _findPoint.first, + last = _findPoint.last, + point = _findPoint.point; + if (!point || first && last) { + continue; + } + if (first) { + postponed.unshift(point); + } else { + points.push(point); + if (!last) { + break; + } + } + } + points.push.apply(points, postponed); +} +function findPoint(line, sourcePoint, property) { + var point = line.interpolate(sourcePoint, property); + if (!point) { + return {}; + } + var pointValue = point[property]; + var segments = line.segments; + var linePoints = line.points; + var first = false; + var last = false; + for (var i = 0; i < segments.length; i++) { + var segment = segments[i]; + var firstValue = linePoints[segment.start][property]; + var lastValue = linePoints[segment.end][property]; + if (pointValue >= firstValue && pointValue <= lastValue) { + first = pointValue === firstValue; + last = pointValue === lastValue; + break; + } + } + return { + first: first, + last: last, + point: point + }; +} function getTarget(source) { var chart = source.chart, fill = source.fill, @@ -9195,19 +9701,23 @@ function getTarget(source) { if (isNumberFinite(fill)) { return getLineByIndex(chart, fill); } + if (fill === 'stack') { + return buildStackLine(source); + } var boundary = computeBoundary(source); - var points = []; - var _loop = false; - var _refPoints = false; if (boundary instanceof simpleArc) { return boundary; } + return createBoundaryLine(boundary, line); +} +function createBoundaryLine(boundary, line) { + var points = []; + var _loop = false; if (isArray(boundary)) { _loop = true; points = boundary; } else { points = pointsFromSegments(boundary, line); - _refPoints = true; } return points.length ? new Line({ points: points, @@ -9215,8 +9725,7 @@ function getTarget(source) { tension: 0 }, _loop: _loop, - _fullLoop: _loop, - _refPoints: _refPoints + _fullLoop: _loop }) : null; } function resolveTarget(sources, index, propagate) { @@ -9278,17 +9787,8 @@ function _segments(line, target, property) { var points = line.points; var tpoints = target.points; var parts = []; - if (target._refPoints) { - for (var i = 0, ilen = tpoints.length; i < ilen; ++i) { - var point = tpoints[i]; - var prop = point._prop; - if (prop) { - point[prop] = point._ref[prop]; - } - } - } - for (var _i = 0; _i < segments.length; _i++) { - var segment = segments[_i]; + for (var i = 0; i < segments.length; i++) { + var segment = segments[i]; var bounds = getBounds(property, points[segment.start], points[segment.end], segment.loop); if (!target.segments) { parts.push({ @@ -9343,7 +9843,7 @@ function _fill(ctx, cfg) { property = cfg.property, color = cfg.color, scale = cfg.scale; - var segments = _segments(cfg.line, cfg.target, property); + var segments = _segments(line, target, property); ctx.fillStyle = color; for (var i = 0, ilen = segments.length; i < ilen; ++i) { var _segments$i = segments[i], @@ -9418,11 +9918,11 @@ var plugin_filler = { if (line && line.options && line instanceof Line) { source = { visible: chart.isDatasetVisible(i), + index: i, fill: decodeFill(line, i, count), chart: chart, scale: meta.vScale, - line: line, - target: undefined + line: line }; } meta.$filler = source; @@ -9434,7 +9934,6 @@ var plugin_filler = { continue; } source.fill = resolveTarget(sources, i, propagate); - source.target = source.fill !== false && getTarget(source); } }, beforeDatasetsDraw: function beforeDatasetsDraw(chart) { @@ -9451,13 +9950,13 @@ var plugin_filler = { beforeDatasetDraw: function beforeDatasetDraw(chart, args) { var area = chart.chartArea; var ctx = chart.ctx; - var meta = args.meta.$filler; - if (!meta || meta.fill === false) { + var source = args.meta.$filler; + if (!source || source.fill === false) { return; } - var line = meta.line, - target = meta.target, - scale = meta.scale; + var target = getTarget(source); + var line = source.line, + scale = source.scale; var lineOpts = line.options; var fillOption = lineOpts.fill; var color = lineOpts.backgroundColor; @@ -9592,7 +10091,7 @@ var Legend = function (_Element) { var labelOpts = opts.labels; var display = opts.display; var ctx = me.ctx; - var labelFont = toFont(labelOpts.font); + var labelFont = toFont(labelOpts.font, me.chart.options.font); var fontSize = labelFont.size; var boxWidth = getBoxWidth(labelOpts, fontSize); var boxHeight = getBoxHeight(labelOpts, fontSize); @@ -9678,7 +10177,6 @@ var Legend = function (_Element) { var opts = me.options; var labelOpts = opts.labels; var defaultColor = defaults.color; - var lineDefault = defaults.elements.line; var legendHeight = me.height; var columnHeights = me.columnHeights; var legendWidth = me.width; @@ -9689,7 +10187,7 @@ var Legend = function (_Element) { me.drawTitle(); var rtlHelper = getRtlAdapter(opts.rtl, me.left, me._minSize.width); var ctx = me.ctx; - var labelFont = toFont(labelOpts.font); + var labelFont = toFont(labelOpts.font, me.chart.options.font); var fontColor = labelFont.color; var fontSize = labelFont.size; var cursor; @@ -9708,15 +10206,15 @@ var Legend = function (_Element) { return; } ctx.save(); - var lineWidth = valueOrDefault(legendItem.lineWidth, lineDefault.borderWidth); + var lineWidth = valueOrDefault(legendItem.lineWidth, 1); ctx.fillStyle = valueOrDefault(legendItem.fillStyle, defaultColor); - ctx.lineCap = valueOrDefault(legendItem.lineCap, lineDefault.borderCapStyle); - ctx.lineDashOffset = valueOrDefault(legendItem.lineDashOffset, lineDefault.borderDashOffset); - ctx.lineJoin = valueOrDefault(legendItem.lineJoin, lineDefault.borderJoinStyle); + ctx.lineCap = valueOrDefault(legendItem.lineCap, 'butt'); + ctx.lineDashOffset = valueOrDefault(legendItem.lineDashOffset, 0); + ctx.lineJoin = valueOrDefault(legendItem.lineJoin, 'miter'); ctx.lineWidth = lineWidth; ctx.strokeStyle = valueOrDefault(legendItem.strokeStyle, defaultColor); if (ctx.setLineDash) { - ctx.setLineDash(valueOrDefault(legendItem.lineDash, lineDefault.borderDash)); + ctx.setLineDash(valueOrDefault(legendItem.lineDash, [])); } if (labelOpts && labelOpts.usePointStyle) { var drawOptions = { @@ -9812,7 +10310,7 @@ var Legend = function (_Element) { var me = this; var opts = me.options; var titleOpts = opts.title; - var titleFont = toFont(titleOpts.font); + var titleFont = toFont(titleOpts.font, me.chart.options.font); var titlePadding = toPadding(titleOpts.padding); if (!titleOpts.display) { return; @@ -9874,7 +10372,7 @@ var Legend = function (_Element) { ; _proto._computeTitleHeight = function _computeTitleHeight() { var titleOpts = this.options.title; - var titleFont = toFont(titleOpts.font); + var titleFont = toFont(titleOpts.font, this.chart.options.font); var titlePadding = toPadding(titleOpts.padding); return titleOpts.display ? titleFont.lineHeight + titlePadding.height : 0; } @@ -10103,7 +10601,7 @@ var Title = function (_Element) { } var lineCount = isArray(opts.text) ? opts.text.length : 1; me._padding = toPadding(opts.padding); - var textSize = lineCount * toFont(opts.font).lineHeight + me._padding.height; + var textSize = lineCount * toFont(opts.font, me.chart.options.font).lineHeight + me._padding.height; me.width = minSize.width = isHorizontal ? me.maxWidth : textSize; me.height = minSize.height = isHorizontal ? textSize : me.maxHeight; }; @@ -10121,7 +10619,7 @@ var Title = function (_Element) { if (!opts.display) { return; } - var fontOpts = toFont(opts.font); + var fontOpts = toFont(opts.font, me.chart.options.font); var lineHeight = fontOpts.lineHeight; var offset = lineHeight / 2 + me._padding.top; var rotation = 0; @@ -10322,11 +10820,11 @@ function createTooltipItem(chart, item) { element: element }; } -function resolveOptions$1(options) { +function resolveOptions$1(options, fallbackFont) { options = merge({}, [defaults.plugins.tooltip, options]); - options.bodyFont = toFont(options.bodyFont); - options.titleFont = toFont(options.titleFont); - options.footerFont = toFont(options.footerFont); + options.bodyFont = toFont(options.bodyFont, fallbackFont); + options.titleFont = toFont(options.titleFont, fallbackFont); + options.footerFont = toFont(options.footerFont, fallbackFont); options.boxHeight = valueOrDefault(options.boxHeight, options.bodyFont.size); options.boxWidth = valueOrDefault(options.boxWidth, options.bodyFont.size); return options; @@ -10540,7 +11038,8 @@ var Tooltip = function (_Element) { var _proto = Tooltip.prototype; _proto.initialize = function initialize() { var me = this; - me.options = resolveOptions$1(me._chart.options.tooltips); + var chartOpts = me._chart.options; + me.options = resolveOptions$1(chartOpts.tooltips, chartOpts.font); } ; _proto._resolveAnimations = function _resolveAnimations() { @@ -11681,7 +12180,7 @@ function fitWithPointLabels(scale) { index: i, label: scale.pointLabels[i] }; - var plFont = toFont(resolve([scale.options.pointLabels.font], context, i)); + var plFont = toFont(resolve([scale.options.pointLabels.font], context, i), scale.chart.options.font); scale.ctx.font = plFont.string; textSize = measureLabelSize(scale.ctx, plFont.lineHeight, scale.pointLabels[i]); scale._pointLabelSizes[i] = textSize; @@ -11752,7 +12251,7 @@ function drawPointLabels(scale) { index: i, label: scale.pointLabels[i] }; - var plFont = toFont(resolve([pointLabelOpts.font], context, i)); + var plFont = toFont(resolve([pointLabelOpts.font], context, i), scale.chart.options.font); ctx.font = plFont.string; ctx.fillStyle = plFont.color; var angle = toDegrees(scale.getIndexAngle(i)); @@ -12606,19 +13105,19 @@ Chart.register(controllers, scales, elements, plugins); Chart.helpers = helpers; Chart._adapters = _adapters; Chart.Animation = Animation; +Chart.Animations = Animations; Chart.animator = animator; -Chart.animationService = Animations; Chart.controllers = registry.controllers.items; Chart.DatasetController = DatasetController; -Chart.defaults = defaults; Chart.Element = Element$1; Chart.elements = elements; Chart.Interaction = Interaction; Chart.layouts = layouts; Chart.platforms = platforms; -Chart.registry = registry; Chart.Scale = Scale; Chart.Ticks = Ticks; +_extends(Chart, controllers, scales, elements, plugins, platforms); +Chart.Chart = Chart; if (typeof window !== 'undefined') { window.Chart = Chart; } diff --git a/lib/chartjs/chart.min.js b/lib/chartjs/chart.min.js index 730823b..7500a28 100644 --- a/lib/chartjs/chart.min.js +++ b/lib/chartjs/chart.min.js @@ -1,7 +1,13 @@ /*! - * Chart.js v3.0.0-alpha.2 + * Chart.js v3.0.0-beta * https://www.chartjs.org * (c) 2020 Chart.js Contributors * Released under the MIT License */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Chart=e()}(this,(function(){"use strict";function t(t,e){for(var i=0;i=0;--s)(a=o[s])._active?(a.tick(e),l=!0):(o[s]=o[o.length-1],o.pop());l&&(r.draw(),t._notify(r,n,e,"progress")),r.options.animation.debug&&function(t,e,i,n){var r=1e3/(i-n)|0,a=t.ctx;a.save(),a.clearRect(0,0,50,24),a.fillStyle="black",a.textAlign="right",e&&(a.fillText(e,50,8),a.fillText(r+" fps",50,18)),a.restore()}(r,o.length,e,t._lastDate),o.length||(n.running=!1,t._notify(r,n,e,"complete")),i+=o.length}})),t._lastDate=e,0===i&&(t._running=!1)},e._getAnims=function(t){var e=this._charts,i=e.get(t);return i||(i={running:!1,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i},e.listen=function(t,e,i){this._getAnims(t).listeners[e].push(i)},e.add=function(t,e){var i;e&&e.length&&(i=this._getAnims(t).items).push.apply(i,e)},e.has=function(t){return this._getAnims(t).items.length>0},e.start=function(t){var e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((function(t,e){return Math.max(t,e._duration)}),0),this._refresh())},e.running=function(t){if(!this._running)return!1;var e=this._charts.get(t);return!!(e&&e.running&&e.items.length)},e.stop=function(t){var e=this._charts.get(t);if(e&&e.items.length){for(var i=e.items,n=i.length-1;n>=0;--n)i[n].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}},e.remove=function(t){return this._charts.delete(t)},t}());function s(){}var l,c=(l=0,function(){return l++});function u(t){return null==t}function h(t){if(Array.isArray&&Array.isArray(t))return!0;var e=Object.prototype.toString.call(t);return"[object"===e.substr(0,7)&&"Array]"===e.substr(-6)}function d(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}var f=function(t){return("number"==typeof t||t instanceof Number)&&isFinite(+t)};function p(t,e){return void 0===t?e:t}function g(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function v(t,e,i,n){var r,a,o;if(h(t))if(a=t.length,n)for(r=a-1;r>=0;r--)e.call(i,t[r],r);else for(r=0;rn&&(n=a),n}function I(t,e,i,n){var r=(n=n||{}).data=n.data||{},a=n.garbageCollect=n.garbageCollect||[];n.font!==e&&(r=n.data={},a=n.garbageCollect=[],n.font=e),t.save(),t.font=e;var o,s,l,c,u,d=0,f=i.length;for(o=0;oi.length){for(o=0;o0&&t.stroke()}}function W(t,e){return t.x>e.left-.5&&t.xe.top-.5&&t.y1;)t[i=r+n>>1]1;)t[n=a+r>>1][e]1;)t[n=a+r>>1][e]0||(G.forEach((function(e){delete t[e]})),delete t._chartjs)}}function Z(t){return null!=t&&"none"!==t}function Q(t){var e=t.parentNode;return e&&"[object ShadowRoot]"===e.toString()&&(e=e.host),e}function J(t,e,i){var n;return"string"==typeof t?(n=parseInt(t,10),-1!==t.indexOf("%")&&(n=n/100*e.parentNode[i])):n=t,n}function tt(t,e,i){var n=document.defaultView,r=Q(t),a=n.getComputedStyle(t)[e],o=n.getComputedStyle(r)[e],s=Z(a),l=Z(o),c=Number.POSITIVE_INFINITY;if(s||l)return Math.min(s?J(a,t,i):c,l?J(o,r,i):c)}function et(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)}function it(t,e,i){return""===(e=et(t,e))?0:e.indexOf("%")>-1?i*parseInt(e,10)/100:parseInt(e,10)}function nt(t,e){var i,n,r=t.originalEvent||t,a=e.canvas,o=a.getBoundingClientRect(),s=r.touches;s&&s.length>0?(i=s[0].clientX,n=s[0].clientY):(i=r.clientX,n=r.clientY);var l=parseFloat(et(a,"padding-left")),c=parseFloat(et(a,"padding-top")),u=parseFloat(et(a,"padding-right")),h=parseFloat(et(a,"padding-bottom")),d=o.right-o.left-l-u,f=o.bottom-o.top-c-h;return{x:i=Math.round((i-o.left-l)/d*a.width/e.currentDevicePixelRatio),y:n=Math.round((n-o.top-c)/f*a.height/e.currentDevicePixelRatio)}}function rt(t,e){return"number"==typeof t?t:e}function at(t){var e=Q(t);if(!e)return rt(t.clientWidth,t.width);var i=e.clientWidth,n=i-it(e,"padding-left",i)-it(e,"padding-right",i),r=function(t){return tt(t,"max-width","clientWidth")}(t);return isNaN(r)?n:Math.min(n,r)}function ot(t){var e=Q(t);if(!e)return rt(t.clientHeight,t.height);var i=e.clientHeight,n=i-it(e,"padding-top",i)-it(e,"padding-bottom",i),r=function(t){return tt(t,"max-height","clientHeight")}(t);return isNaN(r)?n:Math.min(n,r)}function st(t,e){var i=t.currentDevicePixelRatio=e||"undefined"!=typeof window&&window.devicePixelRatio||1,n=t.canvas,r=t.width,a=t.height;n.height=a*i,n.width=r*i,t.ctx.setTransform(i,0,0,i,0,0),!n.style||n.style.height||n.style.width||(n.style.height=a+"px",n.style.width=r+"px")}var lt=Object.freeze({__proto__:null,_getParentNode:Q,getStyle:et,getRelativePosition:nt,getMaximumWidth:at,getMaximumHeight:ot,retinaScale:st});function ct(t,e){return"native"in t?{x:t.x,y:t.y}:nt(t,e)}function ut(t,e){for(var i,n,r,a=t.getSortedVisibleDatasetMetas(),o=0,s=a.length;o0){var s=o[0].datasetIndex,l=t.getDatasetMeta(s).data;o=[];for(var c=0;c0},t.prototype.connect_=function(){Ft&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),Vt?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},t.prototype.disconnect_=function(){Ft&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},t.prototype.onTransitionEnd_=function(t){var e=t.propertyName,i=void 0===e?"":e;zt.some((function(t){return!!~i.indexOf(t)}))&&this.refresh()},t.getInstance=function(){return this.instance_||(this.instance_=new t),this.instance_},t.instance_=null,t}(),Wt=function(t,e){for(var i=0,n=Object.keys(e);i0},t}(),Qt="undefined"!=typeof WeakMap?new WeakMap:new Lt,Jt=function t(e){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var i=Bt.getInstance(),n=new Zt(e,i,this);Qt.set(this,n)};["observe","unobserve","disconnect"].forEach((function(t){Jt.prototype[t]=function(){var e;return(e=Qt.get(this))[t].apply(e,arguments)}}));var te=void 0!==Rt.ResizeObserver?Rt.ResizeObserver:Jt,ee={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"};function ie(t,e){var i=et(t,e),n=i&&i.match(/^(\d+)(\.\d+)?px$/);return n?+n[1]:void 0}var ne=!!function(){var t=!1;try{var e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t}()&&{passive:!0};function re(t,e,i){t.removeEventListener(e,i,ne)}function ae(t,e){var i=!1,n=[];return function(){for(var r=arguments.length,o=new Array(r),s=0;s=1?t:-(Math.sqrt(1-t*t)-1)},easeOutCirc:function(t){return Math.sqrt(1-(t-=1)*t)},easeInOutCirc:function(t){return(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInElastic:function(t){var e,i=0;return 0===t?0:1===t?1:(i||(i=.3),e=i/(2*Math.PI)*Math.asin(1),-1*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/i))},easeOutElastic:function(t){var e,i=0;return 0===t?0:1===t?1:(i||(i=.3),e=i/(2*Math.PI)*Math.asin(1),1*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/i)+1)},easeInOutElastic:function(t){var e,i=0;return 0===t?0:2==(t/=.5)?1:(i||(i=.45),e=i/(2*Math.PI)*Math.asin(1),t<1?1*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/i)*-.5:1*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/i)*.5+1)},easeInBack:function(t){var e=1.70158;return t*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:function(t){return 1-fe.easeOutBounce(1-t)},easeOutBounce:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},easeInOutBounce:function(t){return t<.5?.5*fe.easeInBounce(2*t):.5*fe.easeOutBounce(2*t-1)+.5}},pe={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},ge="0123456789ABCDEF",ve=function(t){return ge[15&t]},me=function(t){return ge[(240&t)>>4]+ge[15&t]},be=function(t){return(240&t)>>4==(15&t)};function xe(t){var e=function(t){return be(t.r)&&be(t.g)&&be(t.b)&&be(t.a)}(t)?ve:me;return t?"#"+e(t.r)+e(t.g)+e(t.b)+(t.a<255?e(t.a):""):t}function ye(t){return t+.5|0}var _e=function(t,e,i){return Math.max(Math.min(t,i),e)};function Me(t){return _e(ye(2.55*t),0,255)}function we(t){return _e(ye(255*t),0,255)}function ke(t){return _e(ye(t/2.55)/100,0,1)}function Pe(t){return _e(ye(100*t),0,100)}var Se=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;var De=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function Te(t,e,i){var n=e*Math.min(i,1-i),r=function(e,r){return void 0===r&&(r=(e+t/30)%12),i-n*Math.max(Math.min(r-3,9-r,1),-1)};return[r(0),r(8),r(4)]}function Ae(t,e,i){var n=function(n,r){return void 0===r&&(r=(n+t/60)%6),i-i*e*Math.max(Math.min(r,4-r,1),0)};return[n(5),n(3),n(1)]}function Oe(t,e,i){var n,r=Te(t,1,.5);for(e+i>1&&(e*=n=1/(e+i),i*=n),n=0;n<3;n++)r[n]*=1-e-i,r[n]+=e;return r}function Ee(t){var e,i,n,r=t.r/255,a=t.g/255,o=t.b/255,s=Math.max(r,a,o),l=Math.min(r,a,o),c=(s+l)/2;return s!==l&&(n=s-l,i=c>.5?n/(2-s-l):n/(s+l),e=60*(e=s===r?(a-o)/n+(a>16&255,i>>8&255,255&i]}return a}()).transparent=[0,0,0,0]);var e=Ie[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}function We(t,e,i){if(t){var n=Ee(t);n[e]=Math.max(0,Math.min(n[e]+n[e]*i,0===e?360:1)),n=Le(n),t.r=n[0],t.g=n[1],t.b=n[2]}}function Ne(t,e){return t?i(e||{},t):t}function He(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=we(t[3]))):(e=Ne(t,{r:0,g:0,b:0,a:1})).a=we(e.a),e}function je(t){return"r"===t.charAt(0)?function(t){var e,i,n,r=Se.exec(t),a=255;if(r){if(r[7]!==e){var o=+r[7];a=255&(r[8]?Me(o):255*o)}return e=+r[1],i=+r[3],n=+r[5],{r:e=255&(r[2]?Me(e):e),g:i=255&(r[4]?Me(i):i),b:n=255&(r[6]?Me(n):n),a:a}}}(t):Re(t)}var Ye=function(){function t(e){if(e instanceof t)return e;var i,n,r,a,o=typeof e;"object"===o?i=He(e):"string"===o&&(a=(n=e).length,"#"===n[0]&&(4===a||5===a?r={r:255&17*pe[n[1]],g:255&17*pe[n[2]],b:255&17*pe[n[3]],a:5===a?17*pe[n[4]]:255}:7!==a&&9!==a||(r={r:pe[n[1]]<<4|pe[n[2]],g:pe[n[3]]<<4|pe[n[4]],b:pe[n[5]]<<4|pe[n[6]],a:9===a?pe[n[7]]<<4|pe[n[8]]:255})),i=r||Be(e)||je(e)),this._rgb=i,this._valid=!!i}var i=t.prototype;return i.rgbString=function(){return this._valid?(t=this._rgb)&&(t.a<255?"rgba("+t.r+", "+t.g+", "+t.b+", "+ke(t.a)+")":"rgb("+t.r+", "+t.g+", "+t.b+")"):this._rgb;var t},i.hexString=function(){return this._valid?xe(this._rgb):this._rgb},i.hslString=function(){return this._valid?function(t){if(t){var e=Ee(t),i=e[0],n=Pe(e[1]),r=Pe(e[2]);return t.a<255?"hsla("+i+", "+n+"%, "+r+"%, "+ke(t.a)+")":"hsl("+i+", "+n+"%, "+r+"%)"}}(this._rgb):this._rgb},i.mix=function(t,e){if(t){var i,n=this.rgb,r=t.rgb,a=e===i?.5:e,o=2*a-1,s=n.a-r.a,l=((o*s==-1?o:(o+s)/(1+o*s))+1)/2;i=1-l,n.r=255&l*n.r+i*r.r+.5,n.g=255&l*n.g+i*r.g+.5,n.b=255&l*n.b+i*r.b+.5,n.a=a*n.a+(1-a)*r.a,this.rgb=n}return this},i.clone=function(){return new t(this.rgb)},i.alpha=function(t){return this._rgb.a=we(t),this},i.clearer=function(t){return this._rgb.a*=1-t,this},i.greyscale=function(){var t=this._rgb,e=ye(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this},i.opaquer=function(t){return this._rgb.a*=1+t,this},i.negate=function(){var t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this},i.lighten=function(t){return We(this._rgb,2,t),this},i.darken=function(t){return We(this._rgb,2,-t),this},i.saturate=function(t){return We(this._rgb,1,t),this},i.desaturate=function(t){return We(this._rgb,1,-t),this},i.rotate=function(t){return function(t,e){var i=Ee(t);i[0]=Fe(i[0]+e),i=Le(i),t.r=i[0],t.g=i[1],t.b=i[2]}(this._rgb,t),this},e(t,[{key:"valid",get:function(){return this._valid}},{key:"rgb",get:function(){var t=Ne(this._rgb);return t&&(t.a=ke(t.a)),t},set:function(t){this._rgb=He(t)}}]),t}();function Xe(t){return new Ye(t)}var Ue=function(t){return t instanceof CanvasGradient||t instanceof CanvasPattern};function qe(t){return Ue(t)?t:Xe(t)}function Ke(t){return Ue(t)?t:Xe(t).saturate(.5).darken(.1).hexString()}var Ge={boolean:function(t,e,i){return i>.5?e:t},color:function(t,e,i){var n=qe(t||"transparent"),r=n.valid&&qe(e||"transparent");return r&&r.valid?r.mix(n,i).hexString():e},number:function(t,e,i){return t+(e-t)*i}},$e=function(){function t(t,e,i,n){var r=e[i];n=xt([t.to,n,r,t.from]);var a=xt([t.from,r,n]);this._active=!0,this._fn=t.fn||Ge[t.type||typeof a],this._easing=fe[t.easing||"linear"],this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=a,this._to=n}var e=t.prototype;return e.active=function(){return this._active},e.update=function(t,e,i){var n=this;if(n._active){var r=n._target[n._prop],a=i-n._start,o=n._duration-a;n._start=i,n._duration=Math.floor(Math.max(o,t.duration)),n._loop=!!t.loop,n._to=xt([t.to,e,r,t.from]),n._from=xt([t.from,r,e])}},e.cancel=function(){this._active&&(this.tick(Date.now()),this._active=!1)},e.tick=function(t){var e,i=this,n=t-i._start,r=i._duration,a=i._prop,o=i._from,s=i._loop,l=i._to;i._active=o!==l&&(s||n1?2-e:e,e=i._easing(Math.min(1,Math.max(0,e))),i._target[a]=i._fn(o,l,e)):i._target[a]=l},t}(),Ze=["borderColor","backgroundColor"];D.set("animation",{duration:1e3,easing:"easeOutQuart",onProgress:s,onComplete:s,colors:{type:"color",properties:Ze},numbers:{type:"number",properties:["x","y","borderWidth","radius","tension"]},active:{duration:400},resize:{duration:0},show:{colors:{type:"color",properties:Ze,from:"transparent"},visible:{type:"boolean",duration:0}},hide:{colors:{type:"color",properties:Ze,to:"transparent"},visible:{type:"boolean",easing:"easeInExpo"}}});var Qe=function(){function t(t,e){this._chart=t,this._properties=new Map,this.configure(e)}var e=t.prototype;return e.configure=function(t){if(d(t)){var e=this._properties,n=function(t){var e={};return Object.keys(t).forEach((function(i){var n=t[i];d(n)||(e[i]=n)})),e}(t);Object.keys(t).forEach((function(r){var a=t[r];d(a)&&(a.properties||[r]).forEach((function(t){e.has(t)?t===r&&e.set(t,i({},e.get(t),a)):e.set(t,i({},n,a))}))}))}},e._animateOptions=function(t,e){var n=e.options,r=[];if(!n)return r;var a=t.options;return a?(a.$shared&&(t.options=a=i({},a,{$shared:!1,$animations:{}})),r=this._createAnimations(a,n)):t.options=n,r},e._createAnimations=function(t,e){var i,n=this._properties,r=[],a=t.$animations||(t.$animations={}),o=Object.keys(e),s=Date.now();for(i=o.length-1;i>=0;--i){var l=o[i];if("$"!==l.charAt(0))if("options"!==l){var c=e[l],u=a[l],h=n.get(l);if(u){if(h&&u.active()){u.update(h,c,s);continue}u.cancel()}h&&h.duration?(a[l]=u=new $e(h,t,l,c),r.push(u)):t[l]=c}else r.push.apply(r,this._animateOptions(t,e))}return r},e.update=function(t,e){if(0===this._properties.size)return function(t,e){var n=t.options,r=e.options;n&&r&&!r.$shared&&(n.$shared?t.options=i({},n,r,{$shared:!1}):i(n,r),delete e.options)}(t,e),void i(t,e);var n=this._createAnimations(t,e);return n.length?(o.add(this._chart,n),!0):void 0},t}(),Je=Math.PI,ti=2*Je,ei=ti+Je;function ii(t){var e,i=[],n=Math.sqrt(t);for(e=1;e=t}function si(t,e,i){var n,r,a;for(n=0,r=t.length;n0?1:-1};function ci(t){return t*(Je/180)}function ui(t){return t*(180/Je)}function hi(t){if(f(t)){for(var e=1,i=0;Math.round(t*e)/e!==t;)e*=10,i++;return i}}function di(t,e){var i=e.x-t.x,n=e.y-t.y,r=Math.sqrt(i*i+n*n),a=Math.atan2(n,i);return a<-.5*Je&&(a+=ti),{angle:a,distance:r}}function fi(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function pi(t,e){return(t-e+ei)%ti-Je}function gi(t){return(t%ti+ti)%ti}function vi(t,e,i){var n=gi(t),r=gi(e),a=gi(i),o=gi(r-n),s=gi(a-n),l=gi(n-r),c=gi(n-a);return n===r||n===a||o>s&&l0&&(g=s._sorted,a=s._parsed[t-1]),!1===o._parsing)s._parsed=l,s._sorted=!0;else{for(n=h(l[t])?o.parseArrayData(s,l,t,e):d(l[t])?o.parseObjectData(s,l,t,e):o.parsePrimitiveData(s,l,t,e),i=0;ia||v=0;--i)if(!m()){o.updateRangeFromParsed(f,t,r,d);break}return f},e.getAllParsedValues=function(t){var e,i,n,r=this._cachedMeta._parsed,a=[];for(e=0,i=r.length;e=0;a--)i=r[a],e[i]=Ke(n[i])},e.getStyle=function(t,e){var i=this,n=i._cachedMeta.dataset;i._config||i.configure();var r=n&&void 0===t?i.resolveDatasetElementOptions(e):i.resolveDataElementOptions(t||0,e&&"active");return e&&i._addAutomaticHoverColors(t,r),r},e._getContext=function(t,e){return{chart:this.chart,dataPoint:this.getParsed(t),dataIndex:t,dataset:this.getDataset(),datasetIndex:this.index,active:e}},e.resolveDatasetElementOptions=function(t){return this._resolveOptions(this.datasetElementOptions,{active:t,type:this.datasetElementType.id})},e.resolveDataElementOptions=function(t,e){var i="active"===e,n=this._cachedDataOpts;if(n[e])return n[e];var r={cacheable:!i},a=this._resolveOptions(this.dataElementOptions,{index:t,active:i,info:r,type:this.dataElementType.id});return r.cacheable&&(a.$shared=!0,n[e]=a),a},e._resolveOptions=function(t,e){for(var i=e.index,n=e.active,r=e.type,a=e.info,o=this._config,s=this.chart.options.elements[r]||{},l={},c=this._getContext(i,n),u=function(t){return h(t)?t:Object.keys(t)}(t),d=0,f=u.length;de?this._insertElements(e,i-e):i1e15)&&(r="scientific");var s=n.length>3?n[2].value-n[1].value:n[1].value-n[0].value;Math.abs(s)>1&&t!==Math.floor(t)&&(s=t-Math.floor(t));var l=ni(Math.abs(s)),c=Math.max(Math.min(-1*Math.floor(l),20),0),u={notation:r,minimumFractionDigits:c,maximumFractionDigits:c};return i(u,this.options.ticks.format),new Intl.NumberFormat(a,u).format(t)},logarithmic:function(t,e,i){if(0===t)return"0";var n=t/Math.pow(10,Math.floor(ni(t)));return 1===n||2===n||5===n?Ai.numeric.call(this,t,e,i):""}},Oi={formatters:Ai};function Ei(t,e){for(var i=[],n=t.length/e,r=t.length,a=0;as+1e-6)))return l}function Li(t){return t.drawTicks?t.tickMarkLength:0}function Fi(t){if(!t.display)return 0;var e=bt(t.font),i=mt(t.padding);return e.lineHeight+i.height}function Ri(t,e,i,n,r){var a,o,s,l=p(n,0),c=Math.min(p(r,t.length),t.length),u=0;for(i=Math.ceil(i),r&&(i=(a=r-n)/Math.floor(a/i)),s=l;s<0;)u++,s=Math.round(l+u*i);for(o=Math.max(l,0);o=l||o<=1||!n.isHorizontal())n.labelRotation=s;else{var u=n._getLabelSizes(),h=u.widest.width,d=u.highest.height-u.highest.offset,f=Math.min(n.maxWidth,n.chart.width-h);h+6>(t=r.offset?n.maxWidth/o:f/(o-1))&&(t=f/(o-(r.offset?.5:1)),e=n.maxHeight-Li(r.gridLines)-a.padding-Fi(r.scaleLabel),i=Math.sqrt(h*h+d*d),c=ui(Math.min(Math.asin(Math.min((u.highest.height+6)/t,1)),Math.asin(Math.min(e/i,1))-Math.asin(d/i))),c=Math.max(s,Math.min(l,c))),n.labelRotation=c}},r.afterCalculateLabelRotation=function(){g(this.options.afterCalculateLabelRotation,[this])},r.beforeFit=function(){g(this.options.beforeFit,[this])},r.fit=function(){var t=this,e={width:0,height:0},i=t.chart,n=t.options,r=n.ticks,a=n.scaleLabel,o=n.gridLines,s=t._isVisible(),l="top"!==n.position&&"x"===t.axis,c=t.isHorizontal();if(c?e.width=t.maxWidth:s&&(e.width=Li(o)+Fi(a)),c?s&&(e.height=Li(o)+Fi(a)):e.height=t.maxHeight,r.display&&s&&t.ticks.length){var u=t._getLabelSizes(),h=u.first,d=u.last,f=u.widest,p=u.highest,g=.8*p.offset,v=r.padding;if(c){var m=0!==t.labelRotation,b=ci(t.labelRotation),x=Math.cos(b),y=Math.sin(b),_=y*f.width+x*(p.height-(m?p.offset:0))+(m?0:g);e.height=Math.min(t.maxHeight,e.height+_+v);var M,w,k=t.getPixelForTick(0)-t.left,P=t.right-t.getPixelForTick(t.ticks.length-1);m?(M=l?x*h.width+y*h.offset:y*(h.height-h.offset),w=l?y*(d.height-d.offset):x*d.width+y*d.offset):(M=h.width/2,w=d.width/2),t.paddingLeft=Math.max((M-k)*t.width/(t.width-k),0)+3,t.paddingRight=Math.max((w-P)*t.width/(t.width-P),0)+3}else{var S=r.mirror?0:f.width+v+g;e.width=Math.min(t.maxWidth,e.width+S),t.paddingTop=d.height/2,t.paddingBottom=h.height/2}}t._handleMargins(),c?(t.width=t._length=i.width-t._margins.left-t._margins.right,t.height=e.height):(t.width=e.width,t.height=t._length=i.height-t._margins.top-t._margins.bottom)},r._handleMargins=function(){var t=this;t._margins&&(t._margins.left=Math.max(t.paddingLeft,t._margins.left),t._margins.top=Math.max(t.paddingTop,t._margins.top),t._margins.right=Math.max(t.paddingRight,t._margins.right),t._margins.bottom=Math.max(t.paddingBottom,t._margins.bottom))},r.afterFit=function(){g(this.options.afterFit,[this])},r.isHorizontal=function(){var t=this.options,e=t.axis,i=t.position;return"top"===i||"bottom"===i||"x"===e},r.isFullWidth=function(){return this.options.fullWidth},r._convertTicksToLabels=function(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t),this.afterTickToLabelConversion()},r._getLabelSizes=function(){var t=this._labelSizes;return t||(this._labelSizes=t=this._computeLabelSizes()),t},r._computeLabelSizes=function(){var t=this,e=t.ctx,i=t._longestTextCache,n=t.options.ticks.sampleSize,r=[],a=[],o=[],s=t.ticks;ne){for(i=0;ie.length-1?null:this.getPixelForValue(e[t].value)},r.getPixelForDecimal=function(t){return this._reversePixels&&(t=1-t),this._startPixel+t*this._length},r.getDecimalForPixel=function(t){var e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e},r.getBasePixel=function(){return this.getPixelForValue(this.getBaseValue())},r.getBaseValue=function(){var t=this.min,e=this.max;return t<0&&e<0?e:t>0&&e>0?t:0},r._autoSkip=function(t){var e=this.options.ticks,i=e.maxTicksLimit||this._length/this._tickSize(),n=e.major.enabled?function(t){var e,i,n=[];for(e=0,i=t.length;ei)return function(t,e,i,n){var r,a=0,o=i[0];for(n=Math.ceil(n),r=0;rr)return l}return Math.max(r,1)}(n,t,i);if(r>0){var c,h,d=r>1?Math.round((o-a)/(r-1)):null;for(Ri(t,s,l,u(d)?0:a-d,a),c=0,h=r-1;co*n?o/i:s/n:s*n0},r._computeGridLineItems=function(t){var e,i,n,r,a,o,s,l,c,u,h,f,p=this,g=p.axis,v=p.chart,m=p.options,b=m.gridLines,x=m.position,y=b.offsetGridLines,_=p.isHorizontal(),M=p.ticks,w=M.length+(y?1:0),k=Li(b),P=[],S={chart:v,scale:p,tick:M[0],index:0},D=b.drawBorder?xt([b.borderWidth,b.lineWidth,0],S,0):0,T=D/2,A=function(t){return z(v,t,D)};if("top"===x)e=A(p.bottom),o=p.bottom-k,l=e-T,u=A(t.top)+T,f=t.bottom;else if("bottom"===x)e=A(p.top),u=t.top,f=A(t.bottom)-T,o=e+T,l=p.top+k;else if("left"===x)e=A(p.right),a=p.right-k,s=e-T,c=A(t.left)+T,h=t.right;else if("right"===x)e=A(p.left),c=t.left,h=A(t.right)-T,a=e+T,s=p.left+k;else if("x"===g){if("center"===x)e=A((t.top+t.bottom)/2);else if(d(x)){var O=Object.keys(x)[0],E=x[O];e=A(p.chart.scales[O].getPixelForValue(E))}u=t.top,f=t.bottom,l=(o=e+T)+k}else if("y"===g){if("center"===x)e=A((t.left+t.right)/2);else if(d(x)){var C=Object.keys(x)[0],L=x[C];e=A(p.chart.scales[C].getPixelForValue(L))}s=(a=e-T)-k,c=t.left,h=t.right}for(i=0;i0&&""!==c.strokeStyle;o.save(),o.translate(l.x,l.y),o.rotate(l.rotation),o.font=c.string,o.fillStyle=c.color,o.textBaseline="middle",o.textAlign=l.textAlign,u&&(o.strokeStyle=c.strokeStyle,o.lineWidth=c.lineWidth);var d=l.label,f=l.textOffset;if(h(d))for(n=0,a=d.length;ne){for(var n=e;n=0;--i)t._drawDataset(e[i]);t._plugins.notify(t,"afterDatasetsDraw")}},e._drawDataset=function(t){var e=this,i=e.ctx,n=t._clip,r=e.chartArea,a={meta:t,index:t.index};!1!==e._plugins.notify(e,"beforeDatasetDraw",[a])&&(N(i,{left:!1===n.left?0:r.left-n.left,right:!1===n.right?e.width:r.right+n.right,top:!1===n.top?0:r.top-n.top,bottom:!1===n.bottom?e.height:r.bottom+n.bottom}),t.controller.draw(),H(i),e._plugins.notify(e,"afterDatasetDraw",[a]))},e.getElementAtEvent=function(t){return gt.modes.nearest(this,t,{intersect:!0})},e.getElementsAtEvent=function(t){return gt.modes.index(this,t,{intersect:!0})},e.getElementsAtXAxis=function(t){return gt.modes.index(this,t,{intersect:!1})},e.getElementsAtEventForMode=function(t,e,i,n){var r=gt.modes[e];return"function"==typeof r?r(this,t,i,n):[]},e.getDatasetAtEvent=function(t){return gt.modes.dataset(this,t,{intersect:!0})},e.getDatasetMeta=function(t){var e=this.data.datasets[t],i=this._metasets,n=i.filter((function(t){return t._dataset===e})).pop();return n||(n=i[t]={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1}),n},e.getVisibleDatasetCount=function(){return this.getSortedVisibleDatasetMetas().length},e.isDatasetVisible=function(t){var e=this.getDatasetMeta(t);return"boolean"==typeof e.hidden?!e.hidden:!this.data.datasets[t].hidden},e.setDatasetVisibility=function(t,e){this.getDatasetMeta(t).hidden=!e},e.toggleDataVisibility=function(t){this._hiddenIndices[t]=!this._hiddenIndices[t]},e.getDataVisibility=function(t){return!this._hiddenIndices[t]},e._updateDatasetVisibility=function(t,e){var i=e?"show":"hide",n=this.getDatasetMeta(t),r=n.controller._resolveAnimations(void 0,i);this.setDatasetVisibility(t,e),r.update(n,{visible:e}),this.update((function(e){return e.datasetIndex===t?i:void 0}))},e.hide=function(t){this._updateDatasetVisibility(t,!1)},e.show=function(t){this._updateDatasetVisibility(t,!0)},e._destroyDatasetMeta=function(t){var e=this._metasets&&this._metasets[t];e&&(e.controller._destroy(),delete this._metasets[t])},e.destroy=function(){var e,i,n=this,r=n.canvas;for(n.stop(),o.remove(n),e=0,i=n.data.datasets.length;e0?u[e-1]:null,(r=e0?u[e-1]:null,r=e0&&W(t[i-1],e)&&(r.controlPointPreviousX=en(r.controlPointPreviousX,e.left,e.right),r.controlPointPreviousY=en(r.controlPointPreviousY,e.top,e.bottom)),iMath.abs(s)&&(l=s,c=o),e[i.axis]=c,e._custom={barStart:l,barEnd:c,start:r,end:a,min:o,max:s}}(t,e,i,n):e[i.axis]=i.parse(t,n),e}function dn(t,e,i,n){var r,a,o,s,l=t.iScale,c=t.vScale,u=l.getLabels(),h=l===c,d=[];for(r=i,a=i+n;r0?Math.min(o,Math.abs(n-i)):o,i=n;return o}(n,r),pixels:r,start:n._startPixel,end:n._endPixel,stackCount:this._getStackCount(),scale:n}},i._calculateBarValuePixels=function(t,e){var i,n,r=this._cachedMeta,a=r.vScale,o=e.minBarLength,s=this.getParsed(t),l=s._custom,c=s[a.axis],u=0,h=r._stacked?this.applyStack(a,s):c;h!==c&&(u=h-c,h=c),fn(l)&&(c=l.barStart,h=l.barEnd-l.barStart,0!==c&&li(c)!==li(l.barEnd)&&(u=0),u+=c);var d=mi(a.getPixelForValue(u),a._startPixel-10,a._endPixel+10);return n=(i=a.getPixelForValue(u+h))-d,void 0!==o&&Math.abs(n)0?n[t-1]:null,o=t=0;--t)e=Math.max(e,this.getStyle(t,!0).radius);return e>0&&e},r.getLabelAndValue=function(t){var e=this._cachedMeta,i=e.xScale,n=e.yScale,r=this.getParsed(t),a=i.getLabelForValue(r.x),o=n.getLabelForValue(r.y),s=r._custom;return{label:e.label,value:"("+a+", "+o+(s?", "+s:"")+")"}},r.update=function(t){var e=this._cachedMeta.data;this.updateElements(e,0,t)},r.updateElements=function(t,e,i){for(var n=this,r="reset"===i,a=n._cachedMeta,o=a.xScale,s=a.yScale,l=n.resolveDataElementOptions(e,i),c=n.getSharedOptions(i,t[e],l),u=n.includeOptions(i,c),h=0;h=vn?-mn:s<-vn?mn:0)+e,c=Math.cos(s),u=Math.sin(s),h=Math.cos(l),d=Math.sin(l),f=s<=0&&l>=0||l>=mn,p=s<=bn&&l>=bn||l>=mn+bn,g=s<=-bn&&l>=-bn||l>=vn+bn,v=s===-vn||l>=vn?-1:Math.min(c,c*i,h,h*i),m=g?-1:Math.min(u,u*i,d,d*i),b=f?1:Math.max(c,c*i,h,h*i),x=p?1:Math.max(u,u*i,d,d*i);n=(b-v)/2,r=(x-m)/2,a=-(b+v)/2,o=-(x+m)/2}return{ratioX:n,ratioY:r,offsetX:a,offsetY:o}}(r.rotation,r.circumference,s),u=c.ratioX,h=c.ratioY,d=c.offsetX,f=c.offsetY,p=e.getMaxBorderWidth(),g=(n.right-n.left-p)/u,v=(n.bottom-n.top-p)/h,m=Math.max(Math.min(g,v)/2,0),b=(m-Math.max(m*s,0))/e._getVisibleDatasetWeightTotal();e.offsetX=d*m,e.offsetY=f*m,a.total=e.calculateTotal(),e.outerRadius=m-b*e._getRingWeightOffset(e.index),e.innerRadius=Math.max(e.outerRadius-b*l,0),e.updateElements(o,0,t)},i._circumference=function(t,e){var i=this.chart.options,n=this._cachedMeta;return e&&i.animation.animateRotate?0:this.chart.getDataVisibility(t)?this.calculateCircumference(n._parsed[t]*i.circumference/mn):0},i.updateElements=function(t,e,i){var n,r=this,a="reset"===i,o=r.chart,s=o.chartArea,l=o.options,c=l.animation,u=(s.left+s.right)/2,h=(s.top+s.bottom)/2,d=a&&c.animateScale,f=d?0:r.innerRadius,p=d?0:r.outerRadius,g=r.resolveDataElementOptions(e,i),v=r.getSharedOptions(i,t[e],g),m=r.includeOptions(i,v),b=l.rotation;for(n=0;n0&&!isNaN(t)?mn*(Math.abs(t)/e):0},i.getMaxBorderWidth=function(t){var e,i,n,r,a,o=0,s=this.chart;if(!t)for(e=0,i=s.data.datasets.length;e0&&x.x-n.x>g};d&&(M.options=r.resolveDataElementOptions(m,i)),r.updateElement(b,m,M,i),n=x}r.updateSharedOptions(h,i)},i.resolveDatasetElementOptions=function(e){var i=this._config,n=this.chart.options,r=n.elements.line,a=t.prototype.resolveDatasetElementOptions.call(this,e),o=p(i.showLine,n.showLines);return a.spanGaps=p(i.spanGaps,n.spanGaps),a.tension=p(i.lineTension,r.tension),a.stepped=xt([i.stepped,r.stepped]),o||(a.borderWidth=0),a},i.getMaxOverflow=function(){var t=this._cachedMeta,e=t.dataset.options.borderWidth||0,i=t.data||[];if(!i.length)return e;var n=i[0].size(),r=i[i.length-1].size();return Math.max(e,n,r)/2},e}(Di);yn.id="line",yn.defaults={datasetElementType:"line",datasetElementOptions:["backgroundColor","borderCapStyle","borderColor","borderDash","borderDashOffset","borderJoinStyle","borderWidth","capBezierPoints","cubicInterpolationMode","fill"],dataElementType:"point",dataElementOptions:{backgroundColor:"pointBackgroundColor",borderColor:"pointBorderColor",borderWidth:"pointBorderWidth",hitRadius:"pointHitRadius",hoverHitRadius:"pointHitRadius",hoverBackgroundColor:"pointHoverBackgroundColor",hoverBorderColor:"pointHoverBorderColor",hoverBorderWidth:"pointHoverBorderWidth",hoverRadius:"pointHoverRadius",pointStyle:"pointStyle",radius:"pointRadius",rotation:"pointRotation"},showLines:!0,spanGaps:!1,hover:{mode:"index"},scales:{_index_:{type:"category"},_value_:{type:"linear"}}};var _n=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this).innerRadius=void 0,n.outerRadius=void 0,n}n(e,t);var i=e.prototype;return i.update=function(t){var e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,t)},i._updateRadius=function(){var t=this,e=t.chart,i=e.chartArea,n=e.options,r=Math.min(i.right-i.left,i.bottom-i.top),a=Math.max(r/2,0),o=(a-Math.max(n.cutoutPercentage?a/100*n.cutoutPercentage:1,0))/e.getVisibleDatasetCount();t.outerRadius=a-o*t.index,t.innerRadius=t.outerRadius-o},i.updateElements=function(t,e,i){var n,r=this,a="reset"===i,o=r.chart,s=r.getDataset(),l=o.options,c=l.animation,u=r._cachedMeta.rScale,h=u.xCenter,d=u.yCenter,f=ci(l.startAngle)-.5*Math.PI,p=f;for(r._cachedMeta.count=r.countVisibleElements(),n=0;nr?(s=r/e.innerRadius,t.arc(a,o,e.innerRadius-r,n+s,i-s,!0)):t.arc(a,o,r,n+Math.PI/2,i-Math.PI/2),t.closePath(),t.clip()}function Tn(t,e){t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath()}function An(t,e,i){var n=e.options,r="inner"===n.borderAlign;r?(t.lineWidth=2*n.borderWidth,t.lineJoin="round"):(t.lineWidth=n.borderWidth,t.lineJoin="bevel"),i.fullCircles&&function(t,e,i,n){var r,a=i.endAngle;for(n&&(i.endAngle=i.startAngle+Sn,Dn(t,i),i.endAngle=a,i.endAngle===i.startAngle&&i.fullCircles&&(i.endAngle+=Sn,i.fullCircles--)),t.beginPath(),t.arc(i.x,i.y,i.innerRadius,i.startAngle+Sn,i.startAngle,!0),r=0;r=Sn||vi(r,s,l))&&(a>=c&&a<=u)},a.getCenterPoint=function(t){var e=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),i=e.x,n=e.y,r=(e.startAngle+e.endAngle)/2,a=(e.innerRadius+e.outerRadius)/2;return{x:i+Math.cos(r)*a,y:n+Math.sin(r)*a}},a.tooltipPosition=function(t){return this.getCenterPoint(t)},a.draw=function(t){var e=this,i=e.options,n="inner"===i.borderAlign?.33:0,r={x:e.x,y:e.y,innerRadius:e.innerRadius,outerRadius:Math.max(e.outerRadius-n,0),pixelMargin:n,startAngle:e.startAngle,endAngle:e.endAngle,fullCircles:Math.floor(e.circumference/Sn)};0!==e.circumference&&(t.save(),t.fillStyle=i.backgroundColor,t.strokeStyle=i.borderColor,function(t,e,i){if(e.fullCircles){e.endAngle=e.startAngle+Sn,Tn(t,e);for(var n=0;n0?e.y:t.y}}function Ln(t,e,i,n){var r={x:t.controlPointNextX,y:t.controlPointNextY},a={x:e.controlPointPreviousX,y:e.controlPointPreviousY},o=En(t,r,i),s=En(r,a,i),l=En(a,e,i),c=En(o,s,i),u=En(s,l,i);return En(c,u,i)}function Fn(t){return"angle"===t?{between:vi,compare:pi,normalize:gi}:{between:function(t,e,i){return t>=e&&t<=i},compare:function(t,e){return t-e},normalize:function(t){return t}}}function Rn(t,e,i,n){return{start:t%n,end:e%n,loop:i&&(e-t+1)%n==0}}function In(t,e,i){if(!i)return[t];var n,r,a,o,s=i.property,l=i.start,c=i.end,u=e.length,h=Fn(s),d=h.compare,f=h.between,p=h.normalize,g=function(t,e,i){var n,r,a=i.property,o=i.start,s=i.end,l=Fn(a),c=l.between,u=l.normalize,h=e.length,d=t.start,f=t.end,p=t.loop;if(p){for(d+=h,f+=h,n=0,r=h;nv&&d(r,l)>0?o:n),null===_||y&&0!==d(r,c)||(x.push(Rn(_,n,b,u)),_=null),o=n);return null!==_&&x.push(Rn(_,m,b,u)),x}function zn(t,e){for(var i=[],n=t.segments,r=0;rl&&(l=k),x=(y*x+w)/++y):(M(),t.lineTo(w,k),o=P,y=0,s=l=k),c=k}M()}function Nn(t){var e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._loop||e.tension||e.stepped||i)?Wn:Bn}On.id="arc",On.defaults={borderAlign:"center",borderColor:"#fff",borderWidth:2},On.defaultRoutes={backgroundColor:"color"};var Hn=function(t){function a(e){var n;return(n=t.call(this)||this).options=void 0,n._loop=void 0,n._fullLoop=void 0,n._points=void 0,n._segments=void 0,e&&i(r(n),e),n}n(a,t);var o=a.prototype;return o.updateControlPoints=function(t){var e=this.options;if(e.tension&&!e.stepped){var i=e.spanGaps?this._loop:this._fullLoop;nn(this._points,e,t,i)}},o.first=function(){var t=this.segments,e=this.points;return t.length&&e[t[0].start]},o.last=function(){var t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]},o.interpolate=function(t,e){var i=this.options,n=t[e],r=this.points,a=zn(this,{property:e,start:n,end:n});if(a.length){var o,s,l=[],c=function(t){return t.stepped?Cn:t.tension?Ln:En}(i);for(o=0,s=a.length;or&&t[a%e].skip;)a--;return{start:r,end:a%=e}}(e,n,r,i),o=a.start,s=a.end;return!0===i?[{start:o,end:s,loop:r}]:function(t,e,i,n){var r,a=t.length,o=[],s=e,l=t[e];for(r=e+1;r<=i;++r){var c=t[r%a];c.skip||c.stop?l.skip||(n=!1,o.push({start:e%a,end:(r-1)%a,loop:n}),e=s=c.stop?r:null):(s=r,l.skip&&(e=r)),l=c}return null!==s&&o.push({start:e%a,end:s%a,loop:n}),o}(e,o,st.x):Xn(e,"bottom","top",t.base=o.left&&e<=o.right)&&(a||i>=o.top&&i<=o.bottom)}jn.id="point",jn.defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3},jn.defaultRoutes={backgroundColor:"color",borderColor:"color"};var $n=function(t){function e(e){var n;return(n=t.call(this)||this).options=void 0,n.horizontal=void 0,n.base=void 0,n.width=void 0,n.height=void 0,e&&i(r(n),e),n}n(e,t);var a=e.prototype;return a.draw=function(t){var e,i,n,r,a,o=this.options,s=(i=Yn(e=this),n=i.right-i.left,r=i.bottom-i.top,a=Kn(e,n/2,r/2),{outer:{x:i.left,y:i.top,w:n,h:r},inner:{x:i.left+a.l,y:i.top+a.t,w:n-a.l-a.r,h:r-a.t-a.b}}),l=s.inner,c=s.outer;t.save(),c.w===l.w&&c.h===l.h||(t.beginPath(),t.rect(c.x,c.y,c.w,c.h),t.clip(),t.rect(l.x,l.y,l.w,l.h),t.fillStyle=o.borderColor,t.fill("evenodd")),t.fillStyle=o.backgroundColor,t.fillRect(l.x,l.y,l.w,l.h),t.restore()},a.inRange=function(t,e,i){return Gn(this,t,e,i)},a.inXRange=function(t,e){return Gn(this,t,null,e)},a.inYRange=function(t,e){return Gn(this,null,t,e)},a.getCenterPoint=function(t){var e=this.getProps(["x","y","base","horizontal"],t),i=e.x,n=e.y,r=e.base,a=e.horizontal;return{x:a?(i+r)/2:i,y:a?n:(n+r)/2}},a.getRange=function(t){return"x"===t?this.width/2:this.height/2},e}(Ti);$n.id="rectangle",$n.defaults={borderSkipped:"start",borderWidth:0},$n.defaultRoutes={backgroundColor:"color",borderColor:"color"};var Zn=Object.freeze({__proto__:null,Arc:On,Line:Hn,Point:jn,Rectangle:$n});function Qn(t,e,i){var n=function(t){var e=t.options,i=e.fill,n=p(i&&i.target,i);return void 0===n&&(n=!!e.backgroundColor),!1!==n&&null!==n&&(!0===n?"origin":n)}(t),r=parseFloat(n);return f(r)&&Math.floor(r)===r?("-"!==n[0]&&"+"!==n[0]||(r=e+r),!(r===e||r<0||r>=i)&&r):["origin","start","end"].indexOf(n)>=0&&n}var Jn=function(){function t(t){this.x=t.x,this.y=t.y,this.radius=t.radius}var e=t.prototype;return e.pathSegment=function(t,e,i){var n=this.x,r=this.y,a=this.radius;return e=e||{start:0,end:2*Math.PI},i.reverse?t.arc(n,r,a,e.end,e.start,!0):t.arc(n,r,a,e.start,e.end),!i.bounds},e.interpolate=function(t,e){var i=this.x,n=this.y,r=this.radius,a=t.angle;if("angle"===e)return{x:i+Math.cos(a)*r,y:n+Math.sin(a)*r,angle:a}},t}();function tr(t){return(t.scale||{}).getPointPositionForValue?function(t){var e,i,n=t.scale,r=t.fill,a=n.options,o=n.getLabels().length,s=[],l=a.reverse?n.max:n.min,c=a.reverse?n.min:n.max,u="start"===r?l:"end"===r?c:n.getBaseValue();if(a.gridLines.circular)return i=n.getPointPositionForValue(0,l),new Jn({x:i.x,y:i.y,radius:n.getDistanceFromCenterForValue(u)});for(e=0;e=0;--e)(i=n[e].$filler)&&i.line.updateControlPoints(r)},beforeDatasetDraw:function(t,e){var i=t.chartArea,n=t.ctx,r=e.meta.$filler;if(r&&!1!==r.fill){var a=r.line,o=r.target,s=r.scale,l=a.options,c=l.fill,u=l.backgroundColor,h=c||{},d=h.above,f=void 0===d?u:d,p=h.below,g=void 0===p?u:p;o&&a.points.length&&(N(n,i),function(t,e){var i=e.line,n=e.target,r=e.above,a=e.below,o=e.area,s=e.scale,l=i._loop?"angle":"x";t.save(),"x"===l&&a!==r&&(nr(t,n,o.top),lr(t,{line:i,target:n,color:r,scale:s,property:l}),t.restore(),t.save(),nr(t,n,o.bottom)),lr(t,{line:i,target:n,color:a,scale:s,property:l}),t.restore()}(n,{line:a,target:o,above:f,below:g,area:i,scale:s}),H(n))}},defaults:{propagate:!0}};function ur(t,e){var i=t.boxWidth;return t.usePointStyle&&i>e||u(i)?e:i}function hr(t,e){var i=t.boxHeight;return t.usePointStyle&&i>e||u(i)?e:i}var dr=function(t){function e(e){var n;return i(r(n=t.call(this)||this),e),n.legendHitBoxes=[],n._hoveredItem=null,n.doughnutMode=!1,n.chart=e.chart,n.options=e.options,n.ctx=e.ctx,n.legendItems=void 0,n.columnWidths=void 0,n.columnHeights=void 0,n.lineWidths=void 0,n._minSize=void 0,n.maxHeight=void 0,n.maxWidth=void 0,n.top=void 0,n.bottom=void 0,n.left=void 0,n.right=void 0,n.height=void 0,n.width=void 0,n._margins=void 0,n.paddingTop=void 0,n.paddingBottom=void 0,n.paddingLeft=void 0,n.paddingRight=void 0,n.position=void 0,n.weight=void 0,n.fullWidth=void 0,n}n(e,t);var a=e.prototype;return a.beforeUpdate=function(){},a.update=function(t,e,i){var n=this;n.beforeUpdate(),n.maxWidth=t,n.maxHeight=e,n._margins=i,n.beforeSetDimensions(),n.setDimensions(),n.afterSetDimensions(),n.beforeBuildLabels(),n.buildLabels(),n.afterBuildLabels(),n.beforeFit(),n.fit(),n.afterFit(),n.afterUpdate()},a.afterUpdate=function(){},a.beforeSetDimensions=function(){},a.setDimensions=function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t._minSize={width:0,height:0}},a.afterSetDimensions=function(){},a.beforeBuildLabels=function(){},a.buildLabels=function(){var t=this,e=t.options.labels||{},i=g(e.generateLabels,[t.chart],t)||[];e.filter&&(i=i.filter((function(i){return e.filter(i,t.chart.data)}))),t.options.reverse&&i.reverse(),t.legendItems=i},a.afterBuildLabels=function(){},a.beforeFit=function(){},a.fit=function(){var t=this,e=t.options,i=e.labels,n=e.display,r=t.ctx,a=bt(i.font),o=a.size,s=ur(i,o),l=hr(i,o),c=Math.max(l,o),u=t.legendHitBoxes=[],h=t._minSize,d=t.isHorizontal(),f=t._computeTitleHeight();if(d?(h.width=t.maxWidth,h.height=n?10:0):(h.width=n?10:0,h.height=t.maxHeight),n){if(r.font=a.string,d){var p=t.lineWidths=[0],g=f;r.textAlign="left",r.textBaseline="middle",t.legendItems.forEach((function(t,e){var n=s+o/2+r.measureText(t.text).width;(0===e||p[p.length-1]+n+2*i.padding>h.width)&&(g+=c+i.padding,p[p.length-(e>0?0:1)]=0),u[e]={left:0,top:0,width:n,height:c},p[p.length-1]+=n+i.padding})),h.height+=g}else{var v=i.padding,m=t.columnWidths=[],b=t.columnHeights=[],x=i.padding,y=0,_=0,M=h.height-f;t.legendItems.forEach((function(t,e){var n=s+o/2+r.measureText(t.text).width;e>0&&_+o+2*v>M&&(x+=y+i.padding,m.push(y),b.push(_),y=0,_=0),y=Math.max(y,n),_+=o+v,u[e]={left:0,top:0,width:n,height:c}})),x+=y,m.push(y),b.push(_),h.width+=x}t.width=h.width,t.height=h.height}else t.width=h.width=t.height=h.height=0},a.afterFit=function(){},a.isHorizontal=function(){return"top"===this.options.position||"bottom"===this.options.position},a.draw=function(){var t=this,e=t.options,i=e.labels,n=D.color,r=D.elements.line,a=t.height,o=t.columnHeights,s=t.width,l=t.lineWidths;if(e.display){t.drawTitle();var c,u=rn(e.rtl,t.left,t._minSize.width),h=t.ctx,d=bt(i.font),f=d.color,g=d.size;h.textAlign=u.textAlign("left"),h.textBaseline="middle",h.lineWidth=.5,h.strokeStyle=f,h.fillStyle=f,h.font=d.string;var v=ur(i,g),m=hr(i,g),b=Math.max(g,m),x=t.legendHitBoxes,y=function(t,n){switch(e.align){case"start":return i.padding;case"end":return t-n;default:return(t-n+i.padding)/2}},_=t.isHorizontal(),M=this._computeTitleHeight();c=_?{x:t.left+y(s,l[0]),y:t.top+i.padding+M,line:0}:{x:t.left+i.padding,y:t.top+y(a,o[0])+M,line:0},an(t.ctx,e.textDirection);var w=b+i.padding;t.legendItems.forEach((function(e,d){var f=h.measureText(e.text).width,M=v+g/2+f,k=c.x,P=c.y;u.setWidth(t._minSize.width),_?d>0&&k+M+i.padding>t.left+t._minSize.width&&(P=c.y+=w,c.line++,k=c.x=t.left+y(s,l[c.line])):d>0&&P+w>t.top+t._minSize.height&&(k=c.x=k+t.columnWidths[c.line]+i.padding,c.line++,P=c.y=t.top+y(a,o[c.line]));var S=u.x(k);!function(t,e,a){if(!(isNaN(v)||v<=0||isNaN(m)||m<0)){h.save();var o=p(a.lineWidth,r.borderWidth);if(h.fillStyle=p(a.fillStyle,n),h.lineCap=p(a.lineCap,r.borderCapStyle),h.lineDashOffset=p(a.lineDashOffset,r.borderDashOffset),h.lineJoin=p(a.lineJoin,r.borderJoinStyle),h.lineWidth=o,h.strokeStyle=p(a.strokeStyle,n),h.setLineDash&&h.setLineDash(p(a.lineDash,r.borderDash)),i&&i.usePointStyle){var s={radius:v*Math.SQRT2/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:o},l=u.xPlus(t,v/2);B(h,s,l,e+g/2)}else{var c=e+Math.max((g-m)/2,0);h.fillRect(u.leftForLtr(t,v),c,v,m),0!==o&&h.strokeRect(u.leftForLtr(t,v),c,v,m)}h.restore()}}(S,P,e),x[d].left=u.leftForLtr(S,x[d].width),x[d].top=P,function(t,e,i,n){var r=g/2,a=u.xPlus(t,v+r),o=e+b/2;h.fillText(i.text,a,o),i.hidden&&(h.beginPath(),h.lineWidth=2,h.moveTo(a,o),h.lineTo(u.xPlus(a,n),o),h.stroke())}(S,P,e,f),_?c.x+=M+i.padding:c.y+=w})),on(t.ctx,e.textDirection)}},a.drawTitle=function(){var t=this,e=t.options,i=e.title,n=bt(i.font),r=mt(i.padding);if(i.display){var a,o,s=rn(e.rtl,t.left,t._minSize.width),l=t.ctx,c=i.position,u=n.size/2,h=t.top+r.top+u,d=t.left,f=t.width;if(this.isHorizontal())switch(f=Math.max.apply(Math,t.lineWidths),e.align){case"start":break;case"end":d=t.right-f;break;default:d=(t.left+t.right)/2-f/2}else{var p=Math.max.apply(Math,t.columnHeights);switch(e.align){case"start":break;case"end":h+=t.height-p;break;default:h+=(t.height-p)/2}}switch(c){case"start":a=d,o="left";break;case"end":a=d+f,o="right";break;default:a=d+f/2,o="center"}l.textAlign=s.textAlign(o),l.textBaseline="middle",l.strokeStyle=n.color,l.fillStyle=n.color,l.font=n.string,l.fillText(i.text,a,h)}},a._computeTitleHeight=function(){var t=this.options.title,e=bt(t.font),i=mt(t.padding);return t.display?e.lineHeight+i.height:0},a._getLegendItemAt=function(t,e){var i,n,r,a=this;if(t>=a.left&&t<=a.right&&e>=a.top&&e<=a.bottom)for(r=a.legendHitBoxes,i=0;i=(n=r[i]).left&&t<=n.left+n.width&&e>=n.top&&e<=n.top+n.height)return a.legendItems[i];return null},a.handleEvent=function(t){var e=this,i=e.options,n="mouseup"===t.type?"click":t.type;if("mousemove"===n){if(!i.onHover&&!i.onLeave)return}else{if("click"!==n)return;if(!i.onClick)return}var r=e._getLegendItemAt(t.x,t.y);"click"===n?r&&g(i.onClick,[t,r,e],e):(i.onLeave&&r!==e._hoveredItem&&(e._hoveredItem&&g(i.onLeave,[t,e._hoveredItem,e],e),e._hoveredItem=r),r&&g(i.onHover,[t,r,e],e))},e}(Ti);function fr(t){return!1!==t&&y({},[D.plugins.legend,t])}function pr(t,e){var i=new dr({ctx:t.ctx,options:e,chart:t});Ot.configure(t,i,e),Ot.addBox(t,i),t.legend=i}var gr={id:"legend",_element:dr,beforeInit:function(t){var e=fr(t.options.legend);e&&pr(t,e)},beforeUpdate:function(t){var e=fr(t.options.legend),i=t.legend;e?i?(Ot.configure(t,i,e),i.options=e):pr(t,e):i&&(Ot.removeBox(t,i),delete t.legend)},afterUpdate:function(t){t.legend&&t.legend.buildLabels()},afterEvent:function(t,e){var i=t.legend;i&&i.handleEvent(e)},defaults:{display:!0,position:"top",align:"center",fullWidth:!0,reverse:!1,weight:1e3,onClick:function(t,e,i){var n=e.datasetIndex,r=i.chart;r.isDatasetVisible(n)?(r.hide(n),e.hidden=!0):(r.show(n),e.hidden=!1)},onHover:null,onLeave:null,labels:{boxWidth:40,padding:10,generateLabels:function(t){var e=t.data.datasets,i=t.options.legend||{},n=i.labels&&i.labels.usePointStyle;return t._getSortedDatasetMetas().map((function(t){var i=t.controller.getStyle(n?0:void 0);return{text:e[t.index].label,fillStyle:i.backgroundColor,hidden:!t.visible,lineCap:i.borderCapStyle,lineDash:i.borderDash,lineDashOffset:i.borderDashOffset,lineJoin:i.borderJoinStyle,lineWidth:i.borderWidth,strokeStyle:i.borderColor,pointStyle:i.pointStyle,rotation:i.rotation,datasetIndex:t.index}}),this)}},title:{display:!1,position:"center",text:""}}},vr=function(t){function e(e){var n;return i(r(n=t.call(this)||this),e),n.chart=e.chart,n.options=e.options,n.ctx=e.ctx,n._margins=void 0,n._padding=void 0,n.top=void 0,n.bottom=void 0,n.left=void 0,n.right=void 0,n.width=void 0,n.height=void 0,n.maxWidth=void 0,n.maxHeight=void 0,n.position=void 0,n.weight=void 0,n.fullWidth=void 0,n}n(e,t);var a=e.prototype;return a.beforeUpdate=function(){},a.update=function(t,e,i){var n=this;n.beforeUpdate(),n.maxWidth=t,n.maxHeight=e,n._margins=i,n.beforeSetDimensions(),n.setDimensions(),n.afterSetDimensions(),n.beforeBuildLabels(),n.buildLabels(),n.afterBuildLabels(),n.beforeFit(),n.fit(),n.afterFit(),n.afterUpdate()},a.afterUpdate=function(){},a.beforeSetDimensions=function(){},a.setDimensions=function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height)},a.afterSetDimensions=function(){},a.beforeBuildLabels=function(){},a.buildLabels=function(){},a.afterBuildLabels=function(){},a.beforeFit=function(){},a.fit=function(){var t=this,e=t.options,i={},n=t.isHorizontal();if(e.display){var r=h(e.text)?e.text.length:1;t._padding=mt(e.padding);var a=r*bt(e.font).lineHeight+t._padding.height;t.width=i.width=n?t.maxWidth:a,t.height=i.height=n?a:t.maxHeight}else t.width=i.width=t.height=i.height=0},a.afterFit=function(){},a.isHorizontal=function(){var t=this.options.position;return"top"===t||"bottom"===t},a.draw=function(){var t=this,e=t.ctx,i=t.options;if(i.display){var n,r,a,o,s=bt(i.font),l=s.lineHeight,c=l/2+t._padding.top,u=0,d=t.top,f=t.left,p=t.bottom,g=t.right;if(t.isHorizontal()){switch(i.align){case"start":r=f,o="left";break;case"end":r=g,o="right";break;default:r=f+(g-f)/2,o="center"}a=d+c,n=g-f}else{switch(r="left"===i.position?f+c:g-c,i.align){case"start":a="left"===i.position?p:d,o="left";break;case"end":a="left"===i.position?d:p,o="right";break;default:a=d+(p-d)/2,o="center"}n=p-d,u=Math.PI*("left"===i.position?-.5:.5)}e.save(),e.fillStyle=s.color,e.font=s.string,e.translate(r,a),e.rotate(u),e.textAlign=o,e.textBaseline="middle";var v=i.text;if(h(v))for(var m=0,b=0;b-1?t.split("\n"):t}function Mr(t,e){var i=e.element,n=e.datasetIndex,r=e.index,a=t.getDatasetMeta(n).controller,o=a.getLabelAndValue(r),s=o.label,l=o.value;return{chart:t,label:s,dataPoint:a.getParsed(r),formattedValue:l,dataset:a.getDataset(),dataIndex:r,datasetIndex:n,element:i}}function wr(t){var e=t._chart.ctx,i=t.body,n=t.footer,r=t.options,a=t.title,o=r.bodyFont,s=r.footerFont,l=r.titleFont,c=r.boxWidth,u=r.boxHeight,h=a.length,d=n.length,f=i.length,p=2*r.yPadding,g=0,m=i.reduce((function(t,e){return t+e.before.length+e.lines.length+e.after.length}),0);(m+=t.beforeBody.length+t.afterBody.length,h&&(p+=h*l.size+(h-1)*r.titleSpacing+r.titleMarginBottom),m)&&(p+=f*(r.displayColors?Math.max(u,o.size):o.size)+(m-f)*o.size+(m-1)*r.bodySpacing);d&&(p+=r.footerMarginTop+d*s.size+(d-1)*r.footerSpacing);var b=0,x=function(t){g=Math.max(g,e.measureText(t).width+b)};return e.save(),e.font=l.string,v(t.title,x),e.font=o.string,v(t.beforeBody.concat(t.afterBody),x),b=r.displayColors?c+2:0,v(i,(function(t){v(t.before,x),v(t.lines,x),v(t.after,x)})),b=0,e.font=s.string,v(t.footer,x),e.restore(),{width:g+=2*r.xPadding,height:p}}function kr(t,e,i){var n,r,a=i.x,o=i.y,s=i.width,l=i.height,c=t.chartArea,u="center",h="center";ot.height-l&&(h="bottom");var d=(c.left+c.right)/2,f=(c.top+c.bottom)/2;"center"===h?(n=function(t){return t<=d},r=function(t){return t>d}):(n=function(t){return t<=s/2},r=function(e){return e>=t.width-s/2});var p=function(t){return t<=f?"top":"bottom"};return n(a)?(u="left",a+s+e.caretSize+e.caretPadding>t.width&&(u="center",h=p(o))):r(a)&&(u="right",function(t){return t-s-e.caretSize-e.caretPadding<0}(a)&&(u="center",h=p(o))),{xAlign:e.xAlign?e.xAlign:u,yAlign:e.yAlign?e.yAlign:h}}function Pr(t,e,i,n){var r=t.caretSize,a=t.caretPadding,o=t.cornerRadius,s=i.xAlign,l=i.yAlign,c=r+a,u=o+a,h=function(t,e,i){var n=t.x,r=t.width;return"right"===e?n-=r:"center"===e&&((n-=r/2)+r>i&&(n=i-r),n<0&&(n=0)),n}(e,s,n.width);return"center"===l?"left"===s?h+=c:"right"===s&&(h-=c):"left"===s?h-=u:"right"===s&&(h+=u),{x:h,y:function(t,e,i){var n=t.y,r=t.height;return"top"===e?n+=i:n-="bottom"===e?r+i:r/2,n}(e,l,c)}}function Sr(t,e){var i=t.options;return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-i.xPadding:t.x+i.xPadding}function Dr(t){return yr([],_r(t))}var Tr=function(t){function e(e){var i;return(i=t.call(this)||this).opacity=0,i._active=[],i._chart=e._chart,i._eventPosition=void 0,i._size=void 0,i._cachedAnimations=void 0,i.$animations=void 0,i.options=void 0,i.dataPoints=void 0,i.title=void 0,i.beforeBody=void 0,i.body=void 0,i.afterBody=void 0,i.footer=void 0,i.xAlign=void 0,i.yAlign=void 0,i.x=void 0,i.y=void 0,i.height=void 0,i.width=void 0,i.caretX=void 0,i.caretY=void 0,i.labelColors=void 0,i.labelTextColors=void 0,i.initialize(),i}n(e,t);var r=e.prototype;return r.initialize=function(){this.options=function(t){return(t=y({},[D.plugins.tooltip,t])).bodyFont=bt(t.bodyFont),t.titleFont=bt(t.titleFont),t.footerFont=bt(t.footerFont),t.boxHeight=p(t.boxHeight,t.bodyFont.size),t.boxWidth=p(t.boxWidth,t.bodyFont.size),t}(this._chart.options.tooltips)},r._resolveAnimations=function(){var t=this,e=t._cachedAnimations;if(e)return e;var i=t._chart,n=t.options,r=n.enabled&&i.options.animation&&n.animation,a=new Qe(t._chart,r);return t._cachedAnimations=Object.freeze(a),a},r.getTitle=function(t){var e=this.options.callbacks,i=e.beforeTitle.apply(this,[t]),n=e.title.apply(this,[t]),r=e.afterTitle.apply(this,[t]),a=[];return a=yr(a,_r(i)),a=yr(a,_r(n)),a=yr(a,_r(r))},r.getBeforeBody=function(t){return Dr(this.options.callbacks.beforeBody.apply(this,[t]))},r.getBody=function(t){var e=this,i=e.options.callbacks,n=[];return v(t,(function(t){var r={before:[],lines:[],after:[]};yr(r.before,_r(i.beforeLabel.call(e,t))),yr(r.lines,i.label.call(e,t)),yr(r.after,_r(i.afterLabel.call(e,t))),n.push(r)})),n},r.getAfterBody=function(t){return Dr(this.options.callbacks.afterBody.apply(this,[t]))},r.getFooter=function(t){var e=this.options.callbacks,i=e.beforeFooter.apply(this,[t]),n=e.footer.apply(this,[t]),r=e.afterFooter.apply(this,[t]),a=[];return a=yr(a,_r(i)),a=yr(a,_r(n)),a=yr(a,_r(r))},r._createItems=function(){var t,e,i=this,n=i._active,r=i.options,a=i._chart.data,o=[],s=[],l=[];for(t=0,e=n.length;t0&&e.stroke()},r._updateAnimationTarget=function(){var t=this,e=t._chart,n=t.options,r=t.$animations,a=r&&r.x,o=r&&r.y;if(a||o){var s=xr[n.position].call(t,t._active,t._eventPosition);if(!s)return;var l=t._size=wr(t),c=i({},s,t._size),u=kr(e,n,c),h=Pr(n,c,u,e);a._to===h.x&&o._to===h.y||(t.xAlign=u.xAlign,t.yAlign=u.yAlign,t.width=l.width,t.height=l.height,t.caretX=s.x,t.caretY=s.y,t._resolveAnimations().update(t,h))}},r.draw=function(t){var e=this,i=e.options,n=e.opacity;if(n){e._updateAnimationTarget();var r={width:e.width,height:e.height},a={x:e.x,y:e.y};n=Math.abs(n)<.001?0:n;var o=e.title.length||e.beforeBody.length||e.body.length||e.afterBody.length||e.footer.length;i.enabled&&o&&(t.save(),t.globalAlpha=n,e.drawBackground(a,t,r),an(t,i.textDirection),a.y+=i.yPadding,e.drawTitle(a,t),e.drawBody(a,t),e.drawFooter(a,t),on(t,i.textDirection),t.restore())}},r.handleEvent=function(t,e){var i,n=this,r=n.options,a=n._active||[],o=[];"mouseout"!==t.type&&(o=n._chart.getElementsAtEventForMode(t,r.mode,r,e),r.reverse&&o.reverse());var s=xr[r.position].call(n,o,t),l=this.caretX!==s.x||this.caretY!==s.y;return(i=e||!m(o,a)||l)&&(n._active=o,(r.enabled||r.custom)&&(n._eventPosition={x:t.x,y:t.y},n.update(!0))),i},e}(Ti);Tr.positioners=xr;var Ar={id:"tooltip",_element:Tr,positioners:xr,afterInit:function(t){t.options.tooltips&&(t.tooltip=new Tr({_chart:t}))},beforeUpdate:function(t){t.tooltip&&t.tooltip.initialize()},reset:function(t){t.tooltip&&t.tooltip.initialize()},afterDraw:function(t){var e=t.tooltip,i={tooltip:e};!1!==t._plugins.notify(t,"beforeTooltipDraw",[i])&&(e&&e.draw(t.ctx),t._plugins.notify(t,"afterTooltipDraw",[i]))},afterEvent:function(t,e,i){if(t.tooltip){var n=i;t.tooltip.handleEvent(e,n)}},defaults:{enabled:!0,custom:null,mode:"nearest",position:"average",intersect:!0,backgroundColor:"rgba(0,0,0,0.8)",titleFont:{style:"bold",color:"#fff"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodySpacing:2,bodyFont:{color:"#fff"},bodyAlign:"left",footerSpacing:2,footerMarginTop:6,footerFont:{color:"#fff",style:"bold"},footerAlign:"left",yPadding:6,xPadding:6,caretPadding:2,caretSize:5,cornerRadius:6,multiKeyBackground:"#fff",displayColors:!0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart",numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:{beforeTitle:s,title:function(t){if(t.length>0){var e=t[0],i=e.chart.data.labels,n=i?i.length:0;if(e.label)return e.label;if(n>0&&e.dataIndex=0&&te.length-1?null:this.getPixelForValue(e[t].value)},i.getValueForPixel=function(t){var e=Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange);return Math.min(Math.max(e,0),this.ticks.length-1)},i.getBasePixel=function(){return this.bottom},e}(Ii);function Cr(t){var e=Math.floor(ni(t)),i=t/Math.pow(10,e);return(i<=1?1:i<=2?2:i<=5?5:10)*Math.pow(10,e)}Er.id="category",Er.defaults={ticks:{callback:Er.prototype.getLabelForValue}};var Lr=function(t){function e(e){var i;return(i=t.call(this,e)||this).start=void 0,i.end=void 0,i._startValue=void 0,i._endValue=void 0,i._valueRange=0,i}n(e,t);var i=e.prototype;return i.parse=function(t,e){return u(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?NaN:+t},i.handleTickRangeOptions=function(){var t=this,e=t.options;if(e.beginAtZero){var i=li(t.min),n=li(t.max);i<0&&n<0?t.max=0:i>0&&n>0&&(t.min=0)}var r=void 0!==e.min||void 0!==e.suggestedMin,a=void 0!==e.max||void 0!==e.suggestedMax;void 0!==e.min?t.min=e.min:void 0!==e.suggestedMin&&(null===t.min?t.min=e.suggestedMin:t.min=Math.min(t.min,e.suggestedMin)),void 0!==e.max?t.max=e.max:void 0!==e.suggestedMax&&(null===t.max?t.max=e.suggestedMax:t.max=Math.max(t.max,e.suggestedMax)),r!==a&&t.min>=t.max&&(r?t.max=t.min+1:t.min=t.max-1),t.min===t.max&&(t.max++,e.beginAtZero||t.min--)},i.getTickLimit=function(){var t,e=this.options.ticks,i=e.maxTicksLimit,n=e.stepSize;return n?t=Math.ceil(this.max/n)-Math.floor(this.min/n)+1:(t=this.computeTickLimit(),i=i||11),i&&(t=Math.min(i,t)),t},i.computeTickLimit=function(){return Number.POSITIVE_INFINITY},i.buildTicks=function(){var t=this,e=t.options,i=e.ticks,n=t.getTickLimit(),r=function(t,e){var i,n,r,a,o=[],s=t.stepSize,l=t.min,c=t.max,h=t.precision,d=s||1,f=t.maxTicks-1,p=e.min,g=e.max,v=Cr((g-p)/f/d)*d;if(v<1e-14&&u(l)&&u(c))return[{value:p},{value:g}];(a=Math.ceil(g/v)-Math.floor(p/v))>f&&(v=Cr(a*v/f/d)*d),s||u(h)?i=Math.pow(10,hi(v)):(i=Math.pow(10,h),v=Math.ceil(v*i)/i),n=Math.floor(p/v)*v,r=Math.ceil(g/v)*v,!s||u(l)||u(c)||oi((c-l)/s,v/1e3)&&(n=l,r=c),a=ai(a=(r-n)/v,Math.round(a),v/1e3)?Math.round(a):Math.ceil(a),n=Math.round(n*i)/i,r=Math.round(r*i)/i,o.push({value:u(l)?n:l});for(var m=1;m0&&(t.min=0),t.handleTickRangeOptions()},i.computeTickLimit=function(){if(this.isHorizontal())return Math.ceil(this.width/40);var t=this._resolveTickFontOptions(0);return Math.ceil(this.height/t.lineHeight)},i.getPixelForValue=function(t){return this.getPixelForDecimal((t-this._startValue)/this._valueRange)},i.getValueForPixel=function(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange},e}(Lr);function Rr(t){return 1===t/Math.pow(10,Math.floor(ni(t)))}function Ir(t,e){return f(t)?t:e}Fr.id="linear",Fr.defaults={ticks:{callback:Oi.formatters.numeric}};var zr=function(t){function e(e){var i;return(i=t.call(this,e)||this).start=void 0,i.end=void 0,i._startValue=void 0,i._valueRange=0,i}n(e,t);var i=e.prototype;return i.parse=function(t,e){var i=Lr.prototype.parse.apply(this,[t,e]);if(0!==i)return f(i)&&i>0?i:NaN},i.determineDataLimits=function(){var t=this.getMinMax(!0),e=t.min,i=t.max;this.min=f(e)?Math.max(0,e):null,this.max=f(i)?Math.max(0,i):null,this.handleTickRangeOptions()},i.handleTickRangeOptions=function(){var t=this.min,e=this.max;t===e&&(t<=0?(t=1,e=10):(t=Math.pow(10,Math.floor(ni(t))-1),e=Math.pow(10,Math.floor(ni(e))+1))),t<=0&&(t=Math.pow(10,Math.floor(ni(e))-1)),e<=0&&(e=Math.pow(10,Math.floor(ni(t))+1)),this.min=t,this.max=e},i.buildTicks=function(){var t=this,e=t.options,i=function(t,e){var i=Math.floor(ni(e.max)),n=Math.ceil(e.max/Math.pow(10,i)),r=[],a=Ir(t.min,Math.pow(10,Math.floor(ni(e.min)))),o=Math.floor(ni(a)),s=Math.floor(a/Math.pow(10,o)),l=o<0?Math.pow(10,Math.abs(o)):1;do{r.push({value:a,major:Rr(a)}),10===++s&&(s=1,l=++o>=0?1:l),a=Math.round(s*Math.pow(10,o)*l)/l}while(or?{start:e-i,end:e}:{start:e,end:e+i}}function Wr(t){return 0===t||180===t?"center":t<180?"left":"right"}function Nr(t,e,i,n){var r,a,o=i.y+n/2;if(h(e))for(r=0,a=e.length;r270||t<90)&&(i.y-=e.h)}function jr(t){return ri(t)?t:0}zr.id="logarithmic",zr.defaults={ticks:{callback:Oi.formatters.logarithmic,major:{enabled:!0}}};var Yr=function(t){function e(e){var i;return(i=t.call(this,e)||this).xCenter=void 0,i.yCenter=void 0,i.drawingArea=void 0,i.pointLabels=[],i}n(e,t);var i=e.prototype;return i.init=function(e){t.prototype.init.call(this,e),this.axis="r"},i.setDimensions=function(){var t=this;t.width=t.maxWidth,t.height=t.maxHeight,t.paddingTop=Vr(t.options)/2,t.xCenter=Math.floor(t.width/2),t.yCenter=Math.floor((t.height-t.paddingTop)/2),t.drawingArea=Math.min(t.height-t.paddingTop,t.width)/2},i.determineDataLimits=function(){var t=this.getMinMax(!1),e=t.min,i=t.max;this.min=f(e)&&!isNaN(e)?e:0,this.max=f(i)&&!isNaN(i)?i:0,this.handleTickRangeOptions()},i.computeTickLimit=function(){return Math.ceil(this.drawingArea/Vr(this.options))},i.generateTickLabels=function(t){var e=this;Lr.prototype.generateTickLabels.call(e,t),e.pointLabels=e.chart.data.labels.map((function(t,i){var n=g(e.options.pointLabels.callback,[t,i],e);return n||0===n?n:""}))},i.fit=function(){var t=this.options;t.display&&t.pointLabels.display?function(t){var e,i,n,r={l:0,r:t.width,t:0,b:t.height-t.paddingTop},a={};t._pointLabelSizes=[];var o,s,l,c=t.chart.data.labels.length;for(e=0;er.r&&(r.r=g.end,a.r=f),v.startr.b&&(r.b=v.end,a.b=f)}t._setReductions(t.drawingArea,r,a)}(this):this.setCenterPoint(0,0,0,0)},i._setReductions=function(t,e,i){var n=this,r=e.l/Math.sin(i.l),a=Math.max(e.r-n.width,0)/Math.sin(i.r),o=-e.t/Math.cos(i.t),s=-Math.max(e.b-(n.height-n.paddingTop),0)/Math.cos(i.b);r=jr(r),a=jr(a),o=jr(o),s=jr(s),n.drawingArea=Math.min(Math.floor(t-(r+a)/2),Math.floor(t-(o+s)/2)),n.setCenterPoint(r,a,o,s)},i.setCenterPoint=function(t,e,i,n){var r=this,a=r.width-e-r.drawingArea,o=t+r.drawingArea,s=i+r.drawingArea,l=r.height-r.paddingTop-n-r.drawingArea;r.xCenter=Math.floor((o+a)/2+r.left),r.yCenter=Math.floor((s+l)/2+r.top+r.paddingTop)},i.getIndexAngle=function(t){var e=this.chart;return gi(t*(2*Math.PI/e.data.labels.length)+ci((e.options||{}).startAngle||0))},i.getDistanceFromCenterForValue=function(t){var e=this;if(u(t))return NaN;var i=e.drawingArea/(e.max-e.min);return e.options.reverse?(e.max-t)*i:(t-e.min)*i},i.getValueForDistanceFromCenter=function(t){if(u(t))return NaN;var e=this,i=t/(e.drawingArea/(e.max-e.min));return e.options.reverse?e.max-i:e.min+i},i.getPointPosition=function(t,e){var i=this.getIndexAngle(t)-Math.PI/2;return{x:Math.cos(i)*e+this.xCenter,y:Math.sin(i)*e+this.yCenter,angle:i}},i.getPointPositionForValue=function(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))},i.getBasePosition=function(t){return this.getPointPositionForValue(t||0,this.getBaseValue())},i.drawGrid=function(){var t,e,i,n=this,r=n.ctx,a=n.options,o=a.gridLines,s=a.angleLines;if(a.pointLabels.display&&function(t){var e=t.ctx,i=t.options,n=i.pointLabels,r=Vr(i),a=t.getDistanceFromCenterForValue(i.ticks.reverse?t.min:t.max);e.save(),e.textBaseline="middle";for(var o=t.chart.data.labels.length-1;o>=0;o--){var s=0===o?r/2:0,l=t.getPointPosition(o,a+s+5),c={chart:t.chart,scale:t,index:o,label:t.pointLabels[o]},u=bt(xt([n.font],c,o));e.font=u.string,e.fillStyle=u.color;var h=ui(t.getIndexAngle(o));e.textAlign=Wr(h),Hr(h,t._pointLabelSizes[o],l),Nr(e,t.pointLabels[o],l,u.lineHeight)}e.restore()}(n),o.display&&n.ticks.forEach((function(t,i){0!==i&&(e=n.getDistanceFromCenterForValue(n.ticks[i].value),function(t,e,i,n){var r,a=t.ctx,o=e.circular,s=t.chart.data.labels.length,l={chart:t.chart,scale:t,index:n,tick:t.ticks[n]},c=xt([e.color],l,n-1),u=xt([e.lineWidth],l,n-1);if((o||s)&&c&&u){if(a.save(),a.strokeStyle=c,a.lineWidth=u,a.setLineDash&&(a.setLineDash(xt([e.borderDash,[]],l)),a.lineDashOffset=xt([e.borderDashOffset],l,n-1)),a.beginPath(),o)a.arc(t.xCenter,t.yCenter,i,0,2*Math.PI);else{r=t.getPointPosition(0,i),a.moveTo(r.x,r.y);for(var h=1;h=0;t--){var l={chart:n.chart,scale:n,index:t,label:n.pointLabels[t]},c=xt([s.lineWidth,o.lineWidth],l,t),u=xt([s.color,o.color],l,t);c&&u&&(r.lineWidth=c,r.strokeStyle=u,r.setLineDash&&(r.setLineDash(xt([s.borderDash,o.borderDash,[]],l)),r.lineDashOffset=xt([s.borderDashOffset,o.borderDashOffset,0],l,t)),e=n.getDistanceFromCenterForValue(a.ticks.reverse?n.min:n.max),i=n.getPointPosition(t,e),r.beginPath(),r.moveTo(n.xCenter,n.yCenter),r.lineTo(i.x,i.y),r.stroke())}r.restore()}},i.drawLabels=function(){var t=this,e=t.ctx,i=t.options,n=i.ticks;if(n.display){var r,a,o=t.getIndexAngle(0);e.save(),e.translate(t.xCenter,t.yCenter),e.rotate(o),e.textAlign="center",e.textBaseline="middle",t.ticks.forEach((function(o,s){var l={chart:t.chart,scale:t,index:s,tick:o};if(0!==s||i.reverse){var c=t._resolveTickFontOptions(s);e.font=c.string,r=t.getDistanceFromCenterForValue(t.ticks[s].value),xt([n.showLabelBackdrop],l,s)&&(a=e.measureText(o.label).width,e.fillStyle=xt([n.backdropColor],l,s),e.fillRect(-a/2-n.backdropPaddingX,-r-c.size/2-n.backdropPaddingY,a+2*n.backdropPaddingX,c.size+2*n.backdropPaddingY)),e.fillStyle=c.color,e.fillText(o.label,0,-r)}})),e.restore()}},i.drawTitle=function(){},e}(Lr);Yr.id="radialLinear",Yr.defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,color:"rgba(0,0,0,0.1)",lineWidth:1,borderDash:[],borderDashOffset:0},gridLines:{circular:!1},ticks:{showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2,callback:Oi.formatters.numeric},pointLabels:{display:!0,font:{size:10},callback:function(t){return t}}};var Xr=Number.MAX_SAFE_INTEGER||9007199254740991,Ur={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},qr=Object.keys(Ur);function Kr(t,e){return t-e}function Gr(t,e){if(u(e))return null;var i=t._adapter,n=t.options.time,r=n.parser,a=n.round,o=n.isoWeekday,s=e;return"function"==typeof r&&(s=r(s)),f(s)||(s="string"==typeof r?i.parse(s,r):i.parse(s)),null===s?s:(a&&(s="week"===a&&o?t._adapter.startOf(s,"isoWeek",o):t._adapter.startOf(s,a)),+s)}function $r(t,e,i,n){for(var r=qr.length,a=qr.indexOf(t);a=i?t[r]:t[a]]=!0}}function Qr(t,e,i){var n,r,a=[],o={},s=e.length;for(n=0;n=0&&(e[a].major=!0);return e}(t,a,o,i):a}var Jr=function(t){function e(e){var i;return(i=t.call(this,e)||this)._cache={data:[],labels:[],all:[]},i._unit="day",i._majorUnit=void 0,i._offsets={},i._normalized=!1,i}n(e,t);var i=e.prototype;return i.init=function(e,i){var n=e.time||(e.time={}),r=this._adapter=new un._date(e.adapters.date);_(n.displayFormats,r.formats()),t.prototype.init.call(this,e),this._normalized=i.normalized},i.parse=function(t,e){return void 0===t?NaN:Gr(this,t)},i.invalidateCaches=function(){this._cache={data:[],labels:[],all:[]}},i.determineDataLimits=function(){var t=this,e=t.options,i=t._adapter,n=e.time.unit||"day",r=t.getUserBounds(),a=r.min,o=r.max,s=r.minDefined,l=r.maxDefined;function c(t){s||isNaN(t.min)||(a=Math.min(a,t.min)),l||isNaN(t.max)||(o=Math.max(o,t.max))}s&&l||(c(t._getLabelBounds()),"ticks"===e.bounds&&"labels"===e.ticks.source||c(t.getMinMax(!1))),a=f(a)&&!isNaN(a)?a:+i.startOf(Date.now(),n),o=f(o)&&!isNaN(o)?o:+i.endOf(Date.now(),n)+1,t.min=Math.min(a,o),t.max=Math.max(a+1,o)},i._getLabelBounds=function(){var t=this.getLabelTimestamps(),e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],i=t[t.length-1]),{min:e,max:i}},i.buildTicks=function(){var t=this,e=t.options,i=e.time,n=e.ticks,r="labels"===n.source?t.getLabelTimestamps():t._generate();"ticks"===e.bounds&&r.length&&(t.min=t._userMin||r[0],t.max=t._userMax||r[r.length-1]);var a=t.min,o=function(t,e,i){for(var n=0,r=t.length;nn&&t[r-1]>i;)r--;return n>0||r=qr.indexOf(i);a--){var o=qr[a];if(Ur[o].common&&t._adapter.diff(r,n,o)>=e-1)return o}return qr[i?qr.indexOf(i):0]}(t,o.length,i.minUnit,t.min,t.max)),t._majorUnit=n.major.enabled&&"year"!==t._unit?function(t){for(var e=qr.indexOf(t)+1,i=qr.length;e1e5*l)throw new Error(n+" and "+r+" are too far apart with stepSize of "+l+" "+s);if("data"===e.options.ticks.source){var d=e.getDataTimestamps();for(t=h;t0?s:1},i.getDataTimestamps=function(){var t,e,i=this,n=i._cache.data||[];if(n.length)return n;var r=i.getMatchingVisibleMetas();if(i._normalized&&r.length)return i._cache.data=r[0].controller.getAllParsedValues(i);for(t=0,e=r.length;te&&a0&&!u(e)?e/i._maxIndex:i.getDecimalForValue(t);return i.getPixelForDecimal((n.start+r)*n.factor)},i.getDecimalForValue=function(t){return ta(this._table,t)/this._maxIndex},i.getValueForPixel=function(t){var e=this._offsets,i=this.getDecimalForPixel(t)/e.factor-e.end;return ta(this._table,i*this._maxIndex,!0)},e}(Jr);ea.id="timeseries",ea.defaults=Jr.defaults;var ia=Object.freeze({__proto__:null,CategoryScale:Er,LinearScale:Fr,LogarithmicScale:zr,RadialLinearScale:Yr,TimeScale:Jr,TimeSeriesScale:ea});return $i.register(Pn,ia,Zn,Or),$i.helpers=sn,$i._adapters=un,$i.Animation=$e,$i.animator=o,$i.animationService=Qe,$i.controllers=Vi.controllers.items,$i.DatasetController=Di,$i.defaults=D,$i.Element=Ti,$i.elements=Zn,$i.Interaction=gt,$i.layouts=Ot,$i.platforms=de,$i.registry=Vi,$i.Scale=Ii,$i.Ticks=Oi,"undefined"!=typeof window&&(window.Chart=$i),$i})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Chart=e()}(this,(function(){"use strict";function t(t,e){for(var i=0;i=0;--s)(a=o[s])._active?(a.tick(e),l=!0):(o[s]=o[o.length-1],o.pop());l&&(r.draw(),t._notify(r,n,e,"progress")),r.options.animation.debug&&function(t,e,i,n){var r=1e3/(i-n)|0,a=t.ctx;a.save(),a.clearRect(0,0,50,24),a.fillStyle="black",a.textAlign="right",e&&(a.fillText(e,50,8),a.fillText(r+" fps",50,18)),a.restore()}(r,o.length,e,t._lastDate),o.length||(n.running=!1,t._notify(r,n,e,"complete")),i+=o.length}})),t._lastDate=e,0===i&&(t._running=!1)},e._getAnims=function(t){var e=this._charts,i=e.get(t);return i||(i={running:!1,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i},e.listen=function(t,e,i){this._getAnims(t).listeners[e].push(i)},e.add=function(t,e){var i;e&&e.length&&(i=this._getAnims(t).items).push.apply(i,e)},e.has=function(t){return this._getAnims(t).items.length>0},e.start=function(t){var e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((function(t,e){return Math.max(t,e._duration)}),0),this._refresh())},e.running=function(t){if(!this._running)return!1;var e=this._charts.get(t);return!!(e&&e.running&&e.items.length)},e.stop=function(t){var e=this._charts.get(t);if(e&&e.items.length){for(var i=e.items,n=i.length-1;n>=0;--n)i[n].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}},e.remove=function(t){return this._charts.delete(t)},t}());function l(){}var c,u=(c=0,function(){return c++});function h(t){return null==t}function f(t){if(Array.isArray&&Array.isArray(t))return!0;var e=Object.prototype.toString.call(t);return"[object"===e.substr(0,7)&&"Array]"===e.substr(-6)}function d(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}var p=function(t){return("number"==typeof t||t instanceof Number)&&isFinite(+t)};function g(t,e){return void 0===t?e:t}function v(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function m(t,e,i,n){var r,a,o;if(f(t))if(a=t.length,n)for(r=a-1;r>=0;r--)e.call(i,t[r],r);else for(r=0;rn&&(n=a),n}function z(t,e,i,n){var r=(n=n||{}).data=n.data||{},a=n.garbageCollect=n.garbageCollect||[];n.font!==e&&(r=n.data={},a=n.garbageCollect=[],n.font=e),t.save(),t.font=e;var o,s,l,c,u,h=0,d=i.length;for(o=0;oi.length){for(o=0;o0&&t.stroke()}}function N(t,e){return t.x>e.left-.5&&t.xe.top-.5&&t.y1;)t[i=r+n>>1]1;)t[n=a+r>>1][e]1;)t[n=a+r>>1][e]n&&t[r-1]>i;)r--;return n>0||r0||(Z.forEach((function(e){delete t[e]})),delete t._chartjs)}}function tt(t){var e,i,n=new Set;for(e=0,i=t.length;e-1?i*parseInt(e,10)/100:parseInt(e,10)}function lt(t,e){var i=t.originalEvent||t,n=i.touches,r=n&&n.length?n[0]:i,a=r.clientX,o=r.clientY,s=r.offsetX||r.layerX||a,l=r.offsetY||r.layerY||o;if(s!==a&&l!==o)return{x:s,y:l};var c=e.canvas,u=e.currentDevicePixelRatio,h=c.getBoundingClientRect(),f=parseFloat(ot(c,"padding-left")),d=parseFloat(ot(c,"padding-top")),p=parseFloat(ot(c,"padding-right")),g=parseFloat(ot(c,"padding-bottom")),v=h.right-h.left-f-p,m=h.bottom-h.top-d-g;return{x:Math.round((s-h.left-f)/v*c.width/u),y:Math.round((l-h.top-d)/m*c.height/u)}}function ct(t,e){return"number"==typeof t?t:e}function ut(t){var e=nt(t);if(!e)return ct(t.clientWidth,t.width);var i=e.clientWidth,n=i-st(e,"padding-left",i)-st(e,"padding-right",i),r=function(t){return at(t,"max-width","clientWidth")}(t);return isNaN(r)?n:Math.min(n,r)}function ht(t){var e=nt(t);if(!e)return ct(t.clientHeight,t.height);var i=e.clientHeight,n=i-st(e,"padding-top",i)-st(e,"padding-bottom",i),r=function(t){return at(t,"max-height","clientHeight")}(t);return isNaN(r)?n:Math.min(n,r)}function ft(t,e){var i=t.currentDevicePixelRatio=e||"undefined"!=typeof window&&window.devicePixelRatio||1,n=t.canvas,r=t.width,a=t.height;n.height=a*i,n.width=r*i,t.ctx.setTransform(i,0,0,i,0,0),!n.style||n.style.height||n.style.width||(n.style.height=a+"px",n.style.width=r+"px")}var dt=function(){var t=!1;try{var e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t}();function pt(t,e){var i=ot(t,e),n=i&&i.match(/^(\d+)(\.\d+)?px$/);return n?+n[1]:void 0}var gt=Object.freeze({__proto__:null,_getParentNode:nt,getStyle:ot,getRelativePosition:lt,getMaximumWidth:ut,getMaximumHeight:ht,retinaScale:ft,supportsEventListenerOptions:dt,readUsedSize:pt});function vt(t,e){return"native"in t?{x:t.x,y:t.y}:lt(t,e)}function mt(t,e){for(var i,n,r,a=t.getSortedVisibleDatasetMetas(),o=0,s=a.length;o0){var s=o[0].datasetIndex,l=t.getDatasetMeta(s).data;o=[];for(var c=0;c0},t.prototype.connect_=function(){Nt&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),Ut?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},t.prototype.disconnect_=function(){Nt&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},t.prototype.onTransitionEnd_=function(t){var e=t.propertyName,i=void 0===e?"":e;Yt.some((function(t){return!!~i.indexOf(t)}))&&this.refresh()},t.getInstance=function(){return this.instance_||(this.instance_=new t),this.instance_},t.instance_=null,t}(),Kt=function(t,e){for(var i=0,n=Object.keys(e);i0},t}(),ae="undefined"!=typeof WeakMap?new WeakMap:new Wt,oe=function t(e){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var i=Xt.getInstance(),n=new re(e,i,this);ae.set(this,n)};["observe","unobserve","disconnect"].forEach((function(t){oe.prototype[t]=function(){var e;return(e=ae.get(this))[t].apply(e,arguments)}}));var se=void 0!==Ht.ResizeObserver?Ht.ResizeObserver:oe,le={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},ce=function(t){return null===t||""===t};var ue=!!dt&&{passive:!0};function he(t,e,i){t.canvas.removeEventListener(e,i,ue)}function fe(t,e,i){var n=t.canvas,r=n&&nt(n)||n,a=new MutationObserver((function(t){var e=nt(r);t.forEach((function(t){for(var n=0;n=1?t:-(Math.sqrt(1-t*t)-1)},easeOutCirc:function(t){return Math.sqrt(1-(t-=1)*t)},easeInOutCirc:function(t){return(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInElastic:function(t){var e,i=0;return 0===t?0:1===t?1:(i||(i=.3),e=i/(2*Math.PI)*Math.asin(1),-1*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/i))},easeOutElastic:function(t){var e,i=0;return 0===t?0:1===t?1:(i||(i=.3),e=i/(2*Math.PI)*Math.asin(1),1*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/i)+1)},easeInOutElastic:function(t){var e,i=0;return 0===t?0:2==(t/=.5)?1:(i||(i=.45),e=i/(2*Math.PI)*Math.asin(1),t<1?1*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/i)*-.5:1*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/i)*.5+1)},easeInBack:function(t){var e=1.70158;return t*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:function(t){return 1-Le.easeOutBounce(1-t)},easeOutBounce:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},easeInOutBounce:function(t){return t<.5?.5*Le.easeInBounce(2*t):.5*Le.easeOutBounce(2*t-1)+.5}},Ce={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},Fe="0123456789ABCDEF",Re=function(t){return Fe[15&t]},Ie=function(t){return Fe[(240&t)>>4]+Fe[15&t]},ze=function(t){return(240&t)>>4==(15&t)}; +/*! + * @kurkle/color v0.1.9 + * https://github.com/kurkle/color#readme + * (c) 2020 Jukka Kurkela + * Released under the MIT License + */function Ve(t){var e=function(t){return ze(t.r)&&ze(t.g)&&ze(t.b)&&ze(t.a)}(t)?Re:Ie;return t?"#"+e(t.r)+e(t.g)+e(t.b)+(t.a<255?e(t.a):""):t}function Be(t){return t+.5|0}var We=function(t,e,i){return Math.max(Math.min(t,i),e)};function Ne(t){return We(Be(2.55*t),0,255)}function He(t){return We(Be(255*t),0,255)}function je(t){return We(Be(t/2.55)/100,0,1)}function Ye(t){return We(Be(100*t),0,100)}var Ue=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;var Xe=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function Ke(t,e,i){var n=e*Math.min(i,1-i),r=function(e,r){return void 0===r&&(r=(e+t/30)%12),i-n*Math.max(Math.min(r-3,9-r,1),-1)};return[r(0),r(8),r(4)]}function qe(t,e,i){var n=function(n,r){return void 0===r&&(r=(n+t/60)%6),i-i*e*Math.max(Math.min(r,4-r,1),0)};return[n(5),n(3),n(1)]}function $e(t,e,i){var n,r=Ke(t,1,.5);for(e+i>1&&(e*=n=1/(e+i),i*=n),n=0;n<3;n++)r[n]*=1-e-i,r[n]+=e;return r}function Ge(t){var e,i,n,r=t.r/255,a=t.g/255,o=t.b/255,s=Math.max(r,a,o),l=Math.min(r,a,o),c=(s+l)/2;return s!==l&&(n=s-l,i=c>.5?n/(2-s-l):n/(s+l),e=60*(e=s===r?(a-o)/n+(a>16&255,i>>8&255,255&i]}return a}()).transparent=[0,0,0,0]);var e=ei[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}function ai(t,e,i){if(t){var n=Ge(t);n[e]=Math.max(0,Math.min(n[e]+n[e]*i,0===e?360:1)),n=Qe(n),t.r=n[0],t.g=n[1],t.b=n[2]}}function oi(t,e){return t?i(e||{},t):t}function si(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=He(t[3]))):(e=oi(t,{r:0,g:0,b:0,a:1})).a=He(e.a),e}function li(t){return"r"===t.charAt(0)?function(t){var e,i,n,r=Ue.exec(t),a=255;if(r){if(r[7]!==e){var o=+r[7];a=255&(r[8]?Ne(o):255*o)}return e=+r[1],i=+r[3],n=+r[5],{r:e=255&(r[2]?Ne(e):e),g:i=255&(r[4]?Ne(i):i),b:n=255&(r[6]?Ne(n):n),a:a}}}(t):ti(t)}var ci=function(){function t(e){if(e instanceof t)return e;var i,n,r,a,o=typeof e;"object"===o?i=si(e):"string"===o&&(a=(n=e).length,"#"===n[0]&&(4===a||5===a?r={r:255&17*Ce[n[1]],g:255&17*Ce[n[2]],b:255&17*Ce[n[3]],a:5===a?17*Ce[n[4]]:255}:7!==a&&9!==a||(r={r:Ce[n[1]]<<4|Ce[n[2]],g:Ce[n[3]]<<4|Ce[n[4]],b:Ce[n[5]]<<4|Ce[n[6]],a:9===a?Ce[n[7]]<<4|Ce[n[8]]:255})),i=r||ri(e)||li(e)),this._rgb=i,this._valid=!!i}var i=t.prototype;return i.rgbString=function(){return this._valid?(t=this._rgb)&&(t.a<255?"rgba("+t.r+", "+t.g+", "+t.b+", "+je(t.a)+")":"rgb("+t.r+", "+t.g+", "+t.b+")"):this._rgb;var t},i.hexString=function(){return this._valid?Ve(this._rgb):this._rgb},i.hslString=function(){return this._valid?function(t){if(t){var e=Ge(t),i=e[0],n=Ye(e[1]),r=Ye(e[2]);return t.a<255?"hsla("+i+", "+n+"%, "+r+"%, "+je(t.a)+")":"hsl("+i+", "+n+"%, "+r+"%)"}}(this._rgb):this._rgb},i.mix=function(t,e){if(t){var i,n=this.rgb,r=t.rgb,a=e===i?.5:e,o=2*a-1,s=n.a-r.a,l=((o*s==-1?o:(o+s)/(1+o*s))+1)/2;i=1-l,n.r=255&l*n.r+i*r.r+.5,n.g=255&l*n.g+i*r.g+.5,n.b=255&l*n.b+i*r.b+.5,n.a=a*n.a+(1-a)*r.a,this.rgb=n}return this},i.clone=function(){return new t(this.rgb)},i.alpha=function(t){return this._rgb.a=He(t),this},i.clearer=function(t){return this._rgb.a*=1-t,this},i.greyscale=function(){var t=this._rgb,e=Be(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this},i.opaquer=function(t){return this._rgb.a*=1+t,this},i.negate=function(){var t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this},i.lighten=function(t){return ai(this._rgb,2,t),this},i.darken=function(t){return ai(this._rgb,2,-t),this},i.saturate=function(t){return ai(this._rgb,1,t),this},i.desaturate=function(t){return ai(this._rgb,1,-t),this},i.rotate=function(t){return function(t,e){var i=Ge(t);i[0]=Je(i[0]+e),i=Qe(i),t.r=i[0],t.g=i[1],t.b=i[2]}(this._rgb,t),this},e(t,[{key:"valid",get:function(){return this._valid}},{key:"rgb",get:function(){var t=oi(this._rgb);return t&&(t.a=je(t.a)),t},set:function(t){this._rgb=si(t)}}]),t}();function ui(t){return new ci(t)}var hi=function(t){return t instanceof CanvasGradient||t instanceof CanvasPattern};function fi(t){return hi(t)?t:ui(t)}function di(t){return hi(t)?t:ui(t).saturate(.5).darken(.1).hexString()}var pi={boolean:function(t,e,i){return i>.5?e:t},color:function(t,e,i){var n=fi(t||"transparent"),r=n.valid&&fi(e||"transparent");return r&&r.valid?r.mix(n,i).hexString():e},number:function(t,e,i){return t+(e-t)*i}},gi=function(){function t(t,e,i,n){var r=e[i];n=St([t.to,n,r,t.from]);var a=St([t.from,r,n]);this._active=!0,this._fn=t.fn||pi[t.type||typeof a],this._easing=Le[t.easing||"linear"],this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=a,this._to=n,this._promises=void 0}var e=t.prototype;return e.active=function(){return this._active},e.update=function(t,e,i){var n=this;if(n._active){var r=n._target[n._prop],a=i-n._start,o=n._duration-a;n._start=i,n._duration=Math.floor(Math.max(o,t.duration)),n._loop=!!t.loop,n._to=St([t.to,e,r,t.from]),n._from=St([t.from,r,e])}},e.cancel=function(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))},e.tick=function(t){var e,i=this,n=t-i._start,r=i._duration,a=i._prop,o=i._from,s=i._loop,l=i._to;if(i._active=o!==l&&(s||n1?2-e:e,e=i._easing(Math.min(1,Math.max(0,e))),i._target[a]=i._fn(o,l,e))},e.wait=function(){var t=this._promises||(this._promises=[]);return new Pe((function(e,i){t.push({res:e,rej:i})}))},e._notify=function(t){for(var e=t?"res":"rej",i=this._promises||[],n=0;n=0||(r[i]=t[i]);return r}(o,["properties"]));e.set(t,i({},s,a))}}else e.set(t,i({},n,a))}))}))}},e._animateOptions=function(t,e){var n=e.options,r=function(t,e){if(!e)return;var n=t.options;if(!n)return void(t.options=e);n.$shared&&!e.$shared&&(t.options=n=i({},n,{$shared:!1,$animations:{}}));return n}(t,n);if(!r)return[];var a=this._createAnimations(r,n);return n.$shared&&!r.$shared&&function(t,e){for(var i=[],n=Object.keys(e),r=0;r=0;--i){var l=o[i];if("$"!==l.charAt(0))if("options"!==l){var c=e[l],u=a[l],h=n.get(l);if(u){if(h&&u.active()){u.update(h,c,s);continue}u.cancel()}h&&h.duration?(a[l]=u=new gi(h,t,l,c),r.push(u)):t[l]=c}else r.push.apply(r,this._animateOptions(t,e))}return r},e.update=function(t,e){if(0===this._properties.size)return function(t,e){var n=t.options,r=e.options;n&&r&&(n.$shared&&!r.$shared?t.options=i({},n,r,{$shared:!1}):i(n,r),delete e.options)}(t,e),void i(t,e);var n=this._createAnimations(t,e);return n.length?(s.add(this._chart,n),!0):void 0},t}();var bi=Math.PI,xi=2*bi,yi=xi+bi;function _i(t){var e,i=[],n=Math.sqrt(t);for(e=1;e=t}function Si(t,e,i){var n,r,a;for(n=0,r=t.length;n0?1:-1};function Ti(t){return t*(bi/180)}function Oi(t){return t*(180/bi)}function Ai(t){if(p(t)){for(var e=1,i=0;Math.round(t*e)/e!==t;)e*=10,i++;return i}}function Ei(t,e){var i=e.x-t.x,n=e.y-t.y,r=Math.sqrt(i*i+n*n),a=Math.atan2(n,i);return a<-.5*bi&&(a+=xi),{angle:a,distance:r}}function Li(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Ci(t,e){return(t-e+yi)%xi-bi}function Fi(t){return(t%xi+xi)%xi}function Ri(t,e,i){var n=Fi(t),r=Fi(e),a=Fi(i),o=Fi(r-n),s=Fi(a-n),l=Fi(n-r),c=Fi(n-a);return n===r||n===a||o>s&&l0&&(g=s._sorted,a=s._parsed[t-1]),!1===o._parsing)s._parsed=l,s._sorted=!0;else{for(n=f(l[t])?o.parseArrayData(s,l,t,e):d(l[t])?o.parseObjectData(s,l,t,e):o.parsePrimitiveData(s,l,t,e),i=0;ia||v=0;--i)if(!m()){o.updateRangeFromParsed(d,t,r,f);break}return d},e.getAllParsedValues=function(t){var e,i,n,r=this._cachedMeta._parsed,a=[];for(e=0,i=r.length;e=0;a--)i=r[a],e[i]=di(n[i])},e.getStyle=function(t,e){var i=this,n=i._cachedMeta.dataset;i._config||i.configure();var r=n&&void 0===t?i.resolveDatasetElementOptions(e):i.resolveDataElementOptions(t||0,e&&"active");return e&&i._addAutomaticHoverColors(t,r),r},e._getContext=function(t,e){return{chart:this.chart,dataPoint:this.getParsed(t),dataIndex:t,dataset:this.getDataset(),datasetIndex:this.index,active:e}},e.resolveDatasetElementOptions=function(t){return this._resolveOptions(this.datasetElementOptions,{active:t,type:this.datasetElementType.id})},e.resolveDataElementOptions=function(t,e){var i=this,n="active"===(e=e||"default"),r=i._cachedDataOpts,a=i.enableOptionSharing;if(r[e])return r[e];var o={cacheable:!n},s=i._resolveOptions(i.dataElementOptions,{index:t,active:n,info:o,type:i.dataElementType.id});return o.cacheable&&(s.$shared=a,r[e]=a?Object.freeze(s):s),s},e._resolveOptions=function(t,e){for(var i=e.index,n=e.active,r=e.type,a=e.info,o=this._config,s=this.chart.options.elements[r]||{},l={},c=this._getContext(i,n),u=function(t){return f(t)?t:Object.keys(t)}(t),h=0,d=u.length;he?this._insertElements(e,i-e):i1e15)&&(r="scientific");var s=n.length>3?n[2].value-n[1].value:n[1].value-n[0].value;Math.abs(s)>1&&t!==Math.floor(t)&&(s=t-Math.floor(t));var l=wi(Math.abs(s)),c=Math.max(Math.min(-1*Math.floor(l),20),0),u={notation:r,minimumFractionDigits:c,maximumFractionDigits:c};return i(u,this.options.ticks.format),new Intl.NumberFormat(a,u).format(t)},logarithmic:function(t,e,i){if(0===t)return"0";var n=t/Math.pow(10,Math.floor(wi(t)));return 1===n||2===n||5===n?$i.numeric.call(this,t,e,i):""}},Gi={formatters:$i};function Zi(t,e){for(var i=[],n=t.length/e,r=t.length,a=0;as+1e-6)))return l}function Ji(t){return t.drawTicks?t.tickMarkLength:0}function tn(t,e){if(!t.display)return 0;var i=Pt(t.font,e),n=kt(t.padding);return i.lineHeight+n.height}function en(t,e,i,n,r){var a,o,s,l=g(n,0),c=Math.min(g(r,t.length),t.length),u=0;for(i=Math.ceil(i),r&&(i=(a=r-n)/Math.floor(a/i)),s=l;s<0;)u++,s=Math.round(l+u*i);for(o=Math.max(l,0);o=l||o<=1||!n.isHorizontal())n.labelRotation=s;else{var u=n._getLabelSizes(),h=u.widest.width,f=u.highest.height-u.highest.offset,d=Math.min(n.maxWidth,n.chart.width-h);h+6>(t=r.offset?n.maxWidth/o:d/(o-1))&&(t=d/(o-(r.offset?.5:1)),e=n.maxHeight-Ji(r.gridLines)-a.padding-tn(r.scaleLabel,n.chart.options.font),i=Math.sqrt(h*h+f*f),c=Oi(Math.min(Math.asin(Math.min((u.highest.height+6)/t,1)),Math.asin(Math.min(e/i,1))-Math.asin(f/i))),c=Math.max(s,Math.min(l,c))),n.labelRotation=c}},r.afterCalculateLabelRotation=function(){v(this.options.afterCalculateLabelRotation,[this])},r.beforeFit=function(){v(this.options.beforeFit,[this])},r.fit=function(){var t=this,e={width:0,height:0},i=t.chart,n=t.options,r=n.ticks,a=n.scaleLabel,o=n.gridLines,s=t._isVisible(),l="top"!==n.position&&"x"===t.axis,c=t.isHorizontal(),u=s&&tn(a,i.options.font);if(c?e.width=t.maxWidth:s&&(e.width=Ji(o)+u),c?s&&(e.height=Ji(o)+u):e.height=t.maxHeight,r.display&&s&&t.ticks.length){var h=t._getLabelSizes(),f=h.first,d=h.last,p=h.widest,g=h.highest,v=.8*g.offset,m=r.padding;if(c){var b=0!==t.labelRotation,x=Ti(t.labelRotation),y=Math.cos(x),_=Math.sin(x),w=_*p.width+y*(g.height-(b?g.offset:0))+(b?0:v);e.height=Math.min(t.maxHeight,e.height+w+m);var M,k,P=t.getPixelForTick(0)-t.left,S=t.right-t.getPixelForTick(t.ticks.length-1);b?(M=l?y*f.width+_*f.offset:_*(f.height-f.offset),k=l?_*(d.height-d.offset):y*d.width+_*d.offset):(M=f.width/2,k=d.width/2),t.paddingLeft=Math.max((M-P)*t.width/(t.width-P),0)+3,t.paddingRight=Math.max((k-S)*t.width/(t.width-S),0)+3}else{var D=r.mirror?0:p.width+m+v;e.width=Math.min(t.maxWidth,e.width+D),t.paddingTop=d.height/2,t.paddingBottom=f.height/2}}t._handleMargins(),c?(t.width=t._length=i.width-t._margins.left-t._margins.right,t.height=e.height):(t.width=e.width,t.height=t._length=i.height-t._margins.top-t._margins.bottom)},r._handleMargins=function(){var t=this;t._margins&&(t._margins.left=Math.max(t.paddingLeft,t._margins.left),t._margins.top=Math.max(t.paddingTop,t._margins.top),t._margins.right=Math.max(t.paddingRight,t._margins.right),t._margins.bottom=Math.max(t.paddingBottom,t._margins.bottom))},r.afterFit=function(){v(this.options.afterFit,[this])},r.isHorizontal=function(){var t=this.options,e=t.axis,i=t.position;return"top"===i||"bottom"===i||"x"===e},r.isFullWidth=function(){return this.options.fullWidth},r._convertTicksToLabels=function(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t),this.afterTickToLabelConversion()},r._getLabelSizes=function(){var t=this._labelSizes;return t||(this._labelSizes=t=this._computeLabelSizes()),t},r._computeLabelSizes=function(){var t=this,e=t.ctx,i=t._longestTextCache,n=t.options.ticks.sampleSize,r=[],a=[],o=[],s=t.ticks;ne){for(i=0;ie.length-1?null:this.getPixelForValue(e[t].value)},r.getPixelForDecimal=function(t){return this._reversePixels&&(t=1-t),this._startPixel+t*this._length},r.getDecimalForPixel=function(t){var e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e},r.getBasePixel=function(){return this.getPixelForValue(this.getBaseValue())},r.getBaseValue=function(){var t=this.min,e=this.max;return t<0&&e<0?e:t>0&&e>0?t:0},r._autoSkip=function(t){var e=this.options.ticks,i=e.maxTicksLimit||this._length/this._tickSize(),n=e.major.enabled?function(t){var e,i,n=[];for(e=0,i=t.length;ei)return function(t,e,i,n){var r,a=0,o=i[0];for(n=Math.ceil(n),r=0;rr)return l}return Math.max(r,1)}(n,t,i);if(r>0){var c,u,f=r>1?Math.round((o-a)/(r-1)):null;for(en(t,s,l,h(f)?0:a-f,a),c=0,u=r-1;co*n?o/i:s/n:s*n0},r._computeGridLineItems=function(t){var e,i,n,r,a,o,s,l,c,u,h,f,p=this,g=p.axis,v=p.chart,m=p.options,b=m.gridLines,x=m.position,y=b.offsetGridLines,_=p.isHorizontal(),w=p.ticks,M=w.length+(y?1:0),k=Ji(b),P=[],S={chart:v,scale:p,tick:w[0],index:0},D=b.drawBorder?St([b.borderWidth,b.lineWidth,0],S,0):0,T=D/2,O=function(t){return V(v,t,D)};if("top"===x)e=O(p.bottom),o=p.bottom-k,l=e-T,u=O(t.top)+T,f=t.bottom;else if("bottom"===x)e=O(p.top),u=t.top,f=O(t.bottom)-T,o=e+T,l=p.top+k;else if("left"===x)e=O(p.right),a=p.right-k,s=e-T,c=O(t.left)+T,h=t.right;else if("right"===x)e=O(p.left),c=t.left,h=O(t.right)-T,a=e+T,s=p.left+k;else if("x"===g){if("center"===x)e=O((t.top+t.bottom)/2);else if(d(x)){var A=Object.keys(x)[0],E=x[A];e=O(p.chart.scales[A].getPixelForValue(E))}u=t.top,f=t.bottom,l=(o=e+T)+k}else if("y"===g){if("center"===x)e=O((t.left+t.right)/2);else if(d(x)){var L=Object.keys(x)[0],C=x[L];e=O(p.chart.scales[L].getPixelForValue(C))}s=(a=e-T)-k,c=t.left,h=t.right}for(i=0;i0&&""!==c.strokeStyle;o.save(),o.translate(l.x,l.y),o.rotate(l.rotation),o.font=c.string,o.fillStyle=c.color,o.textBaseline="middle",o.textAlign=l.textAlign,u&&(o.strokeStyle=c.strokeStyle,o.lineWidth=c.lineWidth);var h=l.label,d=l.textOffset;if(f(h))for(n=0,a=h.length;ne){for(var n=e;n=0;--i)t._drawDataset(e[i]);t._plugins.notify(t,"afterDatasetsDraw")}},e._drawDataset=function(t){var e=this,i=e.ctx,n=t._clip,r=e.chartArea,a={meta:t,index:t.index};!1!==e._plugins.notify(e,"beforeDatasetDraw",[a])&&(H(i,{left:!1===n.left?0:r.left-n.left,right:!1===n.right?e.width:r.right+n.right,top:!1===n.top?0:r.top-n.top,bottom:!1===n.bottom?e.height:r.bottom+n.bottom}),t.controller.draw(),j(i),e._plugins.notify(e,"afterDatasetDraw",[a]))},e.getElementAtEvent=function(t){return wt.modes.nearest(this,t,{intersect:!0})},e.getElementsAtEvent=function(t){return wt.modes.index(this,t,{intersect:!0})},e.getElementsAtXAxis=function(t){return wt.modes.index(this,t,{intersect:!1})},e.getElementsAtEventForMode=function(t,e,i,n){var r=wt.modes[e];return"function"==typeof r?r(this,t,i,n):[]},e.getDatasetAtEvent=function(t){return wt.modes.dataset(this,t,{intersect:!0})},e.getDatasetMeta=function(t){var e=this.data.datasets[t],i=this._metasets,n=i.filter((function(t){return t._dataset===e})).pop();return n||(n=i[t]={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1}),n},e.getVisibleDatasetCount=function(){return this.getSortedVisibleDatasetMetas().length},e.isDatasetVisible=function(t){var e=this.getDatasetMeta(t);return"boolean"==typeof e.hidden?!e.hidden:!this.data.datasets[t].hidden},e.setDatasetVisibility=function(t,e){this.getDatasetMeta(t).hidden=!e},e.toggleDataVisibility=function(t){this._hiddenIndices[t]=!this._hiddenIndices[t]},e.getDataVisibility=function(t){return!this._hiddenIndices[t]},e._updateDatasetVisibility=function(t,e){var i=e?"show":"hide",n=this.getDatasetMeta(t),r=n.controller._resolveAnimations(void 0,i);this.setDatasetVisibility(t,e),r.update(n,{visible:e}),this.update((function(e){return e.datasetIndex===t?i:void 0}))},e.hide=function(t){this._updateDatasetVisibility(t,!1)},e.show=function(t){this._updateDatasetVisibility(t,!0)},e._destroyDatasetMeta=function(t){var e=this._metasets&&this._metasets[t];e&&(e.controller._destroy(),delete this._metasets[t])},e.destroy=function(){var e,i,n=this,r=n.canvas;for(n.stop(),s.remove(n),e=0,i=n.data.datasets.length;e0?u[e-1]:null,(r=e0?u[e-1]:null,r=e0&&N(t[i-1],e)&&(r.controlPointPreviousX=wn(r.controlPointPreviousX,e.left,e.right),r.controlPointPreviousY=wn(r.controlPointPreviousY,e.top,e.bottom)),i0?e.y:t.y}}function Sn(t,e,i,n){var r={x:t.controlPointNextX,y:t.controlPointNextY},a={x:e.controlPointPreviousX,y:e.controlPointPreviousY},o=kn(t,r,i),s=kn(r,a,i),l=kn(a,e,i),c=kn(o,s,i),u=kn(s,l,i);return kn(c,u,i)}function Dn(t,e,i){return t?function(t,e){return{x:function(i){return t+t+e-i},setWidth:function(t){e=t},textAlign:function(t){return"center"===t?t:"right"===t?"left":"right"},xPlus:function(t,e){return t-e},leftForLtr:function(t,e){return t-e}}}(e,i):{x:function(t){return t},setWidth:function(t){},textAlign:function(t){return t},xPlus:function(t,e){return t+e},leftForLtr:function(t,e){return t}}}function Tn(t,e){var i,n;"ltr"!==e&&"rtl"!==e||(n=[(i=t.canvas.style).getPropertyValue("direction"),i.getPropertyPriority("direction")],i.setProperty("direction",e,"important"),t.prevTextDirection=n)}function On(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function An(t){return"angle"===t?{between:Ri,compare:Ci,normalize:Fi}:{between:function(t,e,i){return t>=e&&t<=i},compare:function(t,e){return t-e},normalize:function(t){return t}}}function En(t,e,i,n){return{start:t%n,end:e%n,loop:i&&(e-t+1)%n==0}}function Ln(t,e,i){if(!i)return[t];for(var n,r,a,o=i.property,s=i.start,l=i.end,c=e.length,u=An(o),h=u.compare,f=u.between,d=u.normalize,p=function(t,e,i){var n,r,a=i.property,o=i.start,s=i.end,l=An(a),c=l.between,u=l.normalize,h=e.length,f=t.start,d=t.end,p=t.loop;if(p){for(f+=h,d+=h,n=0,r=h;nr&&t[a%e].skip;)a--;return{start:r,end:a%=e}}(e,n,r,i),o=a.start,s=a.end;return!0===i?[{start:o,end:s,loop:r}]:function(t,e,i,n){var r,a=t.length,o=[],s=e,l=t[e];for(r=e+1;r<=i;++r){var c=t[r%a];c.skip||c.stop?l.skip||(n=!1,o.push({start:e%a,end:(r-1)%a,loop:n}),e=s=c.stop?r:null):(s=r,l.skip&&(e=r)),l=c}return null!==s&&o.push({start:e%a,end:s%a,loop:n}),o}(e,o,sMath.abs(s)&&(l=s,c=o),e[i.axis]=c,e._custom={barStart:l,barEnd:c,start:r,end:a,min:o,max:s}}(t,e,i,n):e[i.axis]=i.parse(t,n),e}function Wn(t,e,i,n){var r,a,o,s,l=t.iScale,c=t.vScale,u=l.getLabels(),h=l===c,f=[];for(r=i,a=i+n;r0?Math.min(o,Math.abs(n-i)):o,i=n;return o}(n,r),pixels:r,start:n._startPixel,end:n._endPixel,stackCount:this._getStackCount(),scale:n}},i._calculateBarValuePixels=function(t,e){var i,n,r=this._cachedMeta,a=r.vScale,o=e.minBarLength,s=this.getParsed(t),l=s._custom,c=s[a.axis],u=0,h=r._stacked?this.applyStack(a,s):c;h!==c&&(u=h-c,h=c),Nn(l)&&(c=l.barStart,h=l.barEnd-l.barStart,0!==c&&Di(c)!==Di(l.barEnd)&&(u=0),u+=c);var f=Ii(a.getPixelForValue(u),a._startPixel-10,a._endPixel+10);return n=(i=a.getPixelForValue(u+h))-f,void 0!==o&&Math.abs(n)0?n[t-1]:null,o=t=0;--t)e=Math.max(e,this.getStyle(t,!0).radius);return e>0&&e},r.getLabelAndValue=function(t){var e=this._cachedMeta,i=e.xScale,n=e.yScale,r=this.getParsed(t),a=i.getLabelForValue(r.x),o=n.getLabelForValue(r.y),s=r._custom;return{label:e.label,value:"("+a+", "+o+(s?", "+s:"")+")"}},r.update=function(t){var e=this._cachedMeta.data;this.updateElements(e,0,t)},r.updateElements=function(t,e,i){for(var n=this,r="reset"===i,a=n._cachedMeta,o=a.xScale,s=a.yScale,l=n.resolveDataElementOptions(e,i),c=n.getSharedOptions(l),u=n.includeOptions(i,c),h=0;h=Yn?-Un:s<-Yn?Un:0)+e,c=Math.cos(s),u=Math.sin(s),h=Math.cos(l),f=Math.sin(l),d=s<=0&&l>=0||l>=Un,p=s<=Xn&&l>=Xn||l>=Un+Xn,g=s<=-Xn&&l>=-Xn||l>=Yn+Xn,v=s===-Yn||l>=Yn?-1:Math.min(c,c*i,h,h*i),m=g?-1:Math.min(u,u*i,f,f*i),b=d?1:Math.max(c,c*i,h,h*i),x=p?1:Math.max(u,u*i,f,f*i);n=(b-v)/2,r=(x-m)/2,a=-(b+v)/2,o=-(x+m)/2}return{ratioX:n,ratioY:r,offsetX:a,offsetY:o}}(r.rotation,r.circumference,s),u=c.ratioX,h=c.ratioY,f=c.offsetX,d=c.offsetY,p=e.getMaxBorderWidth()+e.getMaxOffset(o),g=(n.right-n.left-p)/u,v=(n.bottom-n.top-p)/h,m=Math.max(Math.min(g,v)/2,0),b=(m-Math.max(m*s,0))/e._getVisibleDatasetWeightTotal();e.offsetX=f*m,e.offsetY=d*m,a.total=e.calculateTotal(),e.outerRadius=m-b*e._getRingWeightOffset(e.index),e.innerRadius=Math.max(e.outerRadius-b*l,0),e.updateElements(o,0,t)},i._circumference=function(t,e){var i=this.chart.options,n=this._cachedMeta;return e&&i.animation.animateRotate?0:this.chart.getDataVisibility(t)?this.calculateCircumference(n._parsed[t]*i.circumference/Un):0},i.updateElements=function(t,e,i){var n,r=this,a="reset"===i,o=r.chart,s=o.chartArea,l=o.options,c=l.animation,u=(s.left+s.right)/2,h=(s.top+s.bottom)/2,f=a&&c.animateScale,d=f?0:r.innerRadius,p=f?0:r.outerRadius,g=r.resolveDataElementOptions(e,i),v=r.getSharedOptions(g),m=r.includeOptions(i,v),b=l.rotation;for(n=0;n0&&!isNaN(t)?Un*(Math.abs(t)/e):0},i.getLabelAndValue=function(t){var e=this._cachedMeta;return{label:(this.chart.data.labels||[])[t]||"",value:e._parsed[t]}},i.getMaxBorderWidth=function(t){var e,i,n,r,a,o=0,s=this.chart;if(!t)for(e=0,i=s.data.datasets.length;e0&&x.x-n.x>p};f&&(w.options=h||r.resolveDataElementOptions(m,i)),r.updateElement(b,m,w,i),n=x}r.updateSharedOptions(h,i,u)},i.resolveDatasetElementOptions=function(e){var i=this._config,n=this.chart.options,r=n.elements.line,a=t.prototype.resolveDatasetElementOptions.call(this,e),o=g(i.showLine,n.showLines);return a.spanGaps=g(i.spanGaps,n.spanGaps),a.tension=g(i.lineTension,r.tension),a.stepped=St([i.stepped,r.stepped]),o||(a.borderWidth=0),a},i.getMaxOverflow=function(){var t=this._cachedMeta,e=t.dataset.options.borderWidth||0,i=t.data||[];if(!i.length)return e;var n=i[0].size(),r=i[i.length-1].size();return Math.max(e,n,r)/2},i.draw=function(){this._cachedMeta.dataset.updateControlPoints(this.chart.chartArea),t.prototype.draw.call(this)},e}(Ki);qn.id="line",qn.defaults={datasetElementType:"line",datasetElementOptions:["backgroundColor","borderCapStyle","borderColor","borderDash","borderDashOffset","borderJoinStyle","borderWidth","capBezierPoints","cubicInterpolationMode","fill"],dataElementType:"point",dataElementOptions:{backgroundColor:"pointBackgroundColor",borderColor:"pointBorderColor",borderWidth:"pointBorderWidth",hitRadius:"pointHitRadius",hoverHitRadius:"pointHitRadius",hoverBackgroundColor:"pointHoverBackgroundColor",hoverBorderColor:"pointHoverBorderColor",hoverBorderWidth:"pointHoverBorderWidth",hoverRadius:"pointHoverRadius",pointStyle:"pointStyle",radius:"pointRadius",rotation:"pointRotation"},showLines:!0,spanGaps:!1,hover:{mode:"index"},scales:{_index_:{type:"category"},_value_:{type:"linear"}}};var $n=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this).innerRadius=void 0,n.outerRadius=void 0,n}n(e,t);var i=e.prototype;return i.update=function(t){var e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,t)},i._updateRadius=function(){var t=this,e=t.chart,i=e.chartArea,n=e.options,r=Math.min(i.right-i.left,i.bottom-i.top),a=Math.max(r/2,0),o=(a-Math.max(n.cutoutPercentage?a/100*n.cutoutPercentage:1,0))/e.getVisibleDatasetCount();t.outerRadius=a-o*t.index,t.innerRadius=t.outerRadius-o},i.updateElements=function(t,e,i){var n,r=this,a="reset"===i,o=r.chart,s=r.getDataset(),l=o.options,c=l.animation,u=r._cachedMeta.rScale,h=u.xCenter,f=u.yCenter,d=Ti(l.startAngle)-.5*Math.PI,p=d;for(r._cachedMeta.count=r.countVisibleElements(),n=0;nr?(c=r/l,t.arc(a,o,l,n+c,i-c,!0)):t.arc(a,o,r,n+Math.PI/2,i-Math.PI/2),t.closePath(),t.clip()}function ir(t,e){var i=e.x,n=e.y,r=e.startAngle,a=e.endAngle,o=e.pixelMargin,s=Math.max(e.outerRadius-o,0),l=e.innerRadius+o;t.beginPath(),t.arc(i,n,s,r,a),t.arc(i,n,l,a,r,!0),t.closePath()}function nr(t,e){var i=e.x,n=e.y,r=e.startAngle,a=e.endAngle,o=e.pixelMargin,s=e.options,l=e.outerRadius,c=e.innerRadius+o,u="inner"===s.borderAlign;s.borderWidth&&(u?(t.lineWidth=2*s.borderWidth,t.lineJoin="round"):(t.lineWidth=s.borderWidth,t.lineJoin="bevel"),e.fullCircles&&function(t,e,i){var n,r=e.x,a=e.y,o=e.startAngle,s=e.endAngle,l=e.pixelMargin,c=Math.max(e.outerRadius-l,0),u=e.innerRadius+l;for(i&&(e.endAngle=e.startAngle+tr,er(t,e),e.endAngle=s,e.endAngle===e.startAngle&&(e.endAngle+=tr,e.fullCircles--)),t.beginPath(),t.arc(r,a,u,o+tr,o,!0),n=0;n=tr||Ri(r,s,l))&&(a>=c&&a<=u)},a.getCenterPoint=function(t){var e=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),i=e.x,n=e.y,r=(e.startAngle+e.endAngle)/2,a=(e.innerRadius+e.outerRadius)/2;return{x:i+Math.cos(r)*a,y:n+Math.sin(r)*a}},a.tooltipPosition=function(t){return this.getCenterPoint(t)},a.draw=function(t){var e=this,i=e.options,n=i.offset||0;if(e.pixelMargin="inner"===i.borderAlign?.33:0,e.fullCircles=Math.floor(e.circumference/tr),0!==e.circumference){if(t.save(),n&&e.circumferencel&&(l=k),x=(y*x+M)/++y):(w(),t.lineTo(M,k),o=P,y=0,s=l=k),c=k}w()}function lr(t){var e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._loop||e.tension||e.stepped||i)?sr:or}rr.id="arc",rr.defaults={borderAlign:"center",borderColor:"#fff",borderWidth:2,offset:0},rr.defaultRoutes={backgroundColor:"color"};var cr=function(t){function a(e){var n;return(n=t.call(this)||this).options=void 0,n._loop=void 0,n._fullLoop=void 0,n._points=void 0,n._segments=void 0,n._pointsUpdated=!1,e&&i(r(n),e),n}n(a,t);var o=a.prototype;return o.updateControlPoints=function(t){var e=this,i=e.options;if(i.tension&&!i.stepped&&!e._pointsUpdated){var n=i.spanGaps?e._loop:e._fullLoop;Mn(e._points,i,t,n),e._pointsUpdated=!0}},o.first=function(){var t=this.segments,e=this.points;return t.length&&e[t[0].start]},o.last=function(){var t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]},o.interpolate=function(t,e){var i=this.options,n=t[e],r=this.points,a=Cn(this,{property:e,start:n,end:n});if(a.length){var o,s,l=[],c=function(t){return t.stepped?Pn:t.tension?Sn:kn}(i);for(o=0,s=a.length;ot.x):fr(e,"bottom","top",t.base=o.left&&e<=o.right)&&(a||i>=o.top&&i<=o.bottom)}ur.id="point",ur.defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3},ur.defaultRoutes={backgroundColor:"color",borderColor:"color"};var mr=function(t){function e(e){var n;return(n=t.call(this)||this).options=void 0,n.horizontal=void 0,n.base=void 0,n.width=void 0,n.height=void 0,e&&i(r(n),e),n}n(e,t);var a=e.prototype;return a.draw=function(t){var e,i,n,r,a,o=this.options,s=(i=hr(e=this),n=i.right-i.left,r=i.bottom-i.top,a=gr(e,n/2,r/2),{outer:{x:i.left,y:i.top,w:n,h:r},inner:{x:i.left+a.l,y:i.top+a.t,w:n-a.l-a.r,h:r-a.t-a.b}}),l=s.inner,c=s.outer;t.save(),c.w===l.w&&c.h===l.h||(t.beginPath(),t.rect(c.x,c.y,c.w,c.h),t.clip(),t.rect(l.x,l.y,l.w,l.h),t.fillStyle=o.borderColor,t.fill("evenodd")),t.fillStyle=o.backgroundColor,t.fillRect(l.x,l.y,l.w,l.h),t.restore()},a.inRange=function(t,e,i){return vr(this,t,e,i)},a.inXRange=function(t,e){return vr(this,t,null,e)},a.inYRange=function(t,e){return vr(this,null,t,e)},a.getCenterPoint=function(t){var e=this.getProps(["x","y","base","horizontal"],t),i=e.x,n=e.y,r=e.base,a=e.horizontal;return{x:a?(i+r)/2:i,y:a?n:(n+r)/2}},a.getRange=function(t){return"x"===t?this.width/2:this.height/2},e}(qi);mr.id="rectangle",mr.defaults={borderSkipped:"start",borderWidth:0},mr.defaultRoutes={backgroundColor:"color",borderColor:"color"};var br=Object.freeze({__proto__:null,Arc:rr,Line:cr,Point:ur,Rectangle:mr});function xr(t,e,i){var n=function(t){var e=t.options,i=e.fill,n=g(i&&i.target,i);return void 0===n&&(n=!!e.backgroundColor),!1!==n&&null!==n&&(!0===n?"origin":n)}(t),r=parseFloat(n);return p(r)&&Math.floor(r)===r?("-"!==n[0]&&"+"!==n[0]||(r=e+r),!(r===e||r<0||r>=i)&&r):["origin","start","end","stack"].indexOf(n)>=0&&n}var yr=function(){function t(t){this.x=t.x,this.y=t.y,this.radius=t.radius}var e=t.prototype;return e.pathSegment=function(t,e,i){var n=this.x,r=this.y,a=this.radius;return e=e||{start:0,end:2*Math.PI},i.reverse?t.arc(n,r,a,e.end,e.start,!0):t.arc(n,r,a,e.start,e.end),!i.bounds},e.interpolate=function(t,e){var i=this.x,n=this.y,r=this.radius,a=t.angle;if("angle"===e)return{x:i+Math.cos(a)*r,y:n+Math.sin(a)*r,angle:a}},t}();function _r(t){return(t.scale||{}).getPointPositionForValue?function(t){var e,i,n=t.scale,r=t.fill,a=n.options,o=n.getLabels().length,s=[],l=a.reverse?n.max:n.min,c=a.reverse?n.min:n.max,u="start"===r?l:"end"===r?c:n.getBaseValue();if(a.gridLines.circular)return i=n.getPointPositionForValue(0,l),new yr({x:i.x,y:i.y,radius:n.getDistanceFromCenterForValue(u)});for(e=0;e=h&&r<=f){s=r===h,l=r===f;break}}return{first:s,last:l,point:n}}function Sr(t,e){var i=[],n=!1;return f(t)?(n=!0,i=t):i=function(t,e){var i=t||{},n=i.x,r=void 0===n?null:n,a=i.y,o=void 0===a?null:a,s=e.points,l=[];return e.segments.forEach((function(t){var e=s[t.start],i=s[t.end];null!==o?(l.push({x:e.x,y:o}),l.push({x:i.x,y:o})):null!==r&&(l.push({x:r,y:e.y}),l.push({x:r,y:i.y}))})),l}(t,e),i.length?new cr({points:i,options:{tension:0},_loop:n,_fullLoop:n}):null}function Dr(t,e,i){var n,r=t[e].fill,a=[e];if(!i)return r;for(;!1!==r&&-1===a.indexOf(r);){if(!p(r))return r;if(!(n=t[r]))return!1;if(n.visible)return r;a.push(r),r=n.fill}return!1}function Tr(t,e,i){t.beginPath(),e.path(t),t.lineTo(e.last().x,i),t.lineTo(e.first().x,i),t.closePath(),t.clip()}function Or(t,e,i,n){if(!n){var r=e[t],a=i[t];return"angle"===t&&(r=Fi(r),a=Fi(a)),{property:t,start:r,end:a}}}function Ar(t,e,i,n){return t&&e?n(t[i],e[i]):t?t[i]:e?e[i]:0}function Er(t,e,i){var n=e.chart.chartArea,r=n.top,a=n.bottom,o=i||{},s=o.property,l=o.start,c=o.end;"x"===s&&(t.beginPath(),t.rect(l,r,c-l,a-r),t.clip())}function Lr(t,e,i,n){var r=e.interpolate(i,n);r&&t.lineTo(r.x,r.y)}function Cr(t,e){var i=e.line,n=e.target,r=e.property,a=e.color,o=e.scale,s=function(t,e,i){for(var n=t.segments,r=t.points,a=e.points,o=[],s=0;s=0;--e)(i=n[e].$filler)&&i.line.updateControlPoints(r)},beforeDatasetDraw:function(t,e){var i=t.chartArea,n=t.ctx,r=e.meta.$filler;if(r&&!1!==r.fill){var a=function(t){var e=t.chart,i=t.fill,n=t.line;if(p(i))return function(t,e){var i=t.getDatasetMeta(e);return i&&t.isDatasetVisible(e)?i.dataset:null}(e,i);if("stack"===i)return wr(t);var r=_r(t);return r instanceof yr?r:Sr(r,n)}(r),o=r.line,s=r.scale,l=o.options,c=l.fill,u=l.backgroundColor,h=c||{},f=h.above,d=void 0===f?u:f,g=h.below,v=void 0===g?u:g;a&&o.points.length&&(H(n,i),function(t,e){var i=e.line,n=e.target,r=e.above,a=e.below,o=e.area,s=e.scale,l=i._loop?"angle":"x";t.save(),"x"===l&&a!==r&&(Tr(t,n,o.top),Cr(t,{line:i,target:n,color:r,scale:s,property:l}),t.restore(),t.save(),Tr(t,n,o.bottom)),Cr(t,{line:i,target:n,color:a,scale:s,property:l}),t.restore()}(n,{line:o,target:a,above:d,below:v,area:i,scale:s}),j(n))}},defaults:{propagate:!0}};function Rr(t,e){var i=t.boxWidth;return t.usePointStyle&&i>e||h(i)?e:i}function Ir(t,e){var i=t.boxHeight;return t.usePointStyle&&i>e||h(i)?e:i}var zr=function(t){function e(e){var n;return i(r(n=t.call(this)||this),e),n.legendHitBoxes=[],n._hoveredItem=null,n.doughnutMode=!1,n.chart=e.chart,n.options=e.options,n.ctx=e.ctx,n.legendItems=void 0,n.columnWidths=void 0,n.columnHeights=void 0,n.lineWidths=void 0,n._minSize=void 0,n.maxHeight=void 0,n.maxWidth=void 0,n.top=void 0,n.bottom=void 0,n.left=void 0,n.right=void 0,n.height=void 0,n.width=void 0,n._margins=void 0,n.paddingTop=void 0,n.paddingBottom=void 0,n.paddingLeft=void 0,n.paddingRight=void 0,n.position=void 0,n.weight=void 0,n.fullWidth=void 0,n}n(e,t);var a=e.prototype;return a.beforeUpdate=function(){},a.update=function(t,e,i){var n=this;n.beforeUpdate(),n.maxWidth=t,n.maxHeight=e,n._margins=i,n.beforeSetDimensions(),n.setDimensions(),n.afterSetDimensions(),n.beforeBuildLabels(),n.buildLabels(),n.afterBuildLabels(),n.beforeFit(),n.fit(),n.afterFit(),n.afterUpdate()},a.afterUpdate=function(){},a.beforeSetDimensions=function(){},a.setDimensions=function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t._minSize={width:0,height:0}},a.afterSetDimensions=function(){},a.beforeBuildLabels=function(){},a.buildLabels=function(){var t=this,e=t.options.labels||{},i=v(e.generateLabels,[t.chart],t)||[];e.filter&&(i=i.filter((function(i){return e.filter(i,t.chart.data)}))),t.options.reverse&&i.reverse(),t.legendItems=i},a.afterBuildLabels=function(){},a.beforeFit=function(){},a.fit=function(){var t=this,e=t.options,i=e.labels,n=e.display,r=t.ctx,a=Pt(i.font,t.chart.options.font),o=a.size,s=Rr(i,o),l=Ir(i,o),c=Math.max(l,o),u=t.legendHitBoxes=[],h=t._minSize,f=t.isHorizontal(),d=t._computeTitleHeight();if(f?(h.width=t.maxWidth,h.height=n?10:0):(h.width=n?10:0,h.height=t.maxHeight),n){if(r.font=a.string,f){var p=t.lineWidths=[0],g=d;r.textAlign="left",r.textBaseline="middle",t.legendItems.forEach((function(t,e){var n=s+o/2+r.measureText(t.text).width;(0===e||p[p.length-1]+n+2*i.padding>h.width)&&(g+=c+i.padding,p[p.length-(e>0?0:1)]=0),u[e]={left:0,top:0,width:n,height:c},p[p.length-1]+=n+i.padding})),h.height+=g}else{var v=i.padding,m=t.columnWidths=[],b=t.columnHeights=[],x=i.padding,y=0,_=0,w=h.height-d;t.legendItems.forEach((function(t,e){var n=s+o/2+r.measureText(t.text).width;e>0&&_+o+2*v>w&&(x+=y+i.padding,m.push(y),b.push(_),y=0,_=0),y=Math.max(y,n),_+=o+v,u[e]={left:0,top:0,width:n,height:c}})),x+=y,m.push(y),b.push(_),h.width+=x}t.width=h.width,t.height=h.height}else t.width=h.width=t.height=h.height=0},a.afterFit=function(){},a.isHorizontal=function(){return"top"===this.options.position||"bottom"===this.options.position},a.draw=function(){var t=this,e=t.options,i=e.labels,n=T.color,r=t.height,a=t.columnHeights,o=t.width,s=t.lineWidths;if(e.display){t.drawTitle();var l,c=Dn(e.rtl,t.left,t._minSize.width),u=t.ctx,h=Pt(i.font,t.chart.options.font),f=h.color,d=h.size;u.textAlign=c.textAlign("left"),u.textBaseline="middle",u.lineWidth=.5,u.strokeStyle=f,u.fillStyle=f,u.font=h.string;var p=Rr(i,d),v=Ir(i,d),m=Math.max(d,v),b=t.legendHitBoxes,x=function(t,n){switch(e.align){case"start":return i.padding;case"end":return t-n;default:return(t-n+i.padding)/2}},y=t.isHorizontal(),_=this._computeTitleHeight();l=y?{x:t.left+x(o,s[0]),y:t.top+i.padding+_,line:0}:{x:t.left+i.padding,y:t.top+x(r,a[0])+_,line:0},Tn(t.ctx,e.textDirection);var w=m+i.padding;t.legendItems.forEach((function(e,h){var f=u.measureText(e.text).width,_=p+d/2+f,M=l.x,k=l.y;c.setWidth(t._minSize.width),y?h>0&&M+_+i.padding>t.left+t._minSize.width&&(k=l.y+=w,l.line++,M=l.x=t.left+x(o,s[l.line])):h>0&&k+w>t.top+t._minSize.height&&(M=l.x=M+t.columnWidths[l.line]+i.padding,l.line++,k=l.y=t.top+x(r,a[l.line]));var P=c.x(M);!function(t,e,r){if(!(isNaN(p)||p<=0||isNaN(v)||v<0)){u.save();var a=g(r.lineWidth,1);if(u.fillStyle=g(r.fillStyle,n),u.lineCap=g(r.lineCap,"butt"),u.lineDashOffset=g(r.lineDashOffset,0),u.lineJoin=g(r.lineJoin,"miter"),u.lineWidth=a,u.strokeStyle=g(r.strokeStyle,n),u.setLineDash&&u.setLineDash(g(r.lineDash,[])),i&&i.usePointStyle){var o={radius:p*Math.SQRT2/2,pointStyle:r.pointStyle,rotation:r.rotation,borderWidth:a},s=c.xPlus(t,p/2);W(u,o,s,e+d/2)}else{var l=e+Math.max((d-v)/2,0);u.fillRect(c.leftForLtr(t,p),l,p,v),0!==a&&u.strokeRect(c.leftForLtr(t,p),l,p,v)}u.restore()}}(P,k,e),b[h].left=c.leftForLtr(P,b[h].width),b[h].top=k,function(t,e,i,n){var r=d/2,a=c.xPlus(t,p+r),o=e+m/2;u.fillText(i.text,a,o),i.hidden&&(u.beginPath(),u.lineWidth=2,u.moveTo(a,o),u.lineTo(c.xPlus(a,n),o),u.stroke())}(P,k,e,f),y?l.x+=_+i.padding:l.y+=w})),On(t.ctx,e.textDirection)}},a.drawTitle=function(){var t=this,e=t.options,i=e.title,n=Pt(i.font,t.chart.options.font),r=kt(i.padding);if(i.display){var a,o,s=Dn(e.rtl,t.left,t._minSize.width),l=t.ctx,c=i.position,u=n.size/2,h=t.top+r.top+u,f=t.left,d=t.width;if(this.isHorizontal())switch(d=Math.max.apply(Math,t.lineWidths),e.align){case"start":break;case"end":f=t.right-d;break;default:f=(t.left+t.right)/2-d/2}else{var p=Math.max.apply(Math,t.columnHeights);switch(e.align){case"start":break;case"end":h+=t.height-p;break;default:h+=(t.height-p)/2}}switch(c){case"start":a=f,o="left";break;case"end":a=f+d,o="right";break;default:a=f+d/2,o="center"}l.textAlign=s.textAlign(o),l.textBaseline="middle",l.strokeStyle=n.color,l.fillStyle=n.color,l.font=n.string,l.fillText(i.text,a,h)}},a._computeTitleHeight=function(){var t=this.options.title,e=Pt(t.font,this.chart.options.font),i=kt(t.padding);return t.display?e.lineHeight+i.height:0},a._getLegendItemAt=function(t,e){var i,n,r,a=this;if(t>=a.left&&t<=a.right&&e>=a.top&&e<=a.bottom)for(r=a.legendHitBoxes,i=0;i=(n=r[i]).left&&t<=n.left+n.width&&e>=n.top&&e<=n.top+n.height)return a.legendItems[i];return null},a.handleEvent=function(t){var e=this,i=e.options,n="mouseup"===t.type?"click":t.type;if("mousemove"===n){if(!i.onHover&&!i.onLeave)return}else{if("click"!==n)return;if(!i.onClick)return}var r=e._getLegendItemAt(t.x,t.y);"click"===n?r&&v(i.onClick,[t,r,e],e):(i.onLeave&&r!==e._hoveredItem&&(e._hoveredItem&&v(i.onLeave,[t,e._hoveredItem,e],e),e._hoveredItem=r),r&&v(i.onHover,[t,r,e],e))},e}(qi);function Vr(t){return!1!==t&&_({},[T.plugins.legend,t])}function Br(t,e){var i=new zr({ctx:t.ctx,options:e,chart:t});zt.configure(t,i,e),zt.addBox(t,i),t.legend=i}var Wr={id:"legend",_element:zr,beforeInit:function(t){var e=Vr(t.options.legend);e&&Br(t,e)},beforeUpdate:function(t){var e=Vr(t.options.legend),i=t.legend;e?i?(zt.configure(t,i,e),i.options=e):Br(t,e):i&&(zt.removeBox(t,i),delete t.legend)},afterUpdate:function(t){t.legend&&t.legend.buildLabels()},afterEvent:function(t,e){var i=t.legend;i&&i.handleEvent(e)},defaults:{display:!0,position:"top",align:"center",fullWidth:!0,reverse:!1,weight:1e3,onClick:function(t,e,i){var n=e.datasetIndex,r=i.chart;r.isDatasetVisible(n)?(r.hide(n),e.hidden=!0):(r.show(n),e.hidden=!1)},onHover:null,onLeave:null,labels:{boxWidth:40,padding:10,generateLabels:function(t){var e=t.data.datasets,i=t.options.legend||{},n=i.labels&&i.labels.usePointStyle;return t._getSortedDatasetMetas().map((function(t){var i=t.controller.getStyle(n?0:void 0);return{text:e[t.index].label,fillStyle:i.backgroundColor,hidden:!t.visible,lineCap:i.borderCapStyle,lineDash:i.borderDash,lineDashOffset:i.borderDashOffset,lineJoin:i.borderJoinStyle,lineWidth:i.borderWidth,strokeStyle:i.borderColor,pointStyle:i.pointStyle,rotation:i.rotation,datasetIndex:t.index}}),this)}},title:{display:!1,position:"center",text:""}}},Nr=function(t){function e(e){var n;return i(r(n=t.call(this)||this),e),n.chart=e.chart,n.options=e.options,n.ctx=e.ctx,n._margins=void 0,n._padding=void 0,n.top=void 0,n.bottom=void 0,n.left=void 0,n.right=void 0,n.width=void 0,n.height=void 0,n.maxWidth=void 0,n.maxHeight=void 0,n.position=void 0,n.weight=void 0,n.fullWidth=void 0,n}n(e,t);var a=e.prototype;return a.beforeUpdate=function(){},a.update=function(t,e,i){var n=this;n.beforeUpdate(),n.maxWidth=t,n.maxHeight=e,n._margins=i,n.beforeSetDimensions(),n.setDimensions(),n.afterSetDimensions(),n.beforeBuildLabels(),n.buildLabels(),n.afterBuildLabels(),n.beforeFit(),n.fit(),n.afterFit(),n.afterUpdate()},a.afterUpdate=function(){},a.beforeSetDimensions=function(){},a.setDimensions=function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height)},a.afterSetDimensions=function(){},a.beforeBuildLabels=function(){},a.buildLabels=function(){},a.afterBuildLabels=function(){},a.beforeFit=function(){},a.fit=function(){var t=this,e=t.options,i={},n=t.isHorizontal();if(e.display){var r=f(e.text)?e.text.length:1;t._padding=kt(e.padding);var a=r*Pt(e.font,t.chart.options.font).lineHeight+t._padding.height;t.width=i.width=n?t.maxWidth:a,t.height=i.height=n?a:t.maxHeight}else t.width=i.width=t.height=i.height=0},a.afterFit=function(){},a.isHorizontal=function(){var t=this.options.position;return"top"===t||"bottom"===t},a.draw=function(){var t=this,e=t.ctx,i=t.options;if(i.display){var n,r,a,o,s=Pt(i.font,t.chart.options.font),l=s.lineHeight,c=l/2+t._padding.top,u=0,h=t.top,d=t.left,p=t.bottom,g=t.right;if(t.isHorizontal()){switch(i.align){case"start":r=d,o="left";break;case"end":r=g,o="right";break;default:r=d+(g-d)/2,o="center"}a=h+c,n=g-d}else{switch(r="left"===i.position?d+c:g-c,i.align){case"start":a="left"===i.position?p:h,o="left";break;case"end":a="left"===i.position?h:p,o="right";break;default:a=h+(p-h)/2,o="center"}n=p-h,u=Math.PI*("left"===i.position?-.5:.5)}e.save(),e.fillStyle=s.color,e.font=s.string,e.translate(r,a),e.rotate(u),e.textAlign=o,e.textBaseline="middle";var v=i.text;if(f(v))for(var m=0,b=0;b-1?t.split("\n"):t}function Kr(t,e){var i=e.element,n=e.datasetIndex,r=e.index,a=t.getDatasetMeta(n).controller,o=a.getLabelAndValue(r),s=o.label,l=o.value;return{chart:t,label:s,dataPoint:a.getParsed(r),formattedValue:l,dataset:a.getDataset(),dataIndex:r,datasetIndex:n,element:i}}function qr(t){var e=t._chart.ctx,i=t.body,n=t.footer,r=t.options,a=t.title,o=r.bodyFont,s=r.footerFont,l=r.titleFont,c=r.boxWidth,u=r.boxHeight,h=a.length,f=n.length,d=i.length,p=2*r.yPadding,g=0,v=i.reduce((function(t,e){return t+e.before.length+e.lines.length+e.after.length}),0);(v+=t.beforeBody.length+t.afterBody.length,h&&(p+=h*l.size+(h-1)*r.titleSpacing+r.titleMarginBottom),v)&&(p+=d*(r.displayColors?Math.max(u,o.size):o.size)+(v-d)*o.size+(v-1)*r.bodySpacing);f&&(p+=r.footerMarginTop+f*s.size+(f-1)*r.footerSpacing);var b=0,x=function(t){g=Math.max(g,e.measureText(t).width+b)};return e.save(),e.font=l.string,m(t.title,x),e.font=o.string,m(t.beforeBody.concat(t.afterBody),x),b=r.displayColors?c+2:0,m(i,(function(t){m(t.before,x),m(t.lines,x),m(t.after,x)})),b=0,e.font=s.string,m(t.footer,x),e.restore(),{width:g+=2*r.xPadding,height:p}}function $r(t,e,i){var n,r,a=i.x,o=i.y,s=i.width,l=i.height,c=t.chartArea,u="center",h="center";ot.height-l&&(h="bottom");var f=(c.left+c.right)/2,d=(c.top+c.bottom)/2;"center"===h?(n=function(t){return t<=f},r=function(t){return t>f}):(n=function(t){return t<=s/2},r=function(e){return e>=t.width-s/2});var p=function(t){return t<=d?"top":"bottom"};return n(a)?(u="left",a+s+e.caretSize+e.caretPadding>t.width&&(u="center",h=p(o))):r(a)&&(u="right",function(t){return t-s-e.caretSize-e.caretPadding<0}(a)&&(u="center",h=p(o))),{xAlign:e.xAlign?e.xAlign:u,yAlign:e.yAlign?e.yAlign:h}}function Gr(t,e,i,n){var r=t.caretSize,a=t.caretPadding,o=t.cornerRadius,s=i.xAlign,l=i.yAlign,c=r+a,u=o+a,h=function(t,e,i){var n=t.x,r=t.width;return"right"===e?n-=r:"center"===e&&((n-=r/2)+r>i&&(n=i-r),n<0&&(n=0)),n}(e,s,n.width);return"center"===l?"left"===s?h+=c:"right"===s&&(h-=c):"left"===s?h-=u:"right"===s&&(h+=u),{x:h,y:function(t,e,i){var n=t.y,r=t.height;return"top"===e?n+=i:n-="bottom"===e?r+i:r/2,n}(e,l,c)}}function Zr(t,e){var i=t.options;return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-i.xPadding:t.x+i.xPadding}function Qr(t){return Ur([],Xr(t))}var Jr=function(t){function e(e){var i;return(i=t.call(this)||this).opacity=0,i._active=[],i._chart=e._chart,i._eventPosition=void 0,i._size=void 0,i._cachedAnimations=void 0,i.$animations=void 0,i.options=void 0,i.dataPoints=void 0,i.title=void 0,i.beforeBody=void 0,i.body=void 0,i.afterBody=void 0,i.footer=void 0,i.xAlign=void 0,i.yAlign=void 0,i.x=void 0,i.y=void 0,i.height=void 0,i.width=void 0,i.caretX=void 0,i.caretY=void 0,i.labelColors=void 0,i.labelTextColors=void 0,i.initialize(),i}n(e,t);var r=e.prototype;return r.initialize=function(){var t=this._chart.options;this.options=function(t,e){return(t=_({},[T.plugins.tooltip,t])).bodyFont=Pt(t.bodyFont,e),t.titleFont=Pt(t.titleFont,e),t.footerFont=Pt(t.footerFont,e),t.boxHeight=g(t.boxHeight,t.bodyFont.size),t.boxWidth=g(t.boxWidth,t.bodyFont.size),t}(t.tooltips,t.font)},r._resolveAnimations=function(){var t=this,e=t._cachedAnimations;if(e)return e;var i=t._chart,n=t.options,r=n.enabled&&i.options.animation&&n.animation,a=new mi(t._chart,r);return t._cachedAnimations=Object.freeze(a),a},r.getTitle=function(t){var e=this.options.callbacks,i=e.beforeTitle.apply(this,[t]),n=e.title.apply(this,[t]),r=e.afterTitle.apply(this,[t]),a=[];return a=Ur(a,Xr(i)),a=Ur(a,Xr(n)),a=Ur(a,Xr(r))},r.getBeforeBody=function(t){return Qr(this.options.callbacks.beforeBody.apply(this,[t]))},r.getBody=function(t){var e=this,i=e.options.callbacks,n=[];return m(t,(function(t){var r={before:[],lines:[],after:[]};Ur(r.before,Xr(i.beforeLabel.call(e,t))),Ur(r.lines,i.label.call(e,t)),Ur(r.after,Xr(i.afterLabel.call(e,t))),n.push(r)})),n},r.getAfterBody=function(t){return Qr(this.options.callbacks.afterBody.apply(this,[t]))},r.getFooter=function(t){var e=this.options.callbacks,i=e.beforeFooter.apply(this,[t]),n=e.footer.apply(this,[t]),r=e.afterFooter.apply(this,[t]),a=[];return a=Ur(a,Xr(i)),a=Ur(a,Xr(n)),a=Ur(a,Xr(r))},r._createItems=function(){var t,e,i=this,n=i._active,r=i.options,a=i._chart.data,o=[],s=[],l=[];for(t=0,e=n.length;t0&&e.stroke()},r._updateAnimationTarget=function(){var t=this,e=t._chart,n=t.options,r=t.$animations,a=r&&r.x,o=r&&r.y;if(a||o){var s=Yr[n.position].call(t,t._active,t._eventPosition);if(!s)return;var l=t._size=qr(t),c=i({},s,t._size),u=$r(e,n,c),h=Gr(n,c,u,e);a._to===h.x&&o._to===h.y||(t.xAlign=u.xAlign,t.yAlign=u.yAlign,t.width=l.width,t.height=l.height,t.caretX=s.x,t.caretY=s.y,t._resolveAnimations().update(t,h))}},r.draw=function(t){var e=this,i=e.options,n=e.opacity;if(n){e._updateAnimationTarget();var r={width:e.width,height:e.height},a={x:e.x,y:e.y};n=Math.abs(n)<.001?0:n;var o=e.title.length||e.beforeBody.length||e.body.length||e.afterBody.length||e.footer.length;i.enabled&&o&&(t.save(),t.globalAlpha=n,e.drawBackground(a,t,r),Tn(t,i.textDirection),a.y+=i.yPadding,e.drawTitle(a,t),e.drawBody(a,t),e.drawFooter(a,t),On(t,i.textDirection),t.restore())}},r.handleEvent=function(t,e){var i,n=this,r=n.options,a=n._active||[],o=[];"mouseout"!==t.type&&(o=n._chart.getElementsAtEventForMode(t,r.mode,r,e),r.reverse&&o.reverse());var s=Yr[r.position].call(n,o,t),l=this.caretX!==s.x||this.caretY!==s.y;return(i=e||!b(o,a)||l)&&(n._active=o,(r.enabled||r.custom)&&(n._eventPosition={x:t.x,y:t.y},n.update(!0))),i},e}(qi);Jr.positioners=Yr;var ta={id:"tooltip",_element:Jr,positioners:Yr,afterInit:function(t){t.options.tooltips&&(t.tooltip=new Jr({_chart:t}))},beforeUpdate:function(t){t.tooltip&&t.tooltip.initialize()},reset:function(t){t.tooltip&&t.tooltip.initialize()},afterDraw:function(t){var e=t.tooltip,i={tooltip:e};!1!==t._plugins.notify(t,"beforeTooltipDraw",[i])&&(e&&e.draw(t.ctx),t._plugins.notify(t,"afterTooltipDraw",[i]))},afterEvent:function(t,e,i){if(t.tooltip){var n=i;t.tooltip.handleEvent(e,n)}},defaults:{enabled:!0,custom:null,mode:"nearest",position:"average",intersect:!0,backgroundColor:"rgba(0,0,0,0.8)",titleFont:{style:"bold",color:"#fff"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodySpacing:2,bodyFont:{color:"#fff"},bodyAlign:"left",footerSpacing:2,footerMarginTop:6,footerFont:{color:"#fff",style:"bold"},footerAlign:"left",yPadding:6,xPadding:6,caretPadding:2,caretSize:5,cornerRadius:6,multiKeyBackground:"#fff",displayColors:!0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart",numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:{beforeTitle:l,title:function(t){if(t.length>0){var e=t[0],i=e.chart.data.labels,n=i?i.length:0;if(e.label)return e.label;if(n>0&&e.dataIndex=0&&te.length-1?null:this.getPixelForValue(e[t].value)},i.getValueForPixel=function(t){var e=Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange);return Math.min(Math.max(e,0),this.ticks.length-1)},i.getBasePixel=function(){return this.bottom},e}(nn);function na(t){var e=Math.floor(wi(t)),i=t/Math.pow(10,e);return(i<=1?1:i<=2?2:i<=5?5:10)*Math.pow(10,e)}ia.id="category",ia.defaults={ticks:{callback:ia.prototype.getLabelForValue}};var ra=function(t){function e(e){var i;return(i=t.call(this,e)||this).start=void 0,i.end=void 0,i._startValue=void 0,i._endValue=void 0,i._valueRange=0,i}n(e,t);var i=e.prototype;return i.parse=function(t,e){return h(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?NaN:+t},i.handleTickRangeOptions=function(){var t=this,e=t.options;if(e.beginAtZero){var i=Di(t.min),n=Di(t.max);i<0&&n<0?t.max=0:i>0&&n>0&&(t.min=0)}var r=void 0!==e.min||void 0!==e.suggestedMin,a=void 0!==e.max||void 0!==e.suggestedMax;void 0!==e.min?t.min=e.min:void 0!==e.suggestedMin&&(null===t.min?t.min=e.suggestedMin:t.min=Math.min(t.min,e.suggestedMin)),void 0!==e.max?t.max=e.max:void 0!==e.suggestedMax&&(null===t.max?t.max=e.suggestedMax:t.max=Math.max(t.max,e.suggestedMax)),r!==a&&t.min>=t.max&&(r?t.max=t.min+1:t.min=t.max-1),t.min===t.max&&(t.max++,e.beginAtZero||t.min--)},i.getTickLimit=function(){var t,e=this.options.ticks,i=e.maxTicksLimit,n=e.stepSize;return n?t=Math.ceil(this.max/n)-Math.floor(this.min/n)+1:(t=this.computeTickLimit(),i=i||11),i&&(t=Math.min(i,t)),t},i.computeTickLimit=function(){return Number.POSITIVE_INFINITY},i.buildTicks=function(){var t=this,e=t.options,i=e.ticks,n=t.getTickLimit(),r=function(t,e){var i,n,r,a,o=[],s=t.stepSize,l=t.min,c=t.max,u=t.precision,f=s||1,d=t.maxTicks-1,p=e.min,g=e.max,v=na((g-p)/d/f)*f;if(v<1e-14&&h(l)&&h(c))return[{value:p},{value:g}];(a=Math.ceil(g/v)-Math.floor(p/v))>d&&(v=na(a*v/d/f)*f),s||h(u)?i=Math.pow(10,Ai(v)):(i=Math.pow(10,u),v=Math.ceil(v*i)/i),n=Math.floor(p/v)*v,r=Math.ceil(g/v)*v,!s||h(l)||h(c)||Pi((c-l)/s,v/1e3)&&(n=l,r=c),a=ki(a=(r-n)/v,Math.round(a),v/1e3)?Math.round(a):Math.ceil(a),n=Math.round(n*i)/i,r=Math.round(r*i)/i,o.push({value:h(l)?n:l});for(var m=1;m0&&(t.min=0),t.handleTickRangeOptions()},i.computeTickLimit=function(){if(this.isHorizontal())return Math.ceil(this.width/40);var t=this._resolveTickFontOptions(0);return Math.ceil(this.height/t.lineHeight)},i.getPixelForValue=function(t){return this.getPixelForDecimal((t-this._startValue)/this._valueRange)},i.getValueForPixel=function(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange},e}(ra);function oa(t){return 1===t/Math.pow(10,Math.floor(wi(t)))}function sa(t,e){return p(t)?t:e}aa.id="linear",aa.defaults={ticks:{callback:Gi.formatters.numeric}};var la=function(t){function e(e){var i;return(i=t.call(this,e)||this).start=void 0,i.end=void 0,i._startValue=void 0,i._valueRange=0,i}n(e,t);var i=e.prototype;return i.parse=function(t,e){var i=ra.prototype.parse.apply(this,[t,e]);if(0!==i)return p(i)&&i>0?i:NaN},i.determineDataLimits=function(){var t=this.getMinMax(!0),e=t.min,i=t.max;this.min=p(e)?Math.max(0,e):null,this.max=p(i)?Math.max(0,i):null,this.handleTickRangeOptions()},i.handleTickRangeOptions=function(){var t=this.min,e=this.max;t===e&&(t<=0?(t=1,e=10):(t=Math.pow(10,Math.floor(wi(t))-1),e=Math.pow(10,Math.floor(wi(e))+1))),t<=0&&(t=Math.pow(10,Math.floor(wi(e))-1)),e<=0&&(e=Math.pow(10,Math.floor(wi(t))+1)),this.min=t,this.max=e},i.buildTicks=function(){var t=this,e=t.options,i=function(t,e){var i=Math.floor(wi(e.max)),n=Math.ceil(e.max/Math.pow(10,i)),r=[],a=sa(t.min,Math.pow(10,Math.floor(wi(e.min)))),o=Math.floor(wi(a)),s=Math.floor(a/Math.pow(10,o)),l=o<0?Math.pow(10,Math.abs(o)):1;do{r.push({value:a,major:oa(a)}),10==++s&&(s=1,l=++o>=0?1:l),a=Math.round(s*Math.pow(10,o)*l)/l}while(or?{start:e-i,end:e}:{start:e,end:e+i}}function ha(t){return 0===t||180===t?"center":t<180?"left":"right"}function fa(t,e,i,n){var r,a,o=i.y+n/2;if(f(e))for(r=0,a=e.length;r270||t<90)&&(i.y-=e.h)}function pa(t){return Mi(t)?t:0}la.id="logarithmic",la.defaults={ticks:{callback:Gi.formatters.logarithmic,major:{enabled:!0}}};var ga=function(t){function e(e){var i;return(i=t.call(this,e)||this).xCenter=void 0,i.yCenter=void 0,i.drawingArea=void 0,i.pointLabels=[],i}n(e,t);var i=e.prototype;return i.init=function(e){t.prototype.init.call(this,e),this.axis="r"},i.setDimensions=function(){var t=this;t.width=t.maxWidth,t.height=t.maxHeight,t.paddingTop=ca(t.options)/2,t.xCenter=Math.floor(t.width/2),t.yCenter=Math.floor((t.height-t.paddingTop)/2),t.drawingArea=Math.min(t.height-t.paddingTop,t.width)/2},i.determineDataLimits=function(){var t=this.getMinMax(!1),e=t.min,i=t.max;this.min=p(e)&&!isNaN(e)?e:0,this.max=p(i)&&!isNaN(i)?i:0,this.handleTickRangeOptions()},i.computeTickLimit=function(){return Math.ceil(this.drawingArea/ca(this.options))},i.generateTickLabels=function(t){var e=this;ra.prototype.generateTickLabels.call(e,t),e.pointLabels=e.chart.data.labels.map((function(t,i){var n=v(e.options.pointLabels.callback,[t,i],e);return n||0===n?n:""}))},i.fit=function(){var t=this.options;t.display&&t.pointLabels.display?function(t){var e,i,n,r={l:0,r:t.width,t:0,b:t.height-t.paddingTop},a={};t._pointLabelSizes=[];var o,s,l,c=t.chart.data.labels.length;for(e=0;er.r&&(r.r=g.end,a.r=d),v.startr.b&&(r.b=v.end,a.b=d)}t._setReductions(t.drawingArea,r,a)}(this):this.setCenterPoint(0,0,0,0)},i._setReductions=function(t,e,i){var n=this,r=e.l/Math.sin(i.l),a=Math.max(e.r-n.width,0)/Math.sin(i.r),o=-e.t/Math.cos(i.t),s=-Math.max(e.b-(n.height-n.paddingTop),0)/Math.cos(i.b);r=pa(r),a=pa(a),o=pa(o),s=pa(s),n.drawingArea=Math.min(Math.floor(t-(r+a)/2),Math.floor(t-(o+s)/2)),n.setCenterPoint(r,a,o,s)},i.setCenterPoint=function(t,e,i,n){var r=this,a=r.width-e-r.drawingArea,o=t+r.drawingArea,s=i+r.drawingArea,l=r.height-r.paddingTop-n-r.drawingArea;r.xCenter=Math.floor((o+a)/2+r.left),r.yCenter=Math.floor((s+l)/2+r.top+r.paddingTop)},i.getIndexAngle=function(t){var e=this.chart;return Fi(t*(2*Math.PI/e.data.labels.length)+Ti((e.options||{}).startAngle||0))},i.getDistanceFromCenterForValue=function(t){var e=this;if(h(t))return NaN;var i=e.drawingArea/(e.max-e.min);return e.options.reverse?(e.max-t)*i:(t-e.min)*i},i.getValueForDistanceFromCenter=function(t){if(h(t))return NaN;var e=this,i=t/(e.drawingArea/(e.max-e.min));return e.options.reverse?e.max-i:e.min+i},i.getPointPosition=function(t,e){var i=this.getIndexAngle(t)-Math.PI/2;return{x:Math.cos(i)*e+this.xCenter,y:Math.sin(i)*e+this.yCenter,angle:i}},i.getPointPositionForValue=function(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))},i.getBasePosition=function(t){return this.getPointPositionForValue(t||0,this.getBaseValue())},i.drawGrid=function(){var t,e,i,n=this,r=n.ctx,a=n.options,o=a.gridLines,s=a.angleLines;if(a.pointLabels.display&&function(t){var e=t.ctx,i=t.options,n=i.pointLabels,r=ca(i),a=t.getDistanceFromCenterForValue(i.ticks.reverse?t.min:t.max);e.save(),e.textBaseline="middle";for(var o=t.chart.data.labels.length-1;o>=0;o--){var s=0===o?r/2:0,l=t.getPointPosition(o,a+s+5),c={chart:t.chart,scale:t,index:o,label:t.pointLabels[o]},u=Pt(St([n.font],c,o),t.chart.options.font);e.font=u.string,e.fillStyle=u.color;var h=Oi(t.getIndexAngle(o));e.textAlign=ha(h),da(h,t._pointLabelSizes[o],l),fa(e,t.pointLabels[o],l,u.lineHeight)}e.restore()}(n),o.display&&n.ticks.forEach((function(t,i){0!==i&&(e=n.getDistanceFromCenterForValue(n.ticks[i].value),function(t,e,i,n){var r,a=t.ctx,o=e.circular,s=t.chart.data.labels.length,l={chart:t.chart,scale:t,index:n,tick:t.ticks[n]},c=St([e.color],l,n-1),u=St([e.lineWidth],l,n-1);if((o||s)&&c&&u){if(a.save(),a.strokeStyle=c,a.lineWidth=u,a.setLineDash&&(a.setLineDash(St([e.borderDash,[]],l)),a.lineDashOffset=St([e.borderDashOffset],l,n-1)),a.beginPath(),o)a.arc(t.xCenter,t.yCenter,i,0,2*Math.PI);else{r=t.getPointPosition(0,i),a.moveTo(r.x,r.y);for(var h=1;h=0;t--){var l={chart:n.chart,scale:n,index:t,label:n.pointLabels[t]},c=St([s.lineWidth,o.lineWidth],l,t),u=St([s.color,o.color],l,t);c&&u&&(r.lineWidth=c,r.strokeStyle=u,r.setLineDash&&(r.setLineDash(St([s.borderDash,o.borderDash,[]],l)),r.lineDashOffset=St([s.borderDashOffset,o.borderDashOffset,0],l,t)),e=n.getDistanceFromCenterForValue(a.ticks.reverse?n.min:n.max),i=n.getPointPosition(t,e),r.beginPath(),r.moveTo(n.xCenter,n.yCenter),r.lineTo(i.x,i.y),r.stroke())}r.restore()}},i.drawLabels=function(){var t=this,e=t.ctx,i=t.options,n=i.ticks;if(n.display){var r,a,o=t.getIndexAngle(0);e.save(),e.translate(t.xCenter,t.yCenter),e.rotate(o),e.textAlign="center",e.textBaseline="middle",t.ticks.forEach((function(o,s){var l={chart:t.chart,scale:t,index:s,tick:o};if(0!==s||i.reverse){var c=t._resolveTickFontOptions(s);e.font=c.string,r=t.getDistanceFromCenterForValue(t.ticks[s].value),St([n.showLabelBackdrop],l,s)&&(a=e.measureText(o.label).width,e.fillStyle=St([n.backdropColor],l,s),e.fillRect(-a/2-n.backdropPaddingX,-r-c.size/2-n.backdropPaddingY,a+2*n.backdropPaddingX,c.size+2*n.backdropPaddingY)),e.fillStyle=c.color,e.fillText(o.label,0,-r)}})),e.restore()}},i.drawTitle=function(){},e}(ra);ga.id="radialLinear",ga.defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,color:"rgba(0,0,0,0.1)",lineWidth:1,borderDash:[],borderDashOffset:0},gridLines:{circular:!1},ticks:{showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2,callback:Gi.formatters.numeric},pointLabels:{display:!0,font:{size:10},callback:function(t){return t}}};var va=Number.MAX_SAFE_INTEGER||9007199254740991,ma={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},ba=Object.keys(ma);function xa(t,e){return t-e}function ya(t,e){if(h(e))return null;var i=t._adapter,n=t.options.time,r=n.parser,a=n.round,o=n.isoWeekday,s=e;return"function"==typeof r&&(s=r(s)),p(s)||(s="string"==typeof r?i.parse(s,r):i.parse(s)),null===s?s:(a&&(s="week"===a&&o?t._adapter.startOf(s,"isoWeek",o):t._adapter.startOf(s,a)),+s)}function _a(t,e,i,n){for(var r=ba.length,a=ba.indexOf(t);a=i?t[r]:t[a]]=!0}}function Ma(t,e,i){var n,r,a=[],o={},s=e.length;for(n=0;n=0&&(e[a].major=!0);return e}(t,a,o,i):a}var ka=function(t){function e(e){var i;return(i=t.call(this,e)||this)._cache={data:[],labels:[],all:[]},i._unit="day",i._majorUnit=void 0,i._offsets={},i._normalized=!1,i}n(e,t);var i=e.prototype;return i.init=function(e,i){var n=e.time||(e.time={}),r=this._adapter=new Vn._date(e.adapters.date);w(n.displayFormats,r.formats()),t.prototype.init.call(this,e),this._normalized=i.normalized},i.parse=function(t,e){return void 0===t?NaN:ya(this,t)},i.invalidateCaches=function(){this._cache={data:[],labels:[],all:[]}},i.determineDataLimits=function(){var t=this,e=t.options,i=t._adapter,n=e.time.unit||"day",r=t.getUserBounds(),a=r.min,o=r.max,s=r.minDefined,l=r.maxDefined;function c(t){s||isNaN(t.min)||(a=Math.min(a,t.min)),l||isNaN(t.max)||(o=Math.max(o,t.max))}s&&l||(c(t._getLabelBounds()),"ticks"===e.bounds&&"labels"===e.ticks.source||c(t.getMinMax(!1))),a=p(a)&&!isNaN(a)?a:+i.startOf(Date.now(),n),o=p(o)&&!isNaN(o)?o:+i.endOf(Date.now(),n)+1,t.min=Math.min(a,o),t.max=Math.max(a+1,o)},i._getLabelBounds=function(){var t=this.getLabelTimestamps(),e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],i=t[t.length-1]),{min:e,max:i}},i.buildTicks=function(){var t=this,e=t.options,i=e.time,n=e.ticks,r="labels"===n.source?t.getLabelTimestamps():t._generate();"ticks"===e.bounds&&r.length&&(t.min=t._userMin||r[0],t.max=t._userMax||r[r.length-1]);var a=t.min,o=G(r,a,t.max);return t._unit=i.unit||(n.autoSkip?_a(i.minUnit,t.min,t.max,t._getLabelCapacity(a)):function(t,e,i,n,r){for(var a=ba.length-1;a>=ba.indexOf(i);a--){var o=ba[a];if(ma[o].common&&t._adapter.diff(r,n,o)>=e-1)return o}return ba[i?ba.indexOf(i):0]}(t,o.length,i.minUnit,t.min,t.max)),t._majorUnit=n.major.enabled&&"year"!==t._unit?function(t){for(var e=ba.indexOf(t)+1,i=ba.length;e1e5*l)throw new Error(n+" and "+r+" are too far apart with stepSize of "+l+" "+s);if("data"===e.options.ticks.source){var f=e.getDataTimestamps();for(t=h;t0?s:1},i.getDataTimestamps=function(){var t,e,i=this,n=i._cache.data||[];if(n.length)return n;var r=i.getMatchingVisibleMetas();if(i._normalized&&r.length)return i._cache.data=r[0].controller.getAllParsedValues(i);for(t=0,e=r.length;te&&a0&&!h(e)?e/i._maxIndex:i.getDecimalForValue(t);return i.getPixelForDecimal((n.start+r)*n.factor)},i.getDecimalForValue=function(t){return Pa(this._table,t)/this._maxIndex},i.getValueForPixel=function(t){var e=this._offsets,i=this.getDecimalForPixel(t)/e.factor-e.end;return Pa(this._table,i*this._maxIndex,!0)},e}(ka);Sa.id="timeseries",Sa.defaults=ka.defaults;var Da=Object.freeze({__proto__:null,CategoryScale:ia,LinearScale:aa,LogarithmicScale:la,RadialLinearScale:ga,TimeScale:ka,TimeSeriesScale:Sa});return mn.register(Jn,Da,br,ea),mn.helpers=Rn,mn._adapters=Vn,mn.Animation=gi,mn.Animations=mi,mn.animator=s,mn.controllers=an.controllers.items,mn.DatasetController=Ki,mn.Element=qi,mn.elements=br,mn.Interaction=wt,mn.layouts=zt,mn.platforms=_e,mn.Scale=nn,mn.Ticks=Gi,i(mn,Jn,Da,br,ea,_e),mn.Chart=mn,"undefined"!=typeof window&&(window.Chart=mn),mn})); diff --git a/lib/chartjs/samples/.eslintrc.yml b/lib/chartjs/samples/.eslintrc.yml new file mode 100644 index 0000000..bdf8eab --- /dev/null +++ b/lib/chartjs/samples/.eslintrc.yml @@ -0,0 +1,15 @@ +globals: + $: true + Chart: true + Samples: true + moment: true + luxon: true + randomScalingFactor: true + +rules: + no-new: 0 + no-var: 0 + object-shorthand: 0 + prefer-arrow-callback: 0 + no-invalid-this: 0 + no-unneeded-ternary: 0 diff --git a/lib/chartjs/samples/charts/scatter/multi-axis.html b/lib/chartjs/samples/charts/scatter/multi-axis.html index 936b5ac..853ab35 100644 --- a/lib/chartjs/samples/charts/scatter/multi-axis.html +++ b/lib/chartjs/samples/charts/scatter/multi-axis.html @@ -101,7 +101,13 @@ y: { type: 'linear', // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance display: true, - position: 'left' + position: 'left', + + ticks: { + font: { + color: window.chartColors.red + } + } }, y2: { type: 'linear', // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance @@ -109,7 +115,12 @@ position: 'right', reverse: true, - // grid line settings + ticks: { + font: { + color: window.chartColors.blue + } + }, + gridLines: { drawOnChartArea: false, // only want the grid lines for one axis to show up } diff --git a/modeles/chart.html b/modeles/chart.html index 8523bfe..b3f0cdb 100644 --- a/modeles/chart.html +++ b/modeles/chart.html @@ -55,7 +55,8 @@ - axeX : Afficher l'ordonnée (bool|string) true (défaut) | false - axeY : Afficher l'abscisse (bool|string) - true (défaut) | false + true (défaut) | false + - beginAtZero : pour commencer les ordonnées à zéro - colors : Codes de couleurs à utiliser : nom, hexadécimal, rgb, rgba, hsl, hsla @@ -138,6 +139,7 @@ #SET{labelY, #ENV{labelY}} #SET{uniteX, #ENV{uniteX}} #SET{uniteY, #ENV{uniteY}} +#SET{beginAtZero, #ENV{beginAtZero}|?{#EVAL{true}, #EVAL{false}}} [(#REM) Options ] #SET{stacked, #ENV{stacked}|=={true}|?{true}} @@ -248,6 +250,7 @@ display, #GET{axeY}, stacked, #GET{stacked}, scaleLabel, #ARRAY{display,#GET{labelY}|?{true}, labelString,#GET{labelY}}, + beginAtZero, #GET{beginAtZero}, ticks, #ARRAY{ font, #ARRAY{ size, #GET{fontSize},