Y Axis Label - text

Thread is closed for posting
9 posts, 0 answers
  1. Gregor Suttie
    Gregor Suttie avatar
    19 posts
    Member since:
    Oct 2009

    Posted 27 Oct 2011 Link to this post

    I have my grid working nicely with x and y values as I want - I just want to add a label on the Y axis to signify what kind of data it is - for example say the graph showed money id like a y axis of £, if the y axis was showing temperature data id like to show centigrade.
    Note this label im talking about isnt the actual y axis just a textual label to show what the values relate to.

    Cheers
    Gregor
  2. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 01 Nov 2011 Link to this post

    Hi Gregor Suttie,

    You can change your Y-Axis format by using the CustomFormat property like this:
    radChart.PlotArea.YAxis.Appearance.CustomFormat = ("#£");

    Alternatively you could assign the currency formatter, which will automatically format the label value according to user's local:
    radChart.PlotArea.YAxis.Appearance.CustomFormat = ("C");

    More about label values can be found here.

    Best wishes,
    Peshito
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Gregor Suttie
    Gregor Suttie avatar
    19 posts
    Member since:
    Oct 2009

    Posted 02 Nov 2011 Link to this post

    Hi there

    On the y axis i have values going from 0-100 as an example. I dont want a label next to each value, I just want to have one word Units next to the values.

                100
                90        
                80
                70
                60
    Units    50
                40
                30
                20
                10
                0

    Like so, how can I accomplish this.
  5. Gregor Suttie
    Gregor Suttie avatar
    19 posts
    Member since:
    Oct 2009

    Posted 02 Nov 2011 Link to this post

    Its ok I have managed to work it out - I wasnt setting the visibility to true - it must default to false.
  6. Nathan
    Nathan avatar
    3 posts
    Member since:
    Jun 2011

    Posted 02 Nov 2011 Link to this post

    How would I got about just appending a '%' to the end of the value of the Y axis label?  Trying ("#%") multiplies by 100 and then appends the % this is not what I want.  I just need to append a % to the end of the value being displayed. 
  7. Nathan
    Nathan avatar
    3 posts
    Member since:
    Jun 2011

    Posted 02 Nov 2011 Link to this post

    I got it working by adding:

    void comparisonChart_BeforeLayout(object sender, EventArgs e)
    {
        foreach(ChartAxisItem item in comparisonChart.PlotArea.YAxis.Items)
        {
            item.TextBlock.Text += "%";
        }    
    }

    to the code, but this seems ugly and unnecessary.  Especially since I had to declare the chart at the class level so I could access it in the event handler.  Is there an easier way of doing this?
  8. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 07 Nov 2011 Link to this post

    Hello Nathan,

    Try using the following approach which should do the job and only add a "% sign at the end your Y-Axis labels:
    radChart.PlotArea.YAxis.Appearance.CustomFormat = ("#\\%");
    I am using the Escape character in order to achieve this, which causes the next character to be interpreted as a literal rather than as a custom format specifier.

    You can find more about custom numeric format strings here:
    http://msdn.microsoft.com/en-us/library/0c899ak8.aspx

    Greetings,
    Peshito
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  9. Chris
    Chris avatar
    1 posts
    Member since:
    Jul 2013

    Posted 03 Jul 2013 Link to this post

    Thanks, that was helpful. However, I ran into two subsequent problems:

    1. "#\\%" results in, for example, "100\%". I'm sure everyone can figure out to take out the extra "\".

    2. For the 0% on my chart, it was defaulting to no label. With the custom format that became "%". The final custom format for me was: "#\%;;0\%". Semicolons separate formats for positive, negative, and zero values, respectively.

    By the way, I ran into these issues trying to make a StackedBar100 chart with Y-values that don't add up to 1. I like how the RadChart automatically labeled the Y-axis from 0 to 100, but it would be nice if it were 0% to 100% instead.

    Telerik.Web.UI Version 2012.3.1308.35
  10. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 08 Jul 2013 Link to this post

    Hi Chris,

    Thank you for your feedback.

    I am glad you have found the appropriate solutions to the issues you have faced. Regarding the format used for labeling the axis, this is the default label format used by the control and as you properly mentioned using a custom format solves this.

    Regards,
    Peshito
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017