You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this.options in the context of a DateAdapter instance should always reflect the most recent value of chart.options.scales.x.adapters.date (or whichever scale is applicable).
Current Behavior
The initial options are passed to the DateAdapter constructor, and they can be updated once (and only once). Subsequent updates are not propagated. I believe this to be because after the initial render, chart.options.scales.x.adapters.date still references the same object passed to the DateAdapter constructor. After the first update, chart.options.scales.x.adapters.date is replaced with a new object (as a result of config merging).
Possible Solution
I'm not sure if this is the perfect location for this fix, but I was able to fix it by adding:
The tricky thing here is the order of operations in core.controller:
build the scales
build the elements, which does parsing using the scales
layout, which calls scale.update
A couple options:
Can we build the elements after updating the layout? Then we could just override update to update the adapter
We could add a new scale.init method which happens in buildOrUpdateScales
It should probably take the options as input and so that we can stop doing scale.options = scaleOptions in the controller
Just always throw away the scales and rebuild them when updating. I think it'd be cleaner in some ways and reduce the amount of overall code. But maybe there are plugins that rely on doing some expensive one time setup? It'd be a larger migration effort if we change the way it works and it's probably not the easiest to implement
Expected Behavior
this.options
in the context of aDateAdapter
instance should always reflect the most recent value ofchart.options.scales.x.adapters.date
(or whichever scale is applicable).Current Behavior
The initial options are passed to the
DateAdapter
constructor, and they can be updated once (and only once). Subsequent updates are not propagated. I believe this to be because after the initial render,chart.options.scales.x.adapters.date
still references the same object passed to theDateAdapter
constructor. After the first update,chart.options.scales.x.adapters.date
is replaced with a new object (as a result of config merging).Possible Solution
I'm not sure if this is the perfect location for this fix, but I was able to fix it by adding:
to
TimeScale.buildTicks
at scale.time.js line 671See this CodePen with the change above implemented.
Happy to submit a PR if this is a valid fix.
Steps to Reproduce (for bugs)
adapters.date
for a time scale.In the example, notice that you can switch the timezone from UTC to LST, but you cannot change it back: CodePen
Context
In working to find a solution to #7340, I came across this issue.
Environment
The text was updated successfully, but these errors were encountered: