Spatial Plus
Spatial plus is 2D spatial navigation with one category added. Use it for a scatterplot colored by group.
Each data point belongs to three groups at once: an x range, a y range, and a category. That gives three ways to move from any point.
| Keys | Moves through | Question it answers |
|---|---|---|
| ← → | Every point, in x order | "What is next along the x axis?" |
| ↓ ↑ | Every point, in y order | "What is next along the y axis?" |
| [ ] | Points in the same category | "What else is in this group?" |
The iris chart is the pre-built scatterplot from the Skeleton app, exported in full. It uses the same rule names, keys, and settings an author made in Skeleton's editor.
Shape
Root
├── Species [ ] W goes up here
│ ├── setosa
│ ├── versicolor
│ └── virginica
├── Sepal length ← → J goes up here
│ ├── 4.7 to 5.18
│ └── ...
└── Petal length ↓ ↑ \ goes up here
├── 1 to 2
└── ...
(all three trees share the same 15 flowers)The three top-level groups sit side by side. Left and Right move between them, and the last wraps to the first (level1Options.behavior.extents: 'circular').
Try it
Text chat (works on touch screens)
Inspector (tree view)
Current node: none
How it is built
Three dimensions under one root. The category uses childmostNavigation: 'within', so [ and ] step through one species at a time. The numbers use extents: 'bridgedCousins', so the arrow keys keep going from one range into the next.
// The Skeleton app's pre-built scatterplot, as exported.
const structure = dataNavigator.structure({
data: iris,
idKey: 'pt',
dimensions: {
parentOptions: {
addLevel0: { id: 'root', edges: [] },
level1Options: {
order: ['species', 'sepal_length', 'petal_length'],
behavior: { extents: 'circular' },
navigationRules: {
sibling_sibling: ['left', 'right'],
parent_child: ['drill in', 'drill out to species']
}
}
},
values: [
{
dimensionKey: 'species',
nodeId: 'species',
type: 'categorical',
divisionOptions: { divisionNodeIds: (key, value) => `species-${value}` },
behavior: { extents: 'circular', childmostNavigation: 'within' },
operations: { compressSparseDivisions: true },
navigationRules: {
sibling_sibling: ['backward', 'forward'],
parent_child: ['drill in', 'drill out to species']
}
},
{
dimensionKey: 'sepal_length',
nodeId: 'sepal_length',
type: 'numerical',
divisionOptions: { divisionNodeIds: (key, value) => `sepal-${Math.round(value * 100)}` },
behavior: { extents: 'bridgedCousins', childmostNavigation: 'within' },
operations: { compressSparseDivisions: true, createNumericalSubdivisions: 5 },
navigationRules: {
sibling_sibling: ['left', 'right'],
parent_child: ['drill in', 'drill out to sepal_length']
}
},
{
dimensionKey: 'petal_length',
nodeId: 'petal_length',
type: 'numerical',
divisionOptions: { divisionNodeIds: (key, value) => `petal-${Math.round(value * 100)}` },
behavior: { extents: 'bridgedCousins', childmostNavigation: 'within' },
operations: { compressSparseDivisions: true, createNumericalSubdivisions: 5 },
navigationRules: {
sibling_sibling: ['down', 'up'],
parent_child: ['drill in', 'drill out to petal_length']
}
}
]
},
navigationRules: {
backward: { key: 'BracketLeft', direction: 'source' },
forward: { key: 'BracketRight', direction: 'target' },
left: { key: 'ArrowLeft', direction: 'source' },
right: { key: 'ArrowRight', direction: 'target' },
down: { key: 'ArrowDown', direction: 'source' },
up: { key: 'ArrowUp', direction: 'target' },
'drill in': { key: 'Enter', direction: 'target' },
'drill out to species': { key: 'KeyW', direction: 'source' },
'drill out to sepal_length': { key: 'KeyJ', direction: 'source' },
'drill out to petal_length': { key: 'Backslash', direction: 'source' }
}
});const structure = dataNavigator.structure({
data: cars,
idKey: 'id',
dimensions: {
parentOptions: {
addLevel0: { id: 'chart', edges: [] },
level1Options: { order: ['origin', 'horsepower', 'mpg'], behavior: { extents: 'circular' } }
},
values: [
{
dimensionKey: 'origin',
nodeId: 'origin',
type: 'categorical',
divisionOptions: { divisionNodeIds: (key, value) => `origin-${value.toLowerCase()}` },
behavior: { extents: 'circular', childmostNavigation: 'within' },
navigationRules: {
sibling_sibling: ['backward', 'forward'],
parent_child: ['to-origin', 'drill-in']
}
},
{
dimensionKey: 'horsepower',
nodeId: 'horsepower',
type: 'numerical',
operations: { createNumericalSubdivisions: 4 },
divisionOptions: { divisionNodeIds: (key, value) => `hp-${Math.round(value)}` },
behavior: { extents: 'bridgedCousins', childmostNavigation: 'within' },
navigationRules: {
sibling_sibling: ['left', 'right'],
parent_child: ['to-horsepower', 'drill-in']
}
},
{
dimensionKey: 'mpg',
nodeId: 'mpg',
type: 'numerical',
operations: { createNumericalSubdivisions: 4 },
divisionOptions: { divisionNodeIds: (key, value) => `mpg-${Math.round(value)}` },
behavior: { extents: 'bridgedCousins', childmostNavigation: 'within' },
navigationRules: { sibling_sibling: ['down', 'up'], parent_child: ['to-mpg', 'drill-in'] }
}
]
},
navigationRules: {
backward: { key: 'BracketLeft', direction: 'source' },
forward: { key: 'BracketRight', direction: 'target' },
left: { key: 'ArrowLeft', direction: 'source' },
right: { key: 'ArrowRight', direction: 'target' },
down: { key: 'ArrowDown', direction: 'source' },
up: { key: 'ArrowUp', direction: 'target' },
'drill-in': { key: 'Enter', direction: 'target' },
'drill-out': { key: 'Backspace', direction: 'source' },
'to-origin': { key: 'KeyW', direction: 'source' },
'to-horsepower': { key: 'KeyJ', direction: 'source' },
'to-mpg': { key: 'Backslash', direction: 'source' }
}
});Things to notice in the Skeleton export:
- Every rule is named and keyed by hand. The top-level
navigationRuleslists all of them, so nothing is assigned automatically. - Rule names can be plain language.
'drill out to species'is a valid name. The text chat accepts it as a command, and it reads well in the help list. - Up and Down point the right way. Ranges are stored low to high, so
upusesdirection: 'target'to move toward higher petal lengths. compressSparseDivisions: trueis on for every dimension. It only takes effect if every group would hold one point, which keeps tiny datasets from having pointless levels.
Labels
Scatterplot points name both numbers, since two bare numbers are easy to mix up. The category comes last: Sepal 5.1, petal 1.4, setosa. See Text Labels for an expert option that drops the names.
const n = structure.nodes;
n.root.semantics = {
label: 'Iris: sepal length vs petal length. Scatter plot. 3 groupings: species, sepal length, petal length.'
};
n.species.semantics = { label: 'Species. 3 groups.' };
n.sepal_length.semantics = { label: 'Sepal length. 5 ranges, 4.7 to 7.1 cm.' };
n.petal_length.semantics = { label: 'Petal length. 5 ranges, 1 to 6 cm.' };
species.forEach(s => {
n[`species-${s}`].semantics = { label: `${s}. 5 flowers.` };
});
[
['sepal_length', 'Sepal'],
['petal_length', 'Petal']
].forEach(([key, name]) => {
Object.values(structure.dimensions[key].divisions).forEach(div => {
const [lo, hi] = div.numericalExtents.map(r2);
n[div.id].semantics = {
label: `${name} ${lo} to ${hi} cm. ${Object.keys(div.values).length} flower${Object.keys(div.values).length === 1 ? '' : 's'}.`
};
});
});
iris.forEach(d => {
n[d.pt].semantics = { label: `Sepal ${d.sepal_length}, petal ${d.petal_length}, ${d.species}` };
});Focus indicators
| Node | Indicator |
|---|---|
| Flower or car | Circle on the dot |
| Species or origin | Convex hull around the group's dots (convexHullOfCircles) |
| x range | Vertical band across the plot |
| y range | Horizontal band across the plot |
| Species dimension | The species names (iris), or the color legend (cars) |
| x and y dimensions | The x axis and the y axis |
| Root | The whole plot |
The hulls tell you something about the data. Iris species barely overlap, so their hulls are separate. Car origins overlap a lot, so their hulls pile on top of each other.
n.root.spatialProperties = rectSpatial(boxes.plot, 16);
n.species.spatialProperties = rectSpatial(boxes.labels, 4);
n.sepal_length.spatialProperties = rectSpatial(boxes.xAxis, 4);
n.petal_length.spatialProperties = rectSpatial(boxes.yAxis, 4);
species.forEach(s => {
const set = iris.filter(d => d.species === s).map(d => dots[d.pt]);
const box = unionBox(set.map(c => ({ x: c.x - 16, y: c.y - 16, width: 32, height: 32 })));
n[`species-${s}`].spatialProperties = spatial(box, convexHullOfCircles(set, 10));
});
Object.values(structure.dimensions.sepal_length.divisions).forEach(div => {
n[div.id].spatialProperties = rectSpatial(rangeStripe(x, div.numericalExtents, 'x', boxes.plot), 0);
});
Object.values(structure.dimensions.petal_length.divisions).forEach(div => {
n[div.id].spatialProperties = rectSpatial(rangeStripe(y, div.numericalExtents, 'y', boxes.plot), 0);
});
iris.forEach(d => {
n[d.pt].spatialProperties = circleSpatial(dots[d.pt].x, dots[d.pt].y, dots[d.pt].r);
});