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.
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
↩ Linked from (9)
Shift Left Testing · Removing Secrets from Git History · Building a Graph Component Library
These notes were the groundwork for an in-house network graph library — the full story is in Building a Graph Component Library, and the API design lessons in Headless Component Libraries. Storybook became the place wher…
- Headless Component LibrariesGrowing
…ed, when three products are using the same library and nobody has forked it. I learnt this most clearly while Building a Graph Component Library.
- Pathways into CybercrimeGrowing
…s benchmarking graph renderers and building an in-house network graph library (Graph Visualisation Libraries, Building a Graph Component Library). Now I build real-time data interfaces for a living. The problems are diff…
When I replaced a commercial graph library with our own, we didn't swap it in one release. We matched the old API closely enough that screens could move across one at a time — see the case study.
- Social Network AnalysisGrowing
…regation of parallel edges, and a renderer that copes with thousands of nodes (Graph Visualisation Libraries, Building a Graph Component Library). Graph thinking is one of the most portable skills I have.
- StorybookGrowing
…n-house network graph library, where it was the docs, the demo and the test harness at once — the story is in Building a Graph Component Library. The design principles that make components story-friendly are in Headless…
…ick the platform up. The habit outlasted the project: the design sessions with end users for a graph library (Building a Graph Component Library), schemas shaped around how domain experts think (Keep the UI Dumb: Let Dom…
…twork logic of each use case was core and belonged with the teams who understood it. The same thinking shaped Building a Graph Component Library: we built in-house only once it was clear the capability was specific enoug…
↪ Links to (2)
Related by topic
- Growingcase study
Smart TV Apps on Low-End Devices
Frontend craft - Seedcase study
Making Room for Career-Changers
Career - Seed
Prototype or Product? Scoping a Request Honestly
Career - Seed
requestAnimationFrame and High Refresh Rates
Frontend craft