artus9033 / chartjs-plugin-dragdata

Draggable data points plugin for Chart.js
MIT License
257 stars 55 forks source link

Use up-to-date configuration reference in callbacks #125

Open mf-bruce opened 11 months ago

mf-bruce commented 11 months ago

Summary Callbacks are registered during afterInit, however they were using a fixed reference to the dragData object using the chart instance object at time of initialization. That's fine only if the configuration options never change. However if, as was the case for me, the user is changing their callback definitions and updating the options object accordingly, the new callbacks would never be used by this plugin.

Test Plan

mf-bruce commented 7 months ago

@chrispahm any thoughts on this?

chrispahm commented 7 months ago

Hey @mf-bruce,

I'm sorry for taking so long to answer, I don't work with Chart.js anymore so this work just comes on top of the other things... If you're interested in maintaining this repo (maybe @artus9033?) please write me a short mail (see profile)!

Note that there are still a lot of test cases missing (see https://github.com/chrispahm/chartjs-plugin-dragdata/issues/40), plus there are no unit test at all! This is the main reason why I started lagging behind all these PRs and issues, as all options need to be tested manually after each update. Maybe Github Copilot / ChatGPT could be of help writing these test but I wouldn't be too sure about it...