Chart Blocks
Chart compositions on the chart-card shell: a KPI metric with a headline figure, a dual-axis column/line combo, a waterfall bridge and a grid of liquid gauges. One chart in a card is chart-card plus a chart example. Comparison instead frames a two-series bar chart in a tray, with a range select swapping the bundled dataset client-side.
Preview
@props([
'heading' => 'Revenue & margin',
'subheading' => 'Monthly revenue with gross margin',
'trend' => '+3.4 pts',
'series' => null,
'categories' => null,
'primaryTitle' => 'Revenue ($k)',
'secondaryTitle' => 'Margin %',
'secondaryMax' => 100,
'height' => 340,
])
@php
// Two measures on two scales: each series carries its own `type`, so the
// chart base type stays "line" and ApexCharts renders a column/line combo.
$series ??= [
['name' => __('Revenue'), 'type' => 'column', 'data' => [42, 48, 45, 53, 58, 61, 67, 72]],
['name' => __('Margin %'), 'type' => 'line', 'data' => [38, 40, 39, 42, 44, 45, 47, 48]],
];
$categories ??= [
__('Jan'), __('Feb'), __('Mar'), __('Apr'), __('May'), __('Jun'), __('Jul'), __('Aug'),
];
// The wrapper themes the axis it knows about; a second, opposite axis is
// declared here, so its labels and title carry the same muted token.
$muted = 'var(--muted-foreground-color, hsl(var(--muted-foreground)))';
$axisLabel = ['style' => ['colors' => $muted]];
$options = [
'stroke' => ['curve' => 'smooth', 'width' => [0, 3]],
'plotOptions' => ['bar' => ['borderRadius' => 6, 'columnWidth' => '45%']],
'fill' => ['opacity' => [0.85, 1]],
'markers' => ['size' => 0, 'hover' => ['size' => 5]],
'legend' => ['position' => 'bottom'],
'xaxis' => ['categories' => $categories],
'yaxis' => [
['labels' => $axisLabel, 'title' => ['text' => __($primaryTitle), 'style' => ['color' => $muted]]],
['opposite' => true, 'max' => $secondaryMax, 'labels' => $axisLabel, 'title' => ['text' => __($secondaryTitle), 'style' => ['color' => $muted]]],
],
];
@endphp
<x-ui.chart-card
:heading="$heading"
:subheading="$subheading"
:trend="$trend"
{{ $attributes }}
>
<x-ui.chart
type="line"
:series="$series"
:options="$options"
:height="$height"
:label="__($heading)"
/>
</x-ui.chart-card>
Installation
php artisan ui:add blocks/chart-dual-axis
Registry contract
Install confidence
php artisan ui:add blocks/chart-dual-axis
writes only the generated targets below. The CLI validates each file hash before writing and
prompts before replacing local changes unless --force is used.
- Version
- 1.0.1
- License
- open
- Stability
- stable
- Contract
- v1
- Foundation
- ≥ 1.0.0
| Type | Generated target |
|---|---|
| blade | resources/views/blocks/chart-dual-axis.blade.php |
Registry dependencies
Package dependencies
composer: jml/brok:^0.2
npm: apexcharts
Use with AI
A brief for your coding agent: what the block is, the install command, how to render it, its props and the rules. Copy it, or open a prompt about this block in an assistant.
# Brok UI block: Chart Dual Axis (`chart-dual-axis`)
A chart card overlaying a percentage line on value columns across two opposite y-axes, each axis titled and themed from the muted token.
Brok UI is a Laravel Blade registry. `ui:add` copies this block into the app as plain Blade the app owns; it composes installed `<brok:*>` primitives and semantic design tokens.
## Install
```bash
php artisan ui:add blocks/chart-dual-axis
```
## Render it
```blade
<x-blocks.chart-dual-axis />
```
## Props
- `heading` (string, default `Revenue & margin`) — Card title.
- `subheading` (string, default `Monthly revenue with gross margin`) — Supporting description.
- `trend` (string|null, default `+3.4 pts`) — Delta badge.
- `series` (array|null, default `null`) — Two ApexCharts series, each with its own `type`; null renders a sample.
- `categories` (array|null, default `null`) — X-axis categories.
- `primary-title` (string, default `Revenue ($k)`) — Title of the left axis.
- `secondary-title` (string, default `Margin %`) — Title of the opposite axis.
- `secondary-max` (int|null, default `100`) — Upper bound of the opposite axis.
- `height` (int, default `340`) — Chart height in pixels.
## Use when
- Two measures share an x-axis but not a scale, such as revenue in currency and margin in percent.
- A ratio has to be read against the absolute values it comes from.
## Avoid when
- Both measures share a scale; one axis reads more clearly.
- More than two scales are needed; split the card in two.
## Rules
- Render the installed block with `<x-blocks.chart-dual-axis />` and pass data through its props; edit the copied file only for structural changes.
- Keep the semantic design tokens (`bg-background`, `text-muted-foreground`); never swap in raw colour utilities.
- Keep the `data-slot` attributes and the logical (start/end) spacing so the markup still mirrors under `dir="rtl"`.
## Links
- Docs: https://brokui.dev/blocks/chart-dual-axis
- Registry JSON (files, props, contract): https://brokui.dev/r/open/blocks/chart-dual-axis.json
Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.
Guidance
Use when
- Two measures share an x-axis but not a scale, such as revenue in currency and margin in percent.
- A ratio has to be read against the absolute values it comes from.
Avoid when
- Both measures share a scale; one axis reads more clearly.
- More than two scales are needed; split the card in two.
Anti-patterns
- Do not replace semantic props with conflicting utility classes.
- Do not remove labels, focus styles, or state attributes.
- Anatomy
Usage
Render the block as a component, passing data where useful:
<x-blocks.chart-dual-axis />
Built from primitives
This block composes installed <brok:*> primitives and semantic design
tokens only — it does not reimplement any primitive. Re-theme it (light, dark, admin, customer) by
editing CSS variables; flip the preview to RTL to confirm it mirrors.
Source
The exact, editable file ui:add writes
into your app. The preview above renders this same source — there are no preview-only blocks.
@props([
'heading' => 'Revenue & margin',
'subheading' => 'Monthly revenue with gross margin',
'trend' => '+3.4 pts',
'series' => null,
'categories' => null,
'primaryTitle' => 'Revenue ($k)',
'secondaryTitle' => 'Margin %',
'secondaryMax' => 100,
'height' => 340,
])
@php
// Two measures on two scales: each series carries its own `type`, so the
// chart base type stays "line" and ApexCharts renders a column/line combo.
$series ??= [
['name' => __('Revenue'), 'type' => 'column', 'data' => [42, 48, 45, 53, 58, 61, 67, 72]],
['name' => __('Margin %'), 'type' => 'line', 'data' => [38, 40, 39, 42, 44, 45, 47, 48]],
];
$categories ??= [
__('Jan'), __('Feb'), __('Mar'), __('Apr'), __('May'), __('Jun'), __('Jul'), __('Aug'),
];
// The wrapper themes the axis it knows about; a second, opposite axis is
// declared here, so its labels and title carry the same muted token.
$muted = 'var(--muted-foreground-color, hsl(var(--muted-foreground)))';
$axisLabel = ['style' => ['colors' => $muted]];
$options = [
'stroke' => ['curve' => 'smooth', 'width' => [0, 3]],
'plotOptions' => ['bar' => ['borderRadius' => 6, 'columnWidth' => '45%']],
'fill' => ['opacity' => [0.85, 1]],
'markers' => ['size' => 0, 'hover' => ['size' => 5]],
'legend' => ['position' => 'bottom'],
'xaxis' => ['categories' => $categories],
'yaxis' => [
['labels' => $axisLabel, 'title' => ['text' => __($primaryTitle), 'style' => ['color' => $muted]]],
['opposite' => true, 'max' => $secondaryMax, 'labels' => $axisLabel, 'title' => ['text' => __($secondaryTitle), 'style' => ['color' => $muted]]],
],
];
@endphp
<x-ui.chart-card
:heading="$heading"
:subheading="$subheading"
:trend="$trend"
{{ $attributes }}
>
<x-ui.chart
type="line"
:series="$series"
:options="$options"
:height="$height"
:label="__($heading)"
/>
</x-ui.chart-card>
Ownership & lifecycle
Owner, release state, review evidence and adoption for this item.
- Owner
- Platform UI (@JoshJML)
- Current version
-
1.0.1 - Status
- Stable
- License
-
open - Deprecation
- Not deprecated
- Contract
-
v1 - Foundation
-
≥ 1.0.0