如果在xAxis上使用多个y值,则显示值

时间:2019-04-15 09:01:59

标签: r highcharts r-highcharter

我对于同一个x值有多个y值,除鼠标悬停外,其他所有功能都正常。使用上面的代码,它仅显示一个点的值,而不是每个点的值。我认为他们在https://github.com/highcharts/highcharts/issues/6231处也遇到类似的问题。

library("highcharter")
df1 <- data.frame(x = c(0,0,1,2,2,3,4),
              y = c(50,100,100,105,150,110,120),
              name = c("A","A","A","A","A","A","A"),
              findNearestPointBy= 'xy')

df2 <- data.frame(x = c(3:6),
              y = c(80,90,98,105),
              name = c("B","B","B","B"),
              findNearestPointBy= 'xy')
series_list <- list(df1, df2)


hc2 <- highchart()
for (k in 1:length(series_list)) {
hc2 <- hc2 %>%
hc_add_series(series_list[[k]])
}
hc2

因此,如果光标在x = 0附近,则工具提示始终显示100,而从不显示50,如果我的光标接近50,就不可能显示50?

感谢任何帮助!

1 个答案:

答案 0 :(得分:1)

我有它

library("highcharter")
df1 <- data.frame(x = c(0,0,1,2,2,3,4),
              y = c(50,100,100,105,150,110,120),
              name = c("A","A","A","A","A","A","A"),
              findNearestPointBy= 'xy')

df2 <- data.frame(x = c(3:6),
              y = c(80,90,98,105),
              name = c("B","B","B","B"),
              findNearestPointBy= 'xy')
series_list <- list(df1, df2)


hc2 <- highchart()%>%
hc_plotOptions(line = list(findNearestPointBy = 'xy'))
for (k in 1:length(series_list)) {
    hc2 <- hc2 %>%
    hc_add_series(series_list[[k]])

}
hc2

也许其他人过去也有同样的问题!