This is a migrated thread and some comments may be shown as answers.
1 Answer 42 Views
This is a migrated thread and some comments may be shown as answers.
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); 

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!


1 Answer, 1 is accepted

Sort by
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.

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.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question