Skip to content

Exceptions

LiveCharts throws four typed exceptions. All extend a common LiveChartsException base and produce translated messages via the livecharts.errors.* translation keys.

ExceptionWhen
UnknownEngineExceptionThe slug passed to engine() is not registered.
InvalidChartTypeExceptionThe selected engine doesn’t support the chart type.
EmptyDatasetExceptionA chart was rendered with zero datasets.
DataShapeMismatchExceptionDataset shape doesn’t match the engine’s expectations (e.g. nested array for a single-series chart).

All four are PHP RuntimeException subclasses — handle them with regular try/catch or surface them via Laravel’s exception handler.

Thrown by EngineFactory::resolve() when the slug isn’t in the registry.

try {
LiveCharts::engine('echarts')->line();
} catch (UnknownEngineException $e) {
// Register the engine first via LiveCharts::registerEngine()
}

Thrown at definition time, before render, when the type isn’t in EngineAdapter::supportedTypes().

try {
LiveCharts::engine('chartjs')->treemap(); // requires the matrix plugin
} catch (InvalidChartTypeException $e) {
// Either pick a different engine, or load the missing plugin
}

Thrown by the adapter’s buildPayload() when the chart has no datasets. Catch this for graceful UX:

try {
$payload = $adapter->buildPayload($chart);
} catch (EmptyDatasetException $e) {
return view('charts.empty-state');
}

Thrown when a single-series type (pie, donut, polarArea, radialBar) receives multiple datasets, or when a multi-series type receives malformed input.

LiveCharts::pie()
->dataset('A', [1, 2, 3])
->dataset('B', [4, 5, 6]); // throws — pie expects one series

The full type-per-engine matrix is encoded in the adapters and asserted by Pest arch tests. Today:

TypeApexChartsChart.js
line
area✅ (line + fill: true)
bar
column✅ (bar variant)
pie
donut✅ (doughnut)
radar
polarArea
radialBar
scatter
bubble
heatmap❌ (without plugin)
treemap✅ (via plugin)
candlestick✅ (via financial plugin)
rangeBar