Support using param / expr with `field` keys to control which data column is used for an encoding
See original GitHub issueI suspect there might be an open issue for this somewhere but I could not find it when searching. The new parameter feature looks very cool, but I can’t find and example of param / expr used together with the field
key and when I try it in the vega editor, it says it only supports strings as values for this field. Would it be possible to add this functionality so that a field value could be set dynamically, e.g. to change which column is plotted on the x and y axis via a dropdown? Or am I not understanding how parameters are supposed to work?
A workaround for this is mention in https://github.com/vega/vega-lite/issues/7264 by first folding and then filtering on a param / expr, but it would be need if this feature was directly supported. To be clear a use case would be to create something like this (minus the cluster count calculations):
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:16 (12 by maintainers)
I can confirm this works with the existing Vega-Lite implementation, although I am not sure if it is possible to customise the axis title to be data dependent. It would be useful if axis title could accept an expression in addition to a text literal.
Vega-Lite editor
@jwoLondon @joelostblom Is it in Vega lite possible to select the visualized value depending on a nested field? datum[measure] from the example does not seem to be able to handle values such as Motor.Cylinder.
"data": { "values": [ { "Name": "chevrolet chevelle malibu", "Miles_per_Gallon": 18, "Motor": {"Cylinders": 8, "Horsepower": 130}, "Displacement": 307, ... "transform": [{"calculate": "datum[measure]", "as": "y"}],
Vega lite editor