First, you should load recharts:

library(recharts)

1 Introduction

Title comprises of two parts: title (and title link), subtitle (and subtitle link). The default position is 6 o’clock.

The recommended approach to use setTitle is chart %>% setTitle(...).

2 Function Call

All the function names have two forms: small camel and lowercase_underscore (endorsed by Hadley Wickham).

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

set_title(chart, title = NULL, subtitle = NULL, link = NULL,
  sublink = NULL, pos = 6, bgColor = NULL, borderColor = NULL,
  borderWidth = NULL, textStyle = NULL, subtextStyle = NULL,
  show = TRUE, ...)
Arg Requirement

chart

Echarts object generated by echartR or echart.

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 subtitle, url is passed to sublink. 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.

3 Showcase

g1 <- echartr(iris, Sepal.Width, Petal.Width, Species)
g2 <- echartr(iris, Sepal.Width, Petal.Width, t=Species)
g1 %>% setTheme(width=400, height=300)
g2 %>% setTheme(width=400, height=300)

3.1 Echarts without Timeline

Title and subtitle at the default position.

g1 %>% setTitle(title='Iris data set', subtitle='by: R. A. Fisher')

Relocate the title.

g1 %>% setTitle(title='Iris data set', subtitle='by: R. A. Fisher', pos=12)

Title and subtitle with links.

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

Customize the format (ugly).

g1 %>% 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') %>%
    setGrid(y2=90)

3.2 Echarts with Timeline

Title and subtitle at the default position.

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

Customierzed titles and subtitles. They must be written in vectors and will be then mapped to each timeslots along with the timeline.

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)')
g2 %>% setTitle(titles)

More settings on format. Elements such as textStyle should also be written in lists to map to each timeslots.

g2 %>% setTitle(
    titles,
    textStyle=list(
      textStyle(fontFamily='Impact', color='red', fontStyle='normal'),
      textStyle(fontFamily='Times New Roman', color='darkgreen'),
      textStyle(fontFamily='Calibri', color='blue', fontStyle='oblique')
   ),
   bgColor='yellow')