Chart X-axis label placement.

Thread is closed for posting
7 posts, 1 answers
  1. Jeff
    Jeff avatar
    10 posts
    Member since:
    Mar 2009

    Posted 10 Apr 2009 Link to this post

    I have dates on the x-axis labels. They are too long to all fit. And I can't leave any of them out. And when I rotate them, the text does not look correct. I don't want to rotate them. Is there a way to make them alternate? Like the first date is a bit higher, and the next date is a bit lower, and so forth and so forth? That would just make everything so much easier.

    Any help would be very much appreciated.

    Thank you.

    Sincerely,

    Jeff
  2. Answer
    Ves
    Admin
    Ves avatar
    2927 posts

    Posted 13 Apr 2009 Link to this post

    Hello Jeff,

    Unfortunately, it is not possible to alternate the X axis labels this way. As you cannot  leave any label out, the LabelStep property of X axis would not help here -- it can be used to force the chart to display only certain labels like every other or every third label.

    So, the only way to show all of them without overlapping is to rotate them. You can use an additional setting, which will improve the text quality for the rotated labels:

    RadChart1.Appearance.TextQuality = Telerik.Charting.Styles.TextQuality.AntiAlias;

    Hope this is applicable.

    Best regards,
    Ves
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. Jeff
    Jeff avatar
    10 posts
    Member since:
    Mar 2009

    Posted 13 Apr 2009 Link to this post

    Is there a way to put a textbox around the text values? Like a little rectangle border around them?
  4. Ves
    Admin
    Ves avatar
    2927 posts

    Posted 14 Apr 2009 Link to this post

    Hello Jeff,

    All the text elements in RadChart have border, which is transparent by default. All you need to do is provide a color for that border. Additionally, you can set the border style and width:

    <XAxis> 
        <Appearance> 
            <LabelAppearance RotationAngle="20"
                <Border Color="Red" PenStyle="Dot" Width="1" /> 
            </LabelAppearance> 
        </Appearance> 
    </XAxis> 
     

    Hope this helps.

    Best wishes,
    Ves
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  5. Jeff
    Jeff avatar
    10 posts
    Member since:
    Mar 2009

    Posted 14 Apr 2009 Link to this post

    Thanks! One more small question. I need to format my Yaxis labels. Problem is...

     

    this

     

    .RadChart1.PlotArea.YAxis.Appearance.CustomFormat = "{0:#,#;(#,#);0}";
    does not yield the correct results.

    And neither does...
    this.RadChart1.PlotArea.YAxis.Appearance.CustomFormat = "0:#,#;(#,#);0";

    I basically need two requirements:
    a. That a comma appears after every 3 digits.
    b. That negative numbers are displayed with parenthesis instead of a negative sign.

    You can probably see I was trying to fullfill those requirements with the code above. If anyone can lend me some helpful tips or advice, I would appreciate it.

    Thanks.

    Sincerely,

    Jeff

     

  6. Ves
    Admin
    Ves avatar
    2927 posts

    Posted 15 Apr 2009 Link to this post

    Hello Jeff,

    RadChart will accept all the valid Standard Numeric Format Strings and Custom Numeric Format Strings. So, as long as your format string works in a call to ToString() method, it will work as a custom format for the Y axis.

    Here is how you can achieve this:
    this.RadChart1.PlotArea.YAxis.Appearance.CustomFormat = "#,#;(#,#)";

    Best regards,
    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.
  7. Conrad
    Conrad avatar
    11 posts
    Member since:
    May 2009

    Posted 30 Oct 2009 Link to this post

    Hi Jef,

    Bit late, but I was looking for something similar.  Had very long X-labels and didn't want to rotate or abbreviate.

    So all I did was pop every second label's text to another line.

    For i As Integer = 1 To RadChart1.PlotArea.XAxis.Items.Count - 1 Step 2  
                    RadChart1.PlotArea.XAxis.Item(i).TextBlock.Text = vbCrLf & RadChart1.PlotArea.XAxis.Item(i).TextBlock.Text  
    Next 

    Hope this helps.
Back to Top