在Highcharts组合图中比较工具提示中的两个数据点 [英] Compare two data points inside the tooltip in a Highcharts combination chart

查看:52
本文介绍了在Highcharts组合图中比较工具提示中的两个数据点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个共享单个Y轴的组合条形图.

I have a combination bar-line chart sharing a single Y axis.

条形图和折线图的数据点始终共享相同的Y值.我希望能够计算工具提示中两个X值之间的差.

The data points for both the bar and the line chart always share the same Y values. I'd like to be able to calculate the difference between the two X values in the tooltip.

这是我正在使用的图表:

Here's the chart I'm working with:

组合图

推荐答案

使其正常工作.诀窍在于工具提示的shared和formatter属性:

Got it to work. The trick was in the shared and formatter properties of tooltip:

       tooltip: {

            shared: true,

            formatter: function() {


                var s= this.points[1].y - this.points[0].y;



                return s;

            }

        },

这篇关于在Highcharts组合图中比较工具提示中的两个数据点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆