List
The list is the simplest pattern. One parent node holds every data point.
Use it for small charts with one dimension and only a few marks: a bar chart, a pie chart, or a chart with a single line.
Shape
Fruit (the one parent node)
├── 5, Apples
├── 3, Pears
├── 4, Nectarines
├── 2, Plums
├── 4, Grapes
└── 6, Strawberries- There is one node above the data. There is no extra root and no group level in between.
- Moving past the last item loops back to the first (
extents: 'circular'). - The chart's orientation picks the arrow keys. Bars laid out left to right use Left and Right. Bars stacked top to bottom use Up and Down.
Try it
Press Enter navigation area under the chart, or type enter in the text chat. Then use the keys in the table.
Text chat (works on touch screens)
Inspector (tree view)
Current node: none
How it is built
One categorical dimension makes the parent node and one division per value. Since every division holds a single data point, compressSparseDivisions: true removes the division level. The parent node then leads straight to the data points.
const structure = dataNavigator.structure({
data: fruit,
idKey: 'id',
dimensions: {
values: [
{
dimensionKey: 'fruit',
nodeId: 'fruit',
type: 'categorical',
behavior: { extents: 'circular' },
operations: { compressSparseDivisions: true },
navigationRules: {
sibling_sibling: ['left', 'right'],
parent_child: ['drill-out', 'drill-in']
}
}
]
}
});const structure = dataNavigator.structure({
data: fruit,
idKey: 'id',
dimensions: {
values: [
{
dimensionKey: 'fruit',
nodeId: 'fruit',
type: 'categorical',
behavior: { extents: 'circular' },
operations: { compressSparseDivisions: true },
navigationRules: {
// vertical layout, so Up and Down walk the list
sibling_sibling: ['up', 'down'],
parent_child: ['drill-out', 'drill-in']
}
}
]
}
});const structure = dataNavigator.structure({
data: sorted,
idKey: 'id',
dimensions: {
values: [
{
dimensionKey: 'fruit',
nodeId: 'fruit',
type: 'categorical',
behavior: { extents: 'circular' },
operations: { compressSparseDivisions: true },
navigationRules: {
sibling_sibling: ['left', 'right'],
parent_child: ['drill-out', 'drill-in']
}
}
]
}
});const structure = dataNavigator.structure({
data: seattleMonthly,
idKey: 'id',
dimensions: {
values: [
{
dimensionKey: 'month',
nodeId: 'line',
type: 'categorical',
behavior: { extents: 'circular' },
operations: { compressSparseDivisions: true },
navigationRules: {
sibling_sibling: ['left', 'right'],
parent_child: ['drill-out', 'drill-in']
}
}
]
}
});The only real difference is sibling_sibling. The horizontal bar chart uses ['up', 'down'] because its bars run top to bottom.
Labels
Lead with the number, then name the thing: 5, Apples. The parent node says what the group is and how many items it holds. See Text Labels for more.
structure.nodes.fruit.semantics = { label: 'Fruit. 6 bars, Apples to Strawberries.' };
fruit.forEach(d => {
structure.nodes[d.id].semantics = { label: `${d.count}, ${d.fruit}` };
});structure.nodes.line.semantics = { label: 'Seattle daily high. 12 months, 8.2 to 26.1 degrees.' };
seattleMonthly.forEach(d => {
structure.nodes[d.id].semantics = { label: `${d.high} degrees, ${d.month}` };
});Focus indicators
Each node gets a spatialProperties.path, drawn over the canvas when the node has focus. The shape follows the mark.
| Chart | Data point | Parent node |
|---|---|---|
| Vertical bar | Box around the bar | Box around all bars |
| Horizontal bar | Box around the bar | Box around all bars |
| Pie | Outline of the arc | Circle around the pie |
| Single line | Circle on the point | Band that follows the line |
structure.nodes.fruit.spatialProperties = circleSpatial(cx, cy, r, 6);
sorted.forEach(d => {
const [a0, a1] = slices[d.id];
structure.nodes[d.id].spatialProperties = arcSpatial(cx, cy, 0, r, a0, a1);
});const band = offsetLinePath(points, 8);
structure.nodes.line.spatialProperties = spatial(pointsBox(points), band);
points.forEach(p => {
structure.nodes[p.id].spatialProperties = circleSpatial(p.x, p.y, 4);
});Keyboard and text chat share one position, so there is only ever one outline on the chart.
Source
- Chart modules: list-bar.js, list-hbar.js, list-pie.js, list-line.js
- Shared wiring for keyboard, text chat, and the inspector: mount.js