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]]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I always have a condition that I check in my
AJAXfunction, which checks for no results. Then if no results happen I set a chart so that it looks empty. For this reasonvar data = [[null]]should do, wheredatais a parameter ofjQuery.jqplot('chart', data, {}). The value ofdatamight 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
dataand legend is always enough.