Dynamically capture values after pivot transform in Vega-Lite

Viewed 224

In this example: https://vega.github.io/vega-lite/examples/interactive_multi_line_pivot_tooltip.html

They use a pivot transform & then statically write down each value for the field symbol as a tooltip field.

   "tooltip": [
          {"field": "AAPL", "type": "quantitative"},
          {"field": "AMZN", "type": "quantitative"},
          {"field": "GOOG", "type": "quantitative"},
          {"field": "IBM", "type": "quantitative"},
          {"field": "MSFT", "type": "quantitative"}
        ]

Say i didn't know the actual values in my dataset, how would i dynamically generate the same tooltip?

1 Answers

You should be able to do this by removing the explicit tooltip encoding and setting the mark property as

"mark": {"type": "rule", "tooltip": {"content": "data"}}

(see docs), but there appears to be a bug in this behavior, so it doesn't work as of Vega-Lite 4.9.

The only workaround I'm aware of for the time being is to specify the tooltip values explicitly.

Related