0👍
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);
}
})
}
- [Chartjs]-Set max value of chart.js bar chart
- [Chartjs]-ChartJS won't draw graph inside bootstrap tab until window resize
0👍
If you have access to the chart object from the wrapper you can hide the dataset this way:
if (data < 100) {
chartObject.getDatasetMeta(2).hidden = true
chartObject.update()
}
But im not fammiliar with the ng wrapper so I dont know if they exposed the chart object. If this is not the case you might want to look into using only the normal lib and writing your own wrapper component.
Edit: According to this thread it is possible to acces the chart object (ng2-charts access base chart object)
- [Chartjs]-How to use two datasets in chart.js doughnut chart?
- [Chartjs]-Adding labels and colours to Chart.JS from arrays
0👍
When you set your data, you probably have something like this:
this.barChartData = [
{ data:[1, 2, 3], label: 'legend'}
];
you can add one parameter entitled hidden
:
this.barChartData = [
{ data:[1, 2, 3], label: 'legend', hidden: true }
];
instead of "true", you can probably run a test and beforehand and store the result in a variable.
Source:stackexchange.com