R/stack_exchanges.R
, R/stack_prod.R
, R/tsLegend.R
tsLegend.Rd
These functions create a nice looking legend that displays values when the user hovers a time series produced with plot this package. By default, the different functions already output a legend. This function is mostly useful to share a unique legend between two or more time series plots.
prodStackExchangesLegend(
stack = "default",
legendItemsPerRow = 5,
legendId = "",
language = "en"
)
prodStackLegend(
stack = "eco2mix",
legendItemsPerRow = 5,
legendId = "",
language = "en"
)
tsLegend(labels, colors, types = "line", legendItemsPerRow = 5, legendId = "")
Name of the stack to use. One can visualize available stacks with
prodStackAliases
Number of elements to put in each row of the legend.
Id of the legend linked to the graph. This argument is usefull when one wants to create a shared legend with [prodStackLegend()]
character
language use for label. Defaut to 'en'. Can be 'fr'.
vector containing the names of the times series
vector of colors. It must have the same length as parameter
labels
.
"line" or "area" or a vector with same length as labels
containing these two values.
Thes functions can be used to create a legend shared by multiple plots in a Shiny application or an interactive document created with Rmarkdown. For instance, let assume one wants to display four productions stacks in a 2x2 layout and have a unique legend below them in a Rmarkdown document. To do so, one can use the following chunck code:
```{R, echo = FALSE}
library(manipulateWidget)
combineWidgets(
prodStack(mydata, areas = "fr",
main = "Production stack in France", unit = "GWh",
legend = FALSE, legendId = 1, height = "100%", width = "100%"),
prodStack(mydata, areas = "de",
main = "Production stack in Germany", unit = "GWh",
legend = FALSE, legendId = 1, height = "100%", width = "100%"),
prodStack(mydata, areas = "es",
main = "Production stack in Spain", unit = "GWh",
legend = FALSE, legendId = 1, height = "100%", width = "100%"),
prodStack(mydata, areas = "be",
main = "Production stack in Belgium", unit = "GWh",
legend = FALSE, legendId = 1, height = "100%", width = "100%"),
footer = prodStackLegend(legendId = 1)
)
```