question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support using param / expr with `field` keys to control which data column is used for an encoding

See original GitHub issue

I 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):

image

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:16 (12 by maintainers)

github_iconTop GitHub Comments

7reactions
jwoLondoncommented, Mar 4, 2022

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

{
  "data": {
    "url": "data/weather.csv"
  },
    "params": [
    {
      "name": "measure",
      "value": "temp_max",
      "bind": {
        "input": "select",
        "options": ["temp_max","precipitation","wind"]
      }
    }
  ],
  "transform": [
    {
      "calculate": "datum[measure]",
      "as": "y"
    }
  ],
  
    "mark": "line",
    "encoding": {
      "x": {"field": "date", "timeUnit": "month"},
      "y": {
        "field": "y",
        "aggregate": "mean"
      },
      "color": {"field": "location"}
    }
}
0reactions
Sebastian2023commented, Nov 19, 2022

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Encoding | Vega-Lite
The keys in the encoding object are encoding channels. Vega-Lite supports the following groups of encoding channels.
Read more >
Data conversion parameters - Amazon Redshift
Indicates that Amazon Redshift should load empty CHAR and VARCHAR fields as NULL. Empty fields for other ... All load data must use...
Read more >
Create Parameters - Tableau Help
Organize and Customize Fields in the Data Pane · Create Parameters ... Specify the display format to use in the parameter control (Tableau...
Read more >
Formulas—ArcGIS Survey123 | Documentation
The pulldata() function can't be used to populate the values of select_multiple questions. When using the pulldata() function, your CSV column names cannot ......
Read more >
Use parameters in queries, forms, and reports
This article explains how to use forms in Access to enhance your use of parameters ... Choose a format that reflects the data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found