Some of the numbers on a chart are final. Some are still arriving and may change. Some are estimated. A reader should be able to tell which is which without a caption, and a chart should draw them the same way every time.
dataState is one style key with three values: "settled","pending" and "projected". You say which data is in which state; each mark type draws that state in its own way, in the mark's own color. The looks are defaults: a theme can replace any of them.
States on bars
Set the state in a style rule. Settled months stay solid. The pending month is a grid of squares shaded from full strength at the bottom to faint at the top, and it pulses on a running chart. Projected months are the same grid, held still, inside a dashed outline.
Settled, pending and projected months
import { BarChart } from "semiotic" const frameProps = { /* --- Data --- */ data: months, /* --- Size --- */ height: 300, /* --- Layout --- */ barPadding: 36, /* --- Process --- */ valueAccessor: "orders", categoryAccessor: "month", /* --- Customize --- */ color: "#3366ff", /* --- Annotate --- */ frameProps: { legend: dataStateLegend({ color: BLUE }) }, /* --- Other --- */ styleRules: byState, description: "Orders by month. March to May are settled. June is pending. July and August are projected." } export default () => { return <BarChart {...frameProps} /> }
JSX
styleRules={[ { when: { field: "state", eq: "pending" }, style: { dataState: "pending" } }, { when: { field: "state", eq: "projected" }, style: { dataState: "projected" } }, ]}
What each mark draws
The state never changes a mark's color, so a projected series still reads as the series it continues.
| Mark | settled | pending | projected |
|---|
| Bars, areas, wedges, cells, nodes, regions | solid | shaded grid, pulsing | shaded grid, dashed outline |
| Lines | solid | faded | dashed |
| Points | filled | faint | light fill, dashed outline |
Pictograms, heat cells and candlesticks have no look for a state and are drawn as usual.
A line that becomes a projection
A line is one mark per series, so a rule cannot restyle part of it the way it restyles one bar. A rule on the x axis can: it names a position, and the chart splits each series there. Hover, the legend and the data table still treat each series as one.
Settled to week 8, projected after
import { LineChart } from "semiotic" const frameProps = { /* --- Data --- */ data: signups, /* --- Size --- */ height: 300, /* --- Layout --- */ lineBy: "plan", /* --- Process --- */ xAccessor: "week", yAccessor: "value", /* --- Customize --- */ colorBy: "plan", colorScheme: ["#3366ff","#1f7a8c"], legend: { legendGroups: [{ label: "", items: [{ label: "Settled", color: "var(--semiotic-text, #333)", dataState: "settled" }, { label: "Projected", color: "var(--semiotic-text, #333)", dataState: "projected" }], interactive: false, styleFn: () => ({}), type: (e79) => { let i84 = e79.dataState, l64 = d58?.[i84]; return l64 ? l64({ state: i84, mark: c64, color: n92, size: 16 }) : (function(e80, i85, l65) { return "line" === i85 ? (0, import_jsx_runtime21.jsx)("line", { x1: 0, y1: 8, x2: 16, y2: 8, stroke: l65, strokeWidth: 2, strokeOpacity: "pending" === e80 ? 0.5 : void 0, strokeDasharray: "projected" === e80 ? "4 4" : void 0 }) : "point" === i85 ? (0, import_jsx_runtime21.jsx)("circle", "projected" === e80 ? { cx: 8, cy: 8, r: 5, fill: l65, fillOpacity: 0.2, stroke: l65, strokeWidth: 1, strokeDasharray: "2 2" } : { cx: 8, cy: 8, r: 5, fill: l65, fillOpacity: "pending" === e80 ? 0.5 : void 0 }) : "pending" === e80 ? o29(l65) : "projected" === e80 ? (0, import_jsx_runtime21.jsxs)("g", { children: [ (0, import_jsx_runtime21.jsx)("rect", { x: 0.5, y: 0.5, width: 15, height: 15, fill: "none", stroke: l65, strokeWidth: 1, strokeDasharray: "4 4" }), o29(l65) ] }) : (0, import_jsx_runtime21.jsx)("rect", { width: 16, height: 16, fill: l65 }); })(i84, c64, n92); } }] }, /* --- Other --- */ styleRules: afterNow, description: "Weekly signups by plan. Lines are dashed from week 8 on, where they are projected." } export default () => { return <LineChart {...frameProps} /> }
JSX
<LineChart data={signups} xAccessor="week" yAccessor="value" lineBy="plan" colorBy="plan" // One rule on the x axis: each series is settled before week 8, projected after. styleRules={[{ when: { axis: "x", gte: 8 }, style: { dataState: "projected" } }]} legend={dataStateLegend({ states: ["settled", "projected"], mark: "line" })} description="Weekly signups by plan. Lines are dashed from week 8 on, where they are projected." />
The same rule splits an area: the fill becomes the shaded grid and its top line a dash.
An area, settled then projected
import { AreaChart } from "semiotic" const frameProps = { /* --- Data --- */ data: usage, /* --- Size --- */ height: 280, /* --- Process --- */ xAccessor: "week", yAccessor: "value", /* --- Customize --- */ color: "#b5446e", /* --- Other --- */ styleRules: afterNow, description: "Weekly usage. From week 8 on the area is projected, drawn as a shaded grid." } export default () => { return <AreaChart {...frameProps} /> }
Points, wedges and cells
Projected points are outlined; pending points are faint
import { Scatterplot } from "semiotic" const frameProps = { /* --- Data --- */ data: trials, /* --- Size --- */ height: 300, /* --- Process --- */ xAccessor: "spend", yAccessor: "signups", /* --- Customize --- */ pointRadius: 6, color: "#3366ff", /* --- Annotate --- */ frameProps: { legend: { legendGroups: [{ label: "", items: [{ label: "Settled", color: "#3366ff", dataState: "settled" }, { label: "Pending", color: "#3366ff", dataState: "pending" }, ... ], interactive: false, styleFn: () => ({}), type: (e79) => { let i84 = e79.dataState, l64 = d58?.[i84]; return l64 ? l64({ state: i84, mark: c64, color: n92, size: 16 }) : (function(e80, i85, l65) { return "line" === i85 ? (0, import_jsx_runtime21.jsx)("line", { x1: 0, y1: 8, x2: 16, y2: 8, stroke: l65, strokeWidth: 2, strokeOpacity: "pending" === e80 ? 0.5 : void 0, strokeDasharray: "projected" === e80 ? "4 4" : void 0 }) : "point" === i85 ? (0, import_jsx_runtime21.jsx)("circle", "projected" === e80 ? { cx: 8, cy: 8, r: 5, fill: l65, fillOpacity: 0.2, stroke: l65, strokeWidth: 1, strokeDasharray: "2 2" } : { cx: 8, cy: 8, r: 5, fill: l65, fillOpacity: "pending" === e80 ? 0.5 : void 0 }) : "pending" === e80 ? o29(l65) : "projected" === e80 ? (0, import_jsx_runtime21.jsxs)("g", { children: [ (0, import_jsx_runtime21.jsx)("rect", { x: 0.5, y: 0.5, width: 15, height: 15, fill: "none", stroke: l65, strokeWidth: 1, strokeDasharray: "4 4" }), o29(l65) ] }) : (0, import_jsx_runtime21.jsx)("rect", { width: 16, height: 16, fill: l65 }); })(i84, c64, n92); } }] } }, /* --- Other --- */ styleRules: byState, description: "Signups against spend. The two faint points are pending; the three outlined points are projected." } export default () => { return <Scatterplot {...frameProps} /> }
Shares of a total by state
import { DonutChart } from "semiotic" const frameProps = { /* --- Data --- */ data: pipeline, /* --- Size --- */ height: 300, /* --- Process --- */ valueAccessor: "value", categoryAccessor: "stage", /* --- Customize --- */ colorBy: "stage", colorScheme: ["#3366ff","#1f7a8c", ... ], /* --- Other --- */ styleRules: byState, description: "Sales pipeline: closed is settled, in review is pending, and the rest is projected." } export default () => { return <DonutChart {...frameProps} /> }
Capacity in use, being provisioned, and planned
import { Treemap } from "semiotic" const frameProps = { /* --- Data --- */ data: capacity, /* --- Size --- */ height: 300, /* --- Process --- */ valueAccessor: "value", /* --- Customize --- */ colorBy: "name", /* --- Other --- */ styleRules: byState, description: "Capacity by status. Provisioning is pending; the two planned blocks are projected." } export default () => { return <Treemap {...frameProps} /> }
When one chart wants something else
A state fills in what you did not say. Any key the rules set themselves wins, andfill is always the color the state is drawn in.
JSX
// Keys the rules set win over what the state implies. { style: { dataState: "projected", stroke: "none" } } // the grid, no outline { style: { dataState: "projected", strokeDasharray: "2 2" } } // your own dash { style: { dataState: "projected", fill: "#b5446e" } } // drawn in this color { style: { dataState: "pending", fillPattern: "grid" } } // your own texture // A later rule resets an earlier one. { when: { field: "audited", eq: true }, style: { dataState: "settled" } }
Supplying your own looks
A design system usually has its own way of drawing data that is not final. Give the theme adataStates table: for any state and mark type, a look made of the same keys the defaults use (a fill pattern, opacities, an outline in the mark's color, a dash, a point's size). Every chart under that theme draws it, on canvas, in static SVG and in renderChart, and keys a style rule sets still win.
JSX
import { ThemeProvider, useTheme, dataStateLegend } from "semiotic" // A look replaces the default for one state and one mark type (fill, line, // point); everything you leave out keeps the default. const looks = { pending: { fill: { fillPattern: { cell: "cross", pitch: 8, size: 6, opacity: { from: 1, to: 0.4, direction: "up" }, motion: true }, fillOpacity: 0.2, }, }, projected: { fill: { fillPattern: { cell: "triangle", pitch: 9, size: 6 }, fillOpacity: 0, stroke: "mark", strokeWidth: 1.5, strokeDasharray: "1 3" }, }, } function Chart() { const theme = useTheme() return ( <ThemeProvider theme={{ ...theme, dataStates: looks }}> <BarChart data={months} categoryAccessor="month" valueAccessor="orders" styleRules={byState} /> </ThemeProvider> ) } // Server renders take the same field: renderChart("BarChart", { ...props, theme: { dataStates: looks } })
A look's fill pattern can animate its cells itself: set motion: { amount: 0 }to switch off the built-in pulse, and a cell function receives the chart's clock as time (0 in static renders and under reduced motion). Pills and meters read CSS variables (--semiotic-data-state-pending-background and the like), so a page can restyle them to match.
Pending data moves, a little
On canvas a pending mark's grid pulses, redrawn about fifteen times a second. That is the only thing a state animates. It stops when the reader asks for reduced motion, when the chart is paused, and when the tab is hidden; a server render, a static export and a print draw the grid at rest. The texture is afill pattern, so fillPattern: "pulse"gives you the same look without the state, and motion on any pattern makes it pulse.
Giving the estimate room
The part of a time series that matters is often its shortest: the last few minutes, or the next hour. xZones on TemporalHistogram andRealtimeHistogram splits the time axis into zones that share the width by weight, not by span. Each zone picks its own bar size from a ladder, each bar reports its zone, and a rule can set a state by zone.
Three recorded hours and an estimated hour, sharing the axis
import { TemporalHistogram } from "semiotic" const frameProps = { /* --- Data --- */ data: requests, /* --- Size --- */ height: 300, /* --- Process --- */ timeAccessor: "time", valueAccessor: "value", binSize: [60000,300000, ... ], /* --- Realtime --- */ fill: "#1f7a8c", aggregation: "mean", /* --- Other --- */ xZones: [{ to: 1796043600000, label: "Recorded" }, { label: "Estimate", focus: true }], barWidth: 0.62, roundedTop: 6, styleRules: [{ when: { field: "zone", eq: "Estimate" }, style: { dataState: "projected" } }], description: "Requests per minute over four hours. The first three are recorded; the last hour is an estimate and is given most of the width." } export default () => { return <TemporalHistogram {...frameProps} /> }
JSX
<TemporalHistogram data={requests} timeAccessor="time" valueAccessor="value" aggregation="mean" // a rate: average the readings in each bar binSize={[1, 5, 10, 15, 30, 60].map((minutes) => minutes * 60_000)} xZones={[ { to: now, label: "Recorded" }, // most of the span ... { label: "Estimate", focus: true }, // ... and the hour that matters, given room ]} styleRules={[{ when: { field: "zone", eq: "Estimate" }, style: { dataState: "projected" } }]} />
A key for the states
dataStateLegend() returns a legend group that explains the looks. On charts with a legend prop (LineChart, Heatmap,ChoroplethMap and the realtime charts) it follows the chart's own legend. On the others, pass it as frameProps.legend, where it stands in for the legend. Either way it takes no part in legend hover or isolation, because a state is not a series. A theme with its own looks passes swatches to draw them.
JSX
import { dataStateLegend } from "semiotic" // Charts with a legend prop add the key after their own legend. <LineChart legend={dataStateLegend({ states: ["settled", "projected"], mark: "line" })} ... /> <TemporalHistogram legend={dataStateLegend()} ... /> // On other charts, pass it as the frame's legend. <BarChart frameProps={{ legend: dataStateLegend() }} ... /> <Scatterplot frameProps={{ legend: dataStateLegend({ mark: "point", labels: { pending: "In review" } }) }} ... /> // A theme with its own looks draws its own swatches. dataStateLegend({ swatches: { projected: ({ color, size }) => <rect width={size} height={size} fill="none" stroke={color} strokeDasharray="1 3" /> } })
Say it in words too
A texture or a dash is a look. A reader using a screen reader, or one who cannot tell the textures apart, needs the same fact in text: put it in description orsummary ("Bars after June are projected"). Theaccessibility audit warns when a chart sets a pending or projected state and has neither, and treats a pending state as motion the reader may want to stop.