如何为asp.net图表创建标签?

时间:2012-04-02 06:44:10

标签: asp.net charts

如何显示asp.net图表的标签?我附上了一份样本图表。如何定义产品A,B等? enter image description here

1 个答案:

答案 0 :(得分:1)

看一下下面的例子,你正在寻找的方法被调用 - AddXY:

using System;
using System.Collections.Generic;
using System.Web.UI.DataVisualization.Charting;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Dictionary<int, string> employees = new Dictionary<int, string>();

            employees.Add(10, "Product A");
            employees.Add(20, "Product B");
            employees.Add(30, "Product C");

            Chart1.Series[0].ChartType = SeriesChartType.Bar;

            foreach (KeyValuePair<int, string> employee in employees)
            {
                Chart1.Series[0].Points.AddXY(employee.Value, employee.Key);
            } 
        }
    }
}

ASP.NET MS Chart control