我有一个图表,当 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);
}
}
谢谢
关于c# - 如何在asp图表控件中将错误消息显示到图表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14051948/