knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(echarts4r) e_common( font_family = "Raleway" )
data <- jsonlite::fromJSON("https://echarts.apache.org/examples/data/asset/data/confidence-band.json") data |> dplyr::mutate( date = as.Date(date, "%Y-%m-%d"), l = l + value, u = u - value ) |> e_charts(date) |> e_line(value, symbol = "none") |> e_band( l, u, areaStyle = list(list(color = "grey"), list(color = "grey")) )
data(EuStockMarkets) as.data.frame(EuStockMarkets) |> dplyr::slice_head(n=200) |> dplyr::mutate(day=1:dplyr::n()) |> e_charts(day) |> e_line(CAC, symbol='none') |> e_band2(DAX, FTSE, color='lemonchiffon') |> e_band2(DAX, SMI, color='lightblue', itemStyle=list(borderWidth=0)) |> e_y_axis(scale=TRUE) |> e_datazoom(start = 50)
cor(mtcars) |> e_charts() |> e_correlations(order = "hclust") |> e_tooltip()
df <- data.frame( x = factor(c(1, 2)), y = c(1, 5), upper = c(1.1, 5.3), lower = c(0.8, 4.3) ) df |> e_charts(x) |> e_bar(y) |> e_error_bar(lower, upper)
df <- data.frame( x = c( rnorm(100), runif(100, -5, 10), rnorm(100, 10, 3) ), grp = c( rep(LETTERS[1], 100), rep(LETTERS[2], 100), rep(LETTERS[3], 100) ) ) df |> group_by(grp) |> e_charts() |> e_boxplot(x)
# data.frame df <- data.frame( x = 1:100, y = rnorm(100, 20, 12) ) df |> e_charts() |> e_histogram(y, name = "histogram") |> e_tooltip()
Plot the density on a different Y axis as its range differs much from the that of the histogram.
df |> e_charts() |> e_histogram(y) |> e_density(y, name = "density", areaStyle = list(opacity = .4), smooth = TRUE, y_index = 1) |> e_tooltip()
iris |> group_by(Species) |> e_charts(Sepal.Length) |> e_line(Sepal.Width) |> e_lm(Sepal.Width ~ Sepal.Length) |> e_x_axis(min = 4)
mtcars |> e_charts(disp) |> e_scatter(mpg, qsec) |> e_loess(mpg ~ disp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.