Chart numbers to "Thousand/million/trillion
Question

Hi I have a couple of charts that needs to change from (example) : 54,590 to 54,59K I have the IF condition  from another forum but I don't know where im supposed to add it to so that all my charts use the same IF condition

Hi Steven,

Use Advance format option of the Chart and below is the example how you can use it 

AdvancedFormat_Init(DataPointFormats:,DataSeriesFormats:,XAxisJSON:,YAxisJSON:,HighchartsJSON:"{
      series: [{
    dataLabels: {
      enabled: true,
      formatter: function() {
        if (this.y > 1000000) {
          return Highcharts.numberFormat(this.y / 1000, 3) + 'M'
        } else if (this.y > 1000) {
          return Highcharts.numberFormat(this.y / 1000, 3) + 'K';
        } else {
          return this.y
        }
      }
    },
    type: 'column'
   
  }]
}"
)


Below is the out put and attached is the sample 


Best regards

Devendra



TestJob.oml

Thanks a lot to everyone, @Devendra Singh Baghel had the solution. (Im using tradicional web dev)

@Devendra Singh Baghel is there a way to add this if condition somewhere else instead of in "AdvanceFormat"? The app is currently using the advanceformat for a server action advance format that is necessary for the title of the charts. (The advance format of the server action makes the title of the charts change depending on the filters used.)  *For example one of the charts is  the sales accumulated in USD$ and it has the title that shows from what month to what month is the chart filtered. In case that the user changes the month, then the title would change. (Example: May 2021 to April 2022). Or is there a way to run more than one advance format?

Hi Steven,

Advance format have multiple options to change the chart. Check below link in which it has both custom titles and the custom data values.

https://jsfiddle.net/920khvbj/

Best Regards

Devendra



Could you post an example to ilustrate better?

For what I understand you have a chart that will receive a value that chan be in million, billion or trillion and you want to change the display value. Is that correct?

I can't take a picture directly but yea all the numbers above "10,000.00" should be in the format "10K", and if its a million then it should be "1M". I have the if condition on my work computer, I just don't know where I have to put the condition. 

IMG_1136.HEIC

To maintain coherence in the data if you have one over 10.000 all data should be changed to the K format, so 11K, 9K, 3K (for example).

To do that you need to edit the data before sending it to the chart, so you need to put an If to verify if any value is over 10.000 and in a positive case edit all data with a for each formatting the text. After this, you can send the data to the chart.

If the data is obtained in an aggregate or a data action you should add the logic in the after fetch.

Hi Steven,

Use Advance format option of the Chart and below is the example how you can use it 

AdvancedFormat_Init(DataPointFormats:,DataSeriesFormats:,XAxisJSON:,YAxisJSON:,HighchartsJSON:"{
      series: [{
    dataLabels: {
      enabled: true,
      formatter: function() {
        if (this.y > 1000000) {
          return Highcharts.numberFormat(this.y / 1000, 3) + 'M'
        } else if (this.y > 1000) {
          return Highcharts.numberFormat(this.y / 1000, 3) + 'K';
        } else {
          return this.y
        }
      }
    },
    type: 'column'
   
  }]
}"
)


Below is the out put and attached is the sample 


Best regards

Devendra



TestJob.oml

Thanks a lot to everyone, @Devendra Singh Baghel had the solution. (Im using tradicional web dev)

@Devendra Singh Baghel is there a way to add this if condition somewhere else instead of in "AdvanceFormat"? The app is currently using the advanceformat for a server action advance format that is necessary for the title of the charts. (The advance format of the server action makes the title of the charts change depending on the filters used.)  *For example one of the charts is  the sales accumulated in USD$ and it has the title that shows from what month to what month is the chart filtered. In case that the user changes the month, then the title would change. (Example: May 2021 to April 2022). Or is there a way to run more than one advance format?

Hi Steven,

Advance format have multiple options to change the chart. Check below link in which it has both custom titles and the custom data values.

https://jsfiddle.net/920khvbj/

Best Regards

Devendra



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.