微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我有一个用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>

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

谢谢.

解决方法

我不知道具体的ASP语法,但这里是VB.NET代码,它可以解决这个问题:
Dim gd As New System.Windows.Forms.DataVisualization.Charting.Grid
gd.linewidth = 0

myChart.ChartAreas("MainChartArea").AxisX.MajorGrid = gd

C#版本如果需要:

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

myChart.ChartAreas[0].AxisX.MajorGrid = gd;

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

原文地址:https://www.jb51.cc/aspnet/247962.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐