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

Format Expressions: What expressions are available, eg. {C2}

5 Answers 81 Views
Chart
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 2
David asked on 06 Apr 2011, 08:16 AM
Hi,

I'm reading http://www.telerik.com/help/wpf/radchart-features-format-expressions.html. The bottom of the article displays a table of examples of format expressions, eg. {C2}, however I'm unable to find an article that definitively lists all of the format expressions that are available (I would have expected this list in this help article titled "Format Expressions"). I found an example of {D} for date and guessed {T} for time, but don't know what additional formatting options there are.

In particular, I'm trying to display the Y-value in a tooltip using region specific formatting delimiters. For example, while I'm able to use {0.0} to format a number with at least one integer digit and one place after the decimal point, the region I'm working in uses a comma as a decimal point delimiter. If I try to use {0,0}, I only get one integer digit in the tooltip with no "," and no digit after the decimal point.

What format expressions are available and can this information be added to the help (and I'm guessing this information is span across your chart control over different technologies).

I also don't know which circumstances I can use a token. For example, although the documentation at the top of the page seems to indicate that I can use the #LABEL and #LEGENDLABEL tokens in a tooltip, using it only displays the string "#LABEL" in the tooltip and using the #LEGENDLABEL token displays the raw, unformatted Y value in the tooltip. I'm looking to display the label of the series displayed in the legend along with the Y-value in the tooltip so that it is easy to distinguish which series you are hovering over when there are multiple series on the chart.

Kind regards,
Dave.

5 Answers, 1 is accepted

Sort by
0
Accepted
Evgenia
Telerik team
answered on 08 Apr 2011, 03:48 PM
Hello David,

The sample format strings shown in the bottom of the article are based on the Microsoft's custom format strings as given with links in the second sentence - "Besides the standard, the custom numeric and the date/time format strings ... ".
Adding a full table of format strings that can be set for the Chart is out of the scope of our control and furthermore msdn has already done it in the links mentioned above.

Straight to your questions:
1) Have in mind that Standard Numeric Format Strings are culture dependant. To ensure that the numbers will be shown as you want just set the appropriate culture. For example the following code line added after the Page_Load block will set American culture:
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

2) The custom tokens described in the help article can be set to the DefaultLabelFormat property of the Chart Series to format the Series Items Labels or to thethe ItemLabelFormat property of the Axes to format the Axis Items Labels. The code snippets in the article show these properties in action.

Best wishes,
Evgenia
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
David
Top achievements
Rank 2
answered on 11 Apr 2011, 09:02 AM
Hi,

  1. Thank you for pointing out the links to format strings in the second sentence - I completely missed them. They're exactly what I'm looking for and the links to the official documentation is appropriate since Telerik are following these standards.
  2. Thank you for the tip regarding how to set the regional settings. My actual solution now uses the standard F1 format (instead of a custom format) to have one decimal place and the decimal point is rendered using the correct regional settings.
  3. Unfortunately, I'm not having success with using the #LEGENDLABEL token as a tooltip. For example:
<telerikChart:RadChart.SeriesMappings>
    <telerikChart:SeriesMapping
        CollectionIndex="0"
        LegendLabel="Dry Average">
        <telerikChart:SeriesMapping.SeriesDefinition>
            <telerikChart:LineSeriesDefinition
                ItemToolTipFormat="#LEGENDLABEL: #Y{F1}°C">
displays "#LEGENDLABEL: 30.0°C" instead of "Dry Average: 30.0°C". I'm specifying my series manually. Can this token only be used if it's specified in the DefaultSeriesDefinition?

Kind regards,
Dave.
0
Accepted
Evgenia
Telerik team
answered on 14 Apr 2011, 08:46 AM
Hi David,

I'm glad that you managed to set format strings using our help article.
To your question - the #LEGENDLABEL token represents DataPoint's Legend Label. This means that it expects LegendLabel property to be set for each DataPoint to visualize it. In your case you have set Legendlabel for the Series. Here is how to set it for the DataPoints:

SeriesMapping barSeriesMapping = new SeriesMapping();
           barSeriesMapping.SeriesDefinition = new BarSeriesDefinition() { ShowItemLabels = true, ShowItemToolTips = true, ItemToolTipFormat = "#LEGENDLABEL: #Y{F1}°C" };
           ItemMapping barMapping = new ItemMapping();
           barSeriesMapping.ItemMappings.Add(new ItemMapping("BarValue", DataPointMember.YValue));
           barSeriesMapping.ItemMappings.Add(new ItemMapping("Date", DataPointMember.XCategory));
           barSeriesMapping.ItemMappings.Add(new ItemMapping("BarCompanyName", DataPointMember.LegendLabel));

Greetings,
Evgenia
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
David
Top achievements
Rank 2
answered on 15 Apr 2011, 01:11 PM
Hi Evgenia,

Thank you for your clarification with the #LEGENDLABEL token. Reviewing Telerik's documentation http://www.telerik.com/help/silverlight/radchart-features-format-expressions.html more carefully, I noticed I had used the wrong token to reference the LegendLabel property in the SeriesMapping tag. Here's a closer look at the tokens I had mixed up:

  • #LEGENDLABEL:
DataPoint.LegendLabel
  • #SERIESLABEL:
DataSeries.LegendLabel

The LegendLabel property exists in both the DataPoint and DataSeries tags, however uses different tokens when formatting tool tips. This is where I made my mistake.

Here's a fixed version of my previous example:
<telerikChart:RadChart.SeriesMappings
    <telerikChart:SeriesMapping
        CollectionIndex="0"
        LegendLabel="Dry Average"
        <telerikChart:SeriesMapping.SeriesDefinition
            <telerikChart:LineSeriesDefinition
                ItemToolTipFormat="#SERIESLABEL: #Y{F1}°C">

This now correctly displays, for example "Dry Average: 30.0°C", as a tool tip in the series.

Thank you again for your help with questions.

Kind regards,
Dave.
0
Evgenia
Telerik team
answered on 20 Apr 2011, 02:08 PM
Hi David,

I am glad that you managed to help yourself. Please do not hesitate to contact us if you have any additional questions.


All the Best,
Evgenia
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
Tags
Chart
Asked by
David
Top achievements
Rank 2
Answers by
Evgenia
Telerik team
David
Top achievements
Rank 2
Share this question
or