@nik-sol,
One more help in similar case,
We need to hide legends in this situation as well.
You can toggle showInLegend property if you are looking to hide legend for dataPoints with y-values as 0 or null as shown in the code snippet below:
showDefaultText(chart, "No Data Found!");
function showDefaultText(chart, text) {
var dataPoints = chart.options.data[0].dataPoints;
var isEmpty = !(dataPoints && dataPoints.length > 0);
if (!isEmpty) {
for (var i = 0; i < dataPoints.length; i++) {
isEmpty = !dataPoints[i].y;
if (!isEmpty)
break;
}
}
if (!chart.options.subtitles)
chart.options.subtitles = [];
if (isEmpty) {
chart.options.subtitles.push({
text: text,
verticalAlign: 'center',
});
chart.options.data[0].showInLegend = false;
} else {
chart.options.subtitles = [];
chart.options.data[0].showInLegend = true;
}
}
Please take a look at this updated JSFiddle for a working example with sample code.
—
Sanjoy Debnath
Team CanvasJS