Marcin
Marcin

Reputation: 8074

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

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.

Upvotes: 2

Views: 773

Answers (2)

andrekos
andrekos

Reputation: 2892

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

Upvotes: 0

langusta
langusta

Reputation: 368

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*/
}

Upvotes: 5

Related Questions