我在 ASP.NET (.NET 3.5) 中有一个包含 3 个系列的图表。日期在代码中动态填写。如何为代码中的每个 X 条目设置标签?(标签 1、标签 2、标签 3 等)
问问题
1557 次
1 回答
1
也许你的意思是这个
在 aspx 中
<asp:Chart ID="Chart1" runat="server" Height="400px" Width="500px">
<Series>
<asp:Series Name="Series1" ChartType="Column" ChartArea="ChartArea1" />
<asp:Series Name="Series2" ChartType="Column" ChartArea="ChartArea1" />
<asp:Series Name="Series3" ChartType="Column" ChartArea="ChartArea1" />
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" />
</ChartAreas>
</asp:Chart>
绑定数据
protected void Page_Load(object sender, EventArgs e)
{
// Initialize arrays for series 1
double[] yval1 = { 2, 6, 5 };
string[] xval1 = { "Peter", "Andrew", "Julie" };
// Initialize arrays for series 2
double[] yval2 = { 4, 5, 3 };
string[] xval2 = { "Peter", "Andrew", "Julie" };
// Initialize arrays for series 3
double[] yval3 = { 6, 5,7 };
string[] xval3 = { "Peter", "Andrew", "Julie" };
// Bind the arrays to each data series
Chart1.Series["Series1"].Points.DataBindXY(xval1, yval1);
Chart1.Series["Series2"].Points.DataBindXY(xval2, yval2);
Chart1.Series["Series3"].Points.DataBindXY(xval3, yval3);
// Align series using their X axis labels
Chart1.AlignDataPointsByAxisLabel();
}
于 2013-10-23T12:40:36.787 回答