highcharter: Highlight points in a group

一个人想着一个人 提交于 2019-12-23 12:20:56

问题


When using highcharter for interactive plots, how can I specify that datapoints in a group must highlight together?

library(highcharter)
library(dplyr)
library(tidyr)

dfr <- data.frame(sample=c("A","B","C","D"),part=c(2,3,4,6),cat=c(5,7,3,3))
dfr1 <- dfr %>% tidyr::gather(key=metric,value=value,-sample)
dfr1

  sample metric value
1      A   part     2
2      B   part     3
3      C   part     4
4      D   part     6
5      A    cat     5
6      B    cat     7
7      C    cat     3
8      D    cat     3

dfr1 %>%
  hchart(.,"scatter",hcaes(x=metric,y=value,group=factor(sample))) %>%
  hc_xAxis(type="category",title=list(text="Metrics"),crosshair=TRUE) %>%
  hc_yAxis(type="linear",title=list(text="Counts"),crosshair=TRUE) %>%
  hc_chart(zoomType="xy",inverted=T) %>%
  hc_tooltip(useHTML=TRUE,formatter = JS("function(){
                                         return('<b>Sample: </b>'+this.point.sample+'</br>')}"))

In this example, when I hover over the blue point (Sample A), I would like all other blue points (Sample A's) to be highlighted as well.

来源:https://stackoverflow.com/questions/48263285/highcharter-highlight-points-in-a-group

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!