Skip to Content
Getting started

Getting started

Build a causal graph interface from a dataset, then add the panels and interactions your application needs. CausalWorkspace supplies a complete viewer; CausalProvider lets you compose the pieces, and CausalEditor supplies authoring controls.

This guide uses the source workspace. You need Node.js 22.18 or later.

Install in an existing React 19 app

npm install @cytocausal/react@next cytoscape@3.31.0

Run the starter

git clone https://github.com/SonghaiFan/cytocausal.git cd cytocausal npm install npm run dev

Open http://localhost:3102 for a fictional coffee-shop model with two versions. Open http://localhost:3102/editor for the editable example.

Replace the model

Edit apps/starter/src/data.ts. A dataset contains snapshots; each snapshot has nodes and edges. Edges refer to node IDs, and can carry a positive or negative polarity.

import type { CausalDataset } from "@cytocausal/core"; export const dataset: CausalDataset = { id: "my-graph", snapshots: [ { id: "final", nodes: [ { id: "rain", label: "Rain" }, { id: "floods", label: "Floods" }, ], edges: [{ id: "rain-floods", source: "rain", target: "floods", polarity: "positive" }], }, ], };

CausalWorkspace displays validation issues in its sidebar. For CSV, spreadsheets and existing JSON, follow Bring your own data.

Choose an interface

Edit apps/starter/src/components/App.tsx to change the viewer.

What you needStart withRead next
A graph with search, details and analysis panelsCausalWorkspaceCompose an interface
Your own arrangement of graph and panelsCausalProvider and CausalGraphCompose panels
Node and relationship editingCausalEditorEditable graph
A specialised renderer integrationGraphViewReact lifecycle

Keep the starter’s browser-only loading boundary and give the graph container a height. Import @cytocausal/react/styles.css once; the editor also uses @cytocausal/react/editor.css.

Use document commands for application-driven edits, undo/redo and shared selection.

Continue with your task

The separate Cytoscape.js course teaches native graph APIs with standalone React and vanilla demos. You do not need to complete it before using Cytocausal. When adding native behaviour to the framework, use Extend with Cytoscape.js.

Repository setup and contribution details are in CONTRIBUTING.md . Check DATA.md  before reusing the application datasets.

Last updated on