Open benmusson opened 21 hours ago
please provide a simple reproducible example without react to rule out that the react wrapper causes it.
Here's a simple example: https://codepen.io/benmusson/pen/bGXrRGL
I am intentionally creating a new data object on each button press, because this is representative of my real use case.
EDIT: Bumped to Chartjs v4 and chartjs-chart-graph v4
The chart will render once, but when I do anything that causes the chart to render (for instance, update the data props), I get an error message in the browser console and the chart fails to draw.
Error Message:
Uncaught TypeError: Cannot read properties of undefined (reading 'borderCapStyle')
Full Error Message:
Source Location: https://github.com/sgratzl/chartjs-chart-graph/blob/194f833e66eb1e8f1bb999ca160b6cef65eb3a26/src/elements/EdgeLine.ts#L82
To Reproduce
I don't have a codepen yet, can try to put one together if it is helpful.
Expected behavior
I am using the
react-chartjs-2
wrapper. If I enable theredraw
option (which destroys/rebuilds the chart on every render) no errors occur.I should not need to use the
redraw
option.Screenshots
Context
Additional context
There are differences in how the default line element and
EdgeLine
get their options references in the draw function. I do not understand whyoptions
would be undefined on subsequent renders, but I think this explains the behavior difference.