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

[Solved] Formatting the values that appear on stacked bars

4 Answers 175 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ian
Top achievements
Rank 1
Ian asked on 15 Jun 2009, 05:14 PM
Can someone point me to some documentation/code example of how to format the values that appear on a stacked bar chart. I've found the article "Label Format Expressions" which explains the "tokens" that can be used but not how to set them.

eg I may want to display a Y series value of "100313" as "100,313" or "£100,313" on the bar itself, or a value of "67" as "67%"

Thanks,
Ian 

4 Answers, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 18 Jun 2009, 08:18 AM
Hello Ian,

You can set specific format for the whole series using the SeriesDefinition's DefaultLabelFormat:
DataSeries dataSeries = new DataSeries(); 
dataSeries.Definition = new StackedBarSeriesDefinition(); 
dataSeries.Definition.DefaultLabelFormat = "custom format"

Or directly set the label format for each DataPoint:
DataPoint point = new DataPoint(); 
point.LabelFormat = "#X"

Best, Evtim
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ian
Top achievements
Rank 1
answered on 18 Jun 2009, 01:03 PM
I'm afraid that's still not working for me.

There is no "DefaultLabelFormat" property on the Definition class and it gives a "Cannot resolve symbol" error if entered as shown above.

There IS a "DefaultFormat" property, but setting that appear to have no effect.

eg I'm using dataSeries.Definiton.DefaultFormat = "#Y{C0}" (based on the "Label Format Expressions" documentation) but the values are just being formatted as straight numbers.

If I wanted to output a number with a comma separator for thousands and a currency symbol (eg 99966701 to be displayed as £99,966,701) or with some standard text at the front of the value what would I need to specify?
0
Accepted
Vladimir Milev
Telerik team
answered on 19 Jun 2009, 06:35 AM
Hello Ian,

The label format expressions do work, however, make sure you are using the latest version of  RadChart as it is the only one supporting them. Check this example for more info. The currency sign is dependent on the CultureInfo.CurrentCulture. I'm guessing it needs to be en-GB for you to be getting the pound sign. Since silverlight runtime is executing in the browser currency will be different for different clients depending on their regional settings. You may of course override the culture setting inside your silverlight application.

The comma separation is by the thousands by default for the currency formatting. Check these links for more info on .NET format strings:

http://msdn.microsoft.com/en-us/library/0c899ak8.aspx
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx


Kind regards,
Vladimir Milev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ian
Top achievements
Rank 1
answered on 20 Jun 2009, 02:00 PM
Thanks Vladimir.

The Telerik code behind link was really useful - somehow I missed that code behind when looking for a demo that had formatted values on the graphs themselves. 
Tags
Chart
Asked by
Ian
Top achievements
Rank 1
Answers by
Dwight
Telerik team
Ian
Top achievements
Rank 1
Vladimir Milev
Telerik team
Share this question
or