How to handle different locale in symbols?

Hi All,

Depending on the locale setting of the user accessing Coresight (meaning you have no control at all), data sent to the symbol uses the locale of the user. E.g. 123,456.789 and 123.456,789 are all valid numbers but are quite reversed when using e.g. european versus american locale.

 

Any ideas how to properly handle this in a symbol? parseFloat won't work. the Globalize.js library Globalize.js · GitHub  requires to know the locale we are working in. And about there my knowledge ends...

I won't be the first one needing to deal with this, so curious what solutions people have chosen.

Parents
  • You can apply custom format to returned numbers with the FormatType property in the getDefaultConfig() function. It uses standard .NET string formatting: Standard Numeric Format Strings | Microsoft Docs

    Important note: when you update this property, it's not applied to the symbol unless you recreate it (just the same way as with the DataShape property).

     

    Here is an example:

    getDefaultConfig: function(){

        return {

        ...

        FormatType: "N2"

       }

    }

     


    pastedImage_0.png.png

     

    Edit: Adding one more example for FormatType: "F5"


    pastedImage_4.png.png

     

     

     

    Cheers,

    Anna

  • You just made my day! I have spent a few hours getting my head around the Globalize library, but that is a huge hassle to setup with the loading of locale sets, etc. So this server-side approach makes life easy.

    When will there be a 'all the good stuff about PI Vision Extensibility we did not tell you about yet' - webinar scheduled?

  • Hello Roger. I have the issue. But the code line that Anna mention don't change anything in my symbol, the number appear incorrectly (for example, temperature of 11,88 is display like 1188). Perhaps the problem is the action of recreate, do you know what Anna mean with that? I dont know how to recreate a symbol or shape.

    When the computer (or better the internet explorer) is setting on US, all works properly. When I use the Spanish configuration (like all my users) the new symbols with amCharts go bad.


    image.png

    image_1.png

  • I find a solution for this symbol, I don't know if is the best talking about js, but work for me (sym-amcharts-RadialGauge.js)...

    function myCustomDataUpdateFunction(data) {

    // If there is indeed new data in the update

    if(data) {

    // Update the current scope with the new data value, time, and label

    // MAG este era el original scope.value = data.Value.replace(",","");

    scope.value = data.Value.replace(",",".");

    scope.time = data.Time;

    if(data.Label) {

    scope.label = data.Label;

    }

    But i have some issues with the multiple variables am charts, the same problems, nowadays I don't find a solution. If someone have some trick thanks in advance.

Reply
  • I find a solution for this symbol, I don't know if is the best talking about js, but work for me (sym-amcharts-RadialGauge.js)...

    function myCustomDataUpdateFunction(data) {

    // If there is indeed new data in the update

    if(data) {

    // Update the current scope with the new data value, time, and label

    // MAG este era el original scope.value = data.Value.replace(",","");

    scope.value = data.Value.replace(",",".");

    scope.time = data.Time;

    if(data.Label) {

    scope.label = data.Label;

    }

    But i have some issues with the multiple variables am charts, the same problems, nowadays I don't find a solution. If someone have some trick thanks in advance.

Children
No Data