chartjs-chart-graph-dagre
TypeScript icon, indicating that this package has built-in type declarations

3.1.0 • Public • Published

Chart.js Graphs Dagre Layout

NPM Package Github Actions

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: {
    /**
     * dagre graph options
     */
    graph: {};
    /**
     * dagre node options or a function generating the option per node
     */
    node: ((i: number) => {}) | {};
    /**
     * dagre edge options or a function generating the option per edge
     */
    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';

// register controller in chart.js and ensure the defaults are set
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

Versions

Current Tags

Version History

Package Sidebar

Install

npm i chartjs-chart-graph-dagre

Weekly Downloads

5

Version

3.1.0

License

MIT

Unpacked Size

1.49 MB

Total Files

22

Last publish

Collaborators

  • sgratzl