Skip to content

Chart.js

Chart.js is the alternate engine. It supports line, bar, pie, doughnut, radar, polar area, scatter, and bubble charts. Specialized types are available via plugin bundles: treemap, matrix, sankey, financial (candlestick/OHLC), and time-axis charts via the Luxon adapter.

Chart.js is auto-selected for types it supports exclusively (matrix, sankey). For types supported by both engines, ApexCharts is preferred unless you call ->engine('chartjs') explicitly.

use Matheusmarnt\LiveCharts\Chart;
return Chart::make()
->engine('chartjs')
->type('bar')
->labels(['Q1', 'Q2', 'Q3', 'Q4'])
->dataset('Sales', [100, 200, 150, 300]);

Chart.js core (^4.5.1) ships at resources/dist/chartjs.js. Plugin bundles ship alongside:

PluginFile
chartjs-chart-treemapresources/dist/chartjs-treemap.js
chartjs-chart-matrixresources/dist/chartjs-matrix.js
chartjs-chart-sankeyresources/dist/chartjs-sankey.js
chartjs-chart-financialresources/dist/chartjs-financial.js
luxonresources/dist/luxon.js
chartjs-adapter-luxonresources/dist/chartjs-adapter-luxon.js

The ChartJsAdapter registers the engine asset before any plugin asset to guarantee DOM load ordering — plugins resolve their named imports against the global Chart exposed by the core shim.

Pass any Chart.js-native config via options():

Chart::make()
->engine('chartjs')
->type('line')
->options([
'scales' => [
'y' => ['beginAtZero' => true],
],
'plugins' => [
'legend' => ['position' => 'bottom'],
],
]);

The PHP array maps directly to the configuration object passed to new Chart(ctx, config).