两个不同图表的两个工具提示

时间:2019-10-22 06:26:50

标签: javascript highcharts angular-highcharts

我有两个图表线并分散在一起。我想要两个不同图形的两个不同工具提示。我已经准备好了一个,但我不能为另一个。请帮帮我。

代码

 this.chart = new Chart({
 tooltip: {  
            xDateFormat: '%Y-%m-%d %H:%M',
            shared: true,
          },
          series: [{
            type: 'line',
            name: 'BG',
            color: '#FA8686',
            pointInterval: 3600 * 1000, // one hour
            data: [[1571715050000, 95],[1571729415000, 115]]
          },
          {
            type: 'scatter',
            name: 'Insulin',
            pointInterval: 3600 * 1000, // one hour
            data: [{x:1571715050000, y:30, tool:85},{x:1577729415005, y:30, tool:90}],
          }]
})

我的散布输出

O/P

但是我只希望工具值位于散点图的工具提示中。有什么办法吗?

1 个答案:

答案 0 :(得分:2)

您可以在系列级别上自定义工具提示:

series: [{
        ...,
        tooltip: {
            xDateFormat: '%Y-%m-%d %H:%M',
            pointFormat: '{point.x}'
        },
    },
    {
        ...,
        tooltip: {
            xDateFormat: '%Y-%m-%d %H:%M',
            pointFormat: '{point.y}'
        },
    }
]

实时演示: http://jsfiddle.net/BlackLabel/doqxygb9/

API参考: https://api.highcharts.com/highcharts/series.scatter.tooltip.pointFormat

相关问题