Interaction API
On this page
Examples
Interaction is expressed as Vega-Lite parameters, so it works wherever the specification is rendered in a browser. Interaction shows each method with an example.
Methods: tooltip() · interactive() · brush() · highlight() · slider() · dropdown() · param() · select()
Functions: tooltip() · interactive() · brush() · highlight()
tooltip()
->tooltip(array|string|bool $fields = true): PlotTooltips on every layer: true shows the encoded fields, a list shows those fields.
Function: tooltip().
interactive()
->interactive(array $encodings = [0 => 'x',1 => 'y'], string $name = 'zoom'): PlotPan and zoom by dragging and scrolling (scales bound to an interval selection).
Function: interactive().
brush()
->brush( string $name = 'brush', array $encodings = [0 => 'x'], ?string $unselected = '#cccccc', string $channel = 'color',): PlotA drag-to-select interval named $name. Unselected marks of the first layer turn $unselected; other layers can react with filter: [‘param’ => $name], and linked plots in a composition share it.
Function: brush().
highlight()
->highlight( string $aesthetic = 'color', string $name = 'highlight', ?string $bind = 'legend', float $opacity = 0.15,): PlotClick legend entries (or marks, with bind: null) to highlight their group; others fade to $opacity.
Function: highlight().
slider()
->slider( string $name, int|float $min, int|float $max, int|float|null $step = null, int|float|null $value = null, ?string $label = null,): PlotA slider bound to a parameter; use expr($name) in geoms or a filter to react to it.
dropdown()
->dropdown( string $name, array $options, mixed $value = null, ?string $label = null,): PlotA dropdown bound to a parameter.
param()
->param( string $name, mixed $value = null, ?array $bind = null, ?string $expr = null,): PlotA Vega-Lite parameter: a value, optionally bound to an input, or an expr.
select()
->select(array $param): PlotA raw selection parameter, attached to the first layer.
Functions
tooltip()
tooltip(array|string|bool $fields = true): ClosureThe pipe form of ->tooltip().