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

DefautLabelFormat-ting

1 Answer 77 Views
Chart
This is a migrated thread and some comments may be shown as answers.
gradford
Top achievements
Rank 1
gradford asked on 11 Nov 2009, 10:49 PM
I have been running into some trouble regarding setting the DefaultLabelFormat value for both X and Y-Axis as well as ItemLabels.

I generate random data for my charts, i.e.

            //Random random = new Random(this.GetHashCode() | (int)(DateTime.Now.Ticks)); 
            Random random = new Random(); 
            for (int i = 0; i < 3; i++) 
            { 
                DataPoint dataPoint = new DataPoint(); 
                dataPoint.YValue = random.Next(2, 12); 
                dataSeries.Add(dataPoint); 
            } 

I tried using the following: 

dataSeries.Definition.DefaultLabelFormat = "#%"
Chart.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "#%"

But this takes the percent value of all items in the series (instead of just taking the value and appending a % sign to it), and actually doesn't even show anything for the Y-Axis Label.

So my question is, how I would get both the ItemLabel and Y-Axis Label to look like this: 5%

(Basically just take my value and append a % sign to it).

Thanks for your help!

Garrett

1 Answer, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 16 Nov 2009, 04:32 PM
Hi Garrett,

The "#%" token designates the share of the current item, compared to the sum of all the items in the series. If you need to display the actual value you can use the "#VAL" token and simply add the literals you need:

MyChart.DefaultSeriesDefinition.DefaultLabelFormat = "#VAL%";
MyChart.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "#VAL%";

You can find more information on the available tokens in this help topic.

Sincerely,
Ves
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.
Tags
Chart
Asked by
gradford
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or