Open rohrz4nge opened 2 years ago
On further thought, this behaviour leads to another issue:
As you can see in this codesandbox, even though we return false from the callback, the point still gets changed. The dataPoint is updated inside calcPosition
, which gets called before the callback. So we can't disable this automatic update, even when returning false from the callback.
Hey @rohrz4nge,
Thanks a lot for investigating and even creating a fix in #97. I'm quite behind in reviewing PR's, just wanted to let you know that I have it on my todo!
Describe the bug When supplying charts with a frozen dataset, this plugin uses dataPoint objects given in the dataset. It then tries to overwrite x or y of this frozen object (see lines 150 and 155 of index.js), leading to an error.
To Reproduce https://codesandbox.io/s/react-chartjs-2-line-chart-example-forked-6fq13e
Expected behavior If we return false from the callback, the plugin shouldn't modify the existing data. Thus the dataPoint objects need to be copied instead of modified directly.
https://github.com/chrispahm/chartjs-plugin-dragdata/blob/ce6d694f8a16a8d84436545186b07765bbd7c3c7/src/index.js#L150
https://github.com/chrispahm/chartjs-plugin-dragdata/blob/ce6d694f8a16a8d84436545186b07765bbd7c3c7/src/index.js#L155