Skip to main content

Extensibility & Escape Hatches

Providing functions to

There are some things that cannot be done in a declarative way within NetPanorama (for example, defining a new network layout algorithm).

In such cases, you can specify a data, data transform, layout or layout transform as:

{ "type": "function", "name": "someFunctionName" }

and then include someFunctionName as an attribute of the funcs object provided when calling the NetPanorama function.

External access to parameter values

Detecting changes in the value of a parameter

The options object can also induce a paramCallbacks object, containing functions that will be evaluated when the value of paramaeters changes.

For example:

const options = {
container: "#SVG",

paramCallbacks: {
nodeSize: (newVal) => console.log("Param nodeSize is now:", newVal)
}
};

const viewer = new GraphgraView(spec, { container: "#SVG" })
await viewer.render();

Getting current value of a parameter

You can read the current value of a parameter from the state attribute of the viewer object.

const viewer = new GraphgraView(spec, {container: "#SVG"})
await viewer.render();

console.log("Color is currently:", viewer.state.color)

Setting the value of a parameter

The viewer object has a setParam(paramName: string, newVal: string | number) method.

Example use:

const viewer = new GraphgraView(spec, {container: "#SVG"})
await viewer.render();

viewer.setParam("color", "#00ff00")