VlJson

A JSON value: null, a boolean, a number, text, an array or an object.

This is the value model the whole of Vela exchanges — a specification arrives as one, the chart API emits one, and the runtime reads one. It is pure Ranger with no host JSON, so the same tree is built on every target, which is what makes a scene comparison against the reference implementation mean anything.

Two things it carries that a plain JSON model does not: object keys keep the order they were written in, so a re-serialised specification is stable; and a number remembers whether it was written as an integer, so 5 does not come back as 5.0.

new VlJson()
Static Members
nullValue()
boolValue(value)
numberValue(value)
intValue(value)
stringValue(value)
arrayValue()
objectValue()

VlDataRow

One row of a dataset, filled column by column.

A row is handed back already attached to its dataset, so nothing has to be pushed anywhere by the caller.

new VlDataRow()
Related
VlDataset
Example
const data = VlDataset.create();
data.row().str("region", "North").num("sales", 120.0);
data.row().str("region", "South").num("sales", 93.0);
Instance Members
num(field, value)
whole(field, value)
str(field, value)
flag(field, value)
json(field, value)
back()

VlDataset

A table of rows, built once and given to as many charts as want it.

Rows are JSON objects — the same values the parser produces for "data": {"values": […]} — so a dataset built here and one read off disk are the same thing to everything downstream.

The dataset is a value beside the chart rather than a thing inside it: a spreadsheet's selection becomes one dataset and a dashboard's six panels read it.

new VlDataset()
Related
VlChart
Example
const data = VlDataset.create();
data.row().str("region", "North").num("sales", 120.0);
data.row().str("region", "South").num("sales", 93.0);
Static Members
create()
Instance Members
row()
addRow(row)
fromValues(values)
numbers(field, values)
strings(field, values)
rowAt(index)
count()
hasField(field)
fieldType(field)
toValues()

VlChartMark

One mark and the channels it reads.

Every setter answers the mark, so a mark is written as one sentence.

aggregate, bin, title and the rest apply to the channel most recently named — the cursor — which is what makes that sentence read in the order it is thought. on moves the cursor back to a channel already set.

A channel names a column. A constant goes through valueNumber or valueString, and the two are kept apart on purpose: .color("red") meaning a column called red and .color("#c00") meaning paint it red cannot both be true, and the version that guesses is the one that draws a chart nobody asked for.

new VlChartMark()
Related
VlChart
Example
const data = VlDataset.create();
data.row().str("region", "North").num("sales", 120.0);
const chart = VlChart.create(data);
chart.bar().x("region").y("sales").aggregate("sum").title("Total sales");
Instance Members
channel(name, field)
x(field)
y(field)
x2(field)
y2(field)
color(field)
fill(field)
stroke(field)
size(field)
shape(field)
opacity(field)
theta(field)
radius(field)
detail(field)
text(field)
order(field)
column(field)
row(field)
xOffset(field)
yOffset(field)
count(channel)
valueNumber(channel, value)
valueString(channel, value)
encodeJson(channel, definition)
on(channel)
aggregate(op)
bin()
maxBins(count)
timeUnit(unit)
type(kind)
title(label)
format(pattern)
stack(how)
noStack()
sortBy(field)
keepOrder()
scaleJson(scale)
scaleType(kind)
scheme(name)
noLegend()
noAxis()
axisOrient(side)
axisJson(axis)
propNumber(key, value)
propString(key, value)
propFlag(key, value)
filled(value)
markSize(value)
markColor(value)
markOpacity(value)
interpolate(kind)
withPoints(value)
innerRadius(value)
cornerRadius(value)
tooltip(value)
tooltipField(field)
tooltipFields(fields)
thickness(value)
strokeWidth(value)
orient(value)
extent(value)
chart()

VlChart

A chart: a dataset, the channels every mark shares, how big it is, and the marks.

The fluent surface is a writer of specifications, not the engine. Every call writes into a specification and toSpec hands that specification over; nothing here computes a scale, a layout or a pixel. There is no path where the API computes something the engine would have computed differently, because the API computes nothing at all.

A channel said on the chart is inherited by every mark on it, so a line and the points on top of it are two marks and one set of axes rather than two charts.

A channel need not state its type — the data says. A column of numbers is a quantity, a column of ISO dates an instant, anything else a name. A field the data does not have is an error rather than a guess: errors is non-empty and the caller can say so instead of drawing an empty axis.

new VlChart()
Since: 1.0
Related
VlDataset
Example
const data = VlDataset.create();
data.row().str("region", "North").num("sales", 120.0);
data.row().str("region", "South").num("sales", 93.0);
const chart = VlChart.create(data);
chart.size(300, 200);
chart.bar().x("region").y("sales").aggregate("sum");
const spec = chart.toSpec();
const data = VlDataset.create();
data.row().str("region", "North").num("sales", 120.0);
const chart = VlChart.create(data);
chart.x("region").y("sales").color("region");
chart.area().markOpacity(0.35);
chart.line();
Static Members
create(data)
Instance Members
mark(markType)
bar()
line()
area()
point()
circle()
square()
tick()
rule()
rect()
arc()
label()
boxplot()
errorbar()
errorband()
trail()
image()
geoshape()
latest()
channel(name, field)
x(field)
y(field)
color(field)
detail(field)
encodeJson(channel, definition)
on(channel)
type(kind)
title(label)
timeUnit(unit)
keepOrder()
size(width, height)
width(value)
height(value)
heading(text)
background(colour)
propJson(key, value)
configJson(config)
filter(expression)
calculate(expression, as)
transformJson(transform)
independent(channel)
toSpec()