Charts
Chart.js is bundled: a controller method returns the chart config, an include renders it.
Try it: log in with the demo account
Email demo@frontdesk-demo.test · Password Try-Frontdesk-2026
Everyone shares this account. You may change anything – all data is reset every night.
The code
app/src/Controllers/DashboardController.php – Chart configs
whole file
/**
* Projects per status (doughnut).
*/
public function StatusChartJson(): string
{
$labels = [];
$counts = [];
foreach (Project::STATUSES as $status => $label) {
$labels[] = $label;
$counts[] = Project::get()->filter('Status', $status)->count();
}
return (string) json_encode([
'type' => 'doughnut',
'data' => [
'labels' => $labels,
'datasets' => [['data' => $counts, 'backgroundColor' => ['#94a3b8', '#22c55e', '#f59e0b', '#6366f1']]],
],
'options' => ['responsive' => true, 'maintainAspectRatio' => false],
]);
}
/**
* Budget of the projects starting per month, this year (bars).
*/
public function BudgetChartJson(): string
{
$year = (int) date('Y');
$labels = [];
$sums = [];
for ($month = 1; $month <= 12; $month++) {
$from = sprintf('%d-%02d-01', $year, $month);
$labels[] = date('M', (int) strtotime($from));
$sums[] = (float) Project::get()->filter([
'StartDate:GreaterThanOrEqual' => $from,
'StartDate:LessThanOrEqual' => date('Y-m-t', (int) strtotime($from)),
])->sum('Budget');
}
return (string) json_encode([
'type' => 'bar',
'data' => [
'labels' => $labels,
'datasets' => [['label' => 'Budget (€)', 'data' => $sums, 'backgroundColor' => '#6366f1']],
],
'options' => ['responsive' => true, 'maintainAspectRatio' => false],
]);
}
app/templates/App/Controllers/Layout/DashboardController.ss – Template
whole file
<div class="grid gap-4 lg:grid-cols-2 mb-6">
<% include Atwx\SilverstripeFrontdeskKit\Includes\Chart ChartTitle='Projects by status', ChartHeight='280px', ChartConfigJson=$StatusChartJson %>
<% include Atwx\SilverstripeFrontdeskKit\Includes\Chart ChartTitle='Budget by start month', ChartHeight='280px', ChartConfigJson=$BudgetChartJson %>
</div>