The .gph document
setDocument() accepts the same .gph project used by the workbench and
Python package. Pass the parsed object:
const project = await fetch("/network.gph").then((response) => response.json());await graph.setDocument(project);Project shape
Section titled “Project shape”interface Gph { info: { version: 1; name?: string; created?: string; }; datasets: Array<{ id: string; graph: NodeLinkData; }>; config: { version: number; layout?: "force" | "levels" | "geo"; bindings?: Binding[]; filterStack?: Filter[]; embed?: { tooltip?: { template?: string } }; [key: string]: unknown; };}Older projects may contain "quality"; the loader accepts it as a compatibility
alias for "force", but new projects should emit "force".
The project may also contain positions, saved sets, history, and a story. The embed applies the same validated project-loading path as the workbench.
A saved view’s Group by (config.current.state.structure.groups) needs one to
four levels, each a node field that some node has a value for or a
categorical node algorithm written as a binding source is
({"kind": "algorithm", "id": "connected_components"} draws one ring per
connected component), or null for nested Louvain. When it has no levels,
names a field no node has, or names an algorithm that does not give nodes
categories, the
network opens without rings: setDocument resolves with a warning that says
why (see Skipped parts of a document),
and the browser console says so too. garphield validate and
garphield-mcp validate report both.
Node-link data
Section titled “Node-link data”{ "directed": true, "multigraph": false, "graph": { "title": "Dependencies" }, "nodes": [ { "id": "parser", "label": "Parser", "team": "core" }, { "id": "renderer", "label": "Renderer", "team": "visuals" } ], "links": [ { "source": "parser", "target": "renderer", "weight": 2 } ]}Node and edge attributes become fields in the visual source catalogue.
Visual configuration
Section titled “Visual configuration”Bindings connect a source to a visual channel:
{ "version": 1, "layout": "force", "bindings": [ { "channel": "color", "source": { "kind": "field", "id": "field:team" }, "resultType": "cat" }, { "channel": "size", "source": { "kind": "algorithm", "id": "degree" }, "resultType": "num" } ]}Build the document in the workbench, with Project.from_pandas() or
Project.from_networkx(), or against the published
GPH schema. See the
Binding grammar for every channel, result
type, source kind, and the field: id rule.
Popover template
Section titled “Popover template”config.embed.tooltip.template sets what the embed’s node popover shows (turn
the popover on with chrome=tooltip; see
Choose UI components). It is a small, safe
Markdown template rendered once per node:
{ "embed": { "tooltip": { "template": "### {title}\n`{label}` in **{area}**, {status} on {date}.\n\n[Read the decision]({url})" } }}{field}inserts that node attribute as plain text. Values are never read as Markdown, so data can’t add links, formatting or images. Write\{for a literal brace.{@id}and{@degree}insert the node’s id and degree.{@fields}on its own line shows a grid of the node’s attributes, bound fields first: the first six, then a “N more” button that shows the rest in the card. Position and drawing attributes, the label, URLs, lists, objects and values over 120 characters are left out.- Supported Markdown: headings, paragraphs, line breaks,
**bold**,*italic*,`code`, links, one level of-or1.lists, and images. Raw HTML and other Markdown show as typed. - The first heading becomes the card’s title. A leading image becomes a cover;
give it the title
"thumb"() for a small thumbnail instead. A last line of only links becomes the card’s footer. - In a link or image URL, a placeholder that starts the URL (
[Open]({url})) inserts the attribute as a whole URL. Anywhere else the value is percent-encoded, so it cannot change the URL around it: in the query&,=and#are encoded, in the path only/and@are kept, and a value in the host that would move the URL to another host removes the link or image. A value that is already percent-encoded is encoded again. - An image loads as soon as its card opens, so an image URL with a
placeholder inside it, such as
, is drawn only from the page’s own origin or a public image host:upload.wikimedia.org,i.scdn.co,media.pitchfork.com,avatars.githubusercontent.com,i.imgur.comand OpenStreetMap tiles. Elsewhere, put the whole image URL in one field and write.garphield_validatewarns about such templates (TEMPLATE_SENDS_FIELDS). - Graphs opened from
garphield_sharelinks (their URLs includeimages=safe) draw images, node images included, only from Garphield, the document’s own server, those public hosts anddata:URLs, since an agent may have written the document. PNG exports follow the same rule and name the hosts they skipped. - Only
http:,https:andmailto:links andhttp:/https:images are kept. A link or image whose URL is empty or unsafe is removed, and a line whose placeholders are all empty is dropped. - Numbers show at most three decimals, with grouping. Years show without it
(1948, not 1,948): a field named
year,founded,born,establishedor ending in_year, or one whose values are all whole numbers from 1000 to 2999.
Without a template the card shows the node’s label, its fields (as
{@fields} does) and a link to its url attribute, if it has one.
Link cards
Section titled “Link cards”config.embed.tooltip.linkTemplate gives the embed’s links a hover card,
written in the same template language over the link’s attributes:
{ "embed": { "tooltip": { "linkTemplate": "### {source} to {target}\n{tasks} tasks\n{@markdown changes}" } }}{source}and{target}insert the labels of the link’s two nodes, and{label}the link’slabelattribute (or “source → target”).{@id}is the link’s key;{@degree}is empty.- A line of only
{@markdown field}renders that attribute’s own Markdown: paragraphs,-and1.lists,**bold**,*italic*and`code`. Links, images, headings and braces in the value show as typed. This works in node templates too. - A long card scrolls inside its own height.
Without a link template, links get no card. Set either template with
garphield_style (tooltipTemplate, linkTooltipTemplate; null clears one)
or the CLI (--tooltip, --link-tooltip; none clears one).
Merged node labels
Section titled “Merged node labels”While a merge is on (view.merge, the driver’s setMerge), cards on merged
nodes and links use the templates above over the merged fields, and a merged
node’s label comes from the merge’s own label template. It is plain text,
one line, with three placeholders:
{field}inserts the merged node’s value of that field: a sum for numbers, the most common value for categories, or what the merge’scombinerule for the field says.{members}inserts how many nodes the merged node holds.{field by other}inserts its members’ values offield, one for each value ofother, in the order the members first show it, joined with “ → “. Each value combines the members with that value ofotherby the field’s rule. A value ofothernone of whose members hasfieldshows “–”, and members withoutotherare left out. A node whose members share one value ofothershows that one value.
The task reallocation gallery merges by role with
"{role} {tasks by side}": a role with 31 tasks before AI and 29 now reads
“Engineers 31 → 29”, and new work, only on the before side, reads
“Nobody: new work 68”. Without a label, a merged node is labelled with its
by values.