tanmaya
Posts: 2
Joined: Thu Aug 05, 2021 5:20 pm

Empty Chart, No Plot

Hi,

My api response for highcharts contains series object with data as follows:

series: [
{
data: [{}, null , {}],
}
]

The chart displayed is empty since there is no data greater than zero. Is there a way to know from highcharts that the chart is empty and does not contain any plot in it.

Thanks,
Tanmaya
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Empty Chart, No Plot

Hello!

There are multiple ways of achieving that.

One of them (and I think the best one in terms of performance) would be to check yAxis.dataMin or yAxis.dataMax. It takes the values from all the data points, and if it's null (meaning, there is no max or min value on the chart), then the chart is empty.
DEMO: https://jsfiddle.net/BlackLabel/70nj2zyd/

Other option would be to loop over each series, then loop over each point in series, and check the isNull boolean value. But that would just a tiny bit more demanding in terms of performance (i.e when you have 10k points).

Let me know if that is what you were expecting,
Best regards!
Kamil Musiałowski
Highcharts Developer

Return to “Highcharts Usage”