如何显示asp.net图表的标签?我附上了一份样本图表。如何定义产品A,B等?
答案 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);
}
}
}
}