I am using amCharts to generate graphs and such by pulling data via dataLoader capability.
I have been mulling my brain as to how to gracefully handle lack of data that gets passed from API from time to time so that graph shows a message such as "No Data Available".
Example chart code:
var chart = new AmCharts.AmSerialChart();
chart.dataLoader = { url: "/api/blobs"};
chart.categoryField = "site";
chart.type="serial";
chart.theme = "light";
var graph = new AmCharts.AmGraph();
graph.valueField = "visit";
graph.type = "column";
graph.fillAlphas = 1;
graph.lineAlpha = 0;
var valuesAxis = new AmCharts.ValueAxis();
valuesAxis.integersOnly = true;
graph.balloonText = "[[category]]: <b>Total: [[value]]</b>";
chart.depth3D = 45;
chart.angle = 45;
chart.addGraph(graph);
chart.addValueAxis(valuesAxis);
chart.write("blob_chart");
Anyone have a clue how I can manage to check if dataLoader returns null and if so write a plan "No Data Available" on the chart instead?