chartjs-plugin-dragdata icon indicating copy to clipboard operation
chartjs-plugin-dragdata copied to clipboard

Added custom interaction mode option

Open Ruanrls opened this issue 3 years ago • 1 comments

Problem

Sometimes we need different ways to search for the points to attach the drag. For example, when we have two different datasets, one is behind. We need to be able to use a custom mode to search between these two datasets.

Solution

Add any way to use custom interaction way which developers can implement while using react chart js.

References

Custom interaction modes

Ruanrls avatar Feb 22 '23 20:02 Ruanrls

Bump @chrispahm

Ruanrls avatar Nov 09 '23 23:11 Ruanrls

Thanks for catching this & creating a PR @Ruanrls! The only thing I am concerned about is why in the PR you proposed to provide the interaction variant via drag data plugin's options, while - as stated in the docs that you linked - it is already configured directly in the chart's configuration under options.interaction.mode. I believe it would be better to be consistent with the interaction behaviour (e.g. the tooltip) and use the same configuration property; moreover, I don't see any actual use case in a different situation, but maybe I am missing a point. WDYT?

In the meantime, I merged the current master branch & reformatted a bit your code. Also, I applied the change I described above - in case nobody brings an argument for creating a separate option for that in plugin configuration, I will test & merge the new version which uses the chart's interaction mode.

artus9033 avatar Aug 08 '24 22:08 artus9033

Thanks for catching this & creating a PR @Ruanrls! The only thing I am concerned about is why in the PR you proposed to provide the interaction variant via drag data plugin's options, while - as stated in the docs that you linked - it is already configured directly in the chart's configuration under options.interaction.mode. I believe it would be better to be consistent with the interaction behaviour (e.g. the tooltip) and use the same configuration property; moreover, I don't see any actual use case in a different situation, but maybe I am missing a point. WDYT?

In the meantime, I merged the current master branch & reformatted a bit your code. Also, I applied the change I described above - in case nobody brings an argument for creating a separate option for that in plugin configuration, I will test & merge the new version which uses the chart's interaction mode.

Hey @artus9033. I don't remember exactly why I implemented this way (it was a very long time ago, sorry). But I remember that the issue was when using the dragdata plugin and you have two points (one behind the other), the drag data don't select correctly the point to move, and all the points stays in place, without moving (even if using options.interaction.mode. If I'm not mistaken).

To reproduce that you can simple create a chart, add drag data and try moving the two points at the same place.

Ruanrls avatar Aug 09 '24 01:08 Ruanrls

Sure, thanks for the response @Ruanrls. I see, then I changed the code to pass the options from chart configuration.

artus9033 avatar Aug 14 '24 11:08 artus9033