Oligrapher is a JavaScript app for visualizing network graphs. It allows a user to design a nice-looking network graph using a combination of imported or manually entered data, and to create a collection of annotations for a graph.
Oligrapher was originally developed by LittleSis before it was separated into a standalone library. LittleSis has a large collection of maps created with Oligrapher.
Oligrapher is built with React and Redux and is bundled with esbuild
- easily create and display network graphs
- tell a story about networks with click-through series of annotations
- add images, labels, links, and captions
- customize graph layout by dragging nodes and edges
- import data from LittleSis and other APIs
- undo and redo edits to a graph
- runs on all modern web browsers
- export map as svg or jpeg
- save map to LittleSis.org account
To run Oligrapher app in a web page, include oligrapher.js and oligrapher.css on your page and create a element for the map:
<link rel="stylesheet" href="oligrapher.css">
<script src="oligrapher.js"></script>
<div id="example-oligrapher"></div>
<script>
const oli = new Oligrapher({ isEditor: true, domId: "example-oligrapher" })
</script>
See defaultState.ts for configuration options
To run this app in development mode:
git clone https://github.com/public-accountability/oligrapher
cd oligrapher
npm install
npm run dev
npm run serve
Then point your browser to localhost:8000 to view a blank graph.
Also available:
- example maps :
/exxon.html
&/dev.html
- larger map with annotations :
/dev.html
- map in embedded-mode using an inframe :
/article.html
Production build: npm run build
Development build: npm run build-dev
Build css: npx sass app/oligrapher.scss build/oligrapher.css --style=compressed
Run tests: npm test
id:
(required) a string uniquely identifying the nodename:
(required) a string, which will be displayed underneath the node (on multiple lines if necessary)scale:
relative size of node (1
is default and smallest)status:
default isnormal
, can also behighlighted
orfaded
color:
hexcodeof node colorimage:
image URL or dataurlurl:
optional source URLx:
x-coordinate of the node's positiony:
y-coordinate of the node's positionedgeIds
array of connected edges, calculated internally
id:
(required) an integer or string uniquely identifying the edgenode1_id:
(required) equal to the first node's idnode2_id:
(required) equal to the second node's idlabel:
(required) label appearing above the edgeurl:
optional source URLscale:
relative thickness of edge (1
is default,2
is twice as thick, etc)status:
default isnormal
, can also behighlighted
orfaded
arrow:
Direction of the arrow:'left', 'right', 'both' or false
(default isfalse
)dash:
the kind of dash displayed in edge's line (default isnull
, a solid line)cx:
x-coordinate of the control point for the edge's quadratic Bezier curve, relative to the midpoint of the straight line between the two nodes (if not specified, this is computed to display a slight curve)cy:
y-coordinate of the control point for the edge's quadratic Bezier curve, relative to the midpoint of the straight line between the two nodes (if not specified, this is computed to display a slight curve)
id:
(required) an integer or string uniquely identifying the captiontext:
(required) the caption's text contentx:
x-coordinate of the caption's positiony:
y-coordinate of the caption's positionsize:
caption font-sizefont:
caption font-familyweight:
caption font-weight
The annotations
array should conforms to the following schema:
[
{
header: "The Revolving Door",
text: "Goldman Sachs has many former executives with top positions in the federal government.",
nodeIds: [...],
edgeIds: [...],
captionIds: [...]
},
{
header: "Treasury Department",
text: "Former Treasury Secretary Robert Rubin was co-chair of Goldman before joining the Clinton Administration in 1993." ,
nodeIds: [...],
edgeIds: [...],
captionIds: []
},
...
]
header:
(required) a header to be displayed above the annotationtext:
(required) the text body of the annotation, with optional HTML markupnodeIds:
(required) an array of ids of nodes to highlight from the underlying graph (can be empty)edgeIds:
(required) an array of ids of edges to highlight from the underlying graph (can be empty)captionIds:
(required) an array of ids of captions to highlight from the underlying graph (can be empty)
If no node, edge, or captions are highlighted, the graph will have its normal appearance when viewing the annotation. If there are highlights, non-highlighted content will appear faded.