Dot-Net
帶有 MS 圖表的 ASP.NET 禁用垂直線
我有一個使用 MS Chart 創建的圖表,如下圖所示。如您所見,垂直線與每個條形頂部的值混淆。
替代文字 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 = gdC# 版本(如果需要):
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 可以以相同的方式隱藏。
簡單的方法:
Chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;