Search 71 components and 72 controllers by name, category or description.
Chart
Apache ECharts visualization from inline options or a JSON endpoint with optional polling
Inline option
Pass an ECharts option array directly from Blade.
<hw:chart :option="$option" height="320px" class="rounded-md border" />
Scatter with brush, zoom and marks
Two scatter series with a cross axis pointer, a toolbox for zoom and brush selection, and server-computed mark areas, points and average lines. Scatter is not in the package bundle, so the tag mounts scatter-chart — a subclass that registers the extra ECharts modules.
@php
/** The mark area is the bounding box of the whole sample, computed server-side. */
$bounds = function (array $samples): array {
$heights = array_column($samples, 0);
$weights = array_column($samples, 1);
return [
['xAxis' => min($heights), 'yAxis' => min($weights)],
['xAxis' => max($heights), 'yAxis' => max($weights)],
];
};
$series = fn (string $name, array $samples, string $color): array => [
'name' => $name,
'type' => 'scatter',
'symbolSize' => 9,
'itemStyle' => ['color' => $color, 'opacity' => 0.75],
'emphasis' => ['focus' => 'series'],
'data' => $samples,
'markArea' => [
'silent' => true,
'itemStyle' => ['color' => $color, 'opacity' => 0.06],
'data' => [$bounds($samples)],
],
'markPoint' => [
'symbolSize' => 44,
'data' => [
['type' => 'max', 'name' => 'Heaviest'],
['type' => 'min', 'name' => 'Lightest'],
],
],
'markLine' => [
'lineStyle' => ['type' => 'dashed', 'color' => $color],
'data' => [['type' => 'average', 'name' => 'Average weight']],
],
];
$option = [
'title' => [
'text' => 'Height and weight distribution',
'subtext' => 'Synthetic sample · '.(count($femaleSamples) + count($maleSamples)).' people',
'left' => 'center',
],
'grid' => ['left' => '3%', 'right' => '7%', 'bottom' => 64, 'top' => 72, 'containLabel' => true],
'legend' => ['data' => ['Female', 'Male'], 'left' => 'center', 'bottom' => 8],
'tooltip' => [
'showDelay' => 0,
'axisPointer' => [
'show' => true,
'type' => 'cross',
'lineStyle' => ['type' => 'dashed', 'width' => 1],
],
],
'toolbox' => [
'right' => 8,
'feature' => [
'dataZoom' => ['title' => ['zoom' => 'Zoom to selection', 'back' => 'Undo zoom']],
'brush' => ['type' => ['rect', 'polygon', 'clear']],
],
],
'brush' => [],
'xAxis' => [
'type' => 'value',
'scale' => true,
'name' => 'Height',
'nameLocation' => 'middle',
'nameGap' => 28,
'axisLabel' => ['formatter' => '{value} cm'],
'splitLine' => ['show' => false],
],
'yAxis' => [
'type' => 'value',
'scale' => true,
'name' => 'Weight',
'nameGap' => 16,
'axisLabel' => ['formatter' => '{value} kg'],
'splitLine' => ['show' => false],
],
'series' => [
$series('Female', $femaleSamples, '#c084fc'),
$series('Male', $maleSamples, '#38bdf8'),
],
];
@endphp
<hw:chart
controller="scatter-chart"
:option="$option"
height="520px"
class="rounded-md border"
/>
Force graph with label overlap handling
The component catalog drawn as a force layout: every component linked to the Stimulus controllers it mounts. labelLayout.hideOverlap drops colliding labels as the layout settles, so drag and zoom stay readable. Mounted through the graph-chart subclass.
@php
$option = [
'tooltip' => ['confine' => true],
'legend' => [
'data' => array_column($graphCategories, 'name'),
'left' => 'center',
'bottom' => 8,
'type' => 'scroll',
],
'animationDuration' => 900,
'animationEasingUpdate' => 'quinticInOut',
'series' => [[
'name' => 'Catalog',
'type' => 'graph',
'layout' => 'force',
'roam' => true,
'top' => 24,
'bottom' => 56,
'draggable' => true,
'categories' => $graphCategories,
'data' => $graphNodes,
'links' => $graphLinks,
'label' => [
'show' => true,
'position' => 'right',
'fontSize' => 11,
'formatter' => '{b}',
],
// The whole point of this example: ECharts measures the rendered labels and drops
// the ones that would collide, so a dense force layout stays readable at any zoom.
'labelLayout' => ['hideOverlap' => true],
'emphasis' => [
'focus' => 'adjacency',
'label' => ['show' => true, 'fontWeight' => 'bold'],
'lineStyle' => ['width' => 3],
],
'force' => [
'initLayout' => 'circular',
'repulsion' => 80,
'edgeLength' => [30, 90],
// Gravity keeps the cloud inside the view box; without it a catalog this wide
// drifts past the edges before the layout settles.
'gravity' => 0.2,
'friction' => 0.3,
],
'lineStyle' => ['color' => 'source', 'curveness' => 0.15, 'opacity' => 0.45],
'scaleLimit' => ['min' => 0.5, 'max' => 4],
]],
];
@endphp
<hw:chart
controller="graph-chart"
:option="$option"
height="560px"
class="rounded-md border"
/>
Stimulus controller
Use data attributes when you need lower-level controller wiring.
<div
data-controller="chart"
data-chart-theme-value="dark"
data-chart-option-value='{"xAxis":{"type":"category","data":["Jan","Feb","Mar"]},"yAxis":{"type":"value"},"series":[{"type":"bar","data":[120,200,150]}]}'
style="width: 100%; height: 320px"
class="rounded-md border"
></div>