1

行数== 0の場合、通常どおり棒グラフの場合、「データが存在しません」というメッセージを表示する必要があるグラフがあります。

そのメッセージを表示する方法を教えてください。

前もって感謝します。

4

1 に答える 1

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);
    }
}

ありがとう

于 2012-12-31T06:40:07.480 に答える