-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chart.js
12894 lines (12806 loc) · 379 KB
/
Chart.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*!
* Chart.js v3.0.0-alpha.2
* https://www.chartjs.org
* (c) 2020 Chart.js Contributors
* Released under the MIT License
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Chart = factory());
}(this, (function () { 'use strict';
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
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");
}
return self;
}
function fontString(pixelSize, fontStyle, fontFamily) {
return fontStyle + ' ' + pixelSize + 'px ' + fontFamily;
}
var requestAnimFrame = function () {
if (typeof window === 'undefined') {
return function (callback) {
return callback();
};
}
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;
var 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();
}
var Animator = function () {
function Animator() {
this._request = null;
this._charts = new Map();
this._running = false;
this._lastDate = undefined;
}
var _proto = Animator.prototype;
_proto._notify = function _notify(chart, anims, date, type) {
var callbacks = anims.listeners[type] || [];
var numSteps = anims.duration;
callbacks.forEach(function (fn) {
return fn({
chart: chart,
numSteps: numSteps,
currentStep: Math.min(date - anims.start, numSteps)
});
});
}
;
_proto._refresh = function _refresh() {
var me = this;
if (me._request) {
return;
}
me._running = true;
me._request = requestAnimFrame.call(window, function () {
me._update();
me._request = null;
if (me._running) {
me._refresh();
}
});
}
;
_proto._update = function _update() {
var me = this;
var date = Date.now();
var remaining = 0;
me._charts.forEach(function (anims, chart) {
if (!anims.running || !anims.items.length) {
return;
}
var items = anims.items;
var i = items.length - 1;
var draw = false;
var item;
for (; i >= 0; --i) {
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;
}
}
;
_proto._getAnims = function _getAnims(chart) {
var charts = this._charts;
var anims = charts.get(chart);
if (!anims) {
anims = {
running: false,
items: [],
listeners: {
complete: [],
progress: []
}
};
charts.set(chart, anims);
}
return anims;
}
;
_proto.listen = function listen(chart, event, cb) {
this._getAnims(chart).listeners[event].push(cb);
}
;
_proto.add = function add(chart, items) {
var _this$_getAnims$items;
if (!items || !items.length) {
return;
}
(_this$_getAnims$items = this._getAnims(chart).items).push.apply(_this$_getAnims$items, items);
}
;
_proto.has = function has(chart) {
return this._getAnims(chart).items.length > 0;
}
;
_proto.start = function start(chart) {
var anims = this._charts.get(chart);
if (!anims) {
return;
}
anims.running = true;
anims.start = Date.now();
anims.duration = anims.items.reduce(function (acc, cur) {
return Math.max(acc, cur._duration);
}, 0);
this._refresh();
};
_proto.running = function running(chart) {
if (!this._running) {
return false;
}
var anims = this._charts.get(chart);
if (!anims || !anims.running || !anims.items.length) {
return false;
}
return true;
}
;
_proto.stop = function stop(chart) {
var anims = this._charts.get(chart);
if (!anims || !anims.items.length) {
return;
}
var items = anims.items;
var i = items.length - 1;
for (; i >= 0; --i) {
items[i].cancel();
}
anims.items = [];
this._notify(chart, anims, Date.now(), 'complete');
}
;
_proto.remove = function remove(chart) {
return this._charts["delete"](chart);
};
return Animator;
}();
var animator = new Animator();
function noop() {}
var uid = function () {
var id = 0;
return function () {
return id++;
};
}();
function isNullOrUndef(value) {
return value === null || typeof value === 'undefined';
}
function isArray(value) {
if (Array.isArray && Array.isArray(value)) {
return true;
}
var type = Object.prototype.toString.call(value);
if (type.substr(0, 7) === '[object' && type.substr(-6) === 'Array]') {
return true;
}
return false;
}
function isObject(value) {
return value !== null && Object.prototype.toString.call(value) === '[object Object]';
}
var isNumberFinite = function isNumberFinite(value) {
return (typeof value === 'number' || value instanceof Number) && isFinite(+value);
};
function valueOrDefault(value, defaultValue) {
return typeof value === 'undefined' ? defaultValue : value;
}
function callback(fn, args, thisArg) {
if (fn && typeof fn.call === 'function') {
return fn.apply(thisArg, args);
}
}
function each(loopable, fn, thisArg, reverse) {
var i, len, keys;
if (isArray(loopable)) {
len = loopable.length;
if (reverse) {
for (i = len - 1; i >= 0; i--) {
fn.call(thisArg, loopable[i], i);
}
} else {
for (i = 0; i < len; i++) {
fn.call(thisArg, loopable[i], i);
}
}
} else if (isObject(loopable)) {
keys = Object.keys(loopable);
len = keys.length;
for (i = 0; i < len; i++) {
fn.call(thisArg, loopable[keys[i]], keys[i]);
}
}
}
function _elementsEqual(a0, a1) {
var i, ilen, v0, v1;
if (!a0 || !a1 || a0.length !== a1.length) {
return false;
}
for (i = 0, ilen = a0.length; i < ilen; ++i) {
v0 = a0[i];
v1 = a1[i];
if (v0.datasetIndex !== v1.datasetIndex || v0.index !== v1.index) {
return false;
}
}
return true;
}
function clone(source) {
if (isArray(source)) {
return source.map(clone);
}
if (isObject(source)) {
var target = Object.create(source);
var keys = Object.keys(source);
var klen = keys.length;
var k = 0;
for (; k < klen; ++k) {
target[keys[k]] = clone(source[keys[k]]);
}
return target;
}
return source;
}
function _merger(key, target, source, options) {
var tval = target[key];
var sval = source[key];
if (isObject(tval) && isObject(sval)) {
merge(tval, sval, options);
} else {
target[key] = clone(sval);
}
}
function merge(target, source, options) {
var sources = isArray(source) ? source : [source];
var ilen = sources.length;
if (!isObject(target)) {
return target;
}
options = options || {};
var merger = options.merger || _merger;
for (var i = 0; i < ilen; ++i) {
source = sources[i];
if (!isObject(source)) {
continue;
}
var keys = Object.keys(source);
for (var k = 0, klen = keys.length; k < klen; ++k) {
merger(keys[k], target, source, options);
}
}
return target;
}
function mergeIf(target, source) {
return merge(target, source, {
merger: _mergerIf
});
}
function _mergerIf(key, target, source) {
var tval = target[key];
var sval = source[key];
if (isObject(tval) && isObject(sval)) {
mergeIf(tval, sval);
} else if (!Object.prototype.hasOwnProperty.call(target, key)) {
target[key] = clone(sval);
}
}
function _deprecated(scope, value, previous, current) {
if (value !== undefined) {
console.warn(scope + ': "' + previous + '" is deprecated. Please use "' + current + '" instead');
}
}
function resolveObjectKey(obj, key) {
if (key.length < 3) {
return obj[key];
}
var keys = key.split('.');
for (var i = 0, n = keys.length; i < n; ++i) {
var k = keys[i];
if (k in obj) {
obj = obj[k];
} else {
return;
}
}
return obj;
}
function _capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
var coreHelpers = /*#__PURE__*/Object.freeze({
__proto__: null,
noop: noop,
uid: uid,
isNullOrUndef: isNullOrUndef,
isArray: isArray,
isObject: isObject,
isFinite: isNumberFinite,
valueOrDefault: valueOrDefault,
callback: callback,
each: each,
_elementsEqual: _elementsEqual,
clone: clone,
_merger: _merger,
merge: merge,
mergeIf: mergeIf,
_mergerIf: _mergerIf,
_deprecated: _deprecated,
resolveObjectKey: resolveObjectKey,
_capitalize: _capitalize
});
function getScope(node, key) {
if (!key) {
return node;
}
var keys = key.split('.');
for (var i = 0, n = keys.length; i < n; ++i) {
var k = keys[i];
node = node[k] || (node[k] = {});
}
return node;
}
var Defaults = function () {
function Defaults() {
this.color = 'rgba(0,0,0,0.1)';
this.elements = {};
this.events = ['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove'];
this.font = {
color: '#666',
family: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
size: 12,
style: 'normal',
lineHeight: 1.2,
weight: null,
lineWidth: 0,
strokeStyle: undefined
};
this.hover = {
onHover: null,
mode: 'nearest',
intersect: true
};
this.maintainAspectRatio = true;
this.onClick = null;
this.responsive = true;
this.showLines = true;
this.plugins = {};
this.scale = undefined;
this.doughnut = undefined;
this.scales = {};
this.controllers = undefined;
}
var _proto = Defaults.prototype;
_proto.set = function set(scope, values) {
return merge(getScope(this, scope), values);
};
_proto.get = function get(scope) {
return getScope(this, scope);
}
;
_proto.route = function route(scope, name, targetScope, targetName) {
var _Object$definePropert;
var scopeObject = getScope(this, scope);
var targetScopeObject = getScope(this, targetScope);
var privateName = '_' + name;
Object.defineProperties(scopeObject, (_Object$definePropert = {}, _Object$definePropert[privateName] = {
writable: true
}, _Object$definePropert[name] = {
enumerable: true,
get: function get() {
return valueOrDefault(this[privateName], targetScopeObject[targetName]);
},
set: function set(value) {
this[privateName] = value;
}
}, _Object$definePropert));
};
return Defaults;
}();
var defaults = new Defaults();
var PI = Math.PI;
var RAD_PER_DEG = PI / 180;
var DOUBLE_PI = PI * 2;
var HALF_PI = PI / 2;
var QUARTER_PI = PI / 4;
var TWO_THIRDS_PI = PI * 2 / 3;
function toFontString(font) {
if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) {
return null;
}
return (font.style ? font.style + ' ' : '') + (font.weight ? font.weight + ' ' : '') + font.size + 'px ' + font.family;
}
function _measureText(ctx, data, gc, longest, string) {
var textWidth = data[string];
if (!textWidth) {
textWidth = data[string] = ctx.measureText(string).width;
gc.push(string);
}
if (textWidth > longest) {
longest = textWidth;
}
return longest;
}
function _longestText(ctx, font, arrayOfThings, cache) {
cache = cache || {};
var data = cache.data = cache.data || {};
var gc = cache.garbageCollect = cache.garbageCollect || [];
if (cache.font !== font) {
data = cache.data = {};
gc = cache.garbageCollect = [];
cache.font = font;
}
ctx.save();
ctx.font = font;
var longest = 0;
var ilen = arrayOfThings.length;
var i, j, jlen, thing, nestedThing;
for (i = 0; i < ilen; i++) {
thing = arrayOfThings[i];
if (thing !== undefined && thing !== null && isArray(thing) !== true) {
longest = _measureText(ctx, data, gc, longest, thing);
} else if (isArray(thing)) {
for (j = 0, jlen = thing.length; j < jlen; j++) {
nestedThing = thing[j];
if (nestedThing !== undefined && nestedThing !== null && !isArray(nestedThing)) {
longest = _measureText(ctx, data, gc, longest, nestedThing);
}
}
}
}
ctx.restore();
var gcLen = gc.length / 2;
if (gcLen > arrayOfThings.length) {
for (i = 0; i < gcLen; i++) {
delete data[gc[i]];
}
gc.splice(0, gcLen);
}
return longest;
}
function _alignPixel(chart, pixel, width) {
var devicePixelRatio = chart.currentDevicePixelRatio;
var halfWidth = width / 2;
return Math.round((pixel - halfWidth) * devicePixelRatio) / devicePixelRatio + halfWidth;
}
function clear(chart) {
chart.ctx.clearRect(0, 0, chart.width, chart.height);
}
function drawPoint(ctx, options, x, y) {
var type, xOffset, yOffset, size, cornerRadius;
var style = options.pointStyle;
var rotation = options.rotation;
var radius = options.radius;
var rad = (rotation || 0) * RAD_PER_DEG;
if (style && typeof style === 'object') {
type = style.toString();
if (type === '[object HTMLImageElement]' || type === '[object HTMLCanvasElement]') {
ctx.save();
ctx.translate(x, y);
ctx.rotate(rad);
ctx.drawImage(style, -style.width / 2, -style.height / 2, style.width, style.height);
ctx.restore();
return;
}
}
if (isNaN(radius) || radius <= 0) {
return;
}
ctx.beginPath();
switch (style) {
default:
ctx.arc(x, y, radius, 0, DOUBLE_PI);
ctx.closePath();
break;
case 'triangle':
ctx.moveTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius);
rad += TWO_THIRDS_PI;
ctx.lineTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius);
rad += TWO_THIRDS_PI;
ctx.lineTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius);
ctx.closePath();
break;
case 'rectRounded':
cornerRadius = radius * 0.516;
size = radius - cornerRadius;
xOffset = Math.cos(rad + QUARTER_PI) * size;
yOffset = Math.sin(rad + QUARTER_PI) * size;
ctx.arc(x - xOffset, y - yOffset, cornerRadius, rad - PI, rad - HALF_PI);
ctx.arc(x + yOffset, y - xOffset, cornerRadius, rad - HALF_PI, rad);
ctx.arc(x + xOffset, y + yOffset, cornerRadius, rad, rad + HALF_PI);
ctx.arc(x - yOffset, y + xOffset, cornerRadius, rad + HALF_PI, rad + PI);
ctx.closePath();
break;
case 'rect':
if (!rotation) {
size = Math.SQRT1_2 * radius;
ctx.rect(x - size, y - size, 2 * size, 2 * size);
break;
}
rad += QUARTER_PI;
case 'rectRot':
xOffset = Math.cos(rad) * radius;
yOffset = Math.sin(rad) * radius;
ctx.moveTo(x - xOffset, y - yOffset);
ctx.lineTo(x + yOffset, y - xOffset);
ctx.lineTo(x + xOffset, y + yOffset);
ctx.lineTo(x - yOffset, y + xOffset);
ctx.closePath();
break;
case 'crossRot':
rad += QUARTER_PI;
case 'cross':
xOffset = Math.cos(rad) * radius;
yOffset = Math.sin(rad) * radius;
ctx.moveTo(x - xOffset, y - yOffset);
ctx.lineTo(x + xOffset, y + yOffset);
ctx.moveTo(x + yOffset, y - xOffset);
ctx.lineTo(x - yOffset, y + xOffset);
break;
case 'star':
xOffset = Math.cos(rad) * radius;
yOffset = Math.sin(rad) * radius;
ctx.moveTo(x - xOffset, y - yOffset);
ctx.lineTo(x + xOffset, y + yOffset);
ctx.moveTo(x + yOffset, y - xOffset);
ctx.lineTo(x - yOffset, y + xOffset);
rad += QUARTER_PI;
xOffset = Math.cos(rad) * radius;
yOffset = Math.sin(rad) * radius;
ctx.moveTo(x - xOffset, y - yOffset);
ctx.lineTo(x + xOffset, y + yOffset);
ctx.moveTo(x + yOffset, y - xOffset);
ctx.lineTo(x - yOffset, y + xOffset);
break;
case 'line':
xOffset = Math.cos(rad) * radius;
yOffset = Math.sin(rad) * radius;
ctx.moveTo(x - xOffset, y - yOffset);
ctx.lineTo(x + xOffset, y + yOffset);
break;
case 'dash':
ctx.moveTo(x, y);
ctx.lineTo(x + Math.cos(rad) * radius, y + Math.sin(rad) * radius);
break;
}
ctx.fill();
if (options.borderWidth > 0) {
ctx.stroke();
}
}
function _isPointInArea(point, area) {
var epsilon = 0.5;
return point.x > area.left - epsilon && point.x < area.right + epsilon && point.y > area.top - epsilon && point.y < area.bottom + epsilon;
}
function clipArea(ctx, area) {
ctx.save();
ctx.beginPath();
ctx.rect(area.left, area.top, area.right - area.left, area.bottom - area.top);
ctx.clip();
}
function unclipArea(ctx) {
ctx.restore();
}
function _steppedLineTo(ctx, previous, target, flip, mode) {
if (!previous) {
return ctx.lineTo(target.x, target.y);
}
if (mode === 'middle') {
var midpoint = (previous.x + target.x) / 2.0;
ctx.lineTo(midpoint, previous.y);
ctx.lineTo(midpoint, target.y);
} else if (mode === 'after' !== !!flip) {
ctx.lineTo(previous.x, target.y);
} else {
ctx.lineTo(target.x, previous.y);
}
ctx.lineTo(target.x, target.y);
}
function _bezierCurveTo(ctx, previous, target, flip) {
if (!previous) {
return ctx.lineTo(target.x, target.y);
}
ctx.bezierCurveTo(flip ? previous.controlPointPreviousX : previous.controlPointNextX, flip ? previous.controlPointPreviousY : previous.controlPointNextY, flip ? target.controlPointNextX : target.controlPointPreviousX, flip ? target.controlPointNextY : target.controlPointPreviousY, target.x, target.y);
}
var canvas = /*#__PURE__*/Object.freeze({
__proto__: null,
toFontString: toFontString,
_measureText: _measureText,
_longestText: _longestText,
_alignPixel: _alignPixel,
clear: clear,
drawPoint: drawPoint,
_isPointInArea: _isPointInArea,
clipArea: clipArea,
unclipArea: unclipArea,
_steppedLineTo: _steppedLineTo,
_bezierCurveTo: _bezierCurveTo
});
function _lookup(table, value) {
var hi = table.length - 1;
var lo = 0;
var mid;
while (hi - lo > 1) {
mid = lo + hi >> 1;
if (table[mid] < value) {
lo = mid;
} else {
hi = mid;
}
}
return {
lo: lo,
hi: hi
};
}
function _lookupByKey(table, key, value) {
var hi = table.length - 1;
var lo = 0;
var mid;
while (hi - lo > 1) {
mid = lo + hi >> 1;
if (table[mid][key] < value) {
lo = mid;
} else {
hi = mid;
}
}
return {
lo: lo,
hi: hi
};
}
function _rlookupByKey(table, key, value) {
var hi = table.length - 1;
var lo = 0;
var mid;
while (hi - lo > 1) {
mid = lo + hi >> 1;
if (table[mid][key] < value) {
hi = mid;
} else {
lo = mid;
}
}
return {
lo: lo,
hi: hi
};
}
function _filterBetween(values, min, max) {
var start = 0;
var end = values.length;
while (start < end && values[start] < min) {
start++;
}
while (end > start && values[end - 1] > max) {
end--;
}
return start > 0 || end < values.length ? values.slice(start, end) : values;
}
var arrayEvents = ['push', 'pop', 'shift', 'splice', 'unshift'];
function listenArrayEvents(array, listener) {
if (array._chartjs) {
array._chartjs.listeners.push(listener);
return;
}
Object.defineProperty(array, '_chartjs', {
configurable: true,
enumerable: false,
value: {
listeners: [listener]
}
});
arrayEvents.forEach(function (key) {
var method = '_onData' + _capitalize(key);
var base = array[key];
Object.defineProperty(array, key, {
configurable: true,
enumerable: false,
value: function value() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var res = base.apply(this, args);
array._chartjs.listeners.forEach(function (object) {
if (typeof object[method] === 'function') {
object[method].apply(object, args);
}
});
return res;
}
});
});
}
function unlistenArrayEvents(array, listener) {
var stub = array._chartjs;
if (!stub) {
return;
}
var listeners = stub.listeners;
var index = listeners.indexOf(listener);
if (index !== -1) {
listeners.splice(index, 1);
}
if (listeners.length > 0) {
return;
}
arrayEvents.forEach(function (key) {
delete array[key];
});
delete array._chartjs;
}
function _arrayUnique(items) {
var set = new Set();
var i, ilen;
for (i = 0, ilen = items.length; i < ilen; ++i) {
set.add(items[i]);
}
if (set.size === ilen) {
return items;
}
var result = [];
set.forEach(function (item) {
result.push(item);
});
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';
}
function _getParentNode(domNode) {
var parent = domNode.parentNode;
if (parent && parent.toString() === '[object ShadowRoot]') {
parent = parent.host;
}
return parent;
}
function parseMaxStyle(styleValue, node, parentProperty) {
var valueInPixels;
if (typeof styleValue === 'string') {
valueInPixels = parseInt(styleValue, 10);
if (styleValue.indexOf('%') !== -1) {
valueInPixels = valueInPixels / 100 * node.parentNode[parentProperty];
}
} else {
valueInPixels = styleValue;
}
return valueInPixels;
}
function getConstraintDimension(domNode, maxStyle, percentageProperty) {
var view = document.defaultView;
var parentNode = _getParentNode(domNode);
var constrainedNode = view.getComputedStyle(domNode)[maxStyle];
var constrainedContainer = view.getComputedStyle(parentNode)[maxStyle];
var hasCNode = isConstrainedValue(constrainedNode);
var hasCContainer = isConstrainedValue(constrainedContainer);
var infinity = Number.POSITIVE_INFINITY;
if (hasCNode || hasCContainer) {
return Math.min(hasCNode ? parseMaxStyle(constrainedNode, domNode, percentageProperty) : infinity, hasCContainer ? parseMaxStyle(constrainedContainer, parentNode, percentageProperty) : infinity);
}
}
function getStyle(el, property) {
return el.currentStyle ? el.currentStyle[property] : document.defaultView.getComputedStyle(el, null).getPropertyValue(property);
}
function getConstraintWidth(domNode) {
return getConstraintDimension(domNode, 'max-width', 'clientWidth');
}
function getConstraintHeight(domNode) {
return getConstraintDimension(domNode, 'max-height', 'clientHeight');
}
function _calculatePadding(container, padding, parentDimension) {
padding = getStyle(container, padding);
if (padding === '') {
return 0;
}
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 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
};
}
function fallbackIfNotValid(measure, fallback) {
return typeof measure === 'number' ? measure : fallback;
}
function getMaximumWidth(domNode) {
var container = _getParentNode(domNode);
if (!container) {
return fallbackIfNotValid(domNode.clientWidth, domNode.width);
}
var clientWidth = container.clientWidth;
var paddingLeft = _calculatePadding(container, 'padding-left', clientWidth);
var paddingRight = _calculatePadding(container, 'padding-right', clientWidth);
var w = clientWidth - paddingLeft - paddingRight;
var cw = getConstraintWidth(domNode);
return isNaN(cw) ? w : Math.min(w, cw);
}
function getMaximumHeight(domNode) {
var container = _getParentNode(domNode);
if (!container) {
return fallbackIfNotValid(domNode.clientHeight, domNode.height);
}
var clientHeight = container.clientHeight;
var paddingTop = _calculatePadding(container, 'padding-top', clientHeight);
var paddingBottom = _calculatePadding(container, 'padding-bottom', clientHeight);
var h = clientHeight - paddingTop - paddingBottom;
var ch = getConstraintHeight(domNode);
return isNaN(ch) ? h : Math.min(h, ch);
}
function retinaScale(chart, forceRatio) {
var pixelRatio = chart.currentDevicePixelRatio = forceRatio || typeof window !== 'undefined' && window.devicePixelRatio || 1;
var canvas = chart.canvas,
width = chart.width,
height = chart.height;
canvas.height = height * pixelRatio;
canvas.width = width * pixelRatio;
chart.ctx.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
if (canvas.style && !canvas.style.height && !canvas.style.width) {
canvas.style.height = height + 'px';
canvas.style.width = width + 'px';
}
}
var supportsEventListenerOptions = function () {
var passiveSupported = false;
try {
var options = {
get passive() {
passiveSupported = true;
return false;
}
};