Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Make scatter chart not require the lineElement

Open LeeLenaleee opened this issue 2 years ago • 1 comments

Feature Proposal

Currently when using tree shaking to create a verry basic scatter plot you need to import and register the lineElement since it extends the line controller and sets showLine to false.

This feels weird since a scatter chart does not show lines by default so you would expect it does not need the line element.

Possible Implementation

No response

LeeLenaleee avatar Mar 17 '22 16:03 LeeLenaleee

This seems like a great change to make

etimberg avatar Mar 18 '22 21:03 etimberg

Is it possible that the following bug is related to this?

https://stackoverflow.com/questions/73957247/chartjsreact-toggle-showline-in-scatter-view-doesnt-work

tdonhauser avatar Oct 05 '22 15:10 tdonhauser

I don't think so since you import and register everything with the auto import from chart.js.

Do you have a link with a reproducable sample?

LeeLenaleee avatar Oct 05 '22 15:10 LeeLenaleee

yes, you'll find a running example here:

https://stackblitz.com/edit/react-hdhjmn?file=src/App.js

tdonhauser avatar Oct 05 '22 16:10 tdonhauser

Not sure what exactly is causing the issue, when I try a simpeler case with the react wrapper or with plain js it works fine: wrapper: https://codesandbox.io/s/react-chartjs-2-chart-js-issue-template-forked-wf1d04?file=/src/App.tsx plain js: https://codesandbox.io/s/react-chartjs-2-chart-js-issue-template-forked-ce1ugl?file=/src/App.tsx

LeeLenaleee avatar Oct 05 '22 18:10 LeeLenaleee

Nice! thanks now it works. I tried to find the reason why it's not working with the code before, but can't see the reason.

Thanks for your help!

tdonhauser avatar Oct 06 '22 09:10 tdonhauser

Not sure what exactly is causing the issue, when I try a simpeler case with the react wrapper or with plain js it works fine: wrapper: https://codesandbox.io/s/react-chartjs-2-chart-js-issue-template-forked-wf1d04?file=/src/App.tsx plain js: https://codesandbox.io/s/react-chartjs-2-chart-js-issue-template-forked-ce1ugl?file=/src/App.tsx

If you open the wrapper example and change chart.js version to >=3.9.0 the error occurs again. All the older version don't throw this error. It might be a bug related to the newer versions...

tdonhauser avatar Oct 07 '22 16:10 tdonhauser