首先,加载recharts
:
library(recharts)
缩放漫游默认放置于6点钟位。
建议用chart %>% setDataZoom(...)
格式调用setDataZoom
.
所有函数名都有小驼峰法和小写连划线(Hadly Wickham推荐此法)两种形式。为了便于偷懒,还有缩写版(如dataZoom缩写成dz)。
setDataZoom(chart, show = TRUE, pos = 6, range = NULL, width = 30,
fill = "rgba(144,197,237,0.2)", handle = "rgba(70,130,180,0.8)",
bgColor = "rgba(0,0,0,0)", dataBgColor = "#eee", showDetail = TRUE,
realtime = FALSE, zoomLock = FALSE, ...)
set_datazoom(chart, show = TRUE, pos = 6, range = NULL, width = 30,
fill = "rgba(144,197,237,0.2)", handle = "rgba(70,130,180,0.8)",
bgColor = "rgba(0,0,0,0)", dataBgColor = "#eee", showDetail = TRUE,
realtime = FALSE, zoomLock = FALSE, ...)
set_dz(chart, show = TRUE, pos = 6, range = NULL, width = 30,
fill = "rgba(144,197,237,0.2)", handle = "rgba(70,130,180,0.8)",
bgColor = "rgba(0,0,0,0)", dataBgColor = "#eee", showDetail = TRUE,
realtime = FALSE, zoomLock = FALSE, ...)
setDZ(chart, show = TRUE, pos = 6, range = NULL, width = 30,
fill = "rgba(144,197,237,0.2)", handle = "rgba(70,130,180,0.8)",
bgColor = "rgba(0,0,0,0)", dataBgColor = "#eee", showDetail = TRUE,
realtime = FALSE, zoomLock = FALSE, ...)
参数 | 要求 |
---|---|
chart |
|
show |
逻辑型,是否显示缩放漫游。默认为FALSE。如要把缩放漫游部件整体从Echarts对象中移除,设为NULL. |
pos |
缩放漫游的时钟方位,默认为6,参见 |
range |
向量 |
width |
缩放漫游宽度,默认为20px. |
fill |
缩放漫游控制轴颜色,格式为’rgba(red, green, blue, alpha)’,默认为 |
handle |
缩放漫游手柄颜色,格式为’rgba(red, green, blue, alpha)’,默认为 |
bgColor |
背景色,默认为透明(‘rgba(0,0,0,0)’). |
dataBgColor |
数据剪影的背景色 (只显示第一个系列). 默认为 ‘#eee’. |
showDetail |
逻辑型,缩放时是否显示明细。默认为TRUE. |
realtime |
逻辑型,缩放时是否实时显示明细,默认为FALSE. |
zoomLock |
逻辑型,是否锁定缩放区间。默认为FALSE. |
… |
省略号 |
g <- echartr(iris, Sepal.Width, Petal.Width, Species)
g
初始时不显示缩放漫游,可以打开。
g %>% setDataZoom(show=TRUE)
移动缩放漫游。
g %>% setDataZoom(pos=12)
自定义格式。
g %>% setDataZoom(bgColor='yellow', dataBgColor='gold', fill='tan',
handle='maroon')
初始选中20% - 60%.
g %>% setDataZoom(range=c(20, 60))