setAxis: Set 'x|yAxis' of Echarts (Primary or Secondary)

Description Usage Arguments References See Also Examples

View source: R/coordsys.R

Description

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

You can use work functions setXAxis, setYAxis, setX1Axis, setY1Axis.

This function modified a few default options for the axis component in ECharts:

  1. scale = TRUE (was FALSE by default in ECharts);

  2. axisLine$onZero = FALSE (was TRUE in ECharts).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
setAxis(chart, series = NULL, grid = NULL, which = c("x", "y", "x1", "y1",
  "y2"), type = c("value", "category", "time", "log"), offset = 0,
  show = TRUE, position = c("bottom", "top", "left", "right"),
  inverse = FALSE, name = "", nameLocation = c("end", "middle", "start"),
  onZero = FALSE, nameTextStyle = emptyList(), nameGap = 15,
  nameRotate = NULL, boundaryGap = c(0, 0), min = NULL, max = NULL,
  scale = TRUE, splitNumber = NULL, interval = NULL, logBase = 10,
  silent = FALSE, triggerEvent = FALSE, axisLine = list(show = TRUE,
  onZero = onZero), axisTick = list(show = FALSE), axisLabel = list(show =
  TRUE), splitLine = list(show = TRUE), splitArea = list(show = FALSE),
  data = list(), zlevel = 0, z = 0)

setYAxis(chart, ...)

setY1Axis(chart, ...)

setXAxis(chart, ...)

setX1Axis(chart, ...)

setY2Axis(chart, ...)

Arguments

chart

echarts object generated by echart

series

Which series to be put on this axis. Could be:

  • series names, in vectors. E.g, c('setosa', 'virginica');

  • index of series, in vectors. E.g., 1:2 or c(1,3).

which

Which axis to be modified. Could be one of the following:

x

primary x axis

y

primary y axis

x1

secondary x axis

y1

secondary y axis

type

Type of the axis. Could be c('time', 'value', 'category', 'log'). Default 'value'.

position

Position of this axis. Could be c('bottom', 'top', 'left', 'right') (default for primary x axis, secondary x axis, primary y axis and secondary y axis, respectively.)

boundaryGap

A two-element numeric vector, defining the policy of the space at the two ends of the axis (percents). Deafult c(0, 0).

min

The mininum value of the axis. Default NULL (automatic). If a numeric value is set, boundaryGap is disabled.

max

The maxinum value of the axis. Default NULL (automatic). If a numeric value is set, boundaryGap is disabled.

scale

Logical, for axis of 'value', 'time', 'log' type, to define whether zoom the scale to the range between _min and _max. Default TRUE.

splitNumber

Numeric, how many sections to devide the axis. Default NULL, automatically deviding based on algorithms of min and max.

axisLine

A list. Default:
list(show=TRUE, onZero=FALSE, lineStyle=list(
type='solid', color='#48b', width=2, shadowColor='rgba(0,0,0,0)', shadowBlur=5, shadowOffsetX=3, shadowOffsetY=3))


lineStyle accepts features color, width, type, shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY

axisTick

A list. Default:
show=FALSE, inside=FALSE, length=5, lineStyle=list(color="#333", width=1)

lineStyle accepts feature color, width, type, shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY

axisLabel

A list controlling the axis labels. Default show=TRUE, rotate=0, margin=8, clickable=FALSE, formatter=NULL, textStyle=list(color="#333")

textStyle accepts features color, align, baseline, fontFamily, fontSize, fontStyle, fontWeight.

formatter:

sprintf/format string

String to overide axisLable$formatter. It accepts sprintf (category and value) and strptime (time) formats.

js mode

a JS function/expression, which is default


axisLabel=list(formatter="%s cm") is equal to
axisLabel=list(formatter=JS('function (value) {return value + "cm";}')) or
axisLabel=list(formatter='{value} cm')

splitLine

A list controlling the split lines. Default show=TRUE, lineStyle=list(color=list("#ccc"), width=1, type="solid")

lineStyle accepts features color, width, type, shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY.

splitArea

A list controlling the split areas. Default show=FALSE, onGap=NULL, areaStyle= list(color= list("rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)") , type="default"

areaStyle accepts features color, type.

data

A character vector/list for axis of type 'category', to define the text labels shown in this axis. Default NULL. You can even pass in a complicated list with textSytle list:
list('Jan', 'Feb', 'Mar',
list(value='Apr', textStyle=list(color='red', ...)),
'May', ...)

mode

References

http://echarts.baidu.com/echarts2/doc/option.html#tooltip-line1~xAxis-i

http://echarts.baidu.com/echarts2/doc/option.html#tooltip-line1~yAxis-i

See Also

setXAxis, setYAxis, setX1Axis, setY1Axis

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
g = echart(iris, Sepal.Width, Petal.Width, series=Species)

# Change the style
g %>% setTheme('gray') %>% setXAxis(splitLine=list(show=FALSE)) %>%
      setYAxis(axisLine=list(lineStyle=list(width=0)))

# Dual-yAxis, series 1,2 on primary y-axis, series 3 on secondary y-axis
g %>% setYAxis(1:2, name="setosa/versicolor") %>%
      setY1Axis("virginica", name="virginica")

## End(Not run)

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