ScrollChart
lib/scroll/scroll_chart.march — Charts for notebooks.
import ScrollChart
ScrollChart.new()
|> ScrollChart.title("French electricity load forecast errors")
|> ScrollChart.x_label("Delivery lead (hours)")
|> ScrollChart.y_label("Mean absolute error (MW)")
|> ScrollChart.line("Weekly naive", hours, naive_mae)
|> ScrollChart.line("Chronos-2 Small", hours, chronos_mae)
|> ScrollChart.band("Chronos P10–P90", hours, p10, p90)
|> ScrollChart.show()Every series gets a legend entry and a hover tooltip, and the chart fills the notebook's width. show prints one __SCROLL_BLOB__ block of type application/vnd.scroll.chart+json holding a Vega-Lite spec, which the notebook renders interactively and HTML export embeds as a static SVG. to_spec returns the spec itself, for use outside a notebook.
The x values of one chart are all numbers (line, points, band), all ISO dates (line_dates, points_dates, band_dates) or all category labels (bars).
Types
The x values of one layer.
One layer: a mark, the series name shown in the legend, x values, and one or two y value lists (a band has a low and a high).
title, x label, y label, height in pixels, y axis starts at zero, layers (newest first).
Functions
Add a shaded band between lows[i] and highs[i], e.g. a prediction interval.
Add a shaded band over ISO dates.
Add bars, one per category label; several bars layers sit side by side.
Set the chart's height in pixels (its width follows the notebook).
Add a line through (xs[i], ys[i]).
Add a line over ISO dates (YYYY-MM-DD, optionally with a time).
The sentinel block that displays spec (for tests and composition).
The MIME type the notebook renders as a chart.
An empty chart, 320 pixels high and as wide as the notebook.
Add unconnected points at (xs[i], ys[i]).
Add points over ISO dates.
Start the y axis at zero instead of fitting it to the data.