powered by
Exports a ggplot object as JSON optimized for frontend rendering. Addresses all frontend feedback:
Strict scalar typing (no for missing values)
Structured units with pre-calculated pixel values
Stable IDs for React keys
Consistent Array of Structures pattern
ggplot_to_frontend_json( plot, width = 800, height = 600, include_data = TRUE, include_built = FALSE, pretty = FALSE )
JSON string optimized for frontend.
A ggplot object.
Plot width in pixels.
Plot height in pixels.
Whether to include data.
Whether to include ggplot_build() output.
Format JSON with indentation.
# \donttest{ if (interactive()) { library(ggplot2) p <- ggplot(mtcars, aes(wt, mpg)) + geom_point() json <- ggplot_to_frontend_json(p, width = 800, height = 600) } # }
Run the code above in your browser using DataLab