@fusion.dev/helix-docs 0.191.0 → 0.193.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/metrics.mdx +226 -226
- package/content/spatial-charts.mdx +174 -0
- package/dist/pages.generated.js +6 -0
- package/dist/sources.generated.js +401 -226
- package/package.json +9 -9
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Add charts drawn in three dimensions to your site, styled with your theme, in SVG or with three.js.
|
|
3
|
+
section: Essentials
|
|
4
|
+
title: Spatial charts
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Spatial charts
|
|
8
|
+
|
|
9
|
+
Helix has three charts drawn in three dimensions. Each reads its numbers from a
|
|
10
|
+
table in the document, as every Helix chart does:
|
|
11
|
+
|
|
12
|
+
- `Spatial Heatmap` draws a strip of days as a relief, each day a prism as tall
|
|
13
|
+
as its reading.
|
|
14
|
+
- `Spatial Scatter Chart` places each row as a point in a box, by three measures
|
|
15
|
+
at once.
|
|
16
|
+
- `Spatial Surface Chart` draws one measure as a surface over two others, such
|
|
17
|
+
as load by hour and by day.
|
|
18
|
+
|
|
19
|
+
Each chart draws itself in SVG. `@fusion.dev/helix-plot` can also draw it with
|
|
20
|
+
three.js, in a view you can drag round and zoom.
|
|
21
|
+
|
|
22
|
+
## Draw a spatial chart
|
|
23
|
+
|
|
24
|
+
Put the table in the document, and point the chart at it with `for`:
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<table
|
|
28
|
+
data-hidden-visually
|
|
29
|
+
id="load"
|
|
30
|
+
>
|
|
31
|
+
<caption>Load over a week</caption>
|
|
32
|
+
<thead>
|
|
33
|
+
<tr>
|
|
34
|
+
<th scope="col">Slot</th>
|
|
35
|
+
<th scope="col">Hour</th>
|
|
36
|
+
<th scope="col">Day</th>
|
|
37
|
+
<th scope="col">Requests a minute</th>
|
|
38
|
+
</tr>
|
|
39
|
+
</thead>
|
|
40
|
+
<tbody>
|
|
41
|
+
<tr><th scope="row">Mon 08:00</th><td>8</td><td>1</td><td>994</td></tr>
|
|
42
|
+
…
|
|
43
|
+
</tbody>
|
|
44
|
+
</table>
|
|
45
|
+
|
|
46
|
+
<helix-spatial-surface-chart for="load"></helix-spatial-surface-chart>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Each chart reads its columns in its own way:
|
|
50
|
+
|
|
51
|
+
- **Spatial Scatter Chart** takes the first three numeric columns as across, up,
|
|
52
|
+
and in depth. `group-by` names a column of text that colors each point by its
|
|
53
|
+
group.
|
|
54
|
+
- **Spatial Surface Chart** takes the first numeric column as across, the second
|
|
55
|
+
as depth, and the third as the height. A place on the grid with no reading
|
|
56
|
+
leaves a hole.
|
|
57
|
+
- **Spatial Heatmap** reads its table as `Heatmap` does, down each column of
|
|
58
|
+
`rows` and then across. Its table goes inside it.
|
|
59
|
+
|
|
60
|
+
The drawing is SVG. A server writes the chart's frame, and the drawing arrives
|
|
61
|
+
when the chart reads its table in the browser.
|
|
62
|
+
|
|
63
|
+
## Draw it with three.js
|
|
64
|
+
|
|
65
|
+
Install the package and three.js:
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
bun add @fusion.dev/helix-plot three
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Put an element inside the chart for three.js to draw in, and connect the two:
|
|
72
|
+
|
|
73
|
+
```html
|
|
74
|
+
<helix-spatial-scatter-chart
|
|
75
|
+
for="customers"
|
|
76
|
+
group-by="Segment"
|
|
77
|
+
>
|
|
78
|
+
<div></div>
|
|
79
|
+
</helix-spatial-scatter-chart>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
import { connectSpatialScatterChart } from '@fusion.dev/helix-plot'
|
|
84
|
+
import { threeScatterDriver } from '@fusion.dev/helix-plot/three'
|
|
85
|
+
|
|
86
|
+
const chart = document.querySelector('helix-spatial-scatter-chart')
|
|
87
|
+
const connection = connectSpatialScatterChart(chart, threeScatterDriver(chart.querySelector('div')))
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Each chart has its own connector and driver:
|
|
91
|
+
|
|
92
|
+
| Chart | Connector | Driver |
|
|
93
|
+
|---|---|---|
|
|
94
|
+
| `Spatial Heatmap` | `connectSpatialHeatmap` | `threeHeatmapDriver` |
|
|
95
|
+
| `Spatial Scatter Chart` | `connectSpatialScatterChart` | `threeScatterDriver` |
|
|
96
|
+
| `Spatial Surface Chart` | `connectSpatialSurfaceChart` | `threeSurfaceDriver` |
|
|
97
|
+
|
|
98
|
+
`Spatial Heatmap` takes the element in its `renderer` slot, because its table
|
|
99
|
+
is inside it:
|
|
100
|
+
|
|
101
|
+
```html
|
|
102
|
+
<helix-spatial-heatmap
|
|
103
|
+
for="commits"
|
|
104
|
+
rows="7"
|
|
105
|
+
>
|
|
106
|
+
<table id="commits">…</table>
|
|
107
|
+
<div slot="renderer"></div>
|
|
108
|
+
</helix-spatial-heatmap>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Once three.js has drawn, the chart hides its SVG drawing.
|
|
112
|
+
`connection.disconnect()` frees the renderer and shows the SVG drawing again.
|
|
113
|
+
|
|
114
|
+
## Choose SVG or three.js
|
|
115
|
+
|
|
116
|
+
| | SVG | three.js |
|
|
117
|
+
|---|---|---|
|
|
118
|
+
| What it needs | Nothing more than the chart | `@fusion.dev/helix-plot`, three.js, and WebGL |
|
|
119
|
+
| How the view moves | Shift with an arrow turns it a step | Drag to turn, the wheel or a pinch to zoom, and Shift with an arrow to turn a step |
|
|
120
|
+
| Light | Shaded by which way each face turns, with no perspective | Lit from above, in perspective |
|
|
121
|
+
| Without WebGL | Drawn | Not drawn, and the SVG drawing stays |
|
|
122
|
+
|
|
123
|
+
Start with SVG. Connect three.js where a reader gains from turning the chart
|
|
124
|
+
freely, or where the data is too large for SVG to draw smoothly.
|
|
125
|
+
|
|
126
|
+
## Read a chart with the pointer and the keys
|
|
127
|
+
|
|
128
|
+
A pointer resting on a reading shows its row in the chart's tooltip, the same
|
|
129
|
+
tooltip every Helix chart shows. A tap shows it until a tap lands elsewhere.
|
|
130
|
+
|
|
131
|
+
The plot takes focus, and the keys move the reading:
|
|
132
|
+
|
|
133
|
+
| Key | Spatial Scatter Chart | Spatial Surface Chart |
|
|
134
|
+
|---|---|---|
|
|
135
|
+
| Right, Left | The next or the previous point, in the table's order | Across, to the next or the previous place |
|
|
136
|
+
| Up, Down | Among the point's measures, which the readout says first | In depth, back and forward |
|
|
137
|
+
| Home, End | The first or the last point | The first or the last place |
|
|
138
|
+
| Shift with an arrow | Turns the view a step | Turns the view a step |
|
|
139
|
+
| Enter, Space | Presses the point | Presses the place |
|
|
140
|
+
| Escape | Lets the reading go | Lets the reading go |
|
|
141
|
+
|
|
142
|
+
`Spatial Heatmap` takes `Heatmap`'s keys, and Shift with an arrow turns its
|
|
143
|
+
view, except under `selection-mode="multiple"`, where it selects a range.
|
|
144
|
+
|
|
145
|
+
In three.js, a turn moves over a quarter of a second, and with reduced motion
|
|
146
|
+
set it happens at once. The SVG drawing turns in one step. No spatial chart
|
|
147
|
+
turns by itself.
|
|
148
|
+
|
|
149
|
+
## Color a spatial chart
|
|
150
|
+
|
|
151
|
+
Each chart takes its colors from your theme, and these hooks change them:
|
|
152
|
+
|
|
153
|
+
- **Spatial Scatter Chart**: each group takes a series color,
|
|
154
|
+
`--chart-series-1` and on.
|
|
155
|
+
- **Spatial Surface Chart**: the surface is shaded from `--spatial-surface-chart-low`
|
|
156
|
+
to `--spatial-surface-chart-high`.
|
|
157
|
+
- **Spatial Heatmap**: each day takes its tone's color, as on `Heatmap`:
|
|
158
|
+
`--heatmap-tone-1` to `--heatmap-tone-5` along the ramp, or a named tone such
|
|
159
|
+
as `--heatmap-tone-success`. `--spatial-heatmap-left-shade` and
|
|
160
|
+
`--spatial-heatmap-right-shade` set how much less light each side of a prism
|
|
161
|
+
is than its top.
|
|
162
|
+
|
|
163
|
+
three.js reads the same colors, so the two drawings agree. It lights the
|
|
164
|
+
prisms and the surface itself, so the two shade hooks apply to the SVG drawing
|
|
165
|
+
alone.
|
|
166
|
+
|
|
167
|
+
## Many drawings on one page
|
|
168
|
+
|
|
169
|
+
Every three.js drawing Helix makes on a page shares six WebGL contexts, the
|
|
170
|
+
spatial charts' and the graphs' alike. Past six, a drawing far off screen gives
|
|
171
|
+
its context back and takes it again as it comes near.
|
|
172
|
+
|
|
173
|
+
A three.js drawing draws only while something moves. It asks the browser for no
|
|
174
|
+
frames at rest, or while it is out of view.
|
package/dist/pages.generated.js
CHANGED
|
@@ -206,6 +206,12 @@ export const docPages = [
|
|
|
206
206
|
slug: 'space-and-size',
|
|
207
207
|
title: 'Space and size',
|
|
208
208
|
},
|
|
209
|
+
{
|
|
210
|
+
description: 'Add charts drawn in three dimensions to your site, styled with your theme, in SVG or with three.js.',
|
|
211
|
+
section: 'Essentials',
|
|
212
|
+
slug: 'spatial-charts',
|
|
213
|
+
title: 'Spatial charts',
|
|
214
|
+
},
|
|
209
215
|
{
|
|
210
216
|
description: 'How a property you set becomes a starting value, and how to cancel or take over a change.',
|
|
211
217
|
section: 'Essentials',
|