Is there a best approach to handle "no data" with JqPlot?
Assuming that I'm consuming json data with an ajax call, and eventually no data is available, eg:
[['North'][0],['South'][0],['East'][0],['West'][0]]
I always have a condition that I check in my AJAX
function, which checks for no results. Then if no results happen I set a chart so that it looks empty. For this reason var data = [[null]]
should do, where data
is a parameter of jQuery.jqplot('chart', data, {})
. The value of data
might be dependant on a type of chart, thus I tested it for line, bar and pie chart and it works fine.
Optionally you could also hide legend and maybe other parts of the plot. For me just setting the data
and legend is always enough.