vega / vl-convert

Utilities for converting Vega-Lite specs from the command line and Python
BSD 3-Clause "New" or "Revised" License
98 stars 12 forks source link

Allow A Configuration file in `~/.config/vl-convert/config.json` #18

Closed lsh closed 1 year ago

lsh commented 1 year ago

I could imagine some fun tools making use of vl-convert in a terminal context where having a general config file would be nice (with semantics like { config: { ...userConfig, ...specConfig } }). I would imagine that the config would just be a regular config.

jonmmease commented 1 year ago

That's a cool idea! We should also add support for providing an explicit config file to the various conversion functions.

lsh commented 1 year ago

Do you think it should support everything in the options parameter of vegaLite.compile? Basically, what I'm trying to figure out is if a data structure like the following would be useful to add the following data structure as a parameter in InnerVlConverter::init_vl_version():

struct VLCompileOptions<'c, 'l, 'f> {
  config: Option<&'c str>,
  logger: Option<&'l str>,
  field_title: Option<&'f str>
}

(using &'a str because I'm assuming zero-copy-deserialization)

I only really feel strongly about the config portion, but the above might be better forwards compatibility if we decide to support the latter two.

jonmmease commented 1 year ago

I think the config values make sense, but not the others at this point (as they are pretty JavaScript specific).

I think I would picture making config an argument to the vegalite_to_* functions. It would be fine to pull default values from a config file, but I think it would be nice to be able to set it for individual conversions.

lsh commented 1 year ago

For what it's worth, the reason I'm suggesting config in the vegaLite.compile is specifically because it has the semantics:

Note that configuration properties provided via the config property in the Vega-Lite specification, will override the configurations passed in through the compile function.

jonmmease commented 1 year ago

Should named themes be handled through the same config object? Or to you think we'll need a separate theme configuration setting?

jonmmease commented 1 year ago

Working on this as part of https://github.com/vega/vl-convert/pull/39