DefaultLabelFormat

9 posts, 1 answers
  1. Dr.YSG
    Dr.YSG avatar
    210 posts
    Member since:
    Dec 2009

    Posted 28 Jan 2010 Link to this post

    I have a Y axis that has numeric values from 2000 to 2008. The default format is coming out as 2.01k, 2.01 k, 2.01 k

    This is not very useful all the ticks are labeled the same.

    I tried to fix this with a DefaultLabelFormat and fixing the range.

                                <chart:ChartArea.AxisY>  
                                    <chart:AxisY  
                                        AutoRange="False"  
                                        MinValue="2000"  
                                        MaxValue="2008"  
                                        DefaultLabelFormat="#Y{0}" 
                                        Step="1" />  
                                </chart:ChartArea.AxisY>  

    But even though there should be 9 steps, I am only seeing 5, and they are still all 2.01 k, 2.01 k.

    Also, is there somewhere in the documentation API which describes the meaning of the codes for the label format. I know where to fine find the #X, #Y, #CAT etc. but what is inside the curly braces?


  2. Velin
    Admin
    Velin avatar
    391 posts

    Posted 02 Feb 2010 Link to this post

    Hi Dr.YSG,

    You can switch off the scientific label format behavior which is causing the problem in your scenario:
    RadChart1.DefaultView.ChartArea.LabelFormatBehavior = LabelFormatBehavior.None;

    More information about custom label formatting in RadChart can be found here. In the curly braces there can be any standard format string that is applicable in the specific scenario.

    Hope this will help.

    Regards,
    Velin
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Anne Lyon
    Anne Lyon avatar
    87 posts
    Member since:
    Jan 2010

    Posted 02 Feb 2010 Link to this post

    I had the same problerm, but setting my axis as DateTime and then setting the format (short date for me) worked fine:

    ctlRadChart.DefaultView.ChartArea.AxisX.IsDateTime =

    true;

     

    ctlRadChart.DefaultView.ChartArea.AxisX.DefaultLabelFormat =

    "d";

     

  5. Dr.YSG
    Dr.YSG avatar
    210 posts
    Member since:
    Dec 2009

    Posted 02 Feb 2010 Link to this post

    I tried your suggestion, but I am still getting scientific notation on the Y axis. (but it is giving 9 labels, each one 2.01k). which is sorta correct.
    (thanks for the pointers to the documentation, that was helpful, consider adding it to the online API documentation).

                    <telerik:RadChart.DefaultView> 
                        <chart:ChartDefaultView> 
                            <chart:ChartDefaultView.ChartTitle> 
                                <chart:ChartTitle 
                                    Content="Years vs Passengers" 
                                    HorizontalAlignment="Center" /> 
                            </chart:ChartDefaultView.ChartTitle> 
                            <chart:ChartDefaultView.ChartLegend> 
                                <chart:ChartLegend 
                                    Visibility="Collapsed"/> 
                            </chart:ChartDefaultView.ChartLegend> 
                            <chart:ChartDefaultView.ChartArea> 
                                <chart:ChartArea 
                                    LabelFormatBehavior="None" 
                                    EnableAnimations="False"
                                    <chart:ChartArea.AxisY>  
                                        <chart:AxisY  
                                            AutoRange="False"  
                                            MinValue="2000"  
                                            MaxValue="2008"  
                                            DefaultLabelFormat="#Y{D4}" 
                                            Step="1" />  
                                    </chart:ChartArea.AxisY>  
                                </chart:ChartArea> 
                            </chart:ChartDefaultView.ChartArea> 
                        </chart:ChartDefaultView> 

  6. Velin
    Admin
    Velin avatar
    391 posts

    Posted 04 Feb 2010 Link to this post

    Hello Dr.YSG,

    Our local tests did not confirm an issue with using the LabelFormatBehavior property. We would ask you to send us a small project which we could further investigate and assist you.

    Regards,
    Velin
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  7. Dr.YSG
    Dr.YSG avatar
    210 posts
    Member since:
    Dec 2009

    Posted 04 Feb 2010 Link to this post

    In the process of creating a stripped down sample project, I discovered that the problem was the line:

                                            DefaultLabelFormat="#Y{D4}" 

    By removing that, it performs as expected.

    So now I have a follow on question. Given that this is a Y axis, what string should I use if I want a 4 digit wide value for integers (or for any other sort of format. I tried just {D4} but that gives a XAML syntax error. And if I just say "D4" then I get no labels at all.





  8. Velin
    Admin
    Velin avatar
    391 posts

    Posted 09 Feb 2010 Link to this post

    Hello Dr.YSG,

    Indeed, I was able to reproduce this issue and it has been already logged in our bug tracking system. You can expect it to be resolved with one of the upcoming builds.

    Please accept our apologies for this inconvenience. Your Telerik points have been updated.

    Regards,
    Velin
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  9. Answer
    Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 18 Aug 2010 Link to this post

    Hello Dr.YSG,

    As a quick follow up on the issue discussed in this thread.
    After additional testing on the reported problem, which manifests itself when setting a format string of
    "#Y{D4}". There are two parts to having empty values along the y axis. The first is the improper format string, which should be "#VAL{D4}" for this case.
    Another component of the issue is the format string {D4}. Having empty values along the y axis is not a bug, but rather the default behavior of the format string with the specific format used: "{0:D4}", together with a decimal value. When we have a decimal value, for example:

    string.Format(Cultureinfo, "{0:D4}", 0.0)

    an exception is raised. Internally, the exception is catched, however this returns an empty value.

    There is no issue if the we use a different value. For example:

    string.Format(info, "{0:D4}", 0), the output will be "0000".

    The same issue/exception can be reproduced with the following code:

    System.Globalization.CultureInfo info = new System.Globalization.CultureInfo("en-US");
    string format = "{0:D4}";
    var tokenValue = 0.0;
    var test = string.Format(info, "{0:D4}", tokenValue);

    I hope this information helps.

    Regards,
    Yavor
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Jonam
    Jonam avatar
    36 posts
    Member since:
    Jul 2010

    Posted 19 May 2011 Link to this post

    how does this work for telerik.reporting.chart. This one doesn't have a defaultview. How can i set the y axe labeltype?

    kind regards,

    Jonam
Back to Top
DevCraft banner