dssoca 0.10.0 → 0.11.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/dist/components/BoxPlot.svelte +427 -0
- package/dist/components/BoxPlot.svelte.d.ts +36 -0
- package/dist/components/BumpChart.svelte +351 -0
- package/dist/components/BumpChart.svelte.d.ts +32 -0
- package/dist/components/Heatmap.svelte +333 -0
- package/dist/components/Heatmap.svelte.d.ts +30 -0
- package/dist/components/ScatterPlot.svelte +401 -0
- package/dist/components/ScatterPlot.svelte.d.ts +55 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Size } from '../config.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Row labels, top→bottom. */
|
|
4
|
+
rows: string[];
|
|
5
|
+
/** Column labels, left→right. */
|
|
6
|
+
columns: string[];
|
|
7
|
+
/** values[r][c]; `null` renders a blank cell excluded from the colour scale (e.g. the diagonal). */
|
|
8
|
+
values: (number | null)[][];
|
|
9
|
+
/** Value range mapped to colour intensity; defaults to the [min, max] of all non-null values. */
|
|
10
|
+
domain?: [number, number];
|
|
11
|
+
/** Format a cell value for its text + tooltip. */
|
|
12
|
+
valueFormat?: (v: number) => string;
|
|
13
|
+
/** Render the value text inside each cell. Default true. */
|
|
14
|
+
showValues?: boolean;
|
|
15
|
+
/** X axis caption (drawn under the column headers). */
|
|
16
|
+
xLabel?: string;
|
|
17
|
+
/** Y axis caption (drawn rotated beside the row headers). */
|
|
18
|
+
yLabel?: string;
|
|
19
|
+
/** Square cell size in px. Default 48. */
|
|
20
|
+
cellSize?: number;
|
|
21
|
+
/** Reveal a tooltip on hover/focus of a cell. Default true. */
|
|
22
|
+
tooltip?: boolean;
|
|
23
|
+
/** SR summary + accessible name; auto-generated when absent. */
|
|
24
|
+
summary?: string;
|
|
25
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
26
|
+
size?: Size;
|
|
27
|
+
}
|
|
28
|
+
declare const Heatmap: import("svelte").Component<Props, {}, "">;
|
|
29
|
+
type Heatmap = ReturnType<typeof Heatmap>;
|
|
30
|
+
export default Heatmap;
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export interface ScatterPoint {
|
|
3
|
+
/** Label shown next to the dot and in the tooltip / accessible name. */
|
|
4
|
+
label: string
|
|
5
|
+
x: number
|
|
6
|
+
y: number
|
|
7
|
+
/** Optional magnitude → bubble area (sqrt-scaled radius). Omit for a fixed dot. */
|
|
8
|
+
size?: number
|
|
9
|
+
/** Optional per-point colour; falls back to the cycling palette. */
|
|
10
|
+
color?: string
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
import { scaleLinear, scaleSqrt } from 'd3-scale'
|
|
16
|
+
import { extent, max } from 'd3-array'
|
|
17
|
+
import { resolveComponentSize, type Size } from '../config.js'
|
|
18
|
+
|
|
19
|
+
interface Props {
|
|
20
|
+
/** One dot per datum. Two encoded axes (x, y), optional `size` and `color`. */
|
|
21
|
+
points: ScatterPoint[]
|
|
22
|
+
/** X axis caption (drawn under the axis). */
|
|
23
|
+
xLabel?: string
|
|
24
|
+
/** Y axis caption (drawn rotated beside the axis). */
|
|
25
|
+
yLabel?: string
|
|
26
|
+
/** Draw a dashed vertical reference line at this x (e.g. the median) → quadrants. */
|
|
27
|
+
xRef?: number
|
|
28
|
+
/** Draw a dashed horizontal reference line at this y (e.g. the median) → quadrants. */
|
|
29
|
+
yRef?: number
|
|
30
|
+
/** Corner captions for the four quadrants (needs xRef + yRef to read well). */
|
|
31
|
+
quadrantLabels?: { tl?: string; tr?: string; bl?: string; br?: string }
|
|
32
|
+
/** Force the x domain; defaults to the padded data extent. */
|
|
33
|
+
xDomain?: [number, number]
|
|
34
|
+
/** Force the y domain; defaults to the padded data extent. */
|
|
35
|
+
yDomain?: [number, number]
|
|
36
|
+
/** Format an x value for ticks + tooltip. */
|
|
37
|
+
xFormat?: (x: number) => string
|
|
38
|
+
/** Format a y value for ticks + tooltip. */
|
|
39
|
+
yFormat?: (y: number) => string
|
|
40
|
+
/** Draw each point's label next to its dot. Default true. */
|
|
41
|
+
showLabels?: boolean
|
|
42
|
+
/** Intrinsic drawing height in px. Default 320. */
|
|
43
|
+
height?: number
|
|
44
|
+
/** Intrinsic drawing width in px. Default 420. */
|
|
45
|
+
width?: number
|
|
46
|
+
/** Stretch to the container width via the viewBox (width:100%). */
|
|
47
|
+
fluid?: boolean
|
|
48
|
+
/** Reveal a tooltip on hover/focus of a point. Default true. */
|
|
49
|
+
tooltip?: boolean
|
|
50
|
+
/** SR summary + accessible name; auto-generated when absent. */
|
|
51
|
+
summary?: string
|
|
52
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
53
|
+
size?: Size
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let {
|
|
57
|
+
points,
|
|
58
|
+
xLabel,
|
|
59
|
+
yLabel,
|
|
60
|
+
xRef,
|
|
61
|
+
yRef,
|
|
62
|
+
quadrantLabels,
|
|
63
|
+
xDomain,
|
|
64
|
+
yDomain,
|
|
65
|
+
xFormat,
|
|
66
|
+
yFormat,
|
|
67
|
+
showLabels = true,
|
|
68
|
+
height = 320,
|
|
69
|
+
width = 420,
|
|
70
|
+
fluid = false,
|
|
71
|
+
tooltip = true,
|
|
72
|
+
summary,
|
|
73
|
+
size,
|
|
74
|
+
}: Props = $props()
|
|
75
|
+
|
|
76
|
+
const PALETTE = [
|
|
77
|
+
'var(--ss-primary)',
|
|
78
|
+
'var(--ss-blue)',
|
|
79
|
+
'var(--ss-purple)',
|
|
80
|
+
'var(--ss-cyan)',
|
|
81
|
+
'var(--ss-yellow)',
|
|
82
|
+
'var(--ss-lime)',
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
const M = { top: 12, right: 16, bottom: 36, left: 48 }
|
|
86
|
+
|
|
87
|
+
const clean = $derived(
|
|
88
|
+
(points ?? []).filter((p) => p && Number.isFinite(p.x) && Number.isFinite(p.y)),
|
|
89
|
+
)
|
|
90
|
+
const isEmpty = $derived(clean.length === 0)
|
|
91
|
+
|
|
92
|
+
function colorFor(p: ScatterPoint, i: number): string {
|
|
93
|
+
return p.color ?? PALETTE[i % PALETTE.length]
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const innerW = $derived(Math.max(0, width - M.left - M.right))
|
|
97
|
+
const innerH = $derived(Math.max(0, height - M.top - M.bottom))
|
|
98
|
+
|
|
99
|
+
const fmtX = $derived(xFormat ?? ((x: number) => String(x)))
|
|
100
|
+
const fmtY = $derived(yFormat ?? ((y: number) => String(y)))
|
|
101
|
+
|
|
102
|
+
/** Data extent padded by 8% each side; a flat axis is expanded to ±1. */
|
|
103
|
+
function paddedExtent(values: number[]): [number, number] {
|
|
104
|
+
const e = extent(values) as [number, number]
|
|
105
|
+
if (e[0] === undefined) return [0, 1]
|
|
106
|
+
if (e[0] === e[1]) return [e[0] - 1, e[1] + 1]
|
|
107
|
+
const pad = (e[1] - e[0]) * 0.08
|
|
108
|
+
return [e[0] - pad, e[1] + pad]
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const xDom = $derived(xDomain ?? paddedExtent(clean.map((p) => p.x)))
|
|
112
|
+
const yDom = $derived(yDomain ?? paddedExtent(clean.map((p) => p.y)))
|
|
113
|
+
|
|
114
|
+
const xScaleObj = $derived(scaleLinear().domain(xDom).nice().range([0, innerW]))
|
|
115
|
+
const yScaleObj = $derived(scaleLinear().domain(yDom).nice().range([innerH, 0]))
|
|
116
|
+
|
|
117
|
+
// Bubble radius: sqrt scale (area-true) when any point carries a size, else fixed.
|
|
118
|
+
const hasSizes = $derived(clean.some((p) => typeof p.size === 'number'))
|
|
119
|
+
const rScaleObj = $derived(
|
|
120
|
+
scaleSqrt()
|
|
121
|
+
.domain([0, max(clean, (p) => p.size ?? 0) || 1])
|
|
122
|
+
.range([4, 16]),
|
|
123
|
+
)
|
|
124
|
+
function radiusFor(p: ScatterPoint): number {
|
|
125
|
+
return hasSizes ? rScaleObj(p.size ?? 0) : 5
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const xTicks = $derived(xScaleObj.ticks(5))
|
|
129
|
+
const yTicks = $derived(yScaleObj.ticks(5))
|
|
130
|
+
|
|
131
|
+
const marks = $derived(
|
|
132
|
+
clean.map((p, i) => ({
|
|
133
|
+
cx: xScaleObj(p.x),
|
|
134
|
+
cy: yScaleObj(p.y),
|
|
135
|
+
r: radiusFor(p),
|
|
136
|
+
color: colorFor(p, i),
|
|
137
|
+
label: p.label,
|
|
138
|
+
x: p.x,
|
|
139
|
+
y: p.y,
|
|
140
|
+
})),
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
const corners = $derived.by(() => {
|
|
144
|
+
if (!quadrantLabels) return [] as { x: number; y: number; anchor: string; text: string }[]
|
|
145
|
+
const pad = 4
|
|
146
|
+
const out: { x: number; y: number; anchor: string; text: string }[] = []
|
|
147
|
+
if (quadrantLabels.tl)
|
|
148
|
+
out.push({ x: pad, y: pad + 8, anchor: 'start', text: quadrantLabels.tl })
|
|
149
|
+
if (quadrantLabels.tr)
|
|
150
|
+
out.push({ x: innerW - pad, y: pad + 8, anchor: 'end', text: quadrantLabels.tr })
|
|
151
|
+
if (quadrantLabels.bl)
|
|
152
|
+
out.push({ x: pad, y: innerH - pad, anchor: 'start', text: quadrantLabels.bl })
|
|
153
|
+
if (quadrantLabels.br)
|
|
154
|
+
out.push({ x: innerW - pad, y: innerH - pad, anchor: 'end', text: quadrantLabels.br })
|
|
155
|
+
return out
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
const autoSummary = $derived.by(() => {
|
|
159
|
+
if (isEmpty) return 'No data'
|
|
160
|
+
const names = clean.map((p) => p.label).join(', ')
|
|
161
|
+
return `Scatter plot with ${clean.length} points (${names}).`
|
|
162
|
+
})
|
|
163
|
+
const srText = $derived(summary ?? autoSummary)
|
|
164
|
+
|
|
165
|
+
const resolvedSize = $derived(resolveComponentSize('Chart', size))
|
|
166
|
+
|
|
167
|
+
let active = $state<{ label: string; x: number; y: number; cx: number; cy: number } | null>(null)
|
|
168
|
+
function show(label: string, x: number, y: number, cx: number, cy: number) {
|
|
169
|
+
if (tooltip) active = { label, x, y, cx, cy }
|
|
170
|
+
}
|
|
171
|
+
function hide() {
|
|
172
|
+
active = null
|
|
173
|
+
}
|
|
174
|
+
function datumLabel(label: string, x: number, y: number): string {
|
|
175
|
+
return `${label}: ${fmtX(x)}, ${fmtY(y)}`
|
|
176
|
+
}
|
|
177
|
+
</script>
|
|
178
|
+
|
|
179
|
+
<div
|
|
180
|
+
class="ss-scatter"
|
|
181
|
+
class:fluid
|
|
182
|
+
data-size-variant={resolvedSize}
|
|
183
|
+
role="group"
|
|
184
|
+
aria-label={srText}
|
|
185
|
+
>
|
|
186
|
+
{#if isEmpty}
|
|
187
|
+
<span class="empty" aria-hidden="true">—</span>
|
|
188
|
+
<span class="sr-only">No data</span>
|
|
189
|
+
{:else}
|
|
190
|
+
<div class="plot">
|
|
191
|
+
<svg
|
|
192
|
+
class="canvas"
|
|
193
|
+
viewBox="0 0 {width} {height}"
|
|
194
|
+
width={fluid ? undefined : width}
|
|
195
|
+
height={fluid ? undefined : height}
|
|
196
|
+
preserveAspectRatio="xMidYMid meet"
|
|
197
|
+
role="presentation"
|
|
198
|
+
>
|
|
199
|
+
<g transform="translate({M.left},{M.top})">
|
|
200
|
+
<!-- gridlines + y axis -->
|
|
201
|
+
{#each yTicks as t}
|
|
202
|
+
<line class="grid" x1="0" x2={innerW} y1={yScaleObj(t)} y2={yScaleObj(t)} />
|
|
203
|
+
<text class="tick y" x="-6" y={yScaleObj(t)} dy="0.32em" text-anchor="end"
|
|
204
|
+
>{fmtY(t)}</text
|
|
205
|
+
>
|
|
206
|
+
{/each}
|
|
207
|
+
{#each xTicks as t}
|
|
208
|
+
<text class="tick x" x={xScaleObj(t)} y={innerH + 16} text-anchor="middle"
|
|
209
|
+
>{fmtX(t)}</text
|
|
210
|
+
>
|
|
211
|
+
{/each}
|
|
212
|
+
<line class="axis" x1="0" x2="0" y1="0" y2={innerH} />
|
|
213
|
+
<line class="axis" x1="0" x2={innerW} y1={innerH} y2={innerH} />
|
|
214
|
+
|
|
215
|
+
<!-- quadrant reference lines -->
|
|
216
|
+
{#if xRef !== undefined}
|
|
217
|
+
<line class="ref" x1={xScaleObj(xRef)} x2={xScaleObj(xRef)} y1="0" y2={innerH} />
|
|
218
|
+
{/if}
|
|
219
|
+
{#if yRef !== undefined}
|
|
220
|
+
<line class="ref" x1="0" x2={innerW} y1={yScaleObj(yRef)} y2={yScaleObj(yRef)} />
|
|
221
|
+
{/if}
|
|
222
|
+
|
|
223
|
+
<!-- quadrant captions -->
|
|
224
|
+
{#each corners as c}
|
|
225
|
+
<text class="quadrant" x={c.x} y={c.y} text-anchor={c.anchor}>{c.text}</text>
|
|
226
|
+
{/each}
|
|
227
|
+
|
|
228
|
+
<!-- points -->
|
|
229
|
+
{#each marks as m}
|
|
230
|
+
<circle
|
|
231
|
+
class="point"
|
|
232
|
+
cx={m.cx}
|
|
233
|
+
cy={m.cy}
|
|
234
|
+
r={m.r}
|
|
235
|
+
style="fill:{m.color}"
|
|
236
|
+
tabindex="0"
|
|
237
|
+
role="button"
|
|
238
|
+
aria-label={datumLabel(m.label, m.x, m.y)}
|
|
239
|
+
onfocus={() => show(m.label, m.x, m.y, m.cx, m.cy)}
|
|
240
|
+
onblur={hide}
|
|
241
|
+
onmouseenter={() => show(m.label, m.x, m.y, m.cx, m.cy)}
|
|
242
|
+
onmouseleave={hide}
|
|
243
|
+
/>
|
|
244
|
+
{#if showLabels}
|
|
245
|
+
<text class="point-label" x={m.cx + m.r + 4} y={m.cy} dy="0.32em">{m.label}</text>
|
|
246
|
+
{/if}
|
|
247
|
+
{/each}
|
|
248
|
+
|
|
249
|
+
<!-- axis captions -->
|
|
250
|
+
{#if xLabel}
|
|
251
|
+
<text class="axis-label x" x={innerW / 2} y={innerH + 32} text-anchor="middle"
|
|
252
|
+
>{xLabel}</text
|
|
253
|
+
>
|
|
254
|
+
{/if}
|
|
255
|
+
{#if yLabel}
|
|
256
|
+
<text
|
|
257
|
+
class="axis-label y"
|
|
258
|
+
transform="translate({-M.left + 12},{innerH / 2}) rotate(-90)"
|
|
259
|
+
text-anchor="middle">{yLabel}</text
|
|
260
|
+
>
|
|
261
|
+
{/if}
|
|
262
|
+
</g>
|
|
263
|
+
</svg>
|
|
264
|
+
|
|
265
|
+
{#if tooltip && active}
|
|
266
|
+
<div
|
|
267
|
+
class="tooltip"
|
|
268
|
+
role="status"
|
|
269
|
+
style="left:{((active.cx + M.left) / width) * 100}%;top:{((active.cy + M.top) / height) *
|
|
270
|
+
100}%"
|
|
271
|
+
>
|
|
272
|
+
<span class="t-label">{active.label}</span>
|
|
273
|
+
<span class="t-val">{fmtX(active.x)} · {fmtY(active.y)}</span>
|
|
274
|
+
</div>
|
|
275
|
+
{/if}
|
|
276
|
+
</div>
|
|
277
|
+
{/if}
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
<style>.ss-scatter {
|
|
281
|
+
display: inline-flex;
|
|
282
|
+
flex-direction: column;
|
|
283
|
+
gap: var(--ss-gap-sm);
|
|
284
|
+
font-family: var(--ss-font-body);
|
|
285
|
+
color: var(--ss-fg);
|
|
286
|
+
max-width: 100%;
|
|
287
|
+
}
|
|
288
|
+
.ss-scatter.fluid {
|
|
289
|
+
display: flex;
|
|
290
|
+
width: 100%;
|
|
291
|
+
}
|
|
292
|
+
.ss-scatter .plot {
|
|
293
|
+
position: relative;
|
|
294
|
+
width: 100%;
|
|
295
|
+
}
|
|
296
|
+
.ss-scatter .canvas {
|
|
297
|
+
display: block;
|
|
298
|
+
max-width: 100%;
|
|
299
|
+
height: auto;
|
|
300
|
+
overflow: visible;
|
|
301
|
+
}
|
|
302
|
+
.ss-scatter.fluid .canvas {
|
|
303
|
+
width: 100%;
|
|
304
|
+
}
|
|
305
|
+
.ss-scatter .empty {
|
|
306
|
+
align-self: center;
|
|
307
|
+
margin: auto;
|
|
308
|
+
padding: var(--ss-gap-sm);
|
|
309
|
+
color: var(--ss-fg-muted);
|
|
310
|
+
font-family: var(--ss-font-mono);
|
|
311
|
+
line-height: 1;
|
|
312
|
+
min-height: var(--ss-chart-h, 240px);
|
|
313
|
+
display: flex;
|
|
314
|
+
align-items: center;
|
|
315
|
+
}
|
|
316
|
+
.ss-scatter .sr-only {
|
|
317
|
+
position: absolute;
|
|
318
|
+
width: 1px;
|
|
319
|
+
height: 1px;
|
|
320
|
+
padding: 0;
|
|
321
|
+
margin: -1px;
|
|
322
|
+
overflow: hidden;
|
|
323
|
+
clip: rect(0, 0, 0, 0);
|
|
324
|
+
white-space: nowrap;
|
|
325
|
+
border: 0;
|
|
326
|
+
}
|
|
327
|
+
.ss-scatter .grid {
|
|
328
|
+
stroke: var(--ss-line);
|
|
329
|
+
stroke-width: 1;
|
|
330
|
+
opacity: 0.5;
|
|
331
|
+
shape-rendering: crispEdges;
|
|
332
|
+
}
|
|
333
|
+
.ss-scatter .axis {
|
|
334
|
+
stroke: var(--ss-line);
|
|
335
|
+
stroke-width: 1;
|
|
336
|
+
shape-rendering: crispEdges;
|
|
337
|
+
}
|
|
338
|
+
.ss-scatter .ref {
|
|
339
|
+
stroke: var(--ss-line-strong);
|
|
340
|
+
stroke-width: 1;
|
|
341
|
+
stroke-dasharray: 3 3;
|
|
342
|
+
shape-rendering: crispEdges;
|
|
343
|
+
}
|
|
344
|
+
.ss-scatter .tick {
|
|
345
|
+
font-family: var(--ss-font-mono);
|
|
346
|
+
font-size: var(--ss-ui-xs);
|
|
347
|
+
fill: var(--ss-fg-muted);
|
|
348
|
+
}
|
|
349
|
+
.ss-scatter .quadrant {
|
|
350
|
+
font-family: var(--ss-font-mono);
|
|
351
|
+
font-size: var(--ss-ui-xs);
|
|
352
|
+
fill: var(--ss-fg-muted);
|
|
353
|
+
opacity: 0.75;
|
|
354
|
+
}
|
|
355
|
+
.ss-scatter .axis-label {
|
|
356
|
+
font-family: var(--ss-font-mono);
|
|
357
|
+
font-size: var(--ss-ui-xs);
|
|
358
|
+
fill: var(--ss-fg-muted);
|
|
359
|
+
}
|
|
360
|
+
.ss-scatter .point {
|
|
361
|
+
cursor: pointer;
|
|
362
|
+
fill-opacity: 0.85;
|
|
363
|
+
transition: fill-opacity var(--ss-dur-fast) var(--ss-ease);
|
|
364
|
+
}
|
|
365
|
+
.ss-scatter .point:hover {
|
|
366
|
+
fill-opacity: 1;
|
|
367
|
+
}
|
|
368
|
+
.ss-scatter .point:focus-visible {
|
|
369
|
+
outline: none;
|
|
370
|
+
stroke: var(--ss-fg);
|
|
371
|
+
stroke-width: 2;
|
|
372
|
+
}
|
|
373
|
+
.ss-scatter .point-label {
|
|
374
|
+
font-family: var(--ss-font-mono);
|
|
375
|
+
font-size: var(--ss-ui-xs);
|
|
376
|
+
fill: var(--ss-fg);
|
|
377
|
+
pointer-events: none;
|
|
378
|
+
}
|
|
379
|
+
.ss-scatter .tooltip {
|
|
380
|
+
position: absolute;
|
|
381
|
+
transform: translate(-50%, calc(-100% - 8px));
|
|
382
|
+
pointer-events: none;
|
|
383
|
+
background: var(--ss-bg-elev);
|
|
384
|
+
border: 1px solid var(--ss-line-strong);
|
|
385
|
+
padding: var(--ss-gap-sm);
|
|
386
|
+
font-size: var(--ss-ui-xs);
|
|
387
|
+
line-height: 1.3;
|
|
388
|
+
white-space: nowrap;
|
|
389
|
+
display: flex;
|
|
390
|
+
flex-direction: column;
|
|
391
|
+
gap: 2px;
|
|
392
|
+
z-index: 2;
|
|
393
|
+
}
|
|
394
|
+
.ss-scatter .tooltip .t-label {
|
|
395
|
+
font-family: var(--ss-font-mono);
|
|
396
|
+
color: var(--ss-fg);
|
|
397
|
+
}
|
|
398
|
+
.ss-scatter .tooltip .t-val {
|
|
399
|
+
font-family: var(--ss-font-mono);
|
|
400
|
+
color: var(--ss-fg-muted);
|
|
401
|
+
}</style>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export interface ScatterPoint {
|
|
2
|
+
/** Label shown next to the dot and in the tooltip / accessible name. */
|
|
3
|
+
label: string;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
/** Optional magnitude → bubble area (sqrt-scaled radius). Omit for a fixed dot. */
|
|
7
|
+
size?: number;
|
|
8
|
+
/** Optional per-point colour; falls back to the cycling palette. */
|
|
9
|
+
color?: string;
|
|
10
|
+
}
|
|
11
|
+
import { type Size } from '../config.js';
|
|
12
|
+
interface Props {
|
|
13
|
+
/** One dot per datum. Two encoded axes (x, y), optional `size` and `color`. */
|
|
14
|
+
points: ScatterPoint[];
|
|
15
|
+
/** X axis caption (drawn under the axis). */
|
|
16
|
+
xLabel?: string;
|
|
17
|
+
/** Y axis caption (drawn rotated beside the axis). */
|
|
18
|
+
yLabel?: string;
|
|
19
|
+
/** Draw a dashed vertical reference line at this x (e.g. the median) → quadrants. */
|
|
20
|
+
xRef?: number;
|
|
21
|
+
/** Draw a dashed horizontal reference line at this y (e.g. the median) → quadrants. */
|
|
22
|
+
yRef?: number;
|
|
23
|
+
/** Corner captions for the four quadrants (needs xRef + yRef to read well). */
|
|
24
|
+
quadrantLabels?: {
|
|
25
|
+
tl?: string;
|
|
26
|
+
tr?: string;
|
|
27
|
+
bl?: string;
|
|
28
|
+
br?: string;
|
|
29
|
+
};
|
|
30
|
+
/** Force the x domain; defaults to the padded data extent. */
|
|
31
|
+
xDomain?: [number, number];
|
|
32
|
+
/** Force the y domain; defaults to the padded data extent. */
|
|
33
|
+
yDomain?: [number, number];
|
|
34
|
+
/** Format an x value for ticks + tooltip. */
|
|
35
|
+
xFormat?: (x: number) => string;
|
|
36
|
+
/** Format a y value for ticks + tooltip. */
|
|
37
|
+
yFormat?: (y: number) => string;
|
|
38
|
+
/** Draw each point's label next to its dot. Default true. */
|
|
39
|
+
showLabels?: boolean;
|
|
40
|
+
/** Intrinsic drawing height in px. Default 320. */
|
|
41
|
+
height?: number;
|
|
42
|
+
/** Intrinsic drawing width in px. Default 420. */
|
|
43
|
+
width?: number;
|
|
44
|
+
/** Stretch to the container width via the viewBox (width:100%). */
|
|
45
|
+
fluid?: boolean;
|
|
46
|
+
/** Reveal a tooltip on hover/focus of a point. Default true. */
|
|
47
|
+
tooltip?: boolean;
|
|
48
|
+
/** SR summary + accessible name; auto-generated when absent. */
|
|
49
|
+
summary?: string;
|
|
50
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
51
|
+
size?: Size;
|
|
52
|
+
}
|
|
53
|
+
declare const ScatterPlot: import("svelte").Component<Props, {}, "">;
|
|
54
|
+
type ScatterPlot = ReturnType<typeof ScatterPlot>;
|
|
55
|
+
export default ScatterPlot;
|
package/dist/index.d.ts
CHANGED
|
@@ -38,4 +38,8 @@ export { default as Tooltip } from './components/Tooltip.svelte';
|
|
|
38
38
|
export { default as Avatar } from './components/Avatar.svelte';
|
|
39
39
|
export { default as Pagination } from './components/Pagination.svelte';
|
|
40
40
|
export { default as Switch } from './components/Switch.svelte';
|
|
41
|
+
export { default as ScatterPlot, type ScatterPoint } from './components/ScatterPlot.svelte';
|
|
42
|
+
export { default as BoxPlot, type BoxGroup } from './components/BoxPlot.svelte';
|
|
43
|
+
export { default as BumpChart, type BumpSeries } from './components/BumpChart.svelte';
|
|
44
|
+
export { default as Heatmap } from './components/Heatmap.svelte';
|
|
41
45
|
export { toast, toasts, type Toast, type ToastKind, type ToastAction, type ToastOptions, type ToastPatch, type PromiseMessages, } from './toast.svelte.js';
|
package/dist/index.js
CHANGED
|
@@ -41,4 +41,9 @@ export { default as Tooltip } from './components/Tooltip.svelte';
|
|
|
41
41
|
export { default as Avatar } from './components/Avatar.svelte';
|
|
42
42
|
export { default as Pagination } from './components/Pagination.svelte';
|
|
43
43
|
export { default as Switch } from './components/Switch.svelte';
|
|
44
|
+
// geossoca stats-dashboard charts (DS-0102).
|
|
45
|
+
export { default as ScatterPlot } from './components/ScatterPlot.svelte';
|
|
46
|
+
export { default as BoxPlot } from './components/BoxPlot.svelte';
|
|
47
|
+
export { default as BumpChart } from './components/BumpChart.svelte';
|
|
48
|
+
export { default as Heatmap } from './components/Heatmap.svelte';
|
|
44
49
|
export { toast, toasts, } from './toast.svelte.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dssoca",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Svelte 5 design system — signal green on near-black, monospace-forward, zero border-radius; configured along two axes (color: dark/light, density: comfy/compact).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Rafael Passoca",
|