c3js / c3

:bar_chart: A D3-based reusable chart library
http://c3js.org
MIT License
9.33k stars 1.39k forks source link

ie11 - Object doesn't support property or method 'assign' #2708

Closed nitmpez closed 4 years ago

nitmpez commented 4 years ago

C3 version: 0.7.9 D3 version: 5.12.0 Browser: IE11 OS: Windows 10

https://jsfiddle.net/a8qcbwfz/1/

2019-10-01 10_45_33-

The error appears to be introduced from going from 0.7.8 to 0.7.9.

The legend issue noted in the screen shot, I'm unsure on, as I went all the way back to 0.6.12 and it still occurred. Basically clicking the legend to hide and then clicking the legend to unhide the data doesn't work in IE11.

panthony commented 4 years ago

@nitmpez If this is blocker for you you can, while waiting for a new release, add this piece of code in your own javascript before important c3:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill

if (typeof Object.assign !== 'function') {
    // Must be writable: true, enumerable: false, configurable: true
    Object.defineProperty(Object, "assign", {
        value: function assign(target, varArgs) { // .length of function is 2
            'use strict';
            if (target === null || target === undefined) {
                throw new TypeError('Cannot convert undefined or null to object');
            }

             var to = Object(target);

             for (var index = 1; index < arguments.length; index++) {
                var nextSource = arguments[index];

                 if (nextSource !== null && nextSource !== undefined) {
                    for (var nextKey in nextSource) {
                        // Avoid bugs when hasOwnProperty is shadowed
                        if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
                            to[nextKey] = nextSource[nextKey];
                        }
                    }
                }
            }
            return to;
        },
        writable: true,
        configurable: true
    });
}
nitmpez commented 4 years ago

Just wanted to say thank you for the quick turn around and looking at this.