Skip to content

Angular (2), Chart.JS and Redux freeze exceptions #4157

@philjones88

Description

@philjones88

When trying to combine Angular (2) Redux and Chart.JS you end up with an exception as the arrays of data / labels are frozen.

i.e. https://github.com/buunguyen/redux-freeze

I traced it back to an error in zone.js Cannot read property 'toString' of null

    at Function.Object.defineProperty (http://localhost:8080/static/ng2/js/polyfills.bundle.js:17391:16)
    at listenArrayEvents (http://localhost:8080/static/ng2/js/vendor.bundle.js:109092:10)
    at ChartElement.buildOrUpdateElements (http://localhost:8080/static/ng2/js/vendor.bundle.js:109272:5)
    at Chart.Controller.<anonymous> (http://localhost:8080/static/ng2/js/vendor.bundle.js:108638:48)
    at Object.helpers.each (http://localhost:8080/static/ng2/js/vendor.bundle.js:109514:15)
    at Chart.Controller.update (http://localhost:8080/static/ng2/js/vendor.bundle.js:108637:12)
    at new Chart.Controller (http://localhost:8080/static/ng2/js/vendor.bundle.js:108418:6)
    at new Chart (http://localhost:8080/static/ng2/js/vendor.bundle.js:110793:21)

Stepping through the methods:

buildOrUpdateElements -> listenArrayEvents

which tries to do add listeners and it blows up

Expected Behavior

It should handle failing to add listeners to a frozen array

Current Behavior

Exception

Possible Solution

Detect frozen arrays

Steps to Reproduce (for bugs)

Context

I can't use Chart.JS in my Angular (2.4.10) application on pages with Redux data.

Environment

  • Chart.js version: 2.5.0
  • Browser name and version: Chrome latest
  • Link to your project: commercial

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions