Is there a way to highlight closest series in R dygraphs?

社会主义新天地 提交于 2019-12-11 01:31:57

问题


I am using dygraphs for R https://rstudio.github.io/dygraphs/ and I am wondering is there a way to highlight closest series like it is done in original dygraphs? Demo gallery here: http://dygraphs.com/gallery/#g/highlighted-series

I am really unfamiliar with CSS nor HTML. Thanks for any help and advice.


回答1:


If you just want to highlight the series below mouse cursor then you can use dyHighlight . Check: official R-dygraph website

It is a little more tricky to emphasize the name of the highlighted series in the legend. You need to edit the .highlight class in separate css file and add it to your graph with:

your_dygraph %>% dyCSS("dygraph.css")

Example of dygraph.css:

.highlight {
  /*border: 2px solid black;*/
  background-color: #B0B0B0; /* grey background*/
}



回答2:


Somehow the accepted answer just did not work for me with my current versions of the packages involved. Here is my preferred method that worked (from here or here):

d1$x$css = "
.dygraph-legend > span {display:none;}
.dygraph-legend > span.highlight { display: inline; }
"
d1


来源:https://stackoverflow.com/questions/30309825/is-there-a-way-to-highlight-closest-series-in-r-dygraphs

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