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

[BUG] scales undefined when update options with a new object #4197

Closed
xg-wang opened this issue Apr 29, 2017 · 5 comments
Closed

[BUG] scales undefined when update options with a new object #4197

xg-wang opened this issue Apr 29, 2017 · 5 comments

Comments

@xg-wang
Copy link
Contributor

xg-wang commented Apr 29, 2017

Expected Behavior

Be able to call chart.update() after setting new options related to scales.

Current Behavior

Uncaught TypeError: Cannot set property 'options' of undefined

Possible Solution

It's caused by setting scales in new options to chart.scales directly. Could be fixed by merging with default values and ensureScalesHaveIDs before doing so. Have worked out a PR.

Reproduce

Codepen

Context

When I want to change the tick display format of axes it broke.

@etimberg
Copy link
Member

@xg-wang the issue here is that you need to provide an ID for the axis that is updating. Once we get to the next major version this will be clearer because we'll change from an array of axes to map of ID -> axis but until then this is required.

@xg-wang
Copy link
Contributor Author

xg-wang commented Apr 29, 2017

@etimberg The IDs are set when merging the user input options with Chart.defaults.global and Chart.defaults[chart.config.type], and in the form of 'x-axis-0'. Thus this should not be required from user - user should only input the similar option as used to generate the chart.

Even if I add a field of id to the new option, other default properties are still missing.

@xg-wang
Copy link
Contributor Author

xg-wang commented Apr 29, 2017

@etimberg
So I took a look at the testcase. The required way of updating the config is not creating a new object but just alter the property.

I'm not sure should we allow this, but I noticed the testcase for tooltip is passing in a new config object and passing the testcase.
But this is actually not working (see this pen).

The PR #4198 could allow new object as new config. So this is not a bug but a convention of updating the config. Should the PR be merged?

@xg-wang xg-wang changed the title [BUG] scales undefined when update options [BUG] scales undefined when update options with a new object Apr 29, 2017
@etimberg
Copy link
Member

Sorry, I was away for the weekend and just had a chance to look at this.

I think it should be fine to replace the tooltip options object as the test case does. It's just that the way axes are structured as an array makes it hard.

@simonbrunel thoughts?

@etimberg
Copy link
Member

etimberg commented Jan 1, 2018

Done in #4198

@etimberg etimberg closed this as completed Jan 1, 2018
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

3 participants