Adminix Documentation Help

Chart Line

  1. Description

  2. Configuration

  3. ChartLineModule configuration

  4. Appearance examples

Description

Chart-line is a chart which displays dynamic of creation records of some entity, users, orders, comments etc. Chart can display daily or monthly results.

image.png

Configuration

Example: (there 2 variants of this module)

use App\Models\User; use AlexKudrya\Adminix\Enums\ColorsEnum; use AlexKudrya\Adminix\Modules\ChartLine\ChartLineValueTypeEnum; use AlexKudrya\Adminix\Modules\ChartLine\ChartLineModule; ... $page = new AdminixPage(); ... $page->addModule( ChartLineModule::title('USER REGISTRATIONS DAILY') ->name('user_registrations') ->color(ColorsEnum::DEEP_PINK) ->valueType(ChartLineValueTypeEnum::COUNT_DAILY) ->limit(30) ->dataSource(User::class) ->criteria([ ['role_id', [2,3,4]] ]), ChartLineModule::title('USER REGISTRATIONS YEAR') ->name('user_registrations_year') ->color(ColorsEnum::ORANGE) ->valueType(ChartLineValueTypeEnum::COUNT_MONTHLY) ->limit(6) ->dataSource('users') ->criteria([ ['role_id', 'param:1'] ]), ) ...

To add to the page Chart Line module you need paste AlexKudrya\Adminix\Modules\ChartLine\ChartLineModule class instance as an argument to addModule or addModules method of AdminixPage object.

ChartLineModule Configuration

Method

Description

title

Title of the chart on top of this module

title('USER REGISTRATIONS DAILY')

Optional

name

Name of module, must be unique in current page.

name('user_registrations')

Required

color

Color of lines in chart, can be provided only by AlexKudrya\Adminix\Enums\ColorsEnum Enum class

color(ColorsEnum::DEEP_PINK)

Required

valueType

Type of interval for records counting. Can be provided only by AlexKudrya\Adminix\Modules\ChartLine\ChartLineValueTypeEnum Enum class. Has only two options: COUNT_DAILY and COUNT_MONTHLY

valueType(ChartLineValueTypeEnum::COUNT_DAILY)

Required

baseField

Field with date / datetime (usually it is a record creation timestamp). By default, it is created_at

baseField('created_at')

Optional

dataSource

Source of data for chart, can be an Eloquent Model - \App\Models\User::class or name of table in database users or public.users

dataSource(\App\Models\User::class)

Required

criteria

Database Builder criteria to render records. For example to not show administrator you need paste this:

criteria([ ['role_id', '!=', 1] )

Or you can paste parameter from route:

criteria([ ['role_id', '=', 'param:1'] )

For example, for https://site.com/adminix/users_by_role/2 it wiil be mean that you need dynamics for role_id == 2.

Optional

limit

limit of days / months for displaying in the chart

limit(30)

Required

Appearance examples

Here is an example of Users daily registrations (value_type = count_daily, limit = 30)

image.png

Here is an example of Users monthly registrations (value_type = count_monthly, limit = 6)

image.png
Last modified: 04 June 2024