@mk7s/holochart-traces-graph
Classes
| Class | Description |
|---|---|
| GraphLayoutWorker | A layout worker and the requests sent to it. Most callers use the shared one through layoutInWorker; make your own for a worker that serves one chart and ends with it. |
Interfaces
| Interface | Description |
|---|---|
| AdjacencyMatrix | A graph as a matrix: the x, y and z of a heatmap trace. |
| AdjacencyMatrixOptions | Options of fromAdjacencyMatrix. |
| AdjacencyOptions | Options of adjacencyMatrix. |
| ArcLayoutOptions | Options of arcLayout. Lengths are layout units (CSS px). |
| ArcLayoutResult | What arcLayout returns: the positions and routes, and the order it chose. |
| BundleGraph | The links and, for hierarchical bundling, the hierarchy. A LayoutGraph fits. |
| BundleOptions | Options of bundleLinks: the method, the shared strength, and the options of both methods (each reads its own and ignores the other's). |
| BundlePositions | Node centers, as a LayoutResult has them. The number of nodes is the length of the arrays. |
| BundleResult | What bundleLinks returns. |
| BundleSpace | The space links are bundled in: positions in it are (v − origin) × scale of the calc's linear coordinates, per axis. A computed arrangement is in layout units, a px each, and is bundled as it is. Positions that are data ('preset') may be anything on either axis, dates against counts: they are bundled as they will be drawn, an estimate of their px in the plot area, so that the angles and lengths the bundling compares are the ones on screen. |
| ChordArc | The arc of one node. |
| ChordCalc | Calcdata of a chord trace. |
| ChordGroupArc | The arc of one group, around the arcs of its nodes. |
| ChordLayout | - |
| ChordLayoutInput | What chordLayout lays out. |
| ChordLayoutOptions | - |
| ChordRibbon | The ribbon of one link: a span of its source's arc and a span of its target's. |
| ChordTraceGroups | The outer ring of node.group: one arc around the nodes of every group, with its name. |
| ChordTraceGroupsTextfont | Font of the group labels, drawn across the radius outside the group arcs. Default: textfont, bold. |
| ChordTraceLink | The links: ribbons between the arcs. |
| ChordTraceNode | The nodes: arcs of the ring. |
| ChordTraceNodeLine | Outlines of the node arcs. |
| ChordTraceTextfont | Font of the node labels. Default: layout.font. |
| CircularOptions | Options of circularLayout. |
| CommunityOptions | Options of louvain and modularity. |
| Components | The connected components of a graph. |
| Degrees | Degrees of every node. |
| DendrogramOptions | Options of dendrogramLayout. Lengths are layout units (CSS px). |
| DendrogramResult | What dendrogramLayout returns. |
| EdgeListOptions | Options of fromEdgeList. |
| EncodedLayoutResult | A LayoutResult, or what a layout returns on top of one (order, hidden, valueAxis, …), ready to post: fields holds every property that is not a list of routes (typed arrays, which are transferred, and plain values, which are cloned), routes every list of routes by property name (routes, a tree's parentRoutes). |
| EncodedRoutes | A list of routes as three arrays: route k is kind[k] (0: none, the link is straight; 1: a polyline; 2: a spline) and its points are points[start[k] … start[k + 1]). |
| ForceBundleOptions | Options of forceBundle. |
| ForceBundleResult | What forceBundle returns. |
| ForceOptions | - |
| ForceStart | Positions a force layout goes on from, one per node (NaN: none), and how warm it is there. |
| Graph3dCalc | - |
| Graph3dPlanes | The planes of arrangement: 'layered'. |
| Graph3dTraceForce | Options of the force layout in three dimensions: of arrangement: 'force', and of the nodes within their planes with 'layered' (where linkdistance defaults to layered.ranksep). Lengths are layout units. |
| Graph3dTraceHighlight | Highlighting: the neighbourhood of the node or link under the pointer (or of highlight.nodes), and a shortest path between the two nodes of highlight.path. What is highlighted keeps its look, its label shows even where there was no room for it, and everything else is dimmed; only colors change. A hover comes first, then highlight.nodes, then a path. |
| Graph3dTraceLayered | The layout of arrangement: 'layered': cycles are broken as in the 2D layered layout (the reversed links keep their direction in the drawing), every node gets a rank, each rank is a plane, and the nodes of a plane are spread by the force layout (force) with their coordinate along axis held. |
| Graph3dTraceLink | The links. |
| Graph3dTraceLinkArrow | Arrowheads, as cones. Their tips stop at the node's surface, whatever its size. |
| Graph3dTraceNode | The nodes. |
| Graph3dTraceNodeLine | Outlines of the nodes (node.render: 'sprite' only). |
| GraphBundle | What calc knows of the bundling of a trace's links. |
| GraphCalc | - |
| GraphData | What an adapter returns. |
| GraphForce | What force.simulate needs to run the layout of a calc again, step by step. |
| GraphGuides | Lines an arrangement draws behind the graph (the axes of a hive plot) and their names. |
| GraphLayoutWorkerOptions | Options of a GraphLayoutWorker. |
| GraphLike | Anything with nodes and links by index: a GraphData, or a trace's two containers. |
| GraphLinkData | The link container: one entry per link in every array that is present. |
| GraphModel | - |
| GraphNodeData | The node container: one entry per node in every array that is present. |
| GraphPathInfo | A highlighted path as an app reads it: indices are the trace's own. |
| GraphPending | What a calc waits for: the request the view makes, and the key its answer is kept under. |
| GraphTraceArc | Options of arrangement: 'arc'. Lengths are layout units: CSS px at the size the graph is laid out for, before it is fitted to the plot area. |
| GraphTraceCustom | The layout of arrangement: 'custom'. |
| GraphTraceForce | Options of arrangement: 'force'. Lengths are layout units: CSS px at the size the graph is laid out for, before it is fitted to the plot area. |
| GraphTraceForceStart | A picture the layout goes on from, in place of the spiral: where every node is, and how warm the layout still is there. Pinned nodes (node.x and node.y) are where those say; the layout is centered on the middle of these positions and not moved afterwards. The chart writes it when a node is dragged, so that the figure is the picture on screen: at rest (alpha: 0) on a drop, with alpha: 0.3 when a pinned node is released, and once more at rest when a layout shown with force.simulate has settled. While it is at rest the other force options change nothing: unset it to lay the graph out afresh. |
| GraphTraceHighlight | Highlighting: the neighbourhood of the node or link under the pointer (or of highlight.nodes), and a shortest path between two selected nodes or the two of highlight.path. What is highlighted keeps its look, its label shows even where there was no room for it, and everything else is dimmed; nothing is laid out or built again. A hover comes first, then highlight.nodes, then a path. |
| GraphTraceHive | Options of arrangement: 'hive'. A link between two nodes of one axis is not drawn: a hive plot shows what goes on between the axes. |
| GraphTraceLayered | Options of arrangement: 'layered'. Lengths are layout units: CSS px at the size the graph is laid out for, before it is fitted to the plot area. |
| GraphTraceLink | The links. |
| GraphTraceLinkArrow | Arrowheads. Their tips stop at the node's edge, whatever its size. |
| GraphTraceLinkBundle | Link bundling. Default: none. |
| GraphTraceLinkSecondary | Style of the links an arrangement sets apart from the others: with 'layered', the links that close a cycle, which the layout had to turn around to give every other link one direction (back edges; their arrowheads still point the way the data says); with 'tree', 'radial' and 'dendrogram', the links that are not part of the tree (they skip levels or join two branches, and are drawn straight). Default: dashed and a little fainter. |
| GraphTraceNode | The nodes. |
| GraphTraceNodeLine | Outlines of the nodes. |
| GraphTraceNodeTextfont | Font of the node labels. Default: layout.font, with the automatic halo (shadow: auto). Family, size, weight and style set the size of box nodes. |
| GraphTraceSelected | Style of selected nodes while a selection is active (box or lasso select, selectedpoints). Links between two selected nodes keep their style; the others are dimmed. |
| GraphTraceSelectedNode | Style of selected nodes. |
| GraphTraceTree | Options of the tree arrangements: 'tree', 'radial' and 'dendrogram'. The tree is the one parents gives; with link.source / link.target, each node hangs from the first node that links to it, starting at the nodes without incoming links, and the links left over are drawn in the link.secondary style. Lengths are layout units: CSS px at the size the graph is laid out for, before it is fitted to the plot area. |
| GraphTraceTreeSector | 'radial': the part of the circle the tree fans out over. |
| GraphTraceUnselected | Style of unselected nodes while a selection is active (box or lasso select, selectedpoints). Links between two selected nodes keep their style; the others are dimmed. |
| GraphTraceUnselectedNode | Style of unselected nodes. |
| GraphTree | The tree a tree arrangement drew, for collapsing and expanding. |
| GridOptions | Options of gridLayout. |
| HierarchicalBundleOptions | Options of hierarchicalBundle. |
| HiveLayoutOptions | Options of hiveLayout. Lengths are layout units (CSS px), angles degrees. |
| HiveLayoutResult | What hiveLayout returns: the positions and routes, and the axes it made. |
| Layered3dOptions | Options of layeredLayout3d. |
| Layered3dResult | What layeredLayout3d returns: positions, and where the planes are. |
| LayeredOptions | - |
| LayoutBundleInfo | How the bundling of a request went (see BundleResult). |
| LayoutCluster | A labelled frame around a group of nodes (a layered cluster), in layout units. |
| LayoutGraph | A graph as a layout sees it: node and link counts and one typed array per property. |
| LayoutHandler | A handler made by createLayoutHandler. |
| LayoutHandlerEnvironment | What the handler needs from its surroundings; the defaults are right outside of tests. |
| LayoutProgress | Positions of a simulation on its way to rest. The arrays are the caller's to keep. |
| LayoutProgressOptions | How often a simulation reports its positions. |
| LayoutRequest | Page → worker: lay out a graph. |
| LayoutResult | Where a layout put everything. Arrays are owned by the caller from here on. |
| LayoutRunInfo | How a finished layout went. |
| LayoutRunOptions | Options of one layoutInWorker call. |
| LayoutSimulation | A layout that settles over time (force): the trace runs it to rest in calc, or steps it frame by frame for simulate: true and while a node is dragged. |
| LayoutWorkerLike | The part of a Worker the client uses. |
| LinkRoute | A link's path when it is not the straight line between its ends. |
| MatrixLinks | Links of a square matrix, for chordLayout. |
| MetricOptions | Options shared by the measures. |
| PlotArea | The size in px of the area a trace is laid out for. |
| RadialTreeOptions | Options of radialTreeLayout. Lengths are layout units (CSS px), angles degrees. |
| RadialTreeResult | What radialTreeLayout returns. |
| RealAxis | An axis that carries data under a computed arrangement, and whether it runs backwards. |
| TidyTreeOptions | Options of tidyTreeLayout. Lengths are layout units (CSS px). |
| TreeLayoutResult | What a tree layout returns on top of positions. |
| TreeOptions | Options every tree layout takes. |
Type Aliases
| Type Alias | Description |
|---|---|
| ArcOrder | How arcLayout orders the nodes along the line. |
| ArcSides | Which side of the line the arcs are drawn on. |
| ChordLinkSort | The order of the link ends within an arc. |
| ChordNodeSort | The order of the arcs around the ring. |
| ChordTrace | Chord diagram: nodes as arcs of a ring, as wide as their flow, and links as ribbons between them; from node / link (as sankey and graph take them) or from a square matrix. |
| CollapsedInput | Which subtrees are folded: node indices, or a mask with one byte per node (Uint8Array). |
| ForceAlgorithm | - 'spring': the d3-force model. Links are springs with a rest length, every pair of nodes repels, velocities decay and the whole cools on a fixed schedule. Even link lengths; the usual choice up to a few thousand nodes. - 'forceatlas2': the ForceAtlas2 model (Jacomy et al. 2014). Links attract in proportion to their length, nodes repel in proportion to their degrees, and the step size adapts to how much the nodes swing. It pulls communities apart better on graphs with hubs. |
| Graph3dArrangement | A value of graph3d's arrangement. |
| Graph3dTrace | Network graph in a 3D scene: nodes as lit spheres or sprites and the links between them as lines or tubes, at given positions or placed by a layout in space. |
| GraphArrangement | A value of arrangement. |
| GraphLayout | A layout: positions for graph. Deterministic: the same input gives the same output on every machine (no Math.random, no time, no iteration order of hashed collections), so visual baselines, server rendering and exports agree. |
| GraphTrace | Network graph: nodes and the links between them, at given positions or placed by a layout. |
| LabelRule | What an arrangement says about where its labels have room (node.textposition: 'auto'). Angles are degrees counter-clockwise from the x axis in layout coordinates (y up), as the layouts return them. |
| LayeredRankdir | Where the ranks run: top to bottom, bottom to top, left to right or right to left. |
| LayeredRanker | How ranks are assigned (see rank.ts). |
| LayeredRouting | How links are routed (see route.ts). |
| LayoutMessage | Everything the page sends. |
| LayoutResponse | Everything the worker sends. |
| LayoutThread | Where a layout ran: in the worker, or on the main thread in slices. |
| LinkWeightMode | What a link's weight (link.value) does, relative to the median weight of the graph: - 'strength': a heavier link pulls harder (both algorithms); - 'distance': a heavier link is shorter. 'spring': its rest length is linkDistance divided by the relative weight, kept within a quarter to four times linkDistance. 'forceatlas2' has no rest length, so this is the same as 'strength' there; - 'none': weights are ignored. |
| NodeSort | How nodeOrder sorts. |
| PerNode | A value for every node, or one value per node (NaN: none for that node). |
| PostLayoutResponse | Sends a response; transfer lists the buffers that move with it. |
| TracesGraph | Any trace of @mk7s/holochart-traces-graph, discriminated on type. Type a partial bundle's figures with it: FigureInput<TracesGraph>. |
| TreeLinkShape | How the tree edges of a tidy or radial tree are drawn. |
| TreeOrientation | Where the root is: top ('TB'), bottom ('BT'), left ('LR') or right ('RL'). |
| TreeSort | How siblings are ordered. |
| WorkerArrangement | An arrangement the worker can run. |
Variables
| Variable | Description |
|---|---|
| chord | - |
| chordAttributes | The chord schema. |
| circularLayout | Nodes on a circle around the origin. |
| graph | - |
| GRAPH_ARRANGEMENTS | Every value of the trace's arrangement. |
| graph3d | - |
| GRAPH3D_ARRANGEMENTS | arrangement values of graph3d: the layouts that place nodes in space. |
| graph3dAttributes | The graph3d schema. |
| graphAttributes | The graph schema. |
| gridLayout | Nodes on a grid centered on the origin; the first row is on top (the largest y). |
| layeredLayout | The layered layout as the graph trace calls it: layered: { rankdir, ranksep, nodesep, … } (see LayeredOptions). Returns a position per node, a route per link (also for straight ones: routes end on the nodes' outlines), the links it reversed, and the cluster frames when clusters is on. |
| LAYOUT_PROTOCOL | Version of this protocol: the worker reports it in ready, and the client checks it. |
| presetLayout | Positions as given. |
| tracesGraph | Every graph module, for register(...tracesGraph). |
| tracesGraph3d | The graph3d trace with the 3D scene it is drawn in, for register(...tracesGraph3d). Apart from tracesGraph, so that an app with 2D graphs only does not bundle the 3D package. |
| WORKER_ARRANGEMENTS | The arrangements the worker can run: every built-in one. |
Functions
| Function | Description |
|---|---|
| adjacencyMatrix | The adjacency matrix of a graph, with rows and columns reordered so that its structure shows (backlog G8): it reads at densities where a node-link drawing is a hairball. Draw it with { type: 'heatmap', x, y, z }. An undirected graph (directed: false) fills both triangles. |
| arcLayout | An arc diagram of graph: nodes on one line through the origin, links as half circles. See the module comment for the steps and for what happens to self-links and parallel links. |
| bundleLinks | Bundle the links of a laid-out graph: hierarchical bundling when it has groups, force-directed bundling when it has none (see BundleOptions.method). positions are the node centers a layout returned; the number of nodes is their length. |
| chordLayout | Lay a chord diagram out (see the module comment). |
| connectedComponents | Connected components, ignoring the direction of links (the weak components of a directed graph). A node without links is a component of its own. |
| createForceSimulation | A force simulation of graph, at its start positions and alpha 1. Step it with tick; drag a node with pin and reheat. x, y (and z with dimensions: 3) are its own arrays, updated in place. |
| createLayoutHandler | A handler that answers through post. It keeps the requests that are running, so one handler serves one connection (a worker's, or the client's fallback). |
| decodeResult | The result encodeResult was given, with the same properties. |
| degrees | The degree of every node. With weighted, each link counts as its value (the node's strength). Links with an end that is not a node are skipped. |
| dendrogramLayout | Lays a tree or forest out as a dendrogram. Linear in nodes + links (sorting aside). |
| encodeResult | result in the form it is posted in. Nothing is copied but the routes' points. |
| forceBundle | Force-directed edge bundling: a 'polyline' route for every link that was pulled into a bundle and undefined for a link that stays straight. See the module comment for the model, its bounds and which links stay straight. |
| forceLayout | The force layout as a GraphLayout: a simulation run for options.ticks ticks (or to rest, if a given alphaDecay gets there sooner), cleared of the last overlaps when collide is on, then centered on options.center (the origin by default). It is not centered along an axis where a node is pinned or a positional target is set: those coordinates mean what they say. |
| forceLayout3d | A 3D force layout of graph (dimensions: 3, whatever options says). |
| fromAdjacencyMatrix | A graph from a square adjacency matrix: matrix[i][j] is the weight of the link from row i to column j. Entries that are not finite numbers are no link; the diagonal gives self-links. |
| fromDot | Parse DOT text into a graph. Throws a SyntaxError that names the offset when the text is not DOT. See the module comment for what is read and what is kept. |
| fromEdgeList | A graph from a list of edges: [source, target] or [source, target, value] tuples, or objects with those keys. Ends are node ids (strings or numbers), not indices. Edges without two usable ends are skipped. |
| fromNodeLink | A graph from node-link JSON, whichever of these shapes it has: |
| graphLayoutWorker | The layout worker every graph trace of the page shares, made on first use. |
| graphPath | The path a graph trace highlights: between the two nodes of highlight.path, else between the two selected nodes (selectedpoints) when exactly two are and highlight.mode has 'path'. trace is a defaulted trace, chart.fullData[i], which holds the selection made on the chart; read it in a selected listener or after an update. undefined: no path is asked for, or there is none between the two nodes. |
| hierarchicalBundle | Hierarchical edge bundling: one entry per link (the indices of graph.source), a 'spline' route for every link that is bundled and undefined for a link that stays straight. See the module comment for the hierarchy, the curve and which links stay straight. Without a hierarchy (no groups and no parents) every entry is undefined. |
| hiveLayout | A hive plot of graph: nodes on axes around the origin, links as curves between the axes. See the module comment for the steps and for the links that are left out. |
| isLayoutAbort | Whether error is the rejection of a cancelled or superseded layout, which is not a failure. |
| layeredLayout3d | The layered layout in space (see the module comment). |
| layoutInWorker | Lay a graph out in the shared layout worker, or on the main thread in slices when there is no worker: see GraphLayoutWorker.run and LayoutRunOptions. |
| louvain | Communities by the Louvain method (Blondel et al. 2008): the community of each node, numbered from 0 in the order of each community's first node. Links are read as undirected and weighted by link.value. Deterministic: there is no random node order, so the result is one of the partitions Louvain can find, always the same one. |
| matrixLinks | The links of a square matrix (matrix[i][j]: flow from i to j), see the module comment. Missing cells are 0; negative and non-numeric ones are dropped and counted. |
| modularity | Modularity of a partition (Newman and Girvan): the share of link weight inside communities minus what a random graph with the same degrees would have. Between −0.5 and 1; 0 for one community holding everything. |
| radialTreeLayout | Lays a tree or forest out on rings around its root. Linear in nodes + links (sorting aside). |
| registerGraphLayout | Register a layout for arrangement: 'custom' with custom: { name, options }: the layout is called with the graph and custom.options, in calc. Registering a name again replaces it. Returns a function that removes the layout (only if it is still the one registered). |
| setGraphWorkerUrl | Serve the worker file from a URL of your own: copy dist/layout-worker.js of @mk7s/holochart-traces-graph (one file, no imports) to your site and give its address here, before the first graph is laid out. For apps whose Content Security Policy or bundler keeps the file from loading from where the package looks for it. null goes back to the default. A worker that is already running is ended; the next layout starts one from the new address. |
| tidyTreeLayout | Lays a tree or forest out as a tidy tree. Linear in nodes + links (sorting aside). |