Skip to contents

Convert a chart config to a plain list

Usage

chart_config_to_list(config, complete = FALSE)

Arguments

config

ChartConfig: The chart configuration.

complete

Logical: If TRUE, emit the output-config form: every property, plus provenance.

Value

Named list, ready for jsonlite::toJSON().

Details

Two forms, matching the two the schema publishes:

  • complete = FALSE (default) drops unset properties, so an authored config stays as small as it was authored. type is always kept: it carries the document's shape and is the one key the schema requires.

  • complete = TRUE keeps every property, unset ones included, so they serialize as explicit nulls – and stamps the writer. A consumer of such a document can read every key directly instead of reproducing this package's defaults. Requires a full origin map; see write_chart_config().

Author

EDG

Examples

chart_config_to_list(setup_ScatterConfig(x = "wt", y = "mpg"))
#> $type
#> [1] "scatter"
#> 
#> $origin
#> $origin$dat_path
#> [1] "default"
#> 
#> $origin$title
#> [1] "default"
#> 
#> $origin$legend_position
#> [1] "default"
#> 
#> $origin$legend_placement
#> [1] "default"
#> 
#> $origin$x
#> [1] "user"
#> 
#> $origin$y
#> [1] "user"
#> 
#> $origin$size
#> [1] "default"
#> 
#> $origin$group
#> [1] "default"
#> 
#> $origin$hover
#> [1] "default"
#> 
#> $origin$fit_name
#> [1] "default"
#> 
#> $origin$rug
#> [1] "default"
#> 
#> $origin$fit
#> [1] "default"
#> 
#> $origin$se
#> [1] "default"
#> 
#> $origin$se_times
#> [1] "default"
#> 
#> $origin$rsq
#> [1] "default"
#> 
#> $origin$diagonal
#> [1] "default"
#> 
#> $origin$diagonal_color
#> [1] "default"
#> 
#> $origin$n_fit
#> [1] "default"
#> 
#> $origin$fit_alpha
#> [1] "default"
#> 
#> $origin$palette
#> [1] "default"
#> 
#> $origin$square
#> [1] "default"
#> 
#> $origin$equal_axes
#> [1] "default"
#> 
#> $origin$pad
#> [1] "default"
#> 
#> $origin$xlim
#> [1] "default"
#> 
#> $origin$ylim
#> [1] "default"
#> 
#> $origin$xlab
#> [1] "default"
#> 
#> $origin$ylab
#> [1] "default"
#> 
#> $origin$margin_top
#> [1] "default"
#> 
#> $origin$margin_right
#> [1] "default"
#> 
#> $origin$margin_bottom
#> [1] "default"
#> 
#> $origin$margin_left
#> [1] "default"
#> 
#> 
#> $legend_position
#> [1] "top"
#> 
#> $legend_placement
#> [1] "outside"
#> 
#> $x
#> [1] "wt"
#> 
#> $y
#> [1] "mpg"
#> 
#> $rug
#> [1] FALSE
#> 
#> $se
#> [1] TRUE
#> 
#> $se_times
#> [1] 1.96
#> 
#> $rsq
#> [1] FALSE
#> 
#> $diagonal
#> [1] FALSE
#> 
#> $n_fit
#> [1] 200
#> 
#> $fit_alpha
#> [1] 0.25
#> 
#> $square
#> [1] FALSE
#> 
#> $equal_axes
#> [1] FALSE
#> 
#> $pad
#> [1] 0.04
#>