setLegend: Set 'legend' of Echarts

Description Usage Arguments Value References Examples

View source: R/options.R

Description

When an echart object is generated, you can modify it by setting legend using %>%. You can modify the legend of the echarts object using this function.

Usage

1
2
3
setLegend(chart, show = TRUE, pos = 11, selected = NULL, itemGap = 5,
  borderColor = "#ccc", borderWidth = 0, textStyle = list(color = "auto"),
  formatter = NULL, overideData = NULL, ...)

Arguments

chart

echarts object generated by echart or echartR

show

Logical. Show the legend or not. Default TRUE. If you want to remove legend from the echarts object, set it NULL.

pos

Clock position of the legend. Default 11. Refer to vecPos. Or you can define the position vector c(x, y, orient) yourself.

selected

A vector of series names that are selected on load. If you assign 'none', then none of the series will be selected in the beginning.

itemGap

The gap between legend items. Default 5px.

borderColor

The border color of the legend. Default '#ccc'.

borderWidth

The border width of the legend. Default 0px (not shown).

textStyle

A list of textStyle definition to decorate the text. E.g., list(color='#444') or list(color='auto').

formatter

A named formatter template or a string containing javascript codes. E.g., '{name}'.

overideData

A list of data to overide the legend text. E.g., list(list(name='Series 1', icon='image://../asset/ico/favicon.png', textStyle=list(color='#bbb')))

...

Elipsis.

Value

A modified echarts object.

References

http://echarts.baidu.com/echarts2/doc/option.html#title~legend

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
\donrun{
# No timeline
g = iris %>% echartR(x=Sepal.Width, y=Petal.Width, series=Species,
                      type='scatter')
g %>% setLegend(selected="versicolor")
g %>% setLegend(selected=levels(iris$Species)[1:2],
                textStyle=textStyle(fontFamily='Times New Roman', color='purple',
                               fontWeight='bold', fontSize=16))

# With Timeline
g1 = iris %>% echartR(x=Sepal.Width, y=Petal.Width, t=Species, type='scatter')
g1 %>% setLegend(pos=12, selected='none',
                 textStyle=list(fontFamily='Courier New', fontSize=16))
}

madlogos/recharts2 documentation built on May 21, 2019, 11:03 a.m.