2

Very similar to the question stated in the problem blow, I want to automatically show big numbers using k, M etc. (1200 => 1.2k).

highcharts tooltip format millions billions

This seems to work for standard Highcharts plots but not for Highstock plots. My guess is that this is due to Highstock not having yAxis?

See, e.g., http://jsfiddle.net/1zhga6bm/1/

Would anyone know how to adjust the code below so that it works in Highstock?

var chart = new Highcharts.StockChart({
    chart: {
        renderTo: 'container'
    },

    series: [{
        name: 'USD to EUR',
        data: [10000, 1000000]
    }],

    tooltip: {
        valueSuffix: '',
        formatter: function () {
          var ret = '',
          multi,
          axis = this.series.yAxis,
          numericSymbols = ['k', 'M', 'G', 'T', 'P', 'E'],
          i = numericSymbols.length;

          while (i-- && ret === '') {
                    multi = Math.pow(1000, i + 1);
                    if (axis.tickInterval >= multi && numericSymbols[i] !== null) {
                        ret = Highcharts.numberFormat(this.y / multi, -1) + numericSymbols[i];
                    }
                }
                return ret;
            }
        }

});

Adjusted JSfiddle from below comment.

Many thanks!

S-UP
  • 83
  • 1
  • 8
  • Your example is missing some points : Your data does not have values like "1200" or "10000" or greater AND you are not using the tooltip formatter described in your question. Please update those 2 points first – Weedoze Sep 27 '19 at 06:48
  • Hi @S-UP, That functionality works in the same way in Highstock:http://jsfiddle.net/BlackLabel/84omuaep/ – ppotaczek Sep 27 '19 at 08:17
  • 1
    Thanks for extending on my example. I have added your code but it does not seem to run. Note, I have no JS background. I use R and highcharter as a wrapper. But I have successfully included pure JS code for the tooltip in the past. – S-UP Sep 27 '19 at 08:52

0 Answers0