Bar Chart Semantic UI theme
Bar chart reading from database
HIDE CODE
<style>
canvas{
height: 600px!important;
}
</style>
<?php
// Bar Chart Example - First Instance
$xcrud1 = Xcrud::get_instance();
$xcrud1->table('orderdetails');
$xcrud1->chart_labels(
['S24_2841', 'S24_3420', 'S24_3949', 'S24_4278', 'S32_4289', 'S50_1341'], // Labels
[ // Multiple datasets (even if there's just one)
[
'label' => '# of Quantity Ordered', // Dataset label
'data' => '#select quantityOrdered from orderdetails where id IN (60,61,62,63,64,65)', // Data points
'backgroundColor' => 'rgba(255, 99, 132, 0.2)', // Bar background color
'borderColor' => 'rgba(255, 99, 132, 1)', // Bar border color
'borderWidth' => 1 // Border width
],
[
'label' => '# Price of Order', // Dataset label
'data' => '#select priceEach from orderdetails where id IN (60,61,62,63,64,65)', // Data points
'backgroundColor' => 'rgba(30, 23, 132, 0.2)', // Bar background color
'borderColor' => 'rgba(30, 23, 132, 0.2)', // Bar border color
'borderWidth' => 1 // Border width
]
],
'bar', // Chart type (e.g., 'bar')
[
'scales' => [
'y' => ['beginAtZero' => true] // Custom scale options
],
'plugins' => [
'legend' => ['display' => true] // Custom plugin options (e.g., legend display)
]
] // Custom options (e.g., scale settings, legend display)
);
$xcrud1->chart_view(true);
$xcrud1->unset_add();
$xcrud1->unset_edit();
$xcrud1->unset_remove();
$xcrud1->unset_view();
$xcrud1->unset_csv();
$xcrud1->unset_limitlist();
$xcrud1->unset_numbers();
$xcrud1->unset_pagination();
$xcrud1->unset_print();
$xcrud1->unset_search();
$xcrud1->unset_title();
$xcrud1->unset_sortable();
echo $xcrud1->render();
?>
| Ordernumber | Productcode | Quantityordered | Priceeach | Orderlinenumber | Total |
|---|---|---|---|---|---|
| 10100 | 54e 756itytfv86 | 100 | 136 | 3 | 1360.00 |
| 10100 | S18_2248 | 500 | 55.09 | 2 | 2754.50 |
| 10100 | S24_3969 | 49 | 35.29 | 1 | 1729.20 |
| 10101 | S18_2325 | 20 | 108.06 | 4 | 0.00 |
| 10101 | S18_2795 | 26 | 167.06 | 12222 | 0.00 |
| 10101 | S24_1937 | 45 | 32.53 | 3 | 1463.90 |
| 10101 | S24_2022 | 46 | 44.35 | 2 | |
| 10102 | S18_1342 | 39 | 95.55 | 2 | |
| 10102 | S18_1367 | 41 | 43.13 | 1 | |
| 10103 | S18_1097 | 35 | 94.5 | 10 |