Chart.js: Chart options are not updated by .update()

Created on 28 Dec 2016  ·  7Comments  ·  Source: chartjs/Chart.js

Expected Behavior

When changing chart options of the yAxis, like scaleLabel.fontColor and ticks.fontColor, a call to .update() will draw the chart with updated label and tick colors.

Current Behavior

.update() will update the graph color (which is defined within data) but not ticks or labels (which are in the options dataset). Only reloading the whole site and building the chart from scratch it uses the new values.
As you can see in the screenshot, the graph and fill have been updated to blue, but the temperature label on the left yAxis is still orange (the original value).

localhost-8100- 2

Environment

duplicate bug

Most helpful comment

@etimberg Is there any other way to update the option of the chart instance other than updating the each option field specifically? As @egemon pointed out above, if there's a case for a various of field changes in option, it would be better if we are able to assign the new option object to the option property of the chart instance like, this.chartObj.option = newOptionObj;

All 7 comments

This will work in the next release

Awesome, I'm really looking forward to it. Thanks to all who contributed time and work to chartjs and for sharing it. There seem to be no other lightweight charting libraries, that won't require a whole bunch of other libs & frameworks.

the PR that implemented this was #3587

Closing as implemented since 2.5 will release soon

@etimberg is there any way to pass the same options object to update function as we r passing to constructor. As far as I see, this feature enables doted changes to options. But what if I have a lot of small changes to options that I need to perform. Does it make sense to collect them to single options object and feed this object to update? Is it possible to implement?

@egemon Have you found any way to implement it? I have a few changes in options and want to update the chart(options) accordingly

@etimberg Is there any other way to update the option of the chart instance other than updating the each option field specifically? As @egemon pointed out above, if there's a case for a various of field changes in option, it would be better if we are able to assign the new option object to the option property of the chart instance like, this.chartObj.option = newOptionObj;

Was this page helpful?
0 / 5 - 0 ratings