highcharter xaxis 十字准线工具提示标记所有系列数据点

highcharter xaxis crosshair tooltip labeling all series datapoints

我试图在将鼠标悬停在时间序列上时在十字准线工具提示上标记所有系列数据点。这是我目前拥有的:

library(highcharter)

highchart() %>%
  hc_chart(
    type = "container", zoomType = "x") %>%
  hc_xAxis(type = "datetime") %>%
  hc_xAxis(
    tickLength = 0, 
    crosshair = TRUE
  ) %>%
  hc_yAxis(
    tickLength = 0, 
    crosshair = TRUE
  ) %>%
  hc_add_series(
    type = "line",
    data = airmiles
  ) %>%
  hc_add_series(
    type = "line",
    data = airmiles/2
  )

这是我想要的(或类似的东西):

谢谢!

如果你有两个系列并且你想在工具提示中同时显示它们,请尝试使用 xAxis.crosshair 和 tooltip.shared。

tooltip: {
    shared: true,
},
xAxis: {
    crosshair: true
},

现场演示: https://jsfiddle.net/BlackLabel/d4k8yqc7/

API 参考文献:

https://api.highcharts.com/highcharts/xAxis.crosshair

https://api.highcharts.com/highcharts/tooltip.shared