First, you should load recharts
:
library(recharts)
The default position of toolbox is 1 o’clock.
The recommended approach to use setToolbox
is chart %>% setToolbox(...)
.
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., tb for toolbox).
setToolbox(chart, show = TRUE, language = "cn", controls = c("mark",
"dataZoom", "dataView", "magicType", "restore", "saveAsImage"), pos = 1,
bgColor = "rgba(0,0,0,0)", borderColor = "#ccc", borderWidth = 0,
padding = 5, itemGap = 10, itemSize = 16, color = c("#1e90ff",
"#22bb22", "#4b0082", "#d2691e"), disableColor = "#ddd",
effectiveColor = "red", showTitle = TRUE, textStyle = NULL, ...)
set_toolbox(chart, show = TRUE, language = "cn", controls = c("mark",
"dataZoom", "dataView", "magicType", "restore", "saveAsImage"), pos = 1,
bgColor = "rgba(0,0,0,0)", borderColor = "#ccc", borderWidth = 0,
padding = 5, itemGap = 10, itemSize = 16, color = c("#1e90ff",
"#22bb22", "#4b0082", "#d2691e"), disableColor = "#ddd",
effectiveColor = "red", showTitle = TRUE, textStyle = NULL, ...)
setTB(chart, show = TRUE, language = "cn", controls = c("mark",
"dataZoom", "dataView", "magicType", "restore", "saveAsImage"), pos = 1,
bgColor = "rgba(0,0,0,0)", borderColor = "#ccc", borderWidth = 0,
padding = 5, itemGap = 10, itemSize = 16, color = c("#1e90ff",
"#22bb22", "#4b0082", "#d2691e"), disableColor = "#ddd",
effectiveColor = "red", showTitle = TRUE, textStyle = NULL, ...)
set_tb(chart, show = TRUE, language = "cn", controls = c("mark",
"dataZoom", "dataView", "magicType", "restore", "saveAsImage"), pos = 1,
bgColor = "rgba(0,0,0,0)", borderColor = "#ccc", borderWidth = 0,
padding = 5, itemGap = 10, itemSize = 16, color = c("#1e90ff",
"#22bb22", "#4b0082", "#d2691e"), disableColor = "#ddd",
effectiveColor = "red", showTitle = TRUE, textStyle = NULL, ...)
Arg | Requirement |
---|---|
chart |
Echarts object generated by |
show |
Logical. Show the toolbox or not. Default TRUE. If you want to remove toolbox from the echarts object, set it NULL. |
language |
‘cn’ or ‘en’, the language of the toolbox tooltips. |
controls |
which widgets to show. Default ‘mark’, ‘dataZoom’, ‘dataView’, ‘magicType’, ‘restore’, ‘saveAsImage’. |
pos |
Clock position of the toolbox. Default 1. Refer to |
bgColor |
background color, default transparent (‘rgba(0,0,0,0)’). |
borderColor |
The border color of the toolbox. Default ‘#ccc’. |
borderWidth |
The border width of the toolbox Default 0px (not shown). |
padding |
Padding of the toolbox. Default 5px. Could also be a list assigning padding of top, right, bottom and left. |
itemGap |
Gap between the items. Default 10px. |
itemSize |
Size of the items. Default 16px. |
color |
Colors of the toolbox widgets (applied in loops). Default c(“#1e90ff”, “#22bb22”, “#4b0082”, “#d2691e”). |
disableColor |
Color for disabled widgets. Default ‘#ddd’. |
effectiveColor |
Color for widgets be triggered. Default ‘red’. |
showTitle |
Logical, if widgets title are shown. Default TRUE. |
textStyle |
A list of the text style of the widgets. Default |
… |
Elipsis. |
g <- echartr(iris, Sepal.Width, Petal.Width, Species)
g
Initially toolbox is shown. Let’s turn if off.
g %>% setToolbox(show=FALSE)
The controls’ tooltip is in Chinese by default. If you want them to be in English, set language
‘en’.
g %>% setToolbox(language='en')
Relocate the toolbox
g %>% setToolbox(pos=3)
Only show some of the control widgets.
g %>% setToolbox(controls=c('mark', 'dataView'))
Customize the format.
g %>% setToolbox(textStyle=textStyle(
fontFamily='Times New Roman', color='purple', fontWeight='bold',
fontSize=16), bgColor='yellow', itemGap=20)
Customize the color of the controls.
g %>% setToolbox(color=getColFromPal('hc'))