Public
Edited
Mar 27, 2023
Insert cell
Insert cell
d3.bin().thresholds(15)(_.range(0, 10, 2))
Insert cell
d3.bin()(_.range(0.5, 10, 1))
Insert cell
data = _.range(0, 10, 1).map((x) => ({x, y: x + 0.1, z: "hi " + x, a: new Date()}))
Insert cell
data
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
data_to_sort = [
{x: 0, y: 0},
{x: 0, y: 1},
{x: 1, y: 0},
{x: 1, y: 1},
]
Insert cell
data_to_sort
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
// data2 = [{x: 3, y: 10}, {y: 20, z: "abc", w: undefined}]
data2 = [{x: 3}, {z: 10, w: "2022-01-22"}]
Insert cell
data2
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
chinook.db
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
dataTable[0]
Insert cell
spec = {
void(ticker)
const req = await fetch('https://api.observablehq.com/@joshuahhh/data-table-testing.js?v=3');
const text = await req.text();
// return prettyJs([...text.matchAll(new RegExp("function _dataTable[^\n]*\n([^\n]*)","gs"))][0][1])
// return text
// return prettyJs([...text.matchAll(new RegExp("__query(FileAttachment(\\\"chinook.db\\\"), (.*), invalidation)","gs"))][0][1])
return eval(`(${[...text.matchAll(new RegExp("__query\\(FileAttachment\\(\"chinook.db\"\\),(.*),invalidation\\)","gs"))][0][1]})`)
}
Insert cell
JSON.stringify(spec.filter, null, 2)
Insert cell
JSON.stringify(spec, null, 2)
Insert cell
ticker = {
// let i = 0;
// while (true) {
// yield Promises.delay(5000, ++i);
// }
}
Insert cell
prettyJs(`__query(data,{from:{table:"data"},sort:[],names:[],slice:{to:3,from:null},types:[{name:"x",type:"integer"},{name:"y",type:"number"}],filter:[{type:"eq",operands:[{type:"column",value:"x"},{type:"resolved",value:1}]},{type:"ne",operands:[{type:"column",value:"x"},{type:"resolved",value:2}]},{type:"lt",operands:[{type:"column",value:"x"},{type:"resolved",value:3}]},{type:"gt",operands:[{type:"column",value:"x"},{type:"resolved",value:4}]},{type:"lte",operands:[{type:"column",value:"x"},{type:"resolved",value:5}]},{type:"gte",operands:[{type:"column",value:"x"},{type:"resolved",value:6}]},{type:"in",operands:[{type:"column",value:"x"},{type:"resolved",value:"7"}]},{type:"nin",operands:[{type:"column",value:"x"},{type:"resolved",value:"8"}]},{type:"n",operands:[{type:"column",value:"x"}]},{type:"nn",operands:[{type:"column",value:"x"}]},{type:"v",operands:[{type:"column",value:"x"},{type:"resolved",value:"integer"}]},{type:"nv",operands:[{type:"column",value:"x"},{type:"resolved",value:"integer"}]},{type:"v",operands:[{type:"column",value:"y"},{type:"resolved",value:"number"}]},{type:"nv",operands:[{type:"column",value:"y"},{type:"resolved",value:"number"}]},{type:"eq",operands:[{type:"column",value:"z"},{type:"resolved",value:"\"is\""}]},{type:"ne",operands:[{type:"column",value:"z"},{type:"resolved",value:"\"is not\""}]},{type:"c",operands:[{type:"column",value:"z"},{type:"resolved",value:"\"contains\""}]},{type:"nc",operands:[{type:"column",value:"z"},{type:"resolved",value:"\"does not contain\""}]},{type:"v",operands:[{type:"column",value:"z"},{type:"resolved",value:"string"}]},{type:"nv",operands:[{type:"column",value:"z"},{type:"resolved",value:"string"}]}],select:{columns:["x","y","z"]}},invalidation,"data")`)
Insert cell
prettyJs = (await import('https://cdn.skypack.dev/pretty-js@0.2.2?min')).default
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more