AbelHeinsbroek / chartjs-plugin-crosshair

Crosshair plugin for ChartJS
https://chartjs-plugin-crosshair.netlify.com/samples/
MIT License
145 stars 87 forks source link

Module '"chartjs-plugin-crosshair"' has no exported member 'CrosshairPlugin' and Interpolate #109

Open SharpieX opened 1 year ago

SharpieX commented 1 year ago

Hi I am trying to use plugin with react-chartjs-2 in my typescript project and getting error in title

any solutions

jayantbh commented 1 year ago

The types are outdated. On the DefinitelyTyped repo they're for version 1.1.1 while this repo is on 1.2.0. You may either update the types on definitely typed types, or in a .d.ts file, add this:

declare module 'chartjs-plugin-crosshair';
Daschi1 commented 1 year ago

The types are outdated. On the DefinitelyTyped repo they're for version 1.1.1 while this repo is on 1.2.0. You may either update the types on definitely typed types, or in a .d.ts file, add this:

declare module 'chartjs-plugin-crosshair';

Thank you very much, I had the same issue and your solution fixed it.

SharpieX commented 1 year ago

@Daschi1 @jayantbh could you please share exact changes i am still struglling , do i need to create a .d.ts file

Daschi1 commented 1 year ago

I used the plugin with the sveltjs wrapper of chartjs in a svelte typescript project. I copied declare module 'chartjs-plugin-crosshair'; in my vite-env.d.ts file, but any .d.ts should work.

jayantbh commented 1 year ago

Hey @SharpieX, ^ @Daschi1's instructions should work.

Basically create a file anywhere named anything.d.ts, just needs to be a .d.ts file and add it there. You could also add the declaration mentioned previously in any existing .d.ts file.

I personally have a directory/file like libdefs/ambient.d.ts in my project root where I add all such declarations.

sarates commented 1 year ago

@jayantbh @SharpieX have you guys managed to make this plugin fly with react-chartjs-2? Could you pls share your packages versions? (react-chartjs-2, chartjs, chartjs-plugin-crosshair)