artus9033 / chartjs-plugin-dragdata

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

Added dragY option #37

Closed hokiedsp closed 4 years ago

hokiedsp commented 4 years ago

@chrispahm - Thank you for the fantastic plugin!

For my use, I needed to restrict dragging in Y axis (creating a time cursor along x-axis on a scatter plot) and this PR adds that capability without breaking the existing function. I've also created bubble_xonly.html in /doc to demonstrate the option.

A little off topic, but am I correct that dragX/dragY can only be applied globally? I'll have a case coming up where I need to restrict some datasets but not all...

chrispahm commented 4 years ago

Thanks for your PR, sounds cool! About turning data dragging on/off per dataset: We have the following functionality documented: To avoid dragging specific datasets, you can set dragData to false within the dataset options.

const myChartOptions = {
  type: 'line', // or radar, bar, horizontalBar, bubble
  data: {
    datasets: [
      {
        label: "Data Label",
        fill: false,
        data: dataPoints,
        yAxisID: 'B',
        dragData: false
      }, {
    ...
  },
  options: {
    dragData: true,
    ... // the remainder of your chart options
  }
}

However, this only applies to the data dragging in general. Also, I haven't tested this feature in a while... Anyways, if I have some more time I will try and setup some more test routines as there are now too many features to check manually every time. If you're interested I'd be more than happy about your contribution!

hokiedsp commented 4 years ago

Thanks for the heads up on dragging specific datasets. I'll check it out.