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

Cannot read property 'register' of undefined #54

Closed Creatium closed 2 years ago

Creatium commented 3 years ago

Hi,

Trying to use this plugin with Chart JS 3.2. Anything above Chart JS 2.9.4 gives me this error:

Uncaught TypeError: Cannot read property 'register' of undefined
    at chartjs-plugin-trendline.min.js:formatted:93

Trendline is inlined after chartjs. Chart is being created after an AJAX call for data.

Calling "window.Chart.plugins" on document ready gives "undefined". Is this something that changed with version 3 of Chart JS and needs an update on Trendline side?

kuzudevelopers commented 3 years ago

I can also reproduce this error using inline scripts from cdnjs.com: anything over ChartJS 2.9.3 (latest available version of v2 on cdnjs) causes this error.

Makanz commented 3 years ago

Thanks for the report. I will take a look at it.

jremi commented 3 years ago

@Makanz i'm going to try to review this also, but do you happen to have any ETA on when you may have Chart JS 3.x support so we can use this plugin?

Thx 🙏

husain3012 commented 2 years ago

@Makanz i would like to work on this issue, i figured out the issue causing this bug

Makanz commented 2 years ago

I have a PR from jimm13 that I will take a look at.

Makanz commented 2 years ago

I have now merged the PR and created a new release v1.0.0. Its also published to npm.