setTheme: Set Theme Or Misc Aesthetics (color, background, animation,...

Description Usage Arguments Value Self-defined Themes (UDT) References See Also Examples

View source: R/options.R

Description

Set the entire theme of Echarts. You can use a pre-installed theme or define you own themes.

You can also set aesthetics of Echarts separately, including color, bgColor, animation, calculable, borderColor, borderWidth.

When an echart object is generated, you can modify it by setting aesthetics using %>%.

Usage

1
2
3
4
5
6
setTheme(chart, theme = c("asis", "default", "macarons", "infographic",
  "blue", "dark", "gray", "green", "helianthus", "macarons2", "mint", "red",
  "roma", "sakura", "shine", "vintage"), palette = "asis", bgColor = NULL,
  renderAsImage = FALSE, calculable = FALSE, calculableColor = NULL,
  calculableHolderColor = NULL, animation = TRUE, animationEasing = NULL,
  animationDuration = NULL, width = NULL, height = NULL, ...)

Arguments

chart

echarts object generated by echart or echartR

theme
Pre-installed themes

'default', 'macarons', 'infographic', 'blue', 'dark', 'gray', 'green', 'helianthus', 'macarons2', 'mint', 'red', 'roma', 'sakura', 'shine', 'vintage'

User-defined themes

E.g., list(color=c('#ff7f50', '#87cefa', '#da70d6','#32cd32','#6495ed'),
title=list(x='left', y='top'), legend=list(orient='horizontal'))

palette

name of the palette or a color vector. Default NULL to get echarts default. It could be:

asis

keep the color palette applied in current echarts object

Echarts theme palette

"_default", "_macarons", "_infographic", "_blue", "_dark", "_gray", "_green", "_helianthus", "_macarons2", "_mint", "_red", "_roma", "_sakura", "_shine", "_vintage"

RColorBrewer palettes

Including 'BrBG', 'PiYG', 'PRGn', 'PuOr', 'RdBu', 'RdGy', 'RdYlBu', 'RdYlGn', 'Spectral', 'Accent', 'Dark2', 'Paired', 'Pastel1', 'Pastel2', 'Set1', 'Set2', 'Set3', 'Blues', 'BuGn', 'BuPu', 'GnBu', 'Greens', 'Greys', 'Oranges', 'OrRd', 'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu', 'Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd'

ggthemes palettes

'calc', 'economist', 'economist_white', 'economist_stata', 'excel', 'exel_fill', 'excel_line', 'excel_new', 'few', 'fivethirtyeight', '538', 'manyeyes', 'gdocs', 'pander', 'tableau', 'stata', 'stata1','stata1r','statamono', 'ptol', 'tableau20', 'tableau10medium', 'tableaugray', 'tableauprgy', 'tableaublrd', 'tableaugnor', 'tableaucyclic', 'tableau10light', 'tableaublrd12', 'tableauprgy12', 'tableaugnor12','hc','darkunica', 'solarized','solarized_red', 'solarized_yellow', 'solarized_orange', 'solarized_magenta', 'solarized_violet', 'solarized_blue', 'solarized_cyan', 'solarized_green', 'wsj', 'wsj_rgby', 'wsj_red_green', 'wsj_black_green', 'wsj_dem_rep', 'colorblind', 'trafficlight'

Aetna official palettes

Including 'aetnagreen', 'aetnablue', 'aetnaviolet', 'aetnaorange', 'aetnateal', 'aetnacranberry'

Other palettes

'rainbow', 'terrain', 'topo', 'heat', 'cm'

Usage:

  • If the value is not set, and the function defaults will be loaded

  • Set palette=NULL to use Echarts defaults

  • Set palette=palette name to assign any palette listed above

  • Set palette=palette name(number) to restrict number of colors within the palette (e.g., palette='calc(3)' picks 3 colors out of 'calc' RANDOMLY)

  • Set palette=c(color1, color2, color3, ...) to define a palette vector, made of which either color names or Hex expressions. Use colors() to check available color names and check the effects using demo(colors).

bgColor

Color name/value of the background. Default is transparent ('rgba(0,0,0,0)')

renderAsImage

Logical. If TRUE, the interactive effects are disabled. Default FALSE.

calculable

Logical. If TRUE, the chart is re-calculated after drag. Default FALSE.

calculableColor

The border color of the tooltip during calculable effect. Default 'rgba(255,165,0,0.6)'.

calculableHolderColor

The color of calculableHolder. Default '#ccc'.

animation

Logical. If TRUE, the animation is on at initiation. Default TRUE. For IE8, it is recommended to set FALSE.

animationEasing

The slight moving effect of major elements. Default 'ExponentialOut'. Other choices: 'Linear', 'QuadraticIn', 'QuadraticOut', 'QuadraticInOut', 'CubicIn', 'CubicOut', 'CubicInOut', 'QuarticIn', 'QuarticOut', 'QuarticInOut', 'QuinticIn', 'QuinticOut', 'QuinticInOut', 'SinusoidalIn', 'SinusoidalOut', 'SinusoidalInOut', 'ExponentialIn', 'ExponentialInOut', 'CircularIn', 'CircularOut', 'CircularInOut', 'ElasticIn', 'ElasticOut', 'ElasticInOut', 'BackIn', 'BackOut', 'BackInOut', 'BounceIn', 'BounceOut', 'BounceInOut'

animationDuration

The duration into animation. Default 2000 (ms).

width

Width (px) of the whole chart.

height

Height (px) of the whole chart.

...

Elipsis

Value

A modified echarts object

Self-defined Themes (UDT)

You can design your prefered themes using http://echarts.baidu.com/echarts2/doc/example/themeDesigner.html.

The UDTs in echarts are JS objects. You can write it in a list form and setTheme will parse it into JSON string for process.

A typical theme JS looks like:
{
color: ['#ff7f50','#87cefa','#da70d6','#32cd32','#6495ed'],
title: {x: 'left', y: 'top'},
legend: {orient: 'horizontal'}
}


You should write in the format below:
list(color=c('#ff7f50','#87cefa','#da70d6','#32cd32','#6495ed'),
title=list(x='left', y='top'), legend=list(orient='horizontal'))

References

theme
http://echarts.baidu.com/echarts2/doc/example/theme.html

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

colors
http://echarts.baidu.com/echarts2/doc/option.html#title~color
http://colorbrewer2.org

other features
http://echarts.baidu.com/echarts2/doc/option.html#title~renderAsImage
http://echarts.baidu.com/echarts2/doc/option.html#title~calculable
http://echarts.baidu.com/echarts2/doc/option.html#title~animation
http://echarts.baidu.com/echarts2/doc/option.html#title~calculableColor
http://echarts.baidu.com/echarts2/doc/option.html#title~calculableHolderColor

See Also

brewer.pal, colors

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## Not run: 
g = echartR(iris, Sepal.Width, Petal.Width, series=Species)

# Set themes
## pre-installed themes
g %>% setTheme("infographic")
g %>% setTheme("blue")
g %>% setTheme("dark")
g %>% setTheme("gray")
g %>% setTheme("green")
g %>% setTheme("helianthus")
g %>% setTheme("macarons2")
g %>% setTheme("mint")
g %>% setTheme("red")
g %>% setTheme("sakura")
g %>% setTheme("shine")
g %>% setTheme("vintage")

## self-defined themes
theme = list(color=c("#7AC143", "#7D3F98", "#F47721", "#D20962", "#00A78E",
              "#00BCE4", "#B8D936", "#EE3D94"), backgroundColor="#fef8ef")
g %>% setTheme(theme)

## Misc aethetics
g = echartR(iris, x=Sepal.Width, y=Petal.Width, series=Species, type='scatter')
g %>% setTheme(palette='hc')
g %>% setTheme(palette=c('red', 'gold', 'deepskyblue'), 'gray95',
        animationHoldColor='red', animationEasing='CircularOut',
        animationDuration=10000)

## End(Not run)

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