First, you should load recharts:

library(recharts)

1 Introduction

aesStyle is a big family to construct Echarts styling element objects. E.g., Echarts uses itemStyle heavily, and you can either use itemStyle function or directly build the itemStyle object by writing a list.

Inside an itemStyle list object, there are three types of elements:

  • atomic features
    • ‘color’, ‘borderColor’, ‘borderWidth’, ‘barBorderColor’, ‘barBorderRadius’, ‘barBorderWidth’, which you can directly assign values
  • object features
    • ‘lineStyle’, ‘textStyle’,‘areaStyle’, ‘chordStyle’, ‘nodeStyle’, ‘linkStyle’, which you can yield by aesStyle function family
  • mixed object features
    • ‘label’ and ‘labelLine’, which contains other object features, such as ‘lineStyle’, ‘textStyle’

2 Function Call

All the function names have two forms: small camel and lowercase_underscore (endorsed by Hadley Wickham). To be lazy, we also provide short forms as well (e.g., ll for labelLine).

aesStyle(element = c("text", "line", "area", "chord", "node", "link"), ...)
aes_style(element = c("text", "line", "area", "chord", "node", "link"), ...)

lineStyle(...)
style_line(...)

textStyle(...)
style_text(...)

areaStyle(...)
style_area(...)

chordStyle(...)
style_chord(...)

nodeStyle(...)
style_node(...)

linkStyle(...)
style_link(...)

labelStyle(...)
style_label(...)

labelLineStyle(...)
style_labelline(...)
style_ll(...)

itemStyle(...)
style_item(...)
Arg Requirement

chart

Echarts object generated by echartR or echart.

element

c(“text”, “line”, “area”, “chord”, “node”, “link”).

The params to form an aesthetic element.

2.1 Elipsis

2.1.1 itemStyle (normal|emphasis)

Arg Instruction
color color vector, ‘rgba’, hex color, or color names.
lineStyle for line, k charts and markLine, see lineStyle
textStyle see textStyle
areaStyle for stacked line chart and map, see areaStyle
chordStyle for chord chart, see chordStyle
nodeStyle for force chart, see nodeStyle
linkStyle for force chart, see linkStyle
borderColor color vector, ‘rgba’, hex color, or color names.
borderWidth for symbol, symbole, pie chart, map and markPoint, numeric
barBorderColor for symbol, symbole, pie chart, map and markPoint, numeric
barBorderRadius numeric vector length 1 or 4 (right-bottom-left-top), default 0
barBorderWidth numeric vector length 1 or 4 (right-bottom-left-top), default 00
label for line, bar, k, scatter, pie, map, force, funnel charts and markPoint, markLine, see labelStyle
labelLine for pie and funnel chart, see labelLineStyle

2.1.2 labelStyle / style_label

Arg Instruction

show

TRUE|FALSE, default TRUE

position

  • for pie, ‘outer’/‘inner’;
  • for funnel, ‘inner’/‘left’/‘right’;
  • for line, bar, k, scatter, ‘top’/‘right’/‘inside’/‘left’/‘bottom’;
  • for bar, additionally ‘insideLeft’ / ‘insideRight’ / ‘insideTop’ / ‘insideBottom’

rotate

chord chart only. TRUE|FALSE, default FALSE

distance

chord and pie chart only. numeric, default 10

formatter

see setTooltip

textStyle

see textStyle

x

treemap only, numeric

y

treemap only, numeric

2.1.3 labelLineStyle / style_ll / style_labelline

Arg Instruction
show TRUE
length numeric or ‘auto’, default 40
lineStyle see lineStyle

2.1.4 textStyle / style_text

Arg Instruction
color color vector, ‘rgba’, hex color, or color names.
decoration only for tooltip. string, default ‘none’
align ‘left’ / ‘right’ / ‘center’
baseline ‘top’ / ‘bottom’ / ‘middle’
fontFamily valid font family name
fontSize numeric, default 12
fontStyle ‘normal’ / ‘italic’ / ‘oblique’, default ‘normal’
fontWeight ‘normal’ / ‘bold’ / ‘bolder’ / ‘lighter’ or numeric, default ‘normal’

2.1.5 lineStyle / style_line

Arg Instruction
color color vector, ‘rgba’, hex color, or color names.
type ‘solid’ / ‘dotted’ / ‘dashed’, for tree, additionally ‘curve’ / ‘broken’. Default ‘solid’
width numeric
shadowColor color vector, ‘rgba’, hex color, or color names.
shadowBlur numeric, default 5
shadowOffsetX numeric, default 3
shadowOffsetY numeric, default 3

2.1.6 areaStyle / style_area

Arg Instruction
color color vector, ‘rgba’, hex color, or color names.
type only ‘default’

2.1.7 chordStyle / style_chord

Arg Instruction
width numeric, default 1
color color vector, ‘rgba’, hex color, or color names.
borderWidth numeric, default 1
borderColor color vector, ‘rgba’, hex color, or color names.

2.1.8 nodeStyle / style_node

Arg Instruction
color color vector, ‘rgba’, hex color, or color names.
borderWidth numeric, default 1
borderColor color vector, ‘rgba’, hex color, or color names.

3 Showcase

How to build an itemStyle object?

First, build the low-level style element object.

styText <- textStyle(color='red', fontFamily='Arial')
styLine <- lineStyle(color='#fff', width=4, shadowBlur=5)

Then, build up higher-level style element objects.

lab <- labelStyle(show=TRUE, position='inside', textStyle=styText)

Finally, consolidate an itemSytle object.

itemStyle <- list(normal=itemStyle(lineStyle=styLine, label=lab),
                  emphasis=itemStyle(lineStyle=styLine, label=lab)
              )