1. Components
  2. heatmap

Heatmap

Heatmaps to spot patterns across two dimensions.

Simple

One row per series, one column per category. Intensity follows a single hue, --chart-1 .

Support tickets by hour
Hour Monday Tuesday Wednesday Thursday Friday
08:00 20 26 39 24 9
09:00 27 34 48 32 14
10:00 34 42 56 39 19
11:00 40 49 62 46 25
12:00 45 55 66 51 29
13:00 48 58 68 54 33
14:00 50 60 67 56 35
15:00 50 59 65 55 36
16:00 47 57 60 53 36
17:00 43 52 53 49 34
18:00 38 46 45 43 31
19:00 31 39 35 36 27
20:00 24 31 26 29 22
@php
    // One row per series (weekday), one column per category (hour).
    $hours = collect(range(8, 20))->map(fn (int $h) => [
        'hour' => sprintf('%02d:00', $h),
        'mon' => (int) round(20 + 30 * sin(($h - 8) / 4)),
        'tue' => (int) round(26 + 34 * sin(($h - 8) / 4)),
        'wed' => (int) round(30 + 38 * sin(($h - 7) / 4)),
        'thu' => (int) round(24 + 32 * sin(($h - 8) / 4)),
        'fri' => (int) round(14 + 22 * sin(($h - 9) / 4)),
    ])->all();
@endphp

<x-ui.echart type="heatmap" :data="$hours" index="hour" label="Support tickets by hour" class="h-72 w-full" :config="[
    'mon' => ['label' => 'Monday'],
    'tue' => ['label' => 'Tuesday'],
    'wed' => ['label' => 'Wednesday'],
    'thu' => ['label' => 'Thursday'],
    'fri' => ['label' => 'Friday'],
]" />

A full week, hour by hour

168 cells. The rows are built from a list of days, and options resizes the scale.

Deploys by hour and weekday
Hour Monday Tuesday Wednesday Thursday Friday Saturday Sunday
00 0 3 1 4 2 0 3
01 0 3 1 4 2 0 3
02 1 4 2 5 3 0 3
03 2 5 3 6 4 0 3
04 5 8 6 9 7 0 3
05 8 11 9 12 10 0 3
06 13 16 14 17 15 0 3
07 20 23 21 24 22 0 3
08 28 31 29 32 30 1 4
09 35 38 36 39 37 2 5
10 40 43 41 44 42 4 7
11 42 45 43 46 44 6 9
12 40 43 41 44 42 9 12
13 35 38 36 39 37 12 15
14 28 31 29 32 30 15 18
15 20 23 21 24 22 17 20
16 13 16 14 17 15 18 21
17 8 11 9 12 10 17 20
18 5 8 6 9 7 15 18
19 2 5 3 6 4 12 15
20 1 4 2 5 3 9 12
21 0 3 1 4 2 6 9
22 0 3 1 4 2 4 7
23 0 3 1 4 2 2 5
@php
    // 7 days × 24 hours. Rows are series, so each weekday is one config entry.
    $days = ['mon' => 'Monday', 'tue' => 'Tuesday', 'wed' => 'Wednesday', 'thu' => 'Thursday', 'fri' => 'Friday', 'sat' => 'Saturday', 'sun' => 'Sunday'];
    $hours = collect(range(0, 23))->map(function (int $h) use ($days) {
        $row = ['hour' => sprintf('%02d', $h)];
        foreach (array_keys($days) as $d => $key) {
            $weekend = $d >= 5;
            $row[$key] = max(0, (int) round(($weekend ? 18 : 42) * exp(-(($h - ($weekend ? 16 : 11)) ** 2) / 22) + ($d * 3 % 5)));
        }

        return $row;
    })->all();
@endphp

<x-ui.echart type="heatmap" :data="$hours" index="hour" label="Deploys by hour and weekday" class="h-96 w-full"
    :config="collect($days)->map(fn ($label) => ['label' => $label])->all()"
    :options="['visualMap' => ['itemWidth' => 12, 'itemHeight' => 160]]" />

See Chart for installation and every prop.