Makanz / chartjs-plugin-trendline

This plugin draws an linear trendline in your Chart. Made for Chart.js > 3.0
MIT License
80 stars 57 forks source link

Angular 12.1.2 | Typescript error while importing chartjs-plugin-trendline #63

Open anubhav-aggarwal opened 2 years ago

anubhav-aggarwal commented 2 years ago

I followed the instructions to install the plugin in my Angular 12.1.2 application using - npm i chartjs-plugin-trendline

On importing chartTrendLine, using this command - import {Chart, ChartConfiguration, ChartDataset, registerables} from 'chart.js'; import chartTrendline from "chartjs-plugin-trendline";

I get the following error - "TS7016: Could not find a declaration file for module 'chartjs-plugin-trendline'. '/Users/anubhav.aggarwal/Documents/polaris-repo/polaris-web-app/node_modules/chartjs-plugin-trendline/src/chartjs-plugin-trendline.js' implicitly has an 'any' type.   Try npm i --save-dev @types/chartjs-plugin-trendline if it exists or add a new declaration (.d.ts) file containing declare module 'chartjs-plugin-trendline';"

Hence, I'm not able to register the plugin using following command - Chart.register(chartTrendline);

Kindly help.

Makanz commented 2 years ago

I don't have any experience with Angular 12. I hope someone see this and can help.

Makanz commented 2 years ago

I have released a new version. Please try it and see if it solves your problem. @anubhav-aggarwal

BowieAtSemso commented 2 years ago

Hello, I've tried to install the package on a node.js environment and the same issue still seems to persist. I'm getting the same error where it seems to be missing a .d.ts file.

I simply ran npm i chartjs-plugin-trendline. That didn't work so I tried npm i chart.js chartjs-plugin-trendline which also didn't work. I followed the error and ran npm i --save dev @types/chartjs-plugin-trendline which, according to visual studio code, could solve the issue but it didn't work either.

I'm looking through your github repo and I can't find a .d.ts file anywhere I can manually add. Could you maybe look into adding a .d.ts file? It seems like that's the only issue but maybe you know more about this issue than I do and I'm simply doing something wrong so let me know, thanks in advance!

Ferotiq commented 2 years ago

I opened a pr for DefinitelyTyped to have types implemented for this plugin.

Ferotiq commented 2 years ago

It's now published and you can install @types/chartjs-plugin-trendline

Makanz commented 2 years ago

Thanks @Ferotiq

tvld commented 1 year ago

Very nice... But I can not seem to get to use it. Is there a documentation paragraph? )) I ran npm install --save-dev @types/chartjs-plugin-trendline but that was not enough?

Edit: or you can restart vs-code and then it works ;-P )))