knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(tuichartr) library(ggplot2)
Use type = "datetime"
in tui_xAxis
to use time on x-axis. You can set tick labels format with argument dateFormat
:
tuichart("line") %>% add_data(tail(economics, 30), aes(x = date, y = pce)) %>% tui_chart(title = "Personal consumption expenditures, in billions of dollars") %>% tui_xAxis(tickInterval = "auto", type = "datetime", dateFormat = "YYYY-MM") %>% tui_legend(visible = FALSE)
You can create a spline chart by setting spline = TRUE
in tui_series
:
tuichart("line") %>% add_data(tail(economics, 30), aes(x = date, y = pce)) %>% tui_chart(title = "Personal consumption expenditures, in billions of dollars") %>% tui_xAxis(tickInterval = "auto", type = "datetime", dateFormat = "YYYY-MM") %>% tui_legend(visible = FALSE) %>% tui_series(spline = TRUE)
tuichart("line") %>% add_data(economics_long, aes(x = date, y = value01, group = variable)) %>% tui_chart(title = "Economics dataset from ggplot2") %>% tui_xAxis(tickInterval = "auto", type = "datetime", dateFormat = "YYYY-MM") %>% tui_series(pointWidth = 1, zoomable = TRUE) %>% tui_plot(hideLine = TRUE) %>% tui_tooltip(grouped = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.