This is a migrated thread and some comments may be shown as answers.

DefaultLabelFormat

8 Answers 276 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Dr.YSG
Top achievements
Rank 2
Dr.YSG asked on 28 Jan 2010, 05:44 PM
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?


8 Answers, 1 is accepted

Sort by
0
Velin
Telerik team
answered on 02 Feb 2010, 09:19 AM
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.
0
Anne Lyon
Top achievements
Rank 1
answered on 02 Feb 2010, 10:52 AM
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";

 

0
Dr.YSG
Top achievements
Rank 2
answered on 02 Feb 2010, 02:59 PM
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> 

0
Velin
Telerik team
answered on 04 Feb 2010, 09:16 AM
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.
0
Dr.YSG
Top achievements
Rank 2
answered on 04 Feb 2010, 05:33 PM
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.





0
Velin
Telerik team
answered on 09 Feb 2010, 05:29 PM
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.
0
Accepted
Yavor
Telerik team
answered on 18 Aug 2010, 04:13 PM
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
0
Jonam
Top achievements
Rank 1
answered on 19 May 2011, 01:57 PM
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
Tags
Chart
Asked by
Dr.YSG
Top achievements
Rank 2
Answers by
Velin
Telerik team
Anne Lyon
Top achievements
Rank 1
Dr.YSG
Top achievements
Rank 2
Yavor
Telerik team
Jonam
Top achievements
Rank 1
Share this question
or