artus9033 / chartjs-plugin-dragdata

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

onDragEnd returns value as undefined #42

Closed teepaja closed 4 years ago

teepaja commented 4 years ago

After upgrading to 1.10 (and chart.js 2.9.3):

-    "chart.js": "^2.8.0",
-    "chartjs-plugin-dragdata": "^1.0.4",
+    "chart.js": "^2.9.3",
+    "chartjs-plugin-dragdata": "^1.1.0",
     "react-chartjs-2": "^2.8.0",

I'm getting value as undefined with onDragEnd:

    onDragEnd: (e: any, datasetIndex: any, index: any, value: any) =>
      console.log(index, datasetIndex, value)
    ...
    >> 1, 0, undefined

    // This issue can be circumvented by getting the value from the dataset
    onDragEnd: (e: any, datasetIndex: any, index: any, value: any) =>
      console.log(index, datasetIndex, data.datasets[datasetIndex].data[index])
    ...
    >> 1, 0, 123 <-- actual value

You can also see this behaviour in the console of the example fiddle: https://jsfiddle.net/3v9kexbh/

chrispahm commented 4 years ago

Sorry, that was a bug introduced with the new applyMagnet feature. Thanks for reporting! Should be fixed by the new version 1.1.1