tsLegend: Plot an interactive legend for time series plots

Description Usage Arguments Details

Description

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.

Usage

1
2
3
4
prodStackLegend(stack = "eco2mix", legendItemsPerRow = 5, legendId = "")

tsLegend(labels, colors, types = "line", legendItemsPerRow = 5,
  legendId = "")

Arguments

stack

Name of the stack to use. One can visualize available stacks with prodStackAliases

legendItemsPerRow

Number of elements to put in each row of the legend.

legendId

Id of the legend linked to the graph. This argument is usefull when one wants to create a shared legend with prodStackLegend

labels

vector containing the names of the times series

colors

vector of colors. It must have the same length as parameter labels.

types

"line" or "area" or a vector with same length as labels containing these two values.

Details

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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
```{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)
)
```

rte-antares-rpackage/bpN documentation built on May 31, 2019, 2:52 p.m.