Ticket T509128
Visible to All Users

Cannot remove X Axis grid-lines for XYDiagram bar chart

created 8 years ago

Hello,

I am experiencing an issue trying to remove all the grid lines from my bar chart. It's a simple 2D bar chart and I've tried the following code to remove the vertical line that appears in each grouping which you can see in the attached image.

C#
( (BarSeriesView)ChartControl.SeriesTemplate.View ).AxisX.GridLines.Visible = false;

I've also tried this:

C#
XYDiagram diagram = (XYDiagram)ChartControl.Diagram; diagram.AxisX.GridLines.Visible = false; diagram.AxisX.GridLines.MinorVisible = false; diagram.AxisX.Tickmarks.Visible = false; diagram.AxisX.Tickmarks.MinorVisible = false; diagram.AxisX.Interlaced = false;

I was able to remove all the Y-Axis grid lines just fine using the same code above, but of course changing AxisX to AxisY.

Looking forward to your response,
Thanks.

Answers approved by DevExpress Support

created 8 years ago

Hello Yuvraj,

ChartControl generates series and diagrams when drawing the content. The proper way to customize the diagram in this case is to handle the BoundDataChanged event. It occurs every time a chart control generates its series points from the underlying data source:

C#
private void chartControl1_BoundDataChanged(object sender, EventArgs e) { XYDiagram diagram = (sender as ChartControl).Diagram as XYDiagram; if (diagram == null) return; diagram.AxisX.GridLines.Visible = false; diagram.AxisX.GridLines.MinorVisible = false; diagram.AxisX.Tickmarks.Visible = false; diagram.AxisX.Tickmarks.MinorVisible = false; diagram.AxisX.Interlaced = false; }

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.