blockcharts alpha

Embedding /

Ways to hand over data

The same 2000-point series, four ways. They draw the same picture; they differ in how many bytes the page carries.

Four datasets, one result

All four charts below read a dataset of 2000 rows. Datasets that are encoded are decoded in the background; a chart shows a placeholder until its data is ready, and reports a clear error (naming the column) if the data is broken.

Rows

Columns

gzip + base64

Binary columns

FormSize in the pageWhat it is
Rows41.7 KBAn array of objects. The simplest form, and the largest.
Columns22.2 KBOne array per field: no repeated keys.
gzip + base6413.5 KBThe JSON of rows or columns, gzipped and base64-encoded. The composer does this by itself for big datasets. Needs DecompressionStream: Chrome and Edge 80, Firefox 113, Safari 16.4.
Binary columns13.7 KBNumeric columns as raw values, gzipped, base64: what a data pipeline can write. Integers use the smallest integer type; floats stay 64-bit, so nothing is lost.
Binary, v as float3213.1 KBHalves the values that are not integers, keeps about 7 digits. Only when you ask for it.

What each one looks like

Tiny examples of the four shapes (the demo above has 2000 rows each):

Data forms

// rows
[ { "t": 0, "v": 50.2 }, { "t": 1, "v": 50.9 } ]

// columns
{ "columns": { "t": [0, 1], "v": [50.2, 50.9] } }

// gzip + base64 of the JSON above
{ "encoding": "gzip+base64", "data": "H4sIAAAAAAAA..." }

// binary columns (`scripts/encode-columns.js` writes them)
{ "columns": {
    "t": { "dtype": "uint8",   "encoding": "gzip+base64", "data": "H4sI..." },
    "v": { "dtype": "float64", "encoding": "gzip+base64", "data": "H4sI..." }
} }

// from a CSV file, when composing a page: { "csvFile": "orders.csv" }