我有一个图表,当 rows.count == 0 时,我必须将消息显示为“无数据存在”,否则条形图通常。
我可以知道如何显示该消息。
提前致谢。
试试这个 :
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);
}
}
谢谢