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

Localized decimal point character for NumericIndicator?

3 Answers 132 Views
Gauges
This is a migrated thread and some comments may be shown as answers.
Mitchell
Top achievements
Rank 1
Mitchell asked on 13 Oct 2015, 05:53 PM

An example: I have a NumericScale with a single NumericIndicator. I add 5 HexagonalNumberPosition instances to the indicator because I want to display the number "66.00". (Note: I have tried this with NumericIndicator.Format set to "F2" and ".00;.00;0" both - using the formatting described in the docs, not those exact strings). When English is the current cutlure, the gauge displays "66.00". When Spanish is the current culture, the gauge still displays "66.00". I would expect the decimal place to change with the culture. In this case is should be a comma. After peeking at the code in NumberTemplateSelector.SelectTemplate(), I created classes derived from HexagonalNumberPosition and NumberTemplateSelector just so I could break in NumberTemplateSelector.SelectTemplate(). The code (from Just Decompile) for SelectTemplate shows that a DataTemplate for each hex character is found by concatenating the digit (or symbol) passed in with ""HexagonalSevenSegs".  So, the digit "7" would result in the template with the key of "HexagonalSevenSegs7" being used. (The DataTemplates being located in the Telerik.Windows.Controls.DataVisualization.xaml" file). The problem seems to be that when Spanish is the current culture, the "." is still passed into SelectTemplate() for the decimal point. Even though there is a DataTemplate for the comma character, it is never utilized for the decimal point.  So, is the NumericIndicator ​supposed to display numbers using the current culture or a specific culture? Is it a bug that it is not doing so, or is this by design?

 

Thanks - Mitch

3 Answers, 1 is accepted

Sort by
0
Mitchell
Top achievements
Rank 1
answered on 15 Oct 2015, 03:26 PM
I've created a support ticket for this question. I'll post the answer to my question when I receive it.
0
Accepted
Evgenia
Telerik team
answered on 16 Oct 2015, 01:17 PM
Hi Mitchell,

I'm posting here the copy-pasted answer from your support ticket on the same topic for anyone else that comes upon this forum post.
NumericIndicator supports setting different culture than the default one. You can easily set it to Spanish like this for example (let's say that the x:Name of the indicator is indicator in Xaml):

this.indicator.Language = XmlLanguage.GetLanguage("es-ES");

This will apply comma as separator to your 66 value in case you are using FontNumberPosition class to represent the appearance of characters in your numeric indicator. This will change the dot to comma separator automatically as the FontNumericPosition shows characters using regular fonts and they support localization.

When using the HexagonalNumberPosition class however the approach is more complex. You pointed very correctly that we use TemplateSelector class to pick from a predefined number of templates the one that will represent the Hex number (x:Key = HexagonalSevenSegs0,HexagonalSevenSegs1 and etc. ), the Hex dot (x:Key = HexagonalSevenSegs. ) , the Hex comma (x:Key = HexagonalSevenSegs, ) or Hex dash (x:Key = HexagonalSevenSegs- ). And here comes the problem -- our comma data template is practically same as the one that represents dot and even though you might expect to see comma you will see dot instead. We apologize for this issue and will fix it for one of our upcoming latest internal builds.

Till we fix the issue you might choose from two workaround approaches:
1. Use FontNumberPosition only for the comma symbol:
<telerik:NumericIndicator.Positions>
                         <telerik:HexagonalNumberPosition Background="#FFD6D4D4"  />
                         <telerik:HexagonalNumberPosition Background="#FFD6D4D4"  />
                         <telerik:FontNumberPosition Background="#FFD6D4D4" />
                         <telerik:HexagonalNumberPosition Background="#FFD6D4D4"  />
                         <telerik:HexagonalNumberPosition Background="#FFD6D4D4"  />
                     </telerik:NumericIndicator.Positions>

2. I attached a custom project that demonstrates how you might create a custom HexagonalNumberPosition class where the ContentTemplate is your custom one.

Let me know how these suggestions work for you.

P.S. Please mind that we highly reccomend support threads over forums as the response time there is 24h and not 72h.  

Regards,
Evgenia
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Mitchell
Top achievements
Rank 1
answered on 16 Oct 2015, 04:47 PM

After setting the indicator Language property correctly, and using a FontNumberPosition for just the decimal place (with HexagonalNumberPositions for the other digits), my gauge looks great.  Thanks for the help! - Mitch

 PS - I've attached a screenshot of the mixed number positions final result.

 ​

Tags
Gauges
Asked by
Mitchell
Top achievements
Rank 1
Answers by
Mitchell
Top achievements
Rank 1
Evgenia
Telerik team
Share this question
or