带有MS Chart的ASP.NET禁用垂直线

Ang*_*Wat 9 .net vb.net asp.net data-visualization mschart

我有一个用MS Chart创建的图表,如下图所示.如您所见,垂直线与每个条形顶部的值混淆.

alt text http://img46.imageshack.us/img46/3720/chartimgaxd.png

这是图表的标记:

        <asp:Chart ID="chtNBAChampionships" runat="server">
   <Series>
      <asp:Series Name="Championships" YValueType="Int32"  ChartType="Column" ChartArea="MainChartArea" IsValueShownAsLabel="true">
         <Points>
            <asp:DataPoint AxisLabel="Celtics" YValues="17" />
            <asp:DataPoint AxisLabel="Lakers" YValues="15" />
            <asp:DataPoint AxisLabel="Bulls" YValues="6" />
            <asp:DataPoint AxisLabel="Spurs" YValues="4" />
            <asp:DataPoint AxisLabel="76ers" YValues="3" />
            <asp:DataPoint AxisLabel="Pistons" YValues="3" />
            <asp:DataPoint AxisLabel="Warriors" YValues="3" />

         </Points>
      </asp:Series>
   </Series>
   <ChartAreas>
      <asp:ChartArea Name="MainChartArea">
      </asp:ChartArea>
   </ChartAreas>
</asp:Chart>
Run Code Online (Sandbox Code Playgroud)

我不希望显示垂直线,因为它与每个条顶部的值搞混了.如何禁用垂直线?

谢谢.

Cha*_*nte 14

简单方法:

Chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
Run Code Online (Sandbox Code Playgroud)


Ste*_*bob 6

我不知道具体的ASP语法,但这里有VB.NET代码可以解决这个问题:

Dim gd As New System.Windows.Forms.DataVisualization.Charting.Grid
gd.LineWidth = 0

myChart.ChartAreas("MainChartArea").AxisX.MajorGrid = gd
Run Code Online (Sandbox Code Playgroud)

C#版本如果需要:

System.Web.UI.DataVisualization.Charting.Grid gd = new System.Web.UI.DataVisualization.Charting.Grid(); 
gd.LineWidth = 0; 

myChart.ChartAreas[0].AxisX.MajorGrid = gd;
Run Code Online (Sandbox Code Playgroud)

如您所见,您不能只关闭网格线,您必须将其宽度设置为0. MinorGrid可以以相同的方式隐藏.

  • 是的,将enabled属性设置为false有效! (2认同)