I have created a simple doughnut chart using chartjs plugin in angular like the given screenshot below
now when the chart loads if the dataset value below 100 it should automatically hide like below
here is my complete code https://stackblitz.com/edit/ng2-charts-legend-with-value-hide
tried this piece of code which was taken from this reference https://jsfiddle.net/beaver71/00q06vjp/
pieChartData.data.forEach(function(ds) { ds.hidden = !ds.hidden;
still no luck please help me to solve this issue
Update your ngOnInit on stackBlitz and see if this is what you want
ngOnInit() { const othis = this; this.pieChartData.forEach((data, i) => { if (data < 100) { othis.pieChartData.splice(i, 1); } }) }
2.1m questions
2.1m answers
60 comments
57.0k users