import { StreamOrdinalFrame } from "semiotic" const colors = { Democratic: 4, Republican: 1, "Democratic-Republican": 2, Whig: 3 } const theme = ["#ac58e5","#E0488B","#9fd0cb","#e0d33a","#7566ff","#533f82","#7a255d","#365350","#a19a11","#3f4482"] const frameProps = { /* --- Data --- */ data: [{ name: "George Washington", start: 1789, end: 1797, party: "None" }, { name: "John Adams", start: 1797, end: 1801, party: "Federalist" }, ... ], chartType: "timeline", /* --- Size --- */ size: [900,800], margin: { left: 200, top: 40, bottom: 50, right: 20 }, /* --- Layout --- */ projection: "horizontal", barPadding: 2, /* --- Process --- */ oAccessor: "name", rAccessor: (d12) => [d12.start, d12.end], /* --- Customize --- */ pieceStyle: d => ({ fill: theme[colors[d.party] || 0], stroke: theme[(colors[d.party] || 0) + 5] }), title: "U.S. Presidential Terms", showAxes: true, foregroundGraphics: Object.keys(colors) .concat(["Other"]) .map((d, i) => ( <text key={d} x={700} y={i * 20 + 60}> <tspan fontSize="20" fill={theme[colors[d] || 0]}> ● </tspan>{" "} {d} </text> )), /* --- Annotate --- */ oLabel: true } export default () => { return <StreamOrdinalFrame {...frameProps} /> }