Formatting the values that appear on stacked bars

5 posts, 1 answers
  1. Ian
    Ian avatar
    51 posts
    Member since:
    Apr 2009

    Posted 15 Jun 2009 Link to this post

    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 
  2. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 18 Jun 2009 Link to this post

    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.
  3. Ian
    Ian avatar
    51 posts
    Member since:
    Apr 2009

    Posted 18 Jun 2009 Link to this post

    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?
  4. Answer
    Vladimir Milev
    Admin
    Vladimir Milev avatar
    1061 posts

    Posted 19 Jun 2009 Link to this post

    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.
  5. Ian
    Ian avatar
    51 posts
    Member since:
    Apr 2009

    Posted 20 Jun 2009 Link to this post

    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. 
Back to Top