Skip to content
matthewcm.dev

    ↑ ↓ move · ↵ open · tab scopeopen graph →

    Building a Graph Component Library

    Case study — designing and shipping a React network-graph library for several teams, and why rendering tech, API shape and Storybook mattered most.

    Growingcase studytended planted 3 min read
    On this page

    At Sky I led the design and delivery of a React component library for visualising networks: nodes, links, groupings, and the interactions people need to understand a network at a glance. Several teams and external clients were going to use it, which shaped almost every decision. This is what I learnt — patterns, not internals.

    The problem

    Teams were relying on a capable commercial graph library, but we wanted something we owned: themeable for different products, testable, and fast enough for large networks.

    Decision 1: choose a renderer you can trust, and benchmark it

    The biggest risk wasn’t features; it was scale. DOM and SVG rendering are pleasant to work with but fall over once you reach a few thousand nodes. Canvas gets you further, and WebGL keeps very large graphs interactive because the GPU does the heavy lifting.

    We benchmarked candidate libraries with generated graphs at 100, 1,000 and 10,000 nodes before writing product code. In the end we built on Cytoscape.js: it had a strong track record in scientific and data-science work, documentation packed with examples, and a rich plugin ecosystem (including geographic layouts with a mapping library).

    Decision 2: match the old API, then improve it

    To make adoption painless we kept the public API close to the library we were replacing. That let teams move screen by screen instead of all at once — progressive overload for a codebase.

    Decision 3: headless, compound components

    A library used by several products will never match any one product’s design, so we shipped behaviour with minimal styling and exposed composable parts — canvas, panels, zoom controls — plus events for selection and editing. More on that pattern in Headless Component Libraries.

    Decision 4: Storybook as the contract

    Every functional requirement got a story. Stakeholders could see progress without a demo meeting, developers could build features in isolation, and interaction tests ran against the same stories. Storybook became the shared definition of done.

    Designing it with the team that needed it most

    The team that relied on graphs most had the most at stake. A finished commercial product was a known quantity, and they rightly wanted to be sure an in-house build would fit their needs and arrive in time. So rather than present them with a finished plan, I brought them in:

    • Design sessions with their end users to choose an open-source foundation that met their expectations.
    • A statement of work with their exact requirements, so they could see precisely what they’d get.
    • Benchmarks instead of promises: the candidate compared against other graph libraries up front, and re-benchmarked at every iteration.

    That secured the budget and a team to build it, and that team became part of it: their own people became product owners and supporting developers, so every iteration was shaped by real needs. The first phase landed ahead of their external-facing demo, where they showcased their project with the new library built in. The people with the most at stake make the best co-designers: their questions are the requirements.

    What I’d do again

    • Benchmark the scary requirement first.
    • Make migration incremental by design, not by heroics.
    • Treat documentation and demos as part of the product, not an afterthought.

    What I’d do differently

    Rebuild it on Sigma.js. If I started again, I’d choose Sigma.js (with graphology underneath) over Cytoscape. Cytoscape was a defensible choice: proven in research, superb examples, plugins for almost everything. But Sigma’s WebGL renderer is vastly more performant, its documentation is strong, and I now have first-hand evidence it works: the graph view on this site runs on Sigma, with a force-directed layout settling in a web worker, and it stays smooth while staying cheap to load. Taking everything I learned the first time (benchmark first, headless parts, Storybook as the contract, an API close to what teams already use), I’d get the performance headroom from day one instead of designing around canvas limits.

    Decide earlier how the package and its Storybook live together. Keeping stories beside components is fastest for development, but you also want to test that the built package imports and renders correctly in a consuming app.

    • #graph-visualisation
    • #react
    • #webgl
    • #storybook
    • #component-libraries

    ↪ Links to (2)