Integration
import { Chart, LinearScale } from 'chart.js'import { Flow, SankeyController } from 'chartjs-chart-sankey'
Chart.register(LinearScale, SankeyController, Flow)CommonJS
Section titled “CommonJS”The CommonJS entry registers the sankey controller and flow element as side effects.
const { Chart, LinearScale } = require('chart.js')require('chartjs-chart-sankey')
Chart.register(LinearScale)Browser Bundle
Section titled “Browser Bundle”For script tag usage, load the browser bundle after Chart.js. The browser bundle registers the sankey controller and flow element automatically.
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script><script src="https://cdn.jsdelivr.net/npm/chartjs-chart-sankey"></script>The same bundle can be loaded from UNPKG.
<script src="https://unpkg.com/chart.js"></script><script src="https://unpkg.com/chartjs-chart-sankey"></script>If a CDN does not use the package metadata for its default file, reference the browser bundle directly.
<script src="https://cdn.jsdelivr.net/npm/chartjs-chart-sankey/dist/chartjs-chart-sankey.min.js"></script>The built ESM bundle exports the controller and element and requires explicit registration.
import { Flow, SankeyController } from 'chartjs-chart-sankey/dist/chartjs-chart-sankey.esm.js'
Chart.register(SankeyController, Flow)