ChartWidget
export class VisitsChartWidget extends ChartWidget { static override heading = 'Daily visits (30 days)' static override type = 'line' static override library = 'apex'
static override async data(ctx) { return { labels: ['Mon', 'Tue'], datasets: [{ label: 'Visits', data: [12, 19], color: '#286291' }], } }}Pie / donut slice colors
Section titled “Pie / donut slice colors”Pass a top-level colors array aligned with labels (preferred). Apex and Chart.js both honor it — no host updateOptions patch required.
return { labels: ['Present · 12 (80%)', 'Absent · 3 (20%)'], datasets: [{ label: 'Roll', data: [12, 3] }], colors: ['#2E7D32', '#B3261E'],}Alternatively set datasets[0].colors (or datasets[0].color as a string[]) to the same length, or one color string per dataset when each slice is its own dataset.
Methods
| Method | Description |
|---|---|
static type | line | bar | area | pie | donut. |
static library | apex (default) or chartjs. |
static data(ctx) | Chart payload (async). Prefer `colors` for pie/donut slices; `datasets[].color` for series. |
static columnSpan / heading | Layout. |