I want to display a "no data" label on the View when the chart returns nothing. I'm using ChartDirector, and this is a MVC project.
[HttpGet]
public ActionResult Sales()
{
SALESChart1(ViewBag.Viewer = new RazorChartViewer(HttpContext, "chart1"));
return View();
}
The chart code:
private void SALESChart1(RazorChartViewer viewer)
{
string sQuery = query goes here
// The data for the bar chart
double[] data = myDBTabletoUse.getCol(0);
double[] data2 = myDBTabletoUse.getCol(1);
string[] labels = myDBTabletoUse.getColAsString(2);
chart stuff goes here
// Output the chart
viewer.Image = c.makeWebImage(Chart.PNG);
// Include tool tip for the chart
viewer.ImageMap = c.getHTMLImageMap("", "", "title='{xLabel}: {value} HL'");
}
And view to display chart
<th colspan="2">
@Html.Raw(ViewBag.Viewer.RenderHTML())
</th>
May be you can create an empty chart with the text "No Data" at the center. It is like: