I have a graph created with MS Chart like the following picture. As you can see the vertical lines are messed up with value of the top of each bar.
alt text http://img46.imageshack.us/img46/3720/chartimgaxd.png
Here's the mark-up for the graph:
<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" YValue开发者_开发百科s="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>
I don't want the display the vertical line because it's messed up with the value on top of the each bar. How can I disable the vertical line?
Thank you.
simple way:
Chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
I don't know the specific ASP syntax, but here is the VB.NET code that does the trick:
Dim gd As New System.Windows.Forms.DataVisualization.Charting.Grid
gd.LineWidth = 0
myChart.ChartAreas("MainChartArea").AxisX.MajorGrid = gd
C# version if needed :
System.Web.UI.DataVisualization.Charting.Grid gd = new System.Web.UI.DataVisualization.Charting.Grid();
gd.LineWidth = 0;
myChart.ChartAreas[0].AxisX.MajorGrid = gd;
As you can see, you can't just turn off the gridline, you have to set it's width to 0. The MinorGrid can be hidden the same way.
Simplest way, put the following code in chart load event.
protected void Chart1_Load(object sender, EventArgs e)
{
Chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
Chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = false;
}
This resolved the issue. Thanks.
Below is the c# code....
var gd = new System.Web.UI.DataVisualization.Charting.Grid();
gd.LineWidth = 0;
Chart1.ChartAreas[0].AxisX.MajorGrid = gd;
This could work from source
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
<AxisX>
<MajorGrid LineWidth="0" />
</AxisX>
</asp:ChartArea>
</ChartAreas>
精彩评论