Chart Bar
Description
The Chart-Bar module displays the ratio of the number of records of a certain entity in accordance with specified criteria. For example it can display ratio of the number of users by roles.
Configuration
To add to the page Chart Bar module you need paste AlexKudrya\Adminix\Modules\ChartBar\ChartBarModule class instance as an argument to addModule method of AdminixPage object.
ChartBarModule Configuration
Method | Description | |
|---|---|---|
title | Title of the chart on top of this module
title('USERS BY ROLES')
| Required |
name | Name of module, must be unique in current page.
name('users_by_roles')
| Required |
dataSource | Source of data for chart, can be an
dataSource(User::class)
// or
dataSource('users')
| Required |
criteria | Database
criteria([
['is_banned', '!=', 1],
])
Or you can paste parameter from route:
criteria([
['store_id', '=', 'param:0'],
])
For example, for | Optional |
yAxisStep | Optional Y-axis tick step. When it is omitted, Adminix leaves the Chart.js axis scale automatic. Set it for count-style bar charts when fractional axis labels would be misleading.
yAxisStep(1)
| Optional |
bars | Array of bars for this chart with personal configuration for each of them | Required |
Bars
To add Bars to your ChartBar module you need paste AlexKudrya\Adminix\Modules\ChartBar\ChartBarItem class instance as an argument to addBar or addBars method of ChartBarModule object.
ChartBarItem configuration
Method | Description | |
|---|---|---|
label | Label for current bar in chart
label('Client')
| Required |
color | Color of current bar in chart, can be provided only by
color(ColorsEnum::MEDIUM_SEA_GREEN)
| Required |
criteria | Criteria for selection record to count in current bar For example to display in bar number of users with
criteria([
['role_id', '=', 3],
])
| Required |
Appearance examples
Rendered example:

The rendered canvas has an accessible name and an equivalent visually hidden label/value table, so the series remains available when a browser cannot expose canvas pixels.