Search code examples
rhighchartsr-highcharter

highcharter xaxis crosshair tooltip labeling all series datapoints


I am trying to label all series datapoint on the crosshair tooltip when hovering over a timeseries. Here is what I currently have:

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
  )

enter image description here

This is what I would like to have (or something similar):

enter image description here

Thank you!


Solution

  • if you have two series and do you want to show them both at the tooltip try tu use xAxis.crosshair and tooltip.shared.

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

    Live demo: https://jsfiddle.net/BlackLabel/d4k8yqc7/

    API References:

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

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