How to remove X-Axis Labels without impacting Y Axis

2 posts, 0 answers
  1. Ian
    Ian avatar
    51 posts
    Member since:
    Apr 2009

    Posted 28 May 2009 Link to this post

    I am trying to produce a stacked bar chart but without any X axis labels. At the moment I am getting a number for each stacked chart (0, 1 etc) and don't want these to appear. If I set AxisX.MajorGriidLinesVisibility = Visibility.Collapsed this achieves what I want on the X-axis but messes up the Y axis!

    I have set AxisY.Minimum =0; and AxisY.Maximum = 4000; and these work fine when AxisX.MajorGridLinesVisibility isn't set to Collapsed. But if I set XAxis.MajorGridLinesVisibility to Collapsed the Y axis scale changes so that it ignores the values I've set and goes from 500 to 4500! I don't see why changing the X axis tick marks should have any effect on the label values I've set for the Y axis?!

    The documentation talks about the labels being formatted by the DefaultFormat property and indeed this can be used to eg change the "0" label to "£0.0" but it doesn't tell me how I can just turn off the labels completely.

    After some experimentation setting AxisX.Visibility to Visibility.Collapsed almost achieves what I want but I would prefer to just use the MajorGridLinesVisibility setting which produces a slightly tidier main X axis line (ie a line without tick marks and labels cf no line at all)

    Is there an easy way to keep the X-axis line, but hide the labels and tick marks without impacting the settings I've made for the Y axis?

    Thanks.

    Ian

  2. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 01 Jun 2009 Link to this post

    Hello Ian,

    The easiest way to achieve this is just to clear the TickPoints collection of AxisX after the chart has been populated:

    this.RadChart1.DefaultView.ChartArea.AxisX.TickPoints.Clear();

    However, I am a bit puzzled by the effect caused by setting the MajorGridLinesVisibility - this property is not supposed to hide ticks and labels and does not hide them at my end. It should only control the X axis gridlines, which are hidden by default. Can you confirm you have used this very property?

    As for the Y axis -- this behavior might be caused by the automatic range and step calculations. Hiding the X axis ticks and labels provides more vertical space, so the calculations for Y axis might end up with different results - hence difference MinValue, MaxValue and Step. If you need to set your own values for these you have to set AxisY.AutoRange property to false.

    Hope this helps.

    All the best,
    Ves
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top