图表未显示y轴和x轴上的所有值

时间:2012-09-20 21:56:18

标签: asp.net mschart

我的网页上有条形图控件,我在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); 
        }

任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

在XAxis和YAxis上设置间隔值。如果您想为每个标签添加标记,请在每个轴的MajorTickMark属性上设置Interval。

相关问题