Skip to content

Dashboard

  • brilliance_admin.schema.CategoryDashboard

Dashboard pages display widgets with data from any source.

Subclass CategoryDashboard and implement get_data to return a layout of components.

INFO

Dashboard is a regular category that displays widgets with data from any source. You can create as many dashboards as you need.

CategoryDashboard

from brilliance_admin import schema
from brilliance_admin.schema.dashboard.category_dashboard import (
    DashboardContainer, DashboardData)


class MyDashboard(schema.CategoryDashboard):
    slug = 'dashboard'
    title = 'Dashboard'
    icon = 'mdi-chart-bar-stacked'

    async def get_data(self, data: DashboardData, user) -> DashboardContainer:
        # build and return your layout here
        ...
ParameterDescription
slug requiredUnique identifier
title requiredDisplay name in the sidebar
iconMaterial Design icon name (e.g. 'mdi-chart-bar-stacked') Icons Database
search_enabledEnable search input on the dashboard page
search_helpPlaceholder text for the search input
table_filtersFieldsSchema to render filter controls above the dashboard

DashboardData

ParameterDescription
searchSearch query string (if search_enabled=True)
filtersDict of applied filter values (if table_filters is set)

Layout

Use DashboardContainer to arrange components in a grid. Containers can be nested.

ParameterDescription
colsColumn width (1-12), default 12
mdColumn width on medium screens
lgColumn width on large screens
smColumn width on small screens
componentsList of child components
DashboardContainer(
    components=[
        DashboardContainer(
            cols=12, md=6,
            components=[chart_1],
        ),
        DashboardContainer(
            cols=12, md=6,
            components=[chart_2],
        ),
    ],
)

Components

PeriodGraph

Bar chart with a summary value, change percentage and subcards.

from brilliance_admin.schema.dashboard.category_dashboard import (
    PeriodGraph, Subcard)

period = PeriodGraph(
    title='Operations for period',
    value='150 558,01 RUB',
    change=160,
    subcards=[
        Subcard(title='PayIn', value='24 051 RUB', color='#4CAF50'),
        Subcard(title='PayOut', value='124 051 RUB', color='#1976D2'),
    ],
    horizontal=['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
    vertical=['1 400', '1 050', '700', '350', '0'],
    values=[
        [25, 35],
        [35, 45],
        [8, 40],
        [85, 45],
        [40, 35],
    ],
)
ParameterDescription
titleCard title
valueMain displayed value
changeChange percentage (positive = green, negative = red)
subcardsList of Subcard(title, value, color) below the main value
horizontalX-axis labels
verticalY-axis labels
valuesList of value arrays per bar group

SmallGraph

Compact card with a sparkline.

from brilliance_admin.schema.dashboard.category_dashboard import SmallGraph

balance = SmallGraph(
    title='Wallet balance',
    value='950 150 558 RUB',
    change=15,
    points={'01.05': 5, '05.05': 35, '10.05': 45, '15.05': 30},
)
ParameterDescription
titleCard title
valueMain displayed value
changeChange percentage
pointsDict of {label: value} for the sparkline

ChartData

Any ChartJS chart. Pass data and options directly in ChartJS format.

from brilliance_admin.schema.dashboard.category_dashboard import ChartData

chart = ChartData(
    type='line',
    height=300,
    data={
        'labels': ['Jan', 'Feb', 'Mar', 'Apr'],
        'datasets': [{
            'label': 'Revenue',
            'data': [65, 59, 80, 81],
            'borderColor': '#3b82f6',
        }],
    },
    options={
        'responsive': True,
        'plugins': {'legend': {'position': 'top'}},
    },
)
ParameterDescription
typeChartJS chart type: 'line', 'bar', 'pie', 'doughnut', etc.
dataChartJS data object with labels and datasets
optionsChartJS options object
heightChart height in pixels (default 50)
widthChart width in pixels

TIP

See ChartJS documentation for all available chart types and options.

Full example

https://github.com/brilliance-admin/backend-python/blob/main/example/sections/dashboard.py

AI/LLM: Documentation index available at https://docs.brilliance-admin.com/llms.txt