calculate the difference between 2 series in tooltip for highstock

后端 未结 1 1232
我在风中等你
我在风中等你 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 = '' + Highcharts.dateFormat('%A, %b %e, %Y', this.x) + '';
    
                $.each(this.points, function () {
                    s += '
    Value: ' + this.y; }); s+= '
    Diff: ' + ( this.points[0].y - this.points[1].y ); return s; } },

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