charts
Charts Integration (Line, Bar, Pie, Doughnut)
ArtiGrid also allows you to generate dynamic charts directly from database queries using the chart_labels() method.
You can build charts based on SQL results and visualize your data without writing additional JavaScript.
Supported chart types:
linebarpiedoughnut
<?php
$grid = new ArtiGrid();
$grid->table('orderdetails')
->template('bootstrap5');
$grid->chart_labels(
['S24_2841', 'S24_3420', 'S24_3949', 'S24_4278', 'S32_4289', 'S50_1341'],
[
[
'label' => '# of Quantity Ordered',
'data' => '#select quantityOrdered from orderdetails where id IN (60,61,62,63,64,65)',
'backgroundColor' => 'rgba(255, 99, 132, 0.2)',
'borderColor' => 'rgba(255, 99, 132, 1)',
'borderWidth' => 1
],
[
'label' => '# Price of Order',
'data' => '#select priceEach from orderdetails where id IN (60,61,62,63,64,65)',
'backgroundColor' => 'rgba(30, 23, 132, 0.2)',
'borderColor' => 'rgba(30, 23, 132, 0.2)',
'borderWidth' => 1
]
],
'pie',
[
'scales' => [
'y' => ['beginAtZero' => true]
],
'plugins' => [
'legend' => ['display' => true]
]
]
);
$grid->chart_view(true);
echo $grid->render();
?>