我有一个用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可以以相同的方式隐藏.