Charts plus JS behaviour

Brush chart

A line / area chart with a range brush under it: drag the window to pan, drag the edges to resize (native range inputs, full keyboard); the main plot zooms to the range and dispatches nx-range.

Real scenarios

The component as it is used in a product — not a specimen grid.

Daily active users, last 90 days

The strip under the chart holds all 90 days; the window picks the slice the main plot zooms to. Drag the window to pan, drag either edge to resize — the edges are native range inputs, so Tab lands on them and the arrow keys work as everywhere. With the window focused, arrows pan by a day and Shift+arrow by a whole window. The launch week spike is marked as the range’s high.

Daily active users

Web + app

Selected range

Daily active users
Active users
Day 13,864
Day 24,238
Day 34,533
Day 44,659
Day 54,526
Day 63,775
Day 73,454
Day 84,109
Day 94,504
Day 104,815
Day 114,946
Day 124,803
Day 134,004
Day 143,661
Day 154,353
Day 164,770
Day 175,096
Day 185,234
Day 195,079
Day 204,233
Day 213,869
Day 224,598
Day 235,036
Day 245,378
Day 255,521
Day 265,356
Day 274,462
Day 284,076
Day 294,843
Day 305,302
Day 315,660
Day 325,808
Day 335,633
Day 344,690
Day 354,284
Day 365,088
Day 375,568
Day 385,942
Day 396,096
Day 405,909
Day 414,919
Day 424,491
Day 435,332
Day 445,834
Day 456,224
Day 466,383
Day 476,186
Day 485,148
Day 494,699
Day 505,577
Day 516,100
Day 526,506
Day 536,670
Day 546,463
Day 555,377
Day 564,906
Day 575,822
Day 586,366
Day 596,788
Day 606,957
Day 616,739
Day 627,175
Day 636,903
Day 648,614
Day 658,953
Day 669,050
Day 678,766
Day 687,016
Day 695,834
Day 705,321
Day 716,311
Day 726,898
Day 737,352
Day 747,532
Day 757,292
Day 766,063
Day 775,529
Day 786,556
Day 797,164
Day 807,634
Day 817,819
Day 827,569
Day 836,292
Day 845,736
Day 856,801
Day 867,430
Day 877,916
Day 888,106
Day 897,846
Day 906,521

Two days of CPU, a narrow window

variant="line" without the wash, and a six-hour window. Every move dispatches nx-range with { range, from, to } — the readout below listens to it with plain Alpine.

CPU usage

Percent · app-server-2

Selected range

CPU usage
CPU
00:0015
01:0015
02:0016
03:0019
04:0023
05:0018
06:0025
07:0032
08:0040
09:0048
10:0045
11:0052
12:0057
13:0061
14:0064
15:0055
16:0055
17:0054
18:0051
19:0048
20:0034
21:0030
22:0027
23:0024
00:0023
01:0013
02:0014
03:0017
04:0021
05:0026
06:0023
07:0030
08:0038
09:0046
10:0053
11:0050
12:0055
13:0059
14:0062
15:0063
16:0053
17:0052
18:0049
19:0046
20:0042
21:0028
22:0025
23:0022

Last event: →

Important props

Important props
Prop Type Default What it does
labels / series array [] All the data; the main plot shows only the selected range.
range / min-span array / int last third / 2 The starting [start, end] index range and the narrowest window.
variant / curve string area / smooth area | line, and the curve smooth | linear | step.
x-on:nx-range event — Every change: detail = { range, from, to } — e.g. $wire.set('range', $event.detail.range).
height / brush-height / markers int / int / bool 240 / 56 / true The main plot and strip heights, and high / low markers of the range.

Snippet

<x-nx::brush-chart title="کاربران فعال روزانه" :labels="$days"
    :series="[['name' => 'کاربر فعال', 'values' => $dau]]"
    :range="[60, 89]" min-span="6"
    x-on:nx-range="$wire.set('range', $event.detail.range)" />