我的网页上有这个条形图控件,我在 x 轴和 y 轴上添加了至少 10 个值,但图表仅在 x 上显示 2 个值,在 y 轴上显示 3 个值。下面是我的代码
<asp:Chart ID="ChartTest" runat="server" Height="296px" Width="600px" ImageType="Png"
BackColor="#D3DFF0" Palette="BrightPastel" BorderlineDashStyle="Solid" BackSecondaryColor="White"
BackGradientStyle="TopBottom" BorderWidth="2" BorderColor="26, 59, 105">
<Titles>
<asp:Title ShadowColor="32, 0, 0, 0" Font="Trebuchet MS, 14.25pt, style=Bold" ShadowOffset="3"
Text=" Bar Chart" Name="Title1" ForeColor="26, 59, 105">
</asp:Title>
</Titles>
<Legends>
<asp:Legend Enabled="False" IsTextAutoFit="False" Name="Default" BackColor="Transparent"
Font="Trebuchet MS, 8.25pt, style=Bold">
</asp:Legend>
</Legends>
<BorderSkin SkinStyle="FrameThin1"></BorderSkin>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid"
BackSecondaryColor="White" BackColor="64, 165, 191, 228" ShadowColor="Transparent"
BackGradientStyle="TopBottom">
<Area3DStyle Rotation="9" Perspective="10" Enable3D="True" LightStyle="Realistic"
Inclination="38" PointDepth="200" IsRightAngleAxes="False" WallWidth="0" IsClustered="False" />
<Position Y="10" Height="94" Width="94" X="10" ></Position>
<AxisY LineColor="64, 64, 64, 64">
<LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
<MajorGrid LineColor="64, 64, 64, 64" />
</AxisY>
<AxisX LineColor="64, 64, 64, 64">
<LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
<MajorGrid LineColor="64, 64, 64, 64" />
</AxisX>
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
后面的代码如下
var series = ChartTest.Series.Add("series1");
series.ChartType = SeriesChartType.Column;
series.XValueType = ChartValueType.Auto;
Chart_MRDBHull.Titles[0].Text = "chart 1";
foreach (DataRow dr in ds.Tables[0].Rows)
{
//if(dr.Table.Columns.Contains(
var xValue = dr["class1"].ToString();
var yValue = dr["Total"].ToString();
series.Points.AddXY(xValue, yValue);
}
任何帮助将不胜感激。