我有一个图表,当rows.count == 0时,我必须将消息显示为“No Data Present” 否则就是通常的条形图。
我可以知道如何显示该消息。
提前致谢。
答案 0 :(得分:3)
试试这个:
protected void ChartExample_DataBound(object sender, EventArgs e)
{
// If there is no data in the series, show a text annotation
if(ChartExample.Series[0].Points.Count == 0)
{
System.Web.UI.DataVisualization.Charting.TextAnnotation annotation =
new System.Web.UI.DataVisualization.Charting.TextAnnotation();
annotation.Text = "No data for this period";
annotation.X = 5;
annotation.Y = 5;
annotation.Font = new System.Drawing.Font("Arial", 12);
annotation.ForeColor = System.Drawing.Color.Red;
ChartExample.Annotations.Add(annotation);
}
}
由于