Skip to contents

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

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] +
                                       '<br />wt: ' + params.value[1] +
                                       '<br />qsec: ' + params.value[2];
                                       }")
 )