score:9
Accepted answer
The problem is that you have only one dataset and your code use the index
of legend item clicked to hide datasets[index]
.
On the contrary you need to hide single item data as below:
var meta = chart.getDatasetMeta(0);
var item = meta.data[index];
Check the fiddle updated: https://jsfiddle.net/beaver71/aa2n39s2/
Source: stackoverflow.com
Related Query
- Chart.js HTML custom legend issues with doughnut chart
- Legend isnt moving to the right on my doughnut chart created with chart.js
- Doughnut chart from Chart.js, custom legend and call of original handler not works as expected
- Modify the legend of a double doughnut with chart js
- ChartJS custom legend doughnut separate legend from chart area
- Chartjs Custom Legend for Doughnut Chart Having Labelled Lines Sticking Out of Each Section
- How can I add functionality to Chartjs Doughnut chart custom legend
- Custom Legend with ChartJS v2.0
- chart js how to fill legend box with colour
- ChartJS bar chart with legend which corresponds to each bar
- Chart.JS full-width, responsive doughnut chart with Bootstrap
- Extending Line Chart with custom line
- Increase padding between legend and chart with react-chartjs-2
- Chartjs doughnut chart with gradient color
- Using Chart.js - Creating Legend for Doughnut Chart
- Custom data position on the doughnut chart in chart.js
- Angular chart how to show the legend data value by default along with legend name
- Issue while plotting bar chart with custom x-axis with month and year in chart.js
- Chart Js update legend boxes of graph with graph line style
- Responsive Chart.js Doughnut Chart with minimum height
- Vue Chart.js Doughnut Chart with rounded and spaced arcs (vue3-chart-v2)
- Vue Chart 3 - Doughnut Charts with Text in the Middle (Trouble registering a plugin)
- Create a arc like doughnut chart with Chart js plugins
- Doughnut Chart not displaying data with Chart Js and Backbone js
- Force ChartJS to show Doughnut chart with null values
- ChartJs - Round borders on a doughnut chart with multiple datasets
- Chartjs Custom Legend with Time on Y-axis
- Doughnut chart updates with twice the data
- Chart js custom separate legend returns error when clicking legend
- React with chart js, labelling problems in multiple datasets for doughnut chart
More Query from same tag
- pan on chart.js also zoom on line charts
- chartjs: How to create single outer border for stacked barchart
- Change color of line along labels Chart.js
- Chartjs - keeping 2 graphs aligned side by side
- char.js overlapping bar columns when using type: 'time'
- Chart.js - Black bar colors in mobile devices
- Create multiple dynamic charts
- Using chartjs-plugin-annotation with ng2-charts
- Chart.js x-axis time doesn't show values when using combined (mixed) charts
- Chart.js Doughnut Chart Sizing
- how to set chart.js grid color for line chart
- hereChartJS Line Chart with Time Axis
- Dynamically creating graphs with jQuery
- Update of options for PrimeNG Chart needs two calls instead of one
- ng2-charts customize data and whole html content of tooltip displayed when hovering on bar chart
- How to control visibility of canvas image via button outside the canvas(ChartJs)?
- How to parse time 'HH:MM:SS' and display steps on xAxis every minute in Chart.js
- chartJS Horizontal Bar - Hide Stacked Bars But Still Show In Tooltip
- Reanimate Data Values in CharJS
- ChartJS: Show all tooltips with Total for Multi Pie chart
- Show Count on top of the bar graph - ChartJS
- How to use Chart.js with Typescript without getting assignable errors?
- Chart.js (Customising tool tips of a stacked bar to represent each stacked data)
- how to update chartjs2 option (scale.tick.max)
- Chart JS: Always show tooltips in a multi dataset line chart
- Chartjs animate x-axis displaying data incorrectly in mac device
- Two charts in a page not working, using Chart.js 3.1.1 cdn in Laravel 8.x framework
- Execute onClick function on Custom Legend
- Charts.js scales yaxes ticks min max doesnt work
- Draw points and lines inside a bar in bar chart