]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
IE11 compatibility (#6872)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Mon, 30 Dec 2019 22:15:57 +0000 (00:15 +0200)
committerEvert Timberg <evert.timberg+github@gmail.com>
Mon, 30 Dec 2019 22:15:57 +0000 (17:15 -0500)
src/core/core.animations.js
src/core/core.controller.js

index 6f8f5bb31524dbbe7a830bd717697a264950447c..14bf7b840d7fd2deaa1ed2f83c3a4f20f148d617 100644 (file)
@@ -42,6 +42,17 @@ function copyOptions(target, values) {
        delete values.options;
 }
 
+function extensibleConfig(animations) {
+       const result = {};
+       Object.keys(animations).forEach(key => {
+               const value = animations[key];
+               if (!isObject(value)) {
+                       result[key] = value;
+               }
+       });
+       return result;
+}
+
 export default class Animations {
        constructor(chart, animations) {
                this._chart = chart;
@@ -50,12 +61,17 @@ export default class Animations {
        }
 
        configure(animations) {
+               if (!isObject(animations)) {
+                       return;
+               }
+
                const animatedProps = this._properties;
-               const animDefaults = Object.fromEntries(Object.entries(animations).filter(({1: value}) => !isObject(value)));
+               const animDefaults = extensibleConfig(animations);
 
-               for (let [key, cfg] of Object.entries(animations)) {
+               Object.keys(animations).forEach(key => {
+                       const cfg = animations[key];
                        if (!isObject(cfg)) {
-                               continue;
+                               return;
                        }
                        for (let prop of cfg.properties || [key]) {
                                // Can have only one config per animation.
@@ -66,7 +82,7 @@ export default class Animations {
                                        animatedProps.set(prop, extend({}, animatedProps.get(prop), cfg));
                                }
                        }
-               }
+               });
        }
 
        /**
index 81075d127d520f5cbcbb3fbaca76267d67d35a64..096d4215d375827cc24b5919bb6e0bd937808616 100644 (file)
@@ -68,7 +68,8 @@ function mergeScaleConfig(config, options) {
        });
 
        // apply scale defaults, if not overridden by dataset defaults
-       Object.values(scales).forEach(scale => {
+       Object.keys(scales).forEach(key => {
+               const scale = scales[key];
                helpers.mergeIf(scale, scaleService.getScaleDefaults(scale.type));
        });
 
@@ -139,9 +140,9 @@ function updateConfig(chart) {
        chart.tooltip.initialize();
 }
 
-const KNOWN_POSITIONS = ['top', 'bottom', 'left', 'right', 'chartArea'];
+const KNOWN_POSITIONS = new Set(['top', 'bottom', 'left', 'right', 'chartArea']);
 function positionIsHorizontal(position, axis) {
-       return position === 'top' || position === 'bottom' || (!KNOWN_POSITIONS.includes(position) && axis === 'x');
+       return position === 'top' || position === 'bottom' || (!KNOWN_POSITIONS.has(position) && axis === 'x');
 }
 
 function compare2Level(l1, l2) {