Failure on updating options and data at the same time
ace-han opened this issue · 0 comments
ace-han commented
The issue occurs after upgrade chart.js to 3.0-beta.11
.
As I debugged, I located the issue is that a pull merged in 3.0-beta.11
chartjs/Chart.js#8374. This pull makes options
gets updated depending on prev status
data
(old data)
An obvious bug in my case is that options
with multiple y-axes toggling functionality failure.
Because old data(datasets) say toggling single axis( y
) to y-axes( y1, y2, ...
) had been assigned to y
, net yet assigned to y1, y2, ...
, but updating options
depends on data
(old data)
The problem code lies as below
chartjs-react/src/ReactChart.tsx
Lines 39 to 40 in 2a457b2
We just need to switch these two lines will fix this issue
// $HOME/src/ReactChart.tsx
// other stuff...
useEffect(() => {
chartInstance.current.data = data;
chartInstance.current.options = options;
chartInstance.current.update(updateMode);
}, [data, options]);
// other stuff...