高图表工具提示十字线问题

时间:2018-07-12 06:10:25

标签: highcharts

我有两个系列数据,但是悬停时只能在标签上获得一个系列数据。 在x轴上悬停时是否可以在标签上同时包含两个数据?

Highcharts.chart('container', {

    tooltip: {
        crosshairs: true
    },

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }, {
        data: [216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5]
    }]
});
<script src="https://code.highcharts.com/highcharts.js"></script>

<div id="container" style="height: 400px"></div>

Label has Series 1:176 and I want along with that Series 2:71.5

1 个答案:

答案 0 :(得分:0)

您需要将tooltip.shared参数设置为true。然后,所有定义的序列应在工具提示中可见。

Highcharts.chart('container', {

    tooltip: {
        crosshairs: true,
        shared: true
    },

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }, {
        data: [216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5]
    }]
});

实时示例:http://jsfiddle.net/L0hg2c6r/

API参考:https://api.highcharts.com/highcharts/tooltip.shared