type
requiredstring
Chart type key. See chart types in the sidebar.
All available props for the
x-tayo::chart
component.
type
requiredstring
Chart type key. See chart types in the sidebar.
data
nullarray|null
Chart data. Structure depends on the chart type.
height
320int
Height of the chart canvas in pixels.
colors
'default'string|array
Named palette or array of hex strings.
title
nullstring|null
Optional heading rendered above the chart.
subtitle
nullstring|null
Optional sub-heading rendered below the title.
| Prop | Type | Default | Description |
|---|---|---|---|
| type | string | required | Chart type key. See chart types in the sidebar. |
| data | array|null | null | Chart data. Structure depends on the chart type. |
| height | int | 320 | Height of the chart canvas in pixels. |
| colors | string|array | 'default' | Named palette or array of hex strings. |
| title | string|null | null | Optional heading rendered above the chart. |
| subtitle | string|null | null | Optional sub-heading rendered below the title. |
<x-tayo::chart
type="bar"
:data="$chartData"
:height="320"
colors="ocean"
title="Monthly Revenue"
subtitle="Jan – Dec 2024"
/>
Pass data from a plain getter property. It re-evaluates on every render, so the chart always reflects the latest public property state.
new #[Layout('layouts.app')] class extends Component
{
public string $period = 'monthly';
public function getChartDataProperty(): array
{
return Sale::forPeriod($this->period)
->get()
->map(fn ($s) => ['label' => $s->label, 'value' => $s->total])
->toArray();
}
}
<flux:select wire:model.live="period" label="Period">
<flux:select.option value="monthly">Monthly</flux:select.option>
<flux:select.option value="quarterly">Quarterly</flux:select.option>
</flux:select>
<x-tayo::chart
type="bar"
:data="$this->chartData"
title="Sales"
/>