Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on adding dataset in Time Scale chart #1917

Closed
Charlie-Hua opened this issue Jan 19, 2016 · 2 comments
Closed

Error on adding dataset in Time Scale chart #1917

Charlie-Hua opened this issue Jan 19, 2016 · 2 comments
Milestone

Comments

@Charlie-Hua
Copy link

Thanks for this awesome library!

My version is 2.0.0-beta2.
I am adding datasets dynamically by config.data.datasets[1] = ... or config.data.datasets.push(... in a Time Scale chart but having this error when updating:

TypeError: Cannot read property '0' of undefined
    at Chart.Scale.extend.getLabelMoment (Chart.js:6365)
    at Chart.Scale.extend.getPixelForValue (Chart.js:6536)
    at Chart.controllers.line.Chart.DatasetController.extend.updateElement (Chart.js:4849)
    at null.<anonymous> (Chart.js:4777)
    at Object.helpers.each (Chart.js:155)
    at update (Chart.js:4776)
    at helpers.extend.reset (Chart.js:1796)
    at null.<anonymous> (Chart.js:1416)
    at Object.helpers.each (Chart.js:155)
    at buildOrUpdateControllers (Chart.js:1402)

It can be easily reproduced in /samples/timeScale/line-time-scale.html by clicking "Add Dataset"

My workaround is to create empty datasets in advance, however, this can only be done by modifying the data attribute instead of assigning the whole dataset.
i.e. this works without error: config.data.datasets[1].data = [...
but this doesn't: config.data.datasets[1] = {data: [...
and the error:

TypeError: Cannot read property 'diff' of undefined
    at Chart.Scale.extend.getPixelForValue (Chart.js:6537)
    at Chart.controllers.line.Chart.DatasetController.extend.updateElement (Chart.js:4849)
    at null.<anonymous> (Chart.js:4777)
    at Object.helpers.each (Chart.js:155)
    at update (Chart.js:4776)
    at helpers.extend.reset (Chart.js:1796)
    at null.<anonymous> (Chart.js:1416)
    at Object.helpers.each (Chart.js:155)
    at buildOrUpdateControllers (Chart.js:1402)
    at update (Chart.js:1442)

Thank you!

@etimberg
Copy link
Member

@Charlie-Hua fixed in #1929

@Charlie-Hua
Copy link
Author

wow that was fast!
I will try the next release. Big thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants