X-Axis as a string

9 posts, 0 answers
  1. Richard
    Richard avatar
    15 posts
    Member since:
    Jun 2008

    Posted 09 Jan 2009 Link to this post

    Hi

    I am trying to do a simple bar chart showing the following data;

    Group               Value

    Group 1 140.30
    Group 2   5.00
    Group 3          81.70

    I wish to have the above groups as labels in the x-asis, but the barchart always shows 1,2,3

    Can you please give me a simple example on how to achieve the above.

    Regards
  2. Velin
    Admin
    Velin avatar
    391 posts

    Posted 09 Jan 2009 Link to this post

    Hi Richard,

    After you have added your DataSeries to the ChartArea you can manually access the AxisX.TickPoints collection and set a custom label to any TickPoint within. This could be accomplished with code like this:

                string[] groups = new string[] { "Group1", "Group2", "Group3" }; 
     
                this.RadChart1.DefaultView.ChartArea.DataSeries.Add(series); 
                TickPointCollection tickPoints = RadChart1.DefaultView.ChartArea.AxisX.TickPoints; 
     
                foreach (TickPoint point in tickPoints) 
                { 
                    point.Label = groups[tickPoints.IndexOf(point)]; 
                } 

    Hope this will help.

    Kind regards,
    Velin
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Richard
    Richard avatar
    15 posts
    Member since:
    Jun 2008

    Posted 10 Jan 2009 Link to this post

    Hi Velin

    This worked fine many thanks!

    Regards
  5. Jayesh
    Jayesh avatar
    1 posts
    Member since:
    May 2008

    Posted 10 Feb 2009 Link to this post

    Hi

     

    I am using RadControls for Winforms Q1 2008 SP1. TickPointCollection does not seem to be present in this release. Is there another way to change the X-Axis labels in this release?

    Regards
    Jashin

  6. Velin
    Admin
    Velin avatar
    391 posts

    Posted 10 Feb 2009 Link to this post

    Hi Jashin,

    First, I would like to inform you that there is a separate forum for questions related to RadChart for WinForms as it a completely different product. Please consider writing your future questions here. Thank you.

    And onto your question -- if you are populating RadChart X axis manually, the items are available in RadChart1.PlotArea.XAxis.Items collection. However, if you use the default AutoScale=true setting, the items will be auto-generated and available in the BeforeLayout event handler:

            foreach (ChartAxisItem item in RadChart1.PlotArea.XAxis.Items) 
            { 
                item.TextBlock.Text = "Custom Axis Label"
            } 

    Hope this helps.

    Regards,
    Velin
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. Nick
    Nick avatar
    1 posts
    Member since:
    Mar 2009

    Posted 13 Mar 2009 Link to this post

    Is there any way of fomatting the string on the X axis so that the string is virtical - I have around 60 points with very long labels. It just doesn't dispay well with lables over 10 characters or so?
  8. Velin
    Admin
    Velin avatar
    391 posts

    Posted 16 Mar 2009 Link to this post

    Hi Nick,

    With the Q1 2009 release of RadChart you can rotate the labels on the X axis by applying a simple style to the AxisXLabel2D control. Here is the markup:

            <Style TargetType="telerik:AxisXLabel2D"
                <Setter Property="LayoutTransform"
                    <Setter.Value> 
                        <RotateTransform Angle="-90"/> 
                    </Setter.Value> 
                </Setter> 
            </Style> 


    Best wishes,
    Velin
    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.
  9. Chris
    Chris avatar
    3 posts
    Member since:
    Jun 2009

    Posted 04 Jun 2009 Link to this post

    Hi,

    we using code behind example to create a chart. how can i get following done in code behind not sure how  to get to this propert from code:

    following works in xamel but need to do from code

    <Style TargetType="telerik:AxisXLabel2D"
                <Setter Property="LayoutTransform"
                    <Setter.Value> 
                        <RotateTransform Angle="-90"/> 
                    </Setter.Value> 
                </Setter> 
            </Style> 

    or

     

     

    <telerik:LabelFormatConverter

     

     

    x:Key="labelFormatConverter" />

     

     

     

    <Style

     

     

    TargetType="telerik:AxisXLabel2D">

     

     

     

    <Setter

     

     

    Property="LayoutTransform">

     

     

     

    <Setter.Value>

     

     

     

    <RotateTransform

     

     

    Angle="-90" />

     

     

     

    </Setter.Value>

     

     

     

    </Setter>

     


    thx
  10. Velin
    Admin
    Velin avatar
    391 posts

    Posted 05 Jun 2009 Link to this post

    Hi Chris,

    I'm afraid the only option to modify the appearance of these elements is through a custom style defined as StaticResource. There is no public API exposing AxisXLabel2D objects as they are part of the visual tree and generated  in run time.

    All the best,
    Velin
    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
UI for WPF is Visual Studio 2017 Ready