calculate the difference between 2 series in tooltip for highstock

后端 未结 1 1208
我在风中等你
我在风中等你 2021-01-28 08:04

I need some help to find a solution to display the difference between the series in the tooltip.

Here <- is a simple screenshot with my problem:

how can i sol

相关标签:
1条回答
  • 2021-01-28 08:28

    Use tooltip.formatter - you have there access to the points (this.points[0], this.points[1] etc.). Just calculate different between y-values.

    Note: tooltip.formatter is available only on the highest level of options, like in the API.

    Demo: http://jsfiddle.net/bwefs1ak/

        tooltip: {
            formatter: function () {
                var s = '<b>' + Highcharts.dateFormat('%A, %b %e, %Y', this.x) + '</b>';
    
                $.each(this.points, function () {
                    s += '<br/>Value: ' + this.y;
                });
    
                s+= '<br>Diff: ' + ( this.points[0].y - this.points[1].y );
    
                return s;
            }
        },
    
    0 讨论(0)
提交回复
热议问题