I'vw plotted a dygraph using a dygraph
function from a dygraphs R package. I wonder is there a way to put legend next to the plot, not exactly on it like it is done by default...
Code to reproduce this dygraph is below:
library(archivist)
library(dplyr)
library(devtools)
devtools::install_github("rstudio/dygraphs")
library(dygraphs)
seriesReactive <- loadFromGithubRepo( "db914a43536d4d3f00cf3df8bf236b4a", user= "MarcinKosinski", repo="Museum", value = TRUE)
dygraph(seriesReactive, main = "Dzienna proporcja kliknięć do odsłon dla danych struktur", ylab = "Proporcja") %>%
dyRangeSelector()
Yes, read
?dygraphs::dyLegend
. The description oflabelsDiv
argument says:This is easy to do in a shiny context of course, but not in rstudio.
For instance, in Shiny
ui.R
file, I have added this line:Which creates an HTML
<div>
tag with the IDlegendDivID
. Then, in Shinyserver.R
file, I use the same ID in dygraphs params:And it works like a charm.
In your case, here is the result:
And the code (just create
app.R
script in RStudio and run it by callingshiny::runApp()
):