Assets for the echarts4r package.

ea_asset(asset, convert = TRUE)

ea_convert(file)

ea_copy(asset, dir = "www")

ea_source(asset, dir = "www")

Arguments

asset

Name of texture, see details below.

convert

Converts image to JSON formatted arrays.

file

Path to file.

dir

Directory to copy asset to.

Details

Due to browser "same origin policy" security restrictions, loading textures from a file system may lead to a security exception, see https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally. References to file locations work in Shiny apps, but not in stand-alone examples. The *texture functions facilitates transfer of image texture data from R into textures when convert is set to TRUE.

Valid run ea_bank asset.

Note

See ea_bank for valid assets.

Functions

  • ea_asset include asset.

  • ea_convert convert file to JSON formatted array.

  • ea_copy moves an asset to the folder of your choice. This is useful as convert = TRUE argment is computationally expensive, for instance, in Shiny, move the asset to your www folder for better perfromances.

  • ea_source source your copied asset.

Examples

# NOT RUN {
library(shiny)
library(echarts4r)

# copy asset to www folder
ea_copy("world")

ui <- fluidPage(
  echarts4rOutput("globe")
)

server <- function(input, output){

  output$globe <- renderEcharts4r({

    e_charts() %>%
      e_globe(
        environment = ea_source("earth"),
        base_texture = e_globe_texture()
      )
  })

}

shinyApp(ui, server)
# }