View Source Kino.VegaLite (KinoVegaLite v0.1.8)
A kino wrapping VegaLite graphic.
This kino allow for rendering regular VegaLite graphic and then streaming new data points to update the graphic.
examples
Examples
chart =
Vl.new(width: 400, height: 400)
|> Vl.mark(:line)
|> Vl.encode_field(:x, "x", type: :quantitative)
|> Vl.encode_field(:y, "y", type: :quantitative)
|> Kino.VegaLite.new()
|> Kino.render()
for i <- 1..300 do
point = %{x: i / 10, y: :math.sin(i / 10)}
Kino.VegaLite.push(chart, point)
Process.sleep(25)
end
Link to this section Summary
Functions
Removes all data points from the graphic dataset.
Creates a new kino with the given VegaLite definition.
Registers a callback to run periodically in the kino process.
Appends a single data point to the graphic dataset.
Appends a number of data points to the graphic dataset.
Link to this section Types
@type t() :: Kino.JS.Live.t()
Link to this section Functions
Removes all data points from the graphic dataset.
options
Options
dataset
- name of the targetted dataset from the VegaLite specification. Defaults to the default anonymous dataset
@spec new(VegaLite.t()) :: t()
Creates a new kino with the given VegaLite definition.
@spec periodically(t(), pos_integer(), term(), (term() -> {:cont, term()} | :halt)) :: :ok
Registers a callback to run periodically in the kino process.
The callback is run every interval_ms
milliseconds and receives
the accumulated value. The callback should return either of:
{:cont, acc}
- the continue with the new accumulated value:halt
- to no longer schedule callback evaluation
The callback is run for the first time immediately upon registration.
Appends a single data point to the graphic dataset.
options
Options
:window
- the maximum number of data points to keep. This option is useful when you are appending new data points to the plot over a long period of timedataset
- name of the targetted dataset from the VegaLite specification. Defaults to the default anonymous dataset
Appends a number of data points to the graphic dataset.
See push/3
for more details.