setTitle: Set 'title' (And Subtitle) of Echarts

Description Usage Arguments Details Value References Examples

View source: R/options.R

Description

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

Usage

1
2
3
4
setTitle(chart, title = NULL, subtitle = NULL, link = NULL,
  sublink = NULL, pos = 6, bgColor = NULL, borderColor = NULL,
  borderWidth = NULL, textStyle = NULL, subtextStyle = NULL,
  show = TRUE, ...)

Arguments

chart

echarts object generated by echart or echartR

title

text of the title. If written in markdown format [caption](url), then caption is passed to title, url is passed to link. If the length of the title vector equals to the length of timeline slices, the title vector will be used as slice-specific user-defined title.

subtitle

text of the subtitle. If written in markdown format [caption](url), then caption is passed to title, url is passed to link. If the length of the subtitle vector equals to the length of timeline slices, the subtitle vector will be used as slice-specific user-defined title.

link

link of the title

sublink

link of the subtitle

pos

the clock-position of title (and subtitle), refer to vecPos. Or define a vector c(x, y, orient) yourself.

bgColor

background color of title. Default 'rgba(0,0,0,0)' (transparent)

borderColor

border color of the title. Default '#ccc'.

borderWidth

border width of the title. Default 0px (not shown).

textStyle

You can place self-defined textStyle list of the title here. E.g., list( fontFamily='Arial|Verdana|sans-serif', fontSize=20, fontWeight='normal|bold|bolder|lighter|<numbers>', fontStyle='normal|italic|oblique', color='red')

subtextStyle

You can place self-defined textStyle of the subtitle here.

show

Logical. Whether to show the title. If you want to remove title from the echarts object, set it NULL.

...

elipsis

Details

In echarts with timeline, you can set title, subtitle, link, sublink, bgColor, borderColor, borderWidth as vectors of the same length as z. For textSytle, subtextStyle, you need to pack the user-defined lists in a list.

Value

A modified echart object

References

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

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
32
33
34
35
36
37
38
39
40
41
42
## Not run: 
## simple echarts scatter plot
g = iris %>% echartR(x=Sepal.Width, y=Petal.Width, series=Species,
                      type='scatter')

## set simple titles
g %>% setTitle(title='Iris data set', subtitle='by: R. A. Fisher')

## set titles with links and textStyles
g %>% setTitle(
  '[Iris data set](https://en.wikipedia.org/wiki/Iris_flower_data_set)',
  '[R. A. Fisher](https://en.wikipedia.org/wiki/Ronald_Fisher)',
  textStyle=textStyle(fontFamily='Courier New', fontSize=24, color='gold'),
  subtextStyle=textStyle(color='silver'), bgColor='lightgreen')


## echarts with timeline
g1 = iris %>% echartR(x=Sepal.Width, y=Petal.Width, t=Species, type='scatter')

## simple titles/subtitles
g1 %>% setTitle(
    '[Iris data set](https://en.wikipedia.org/wiki/Iris_flower_data_set)',
    '[R. A. Fisher](https://en.wikipedia.org/wiki/Ronald_Fisher)')

## user-defined titles/subtitles
titles = c(
    '[Iris setosa](https://en.wikipedia.org/wiki/Iris_setosa)',
    '[Iris versicolor](https://en.wikipedia.org/wiki/Iris_versicolor)',
    '[Iris virginica](https://en.wikipedia.org/wiki/Iris_virginica)')

g1 %>%
setTitle(
   titles,
   textStyle=list(
      textStyle(fontFamily='Impact', color='red', fontStyle='normal'),
      textStyle(fontFamily='Times New Roman', color='green'),
      textStyle(fontFamily='Calibri', color='blue', fontStyle='oblique')
   ),
   bgColor='lightyellow')
## textStyle is a list length 3, mapping 3 levels for timeline

## End(Not run)

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