1
1
/*!
2
- * Chart.js v2.9.3
2
+ * Chart.js v2.9.4
3
3
* https://www.chartjs.org
4
- * (c) 2019 Chart.js Contributors
4
+ * (c) 2020 Chart.js Contributors
5
5
* Released under the MIT License
6
6
*/
7
7
(function (global, factory) {
@@ -2107,6 +2107,10 @@ if (typeof window !== 'undefined') {
2107
2107
2108
2108
var chartjsColor = Color;
2109
2109
2110
+ function isValidKey(key) {
2111
+ return ['__proto__', 'prototype', 'constructor'].indexOf(key) === -1;
2112
+ }
2113
+
2110
2114
/**
2111
2115
* @namespace Chart.helpers
2112
2116
*/
@@ -2282,7 +2286,7 @@ var helpers = {
2282
2286
}
2283
2287
2284
2288
if (helpers.isObject(source)) {
2285
- var target = {} ;
2289
+ var target = Object.create(source) ;
2286
2290
var keys = Object.keys(source);
2287
2291
var klen = keys.length;
2288
2292
var k = 0;
@@ -2303,6 +2307,12 @@ var helpers = {
2303
2307
* @private
2304
2308
*/
2305
2309
_merger: function(key, target, source, options) {
2310
+ if (!isValidKey(key)) {
2311
+ // We want to ensure we do not copy prototypes over
2312
+ // as this can pollute global namespaces
2313
+ return;
2314
+ }
2315
+
2306
2316
var tval = target[key];
2307
2317
var sval = source[key];
2308
2318
@@ -2318,6 +2328,12 @@ var helpers = {
2318
2328
* @private
2319
2329
*/
2320
2330
_mergerIf: function(key, target, source) {
2331
+ if (!isValidKey(key)) {
2332
+ // We want to ensure we do not copy prototypes over
2333
+ // as this can pollute global namespaces
2334
+ return;
2335
+ }
2336
+
2321
2337
var tval = target[key];
2322
2338
var sval = source[key];
2323
2339
@@ -3816,7 +3832,7 @@ helpers$1.extend(DatasetController.prototype, {
3816
3832
*/
3817
3833
_configure: function() {
3818
3834
var me = this;
3819
- me._config = helpers$1.merge({} , [
3835
+ me._config = helpers$1.merge(Object.create(null) , [
3820
3836
me.chart.options.datasets[me._type],
3821
3837
me.getDataset(),
3822
3838
], {
@@ -7086,7 +7102,8 @@ function updateDims(chartArea, params, layout) {
7086
7102
chartArea.h = newHeight;
7087
7103
7088
7104
// return true if chart area changed in layout's direction
7089
- return layout.horizontal ? newWidth !== chartArea.w : newHeight !== chartArea.h;
7105
+ var sizes = layout.horizontal ? [newWidth, chartArea.w] : [newHeight, chartArea.h];
7106
+ return sizes[0] !== sizes[1] && (!isNaN(sizes[0]) || !isNaN(sizes[1]));
7090
7107
}
7091
7108
}
7092
7109
@@ -7390,7 +7407,7 @@ var platform_basic = {
7390
7407
}
7391
7408
};
7392
7409
7393
- var platform_dom = "/*\n * DOM element rendering detection\n * https://davidwalsh.name/detect-node-insertion\n */\n@keyframes chartjs-render-animation {\n\tfrom { opacity: 0.99; }\n\tto { opacity: 1; }\n}\n\ n.chartjs-render-monitor {\n\tanimation: chartjs-render-animation 0.001s;\n}\n\ n/*\n * DOM element resizing detection\n * https://github.com/marcj/css-element-queries\n */\n.chartjs-size-monitor,\n.chartjs-size-monitor-expand,\n.chartjs-size-monitor-shrink {\n\tposition: absolute;\n\tdirection: ltr;\n\tleft: 0;\n\ttop: 0;\n\tright: 0;\n\tbottom: 0;\n\toverflow: hidden;\n\tpointer-events: none;\n\tvisibility: hidden;\n\tz-index: -1;\n}\n\ n.chartjs-size-monitor-expand > div {\n\tposition: absolute;\n\twidth: 1000000px;\n\theight: 1000000px;\n\tleft: 0;\n\ttop: 0;\n}\n\ n.chartjs-size-monitor-shrink > div {\n\tposition: absolute;\n\twidth: 200%;\n\theight: 200%;\n\tleft: 0;\n\ttop: 0;\n} \n";
7410
+ var platform_dom = "/*\r\ n * DOM element rendering detection\r\ n * https://davidwalsh.name/detect-node-insertion\r\ n */\r\ n@keyframes chartjs-render-animation {\r\ n\tfrom { opacity: 0.99; }\r\ n\tto { opacity: 1; }\r\ n}\r\n\r\ n.chartjs-render-monitor {\r\ n\tanimation: chartjs-render-animation 0.001s;\r\ n}\r\n\r\ n/*\r\ n * DOM element resizing detection\r\ n * https://github.com/marcj/css-element-queries\r\ n */\r\ n.chartjs-size-monitor,\r\ n.chartjs-size-monitor-expand,\r\ n.chartjs-size-monitor-shrink {\r\ n\tposition: absolute;\r\ n\tdirection: ltr;\r\ n\tleft: 0;\r\ n\ttop: 0;\r\ n\tright: 0;\r\ n\tbottom: 0;\r\ n\toverflow: hidden;\r\ n\tpointer-events: none;\r\ n\tvisibility: hidden;\r\ n\tz-index: -1;\r\ n}\r\n\r\ n.chartjs-size-monitor-expand > div {\r\ n\tposition: absolute;\r\ n\twidth: 1000000px;\r\ n\theight: 1000000px;\r\ n\tleft: 0;\r\ n\ttop: 0;\r\ n}\r\n\r\ n.chartjs-size-monitor-shrink > div {\r\ n\tposition: absolute;\r\ n\twidth: 200%;\r\ n\theight: 200%;\r\ n\tleft: 0;\r\ n\ttop: 0;\r\n}\r \n";
7394
7411
7395
7412
var platform_dom$1 = /*#__PURE__*/Object.freeze({
7396
7413
__proto__: null,
@@ -8098,7 +8115,7 @@ var core_scaleService = {
8098
8115
},
8099
8116
getScaleDefaults: function(type) {
8100
8117
// Return the scale defaults merged with the global settings so that we always use the latest ones
8101
- return this.defaults.hasOwnProperty(type) ? helpers$1.merge({} , [core_defaults.scale, this.defaults[type]]) : {};
8118
+ return this.defaults.hasOwnProperty(type) ? helpers$1.merge(Object.create(null) , [core_defaults.scale, this.defaults[type]]) : {};
8102
8119
},
8103
8120
updateScaleDefaults: function(type, additions) {
8104
8121
var me = this;
@@ -9173,7 +9190,7 @@ core_defaults._set('global', {
9173
9190
* returns a deep copy of the result, thus doesn't alter inputs.
9174
9191
*/
9175
9192
function mergeScaleConfig(/* config objects ... */) {
9176
- return helpers$1.merge({} , [].slice.call(arguments), {
9193
+ return helpers$1.merge(Object.create(null) , [].slice.call(arguments), {
9177
9194
merger: function(key, target, source, options) {
9178
9195
if (key === 'xAxes' || key === 'yAxes') {
9179
9196
var slen = source[key].length;
@@ -9213,9 +9230,9 @@ function mergeScaleConfig(/* config objects ... */) {
9213
9230
* a deep copy of the result, thus doesn't alter inputs.
9214
9231
*/
9215
9232
function mergeConfig(/* config objects ... */) {
9216
- return helpers$1.merge({} , [].slice.call(arguments), {
9233
+ return helpers$1.merge(Object.create(null) , [].slice.call(arguments), {
9217
9234
merger: function(key, target, source, options) {
9218
- var tval = target[key] || {} ;
9235
+ var tval = target[key] || Object.create(null) ;
9219
9236
var sval = source[key];
9220
9237
9221
9238
if (key === 'scales') {
@@ -9232,7 +9249,7 @@ function mergeConfig(/* config objects ... */) {
9232
9249
}
9233
9250
9234
9251
function initConfig(config) {
9235
- config = config || {} ;
9252
+ config = config || Object.create(null) ;
9236
9253
9237
9254
// Do NOT use mergeConfig for the data object because this method merges arrays
9238
9255
// and so would change references to labels and datasets, preventing data updates.
@@ -11213,6 +11230,8 @@ function computeLabelSizes(ctx, tickFonts, ticks, caches) {
11213
11230
var widths = [];
11214
11231
var heights = [];
11215
11232
var offsets = [];
11233
+ var widestLabelSize = 0;
11234
+ var highestLabelSize = 0;
11216
11235
var i, j, jlen, label, tickFont, fontString, cache, lineHeight, width, height, nestedLabel, widest, highest;
11217
11236
11218
11237
for (i = 0; i < length; ++i) {
@@ -11240,11 +11259,13 @@ function computeLabelSizes(ctx, tickFonts, ticks, caches) {
11240
11259
widths.push(width);
11241
11260
heights.push(height);
11242
11261
offsets.push(lineHeight / 2);
11262
+ widestLabelSize = Math.max(width, widestLabelSize);
11263
+ highestLabelSize = Math.max(height, highestLabelSize);
11243
11264
}
11244
11265
garbageCollect(caches, length);
11245
11266
11246
- widest = widths.indexOf(Math.max.apply(null, widths) );
11247
- highest = heights.indexOf(Math.max.apply(null, heights) );
11267
+ widest = widths.indexOf(widestLabelSize );
11268
+ highest = heights.indexOf(highestLabelSize );
11248
11269
11249
11270
function valueAt(idx) {
11250
11271
return {
@@ -20752,4 +20773,4 @@ core_controller.helpers.each(
20752
20773
20753
20774
return src;
20754
20775
20755
- })));
20776
+ })));
0 commit comments