Legend onclick can not override chart onclick
See original GitHub issueHi,
I want trigger legend onclick function, but when I click legend, it seems to trigger the chart onclick function to setState. Is there any way to prevent chart onclick when click the legend.
Thanks a lot!
options = {legend: { display: true, onClick: (e, item) => {console.log("Click Legend")} }, events: ['click', 'mousemove'], onClick: (e, data) => { this.setState(newState) }}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5
Top Results From Across the Web
Legend onclick can not override chart onclick #299 - GitHub
Hi, I want trigger legend onclick function, but when I click legend, it seems to trigger the chart onclick function to setState. Is...
Read more >Chart.JS custom legend onClick event returns error when ...
I'm trying to create custom onClick handler for pie chart legend and I get this error: ERROR TypeError: Cannot read property ...
Read more >onClick of ui.chart, Properties Webix Docs - Documentation
... of ui.chart. This page contains onClick documentation to help in learning the library. ... the onClick handler can override the default onclick...
Read more >Legend onClick override with default behaviour-Chart.js
The only issue with this fix is that by default, in ng2-charts the .hidden artibute is not exposed by default so i had...
Read more >Legend Onclick Chart JS | ChartJS 2.9.x - YouTube
Legend Onclick Chart JS | ChartJS 2.9.x. In this video we will explore how to create an onclick event on the legend. This...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@KhalidOuaz I’ve found this and test it with another chart (bar chart). Maybe can help you with the behavior of legend.
legend: { display: true, position: ‘bottom’, onClick: (e, legendItem, chart) => { // console.log(‘e’, e); // EVENT // console.log(‘legendItem’, legendItem); // ITEMS // console.log(‘chartRef’); // REF const ci = chartRef.chartInstance; let meta = ci.getDatasetMeta(0); // console.log(meta);
Cheers
Hello Button continue to be override, i have a test here but i am still not finding a solution. Can you help me please https://codesandbox.io/s/gallant-archimedes-zqxre