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
- Set backgroundColor of bar-char (chart.js)
- chartjs radar glowing edges effect
- Chart.js bezier curve discontinuity
- How to compare input text with database value in Spring Boot?
- How can I load multiple Chartjs charts with different data on the same page?
- Pie chart legend styling using Chart js
- Chart.js Update to X Axis Not Updating
- How to make chartJs stacked bar always rounded when data is 0?
- Select missing dates from a table in MySQL
- How can I remove the grid line in the background of the line chart?
- How to update a react-chartjs-2 plot using useState()
- Make a Histogram in Chart.js
- Blank PNG image using Chart JS . toBase64Image() function
- How to make a chart with chartjs and Angular?
- Skip labels when associated value is null in chartJS
- The engine “node” is incompatible with this module when installing React-chartjs-2 Chart.js,
- Call ChartJS details in main Javascript file
- How to access all data in a function with ChartJs?
- Chartjs not rendering in navigation stack
- Long text in x-axis is cut in bar graphs ng2-charts
- Angularjs lazy load chartjs when in another tab
- how to manipulate with the y-axis values in chartjs
- Chart.js Scaling issue when initially loading the page
- Is there any way to display float bar in chart.js?
- Inserting data from arrays into a pie chart (chart.js)
- Map event position to y axis value in chartjs line chart
- Dynamically updating Chart.js data in angular
- Chart.js - Show new data on button click
- Chart.js not resorting rows based on plugin after using update function
- ChartJS v2: Scale value at click coordinates (time scale)