Skip to content

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.

Chart

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.

js
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']
                }
            }
        ]
    }
});
js
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']
                }
            }
        ]
    }
});
js
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']
                }
            }
        ]
    }
});
js
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.

js
structure.nodes.fruit.semantics = { label: 'Fruit. 6 bars, Apples to Strawberries.' };
fruit.forEach(d => {
    structure.nodes[d.id].semantics = { label: `${d.count}, ${d.fruit}` };
});
js
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.

ChartData pointParent node
Vertical barBox around the barBox around all bars
Horizontal barBox around the barBox around all bars
PieOutline of the arcCircle around the pie
Single lineCircle on the pointBand that follows the line
js
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);
});
js
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 ​

Released under the MIT License.