Skip to contents

Write a chart config to a JSON file

Usage

write_chart_config(config, path, complete = FALSE)

Arguments

config

ChartConfig: The chart configuration.

path

Character: Destination file.

complete

Logical: If TRUE, write the output-config form.

Value

path, invisibly.

Details

complete = FALSE (default) writes an input config: only the properties that are set. It validates against the chart's schema.json.

complete = TRUE writes an output config: every property, unset ones as explicit nulls, with this package stamped as the writer. It validates against record.json, and is what an interface hands to another interface – nothing is left for the reader to infer. Resolve the config first, so that the values the data determines are written as the derived facts they are:

write_chart_config(resolve(config, data), path, complete = TRUE)

Author

EDG

Examples

path <- tempfile(fileext = ".json")
write_chart_config(setup_ScatterConfig(x = "wt", y = "mpg"), path)

# An output config: resolved against the data, then written in full.
cfg <- resolve(setup_ScatterConfig(x = "wt", y = "mpg"), data = mtcars)
write_chart_config(cfg, path, complete = TRUE)
unlink(path)