Chart.js Graphs Dagre Layout

Adds another graph controller dagre
to chart.js based on chartjs-chart-graph which uses the Dagre library for performing the graph layout.
Related Plugins
Check out also my other chart.js plugins:
Install
npm install --save chart.js chartjs-chart-graph chartjs-chart-graph-dagre
Usage
see Samples on Github
Options
The options are wrapper for specifying dagre graph, node, and edge options. see https://github.com/dagrejs/dagre/wiki#configuring-the-layout.
interface IDagreOptions {
dagre: {
graph: {};
node: ((i: number) => {}) | {};
edge: ((source: number, target: number) => {}) | {};
};
}
ESM and Tree Shaking
The ESM build of the library supports tree shaking thus having no side effects. As a consequence the chart.js library won't be automatically manipulated nor new controllers automatically registered. One has to manually import and register them.
Variant A:
import Chart from 'chart.js';
import { EdgeLine } from 'chartjs-chart-graph';
import { DagreGraphController } from 'chartjs-chart-graph-dagre';
Chart.register(DagreGraphController, EdgeLine);
...
new Chart(ctx, {
type: DagreGraphController.id,
data: [...],
});
Variant B:
import { DagreGraphChart } from 'chartjs-chart-graph-dagre';
new DagreGraphChart(ctx, {
data: [...],
});
Development Environment
npm i -g yarn
yarn set version 2
yarn install
yarn pnpify --sdk vscode
Building
yarn install
yarn build