(jQuery Highchart) Is there any way to put extra custom data inside Tooltip Box?

后端 未结 1 1772
太阳男子
太阳男子 2021-01-06 04:15

I want to add extra custom statistic data lines inside Tooltip Box, which appears over mouse hover. As far as i\'ve learned, it shows only the data inside t

相关标签:
1条回答
  • 2021-01-06 04:49

    You can store this information with the series, like the following.

    {
        type: 'bar',
        name: 'Bar3',
        composition: {
            'Caffeine': '51%',
            'Alcohol': '31%',
            'Water': '4%'
        },
        data: [35]
    }
    

    Then you can get it through the tooltip formatter. Use this to reference the series.

    tooltip: {
        formatter: function() {
            console.log(this.series.options.composition);
        }
    }
    

    Then you only have to format the text according to what you want.

    Demo

    Reference:

    • Tooltip formatter
    0 讨论(0)
提交回复
热议问题