highchartstooltipsuffix

Highcharts windbarbs tooltip in other unit than m/s


I use Windbarbs in my charts. However, the data for the windbarbs must be in m/s and therefore the tooltips show the same unit.

I want to display the km/h figure and unit in the tooltip. I use the code:

thisChart.addSeries({
        name: 'WindBarbs',
        xAxis: 1,
        color: 'black',
        type: 'windbarb',
        visible: true,
        dataGrouping: {
            enabled: true,
            units: [
                ['hour', [3]]
            ]
        },
        tooltip: {
            pointFormat: '{series.name}: {point.y * 3.6}',
            valueSuffix: ' km/h',

        },
        data: WindBarbData
    }, false);

However this does not work. What do I do wrong, how to accomplish this?

NOTE: Windbarbs as tag does not exist. Cannot create it.


Solution

  • This behavior don't occurs due to valueSuffix but because of two mistakes in tooltip.pointFormat.

    First of all, in pointFormat option should be used point.value instead of point.y.

    Demo: https://jsfiddle.net/BlackLabel/u5pw83mf/

    API Reference: https://api.highcharts.com/highcharts/series.windbarb.tooltip.pointFormat

    Secondly, multiplication is not possible in the pointFormat option. If you need to make some calculations, use pointFormatter to achieve that.

    Demo: https://jsfiddle.net/BlackLabel/0Ljumyan/

    API Reference: https://api.highcharts.com/highcharts/tooltip.pointFormatter