Skip to content

Basic Frame ​

A chart drawn on a <canvas> is one image to a screen reader. Its title, axis names, and legend are pixels, so nobody can read them. The basic frame gives each of those parts a node, in the order a sighted reader takes them in, before the data.

The frame wraps any other pattern. The last item holds the data, and the data can be a list, a tree, a dual tree, or a 2D grid.

Shape ​

Chart (root)
├── Title
├── Subtitle          (if there is one)
├── Y axis
├── X axis
├── Legend or labels (one per legend, or one for direct labels)
└── Data              (the only node with children)
    └── list, tree, dual tree, or grid
  • Enter on the root goes to the title. Left and Right move through the frame. The last item wraps back to the first.
  • Every frame item except Data is descriptive only. Enter does nothing there.
  • Enter on Data goes into the data, using whatever pattern is inside.
  • Backspace from anywhere in the frame goes back to the root.

Try it ​

The bubble chart has two legends, one for color and one for size. Each gets its own node. The stacked bar and line charts name their series with direct labels instead, so the labels get one node.

Chart

Text chat (works on touch screens)

Inspector (tree view)

Current node: none

How it is built ​

The frame option adds the root and the frame items around whatever else you build.

js
const structure = dataNavigator.structure({
    data: fruit,
    idKey: 'id',
    frame: {
        root: { id: 'chart', semantics: { label: alt } },
        elements: [
            { id: 'title', semantics: { label: 'Title: Fruit in the basket.' } },
            { id: 'subtitle', semantics: { label: 'Subtitle: Count of each fruit.' } },
            { id: 'y-axis', semantics: { label: 'Y axis: Count, 0 to 7.' } },
            { id: 'x-axis', semantics: { label: 'X axis: Fruit, 6 categories, Apples to Strawberries.' } }
        ]
        // no data node given, so the list's parent node is the last element
    },
    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: cities,
    idKey: 'id',
    frame: {
        root: { id: 'chart', semantics: { label: alt } },
        elements: [
            { id: 'title', semantics: { label: 'Title: Monthly temperature.' } },
            { id: 'subtitle', semantics: { label: 'Subtitle: Average in degrees Celsius.' } },
            { id: 'y-axis', semantics: { label: 'Y axis: Temperature, 0 to 30 degrees.' } },
            { id: 'x-axis', semantics: { label: 'X axis: Month, January to December.' } },
            { id: 'labels', semantics: { label: 'Line labels: New York, London, Sydney.' } }
        ]
    },
    dimensions: {
        values: [
            {
                dimensionKey: 'city',
                nodeId: 'cities',
                type: 'categorical',
                divisionOptions: { divisionNodeIds: (key, value) => `city-${slug(value)}` },
                behavior: { extents: 'circular', childmostNavigation: 'within' },
                navigationRules: { sibling_sibling: ['left', 'right'], parent_child: ['drill-out', 'drill-in'] }
            }
        ]
    }
});
js
const topToBottom = [...stacks].reverse();
const firstRow = division => Object.values(division.values)[0];
const structure = dataNavigator.structure({
    data: browsers,
    idKey: 'id',
    frame: {
        root: { id: 'chart', semantics: { label: alt } },
        elements: [
            { id: 'title', semantics: { label: 'Title: Browser market share.' } },
            { id: 'subtitle', semantics: { label: 'Subtitle: Percent of page views, 2015 to 2017.' } },
            { id: 'y-axis', semantics: { label: 'Y axis: Share, 0 to 100 percent.' } },
            { id: 'x-axis', semantics: { label: 'X axis: Year, 2015 to 2017.' } },
            {
                id: 'labels',
                semantics: { label: 'Browser labels: Chrome, Firefox, Safari, Edge, Other.' }
            }
        ],
        // with two dimensions, the data node holds both of them
        data: { id: 'data', semantics: { label: 'Data: 15 segments, grouped by year and by browser.' } }
    },
    dimensions: {
        values: [
            {
                dimensionKey: 'year',
                nodeId: 'years',
                type: 'categorical',
                divisionOptions: { divisionNodeIds: (key, value) => `year-${value}` },
                behavior: { extents: 'circular', childmostNavigation: 'across' },
                navigationRules: { sibling_sibling: ['left', 'right'], parent_child: ['to-year', 'drill-in'] }
            },
            {
                dimensionKey: 'browser',
                nodeId: 'browsers',
                type: 'categorical',
                divisionOptions: { divisionNodeIds: (key, value) => `browser-${value.toLowerCase()}` },
                operations: {
                    sortFunction: (a, b) =>
                        topToBottom.indexOf(firstRow(a).browser) - topToBottom.indexOf(firstRow(b).browser)
                },
                behavior: { extents: 'circular', childmostNavigation: 'across' },
                navigationRules: { sibling_sibling: ['up', 'down'], parent_child: ['to-browser', 'drill-in'] }
            }
        ]
    }
});
js
const structure = dataNavigator.structure({
    data: cars,
    idKey: 'id',
    frame: {
        root: { id: 'chart', semantics: { label: alt } },
        elements: [
            { id: 'title', semantics: { label: 'Title: Power and fuel economy.' } },
            { id: 'subtitle', semantics: { label: 'Subtitle: 60 cars from 1970 to 1982.' } },
            { id: 'y-axis', semantics: { label: 'Y axis: Miles per gallon, 10 to 50.' } },
            { id: 'x-axis', semantics: { label: 'X axis: Horsepower, 40 to 240.' } },
            {
                id: 'color-legend',
                semantics: { label: 'Legend, color: Origin. USA in blue, Europe and Japan in grey.' }
            },
            {
                id: 'size-legend',
                semantics: { label: 'Legend, size: Weight, 2,000 to 5,000 pounds. Bigger circles are heavier.' }
            }
        ]
    },
    spatialGrid: {
        xKey: 'horsepower',
        yKey: 'mpg',
        xExtent: [40, 240],
        yExtent: [10, 50],
        levels: [2],
        root: { id: 'data', edges: [] }
    }
});
OptionWhat it does
rootThe top node. Give it the chart's alt text as its label.
elementsThe descriptive items, in reading order. They never have children.
dataOptional. The last item. With two or more dimensions, it becomes their shared parent. Leave it out when the data already has one top node, like a single dimension or a grid.
behavior.extents'circular' (default) or 'terminal'.
navigationRulesSibling and parent rule names. Defaults: Left and Right, Enter and Backspace.

After building, structure.frame holds { rootId, elementIds, dataId }. The text chat starts at rootId by default.

Labels ​

Frame items say what they are, then what they say: Title: Fruit in the basket., Y axis: Count, 0 to 7., Legend, size: Weight, 2,000 to 5,000 pounds. Data says how much is inside: Data: 6 bars.

Focus indicators ​

NodeIndicator
RootThe whole chart
Title, subtitleA box around the text
Y axis, x axisA box around the axis line, ticks, and axis name
LegendA box around that legend
Direct labelsA box around all of the labels
DataThe plot area, or the bars

These boxes come from the canvas itself. The drawing helpers return the bounding box of every piece of text they draw, so the indicator fits what is on screen.

js
n.chart.spatialProperties = rectSpatial({ x: 6, y: 6, width: width - 12, height: height - 12 }, 0);
n.title.spatialProperties = rectSpatial(boxes.title, 4);
n.subtitle.spatialProperties = rectSpatial(boxes.subtitle, 4);
n['y-axis'].spatialProperties = rectSpatial(boxes.yAxis, 4);
n['x-axis'].spatialProperties = rectSpatial(boxes.xAxis, 4);
n['color-legend'].spatialProperties = rectSpatial(boxes.colorLegend.box, 4);
n['size-legend'].spatialProperties = rectSpatial(boxes.sizeLegend.box, 4);
n.data.spatialProperties = rectSpatial(boxes.plot, 4);
structure.spatialGrid.cellsByLevel.flat().forEach(id => {
    const { xExtent, yExtent } = n[id].data;
    const box = {
        x: x(xExtent[0]),
        y: y(yExtent[1]),
        width: x(xExtent[1]) - x(xExtent[0]),
        height: y(yExtent[0]) - y(yExtent[1])
    };
    n[id].spatialProperties = rectSpatial(box, 0);
});
cars.forEach(d => {
    n[d.id].spatialProperties = circleSpatial(dots[d.id].x, dots[d.id].y, dots[d.id].r);
});

Released under the MIT License.