artus9033 / chartjs-plugin-dragdata

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

Vue3 compability #111

Open Mikolaj-Graja opened 1 year ago

Mikolaj-Graja commented 1 year ago

Events are not working on Vue3 (composition api)

Example:

const chartPlugins = [{
        id: 'mousedownCatcher',
        dragData: {
          round: 1,
          showTooltip: true,
          onDragStart: function (e, datasetIndex, index, value) {
            console.log(e)
          },
          onDrag: function (e, datasetIndex, index, value) {
            e.target.style.cursor = 'grabbing'
            console.log(e, datasetIndex, index, value)
          },
          onDragEnd: function (e, datasetIndex, index, value) {
            e.target.style.cursor = 'default'
            console.log(datasetIndex, index, value)
          },
        }
  }]

  const draggableChart = new Chart('draggableChart', {
        type: 'line',
        data: chartData,
        options: chartOptions,
        plugins: chartPlugins
  })
  + dragData: true on datasets in chartData

Result: no console logs, no changes in chart behaviour on click/ drag etc.

Plugin installed by npm

chrispahm commented 1 year ago

Hey @Mikolaj-Graja,

Thanks for raising an issue. As always, I'd need a reproducible example on jsFiddle / Codesandbox etc. before having a deeper look.

bitbytebit1 commented 1 year ago

Can confirm I'm seeing the same issue: https://stackblitz.com/edit/nuxt-starter-2tb3jw?file=app.vue

bitbytebit1 commented 1 year ago

Got it working: https://stackblitz.com/edit/nuxt-starter-2tb3jw?file=app.vue