phiz

Interaction API

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

Tooltips 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'): Plot

Pan 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',): Plot

A 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,): Plot

Click 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,): Plot

A slider bound to a parameter; use expr($name) in geoms or a filter to react to it.

param()

->param(    string $name,    mixed $value = null,    ?array $bind = null,    ?string $expr = null,): Plot

A Vega-Lite parameter: a value, optionally bound to an input, or an expr.

select()

->select(array $param): Plot

A raw selection parameter, attached to the first layer.

Functions

tooltip()

tooltip(array|string|bool $fields = true): Closure

The pipe form of ->tooltip().