Skip to content

Class: 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.

Constructors ​

Constructor ​

ts
new GraphLayoutWorker(options?): GraphLayoutWorker;

Parameters ​

ParameterType
optionsGraphLayoutWorkerOptions

Returns ​

GraphLayoutWorker

Accessors ​

pending ​

Get Signature ​

ts
get pending(): number;

Requests that have not ended: sent, waiting for the worker to load, or running here.

Returns ​

number


thread ​

Get Signature ​

ts
get thread(): LayoutThread | undefined;

Where requests run: 'worker' once the worker has loaded, 'main' once it is known that there is none, undefined before the first request and while the worker loads.

Returns ​

LayoutThread | undefined

Methods ​

cancel() ​

ts
cancel(owner?): void;

Cancel the request of owner, or every request when called without one. Their promises reject with an AbortError.

Parameters ​

ParameterType
owner?unknown

Returns ​

void


dispose() ​

ts
dispose(): void;

Cancel everything and end the worker. The next request starts a new one.

Returns ​

void


run() ​

ts
run<Result>(
   graph,
   arrangement,
   options?,
   run?
): Promise<Result>;

Lay graph out with a built-in arrangement and that layout's own options (ForceOptions, LayeredOptions, …: what the trace builds from its option containers and would pass to the layout in calc). Resolves with what the layout returns, the same bits as calling it directly. Rejects with an AbortError when cancelled (isLayoutAbort), and with the layout's error when it throws.

Type Parameters ​

Type ParameterDefault type
Result extends LayoutResultLayoutResult

Parameters ​

ParameterType
graphLayoutGraph
arrangement| "radial" | "preset" | "force" | "layered" | "tree" | "dendrogram" | "circular" | "grid" | "arc" | "hive"
options?unknown
run?LayoutRunOptions

Returns ​

Promise<Result>


start() ​

ts
start(): Promise<LayoutThread>;

Start the worker ahead of the first request, so that request does not wait for the file. Resolves with where requests will run.

Returns ​

Promise<LayoutThread>

Released under the MIT License.