Hover on highchart


#1

I am unable to get hover working for a chart using highchart. I just get the value but not the name .

The format I want to: value

Below is my data and the code:

fntltp <- JS("function(){
  return this.point.x + ' ' +  this.series.yAxis.categories[this.point.y] + ':<br>' +
             Highcharts.numberFormat(this.point.value, 2);
             }")

highchart() %>%
  hc_chart(type = "treemap") %>%
  hc_xAxis(categories =df_net$to) %>%
  hc_add_series(data = df_net$value,
                name = "interaction data",colorByPoint = TRUE)%>%
  hc_tooltip(formatter = fntltp) %>% 
  
  hc_add_theme(hc_theme_google())
Month_considered        to     value
1            Apr-17  aaaaaaa    20.641753
2            Apr-17  bbbbbbbb   75.953825
3            Apr-17  ccccccc    5.947955
4            Apr-17  dddddddd   12.013305
5            Apr-17  eee        2.778321
6            Apr-17  fffffff    18.880845
7            Apr-17  ffff       0.763060
8            Apr-17  asdasda    11.348073
9            Apr-17  etreter    6.574056
10           Apr-17  yuyuyu     3.776169

#2

highcharts treemaps technically don't have an x-axis, they work with name and value data. So if you rename your to column to name and supply the whole dataframe to the data argument to the hc_add_series function and remove the hc_xAxis function you should get your desired tooltip by default:

highchart() %>%
  hc_chart(type = "treemap") %>%
  hc_add_series(data = df_net,
                name = "interaction data", colorByPoint = TRUE) %>%
  hc_add_theme(hc_theme_google())

Alternatively you could use the hchart function and specify your name column:

hchart(df_net, 'treemap', hcaes(name = to, value = value)) %>% 
  hc_plotOptions(treemap = list(colorByPoint = TRUE))