artus9033 / chartjs-plugin-dragdata

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

Uncaught TypeError: Cannot read properties of undefined (reading 'update') Solidjs #107

Closed Ladvace closed 1 year ago

Ladvace commented 1 year ago

Describe the bug I'm getting the following error while dragging a point, I'm using charts js with solidjs

Uncaught TypeError: Cannot read properties of undefined (reading 'update') To Reproduce https://stackblitz.com/edit/solidjs-template-aoycrm?file=src/App.tsx

Expected behavior updating without errors

chrispahm commented 1 year ago

Hey @Ladvace,

This is a bug which has been fixed by #85... And thanks to your issue I just realised that the fix hasn't been published to npm yet due to the dist folder being out of sync! Once again stumbling over the missing test cases (see #40 if you have some time on your hands) and Github Actions...

Anyways: From a UI perspective, I'd strongly argue for using tooltips with this plugin. It's much easier to reach the desired values when you can actually see the value you are currently dragging 😊 https://stackblitz.com/edit/solidjs-template-zyg537?file=src/App.tsx

Ladvace commented 1 year ago

Hey @chrispahm thanks for the update and for the stackblitz, I managed to fix it registering "registerables" as below:

import {
  Chart,
  registerables,
  LineController,
  LineElement,
  PointElement,
  LinearScale,
  Title,
  CategoryScale,
} from "chart.js";

Chart.register(
  ...registerables,
  dragdataPlugin,
  LineController,
  LineElement,
  PointElement,
  LinearScale
  Title,
  CategoryScale
);

I'll try to give it a look this Friday/weekend as I should have more time

chrispahm commented 1 year ago

Perfect! In that case you may also just use the following simple two-liner (as per the documentation:

import Chart from 'chart.js/auto';
Chart.register(dragdataPlugin)

I just release v2.2.5 which includes the fix from #85. Closing this as answered, please re-open if the issue persists!