简体   繁体   English

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

[英]chart not showing all values on y-axis and x-axis

I have this bar chart control on my web page, I am adding at least 10 values to x-axis and y-axis, but the chart only shows 2 values on x and 3 values on y axis. 我的网页上有此条形图控件,我要在x轴和y轴上至少添加10个值,但是该图表在x轴上仅显示2个值,在y轴上仅显示3个值。 Below is my code 下面是我的代码

<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>

and the code behind is below 而后面的代码如下

     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); 
        }

any help will be appreciated. 任何帮助将不胜感激。

Set the Interval values on both the XAxis and YAxis. 在XAxis和YAxis上设置时间间隔值。 If you want tickmarks for each label, set the Interval on the MajorTickMark property of each axis as well. 如果需要每个标签的刻度线,请在每个轴的MajorTickMark属性上设置时间间隔。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM