Meteorite
Meteorite

Reputation: 374

Highchart accessing series.data in tooltip pointFormat

https://jsfiddle.net/z6rvjem5/

series.data would show an array of objects in the tooltip, but series.data[0] just gives undefined. How do I access the actual data and show in pointformatter (for example: I want to show the difference between every y value and the previous one without setting compare: 'value')

Upvotes: 1

Views: 2436

Answers (1)

ppotaczek
ppotaczek

Reputation: 39099

The pointFormat doesn't support more than one nesting level. Use pointFormatter function which has more flexibility.

    pointFormatter: function(){
        var point = this,
            series = point.series;

        return `${series.name}: <b>${point.y}</b><br/>${series.data[0].y}`
    }

Live demo: https://jsfiddle.net/BlackLabel/1ets3xn2/

API Reference:

https://api.highcharts.com/highcharts/tooltip.pointFormat

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

Upvotes: 2

Related Questions