Learn R Programming

echarts4r (version 0.5.0)

e_insert_data: Insert binded data

Description

Utility function to attach an existing column(s) from your data to an existing series

Usage

e_insert_data(e, .serie, .data)

Arguments

e

An echarts4r object as returned by e_charts or a proxy as returned by echarts4rProxy.

.serie

Serie's index to add the data.

.data

Column names for the new data.

Details

This inserts new data into a series's values which allows for use in mapping things like e_visual_map or tooltip parameters. This function also works when using timelines.

Examples

Run this code
mtcars |>
 e_charts(mpg) |>
 e_scatter(wt, scale = e_scale) |>
 e_insert_data(.serie = 1, .data = "qsec") |>
 e_visual_map(qsec, scale = e_scale, dimension = 2) |>
 e_tooltip(trigger = "item",
           formatter = htmlwidgets::JS("function(params) {
                                       return 'mpg: ' + params.value[0] +
                                       'wt: ' + params.value[1] +
                                       'qsec: ' + params.value[2];
                                       }")
 )

Run the code above in your browser using DataLab