@sentropic/design-system-svelte 0.34.73 → 0.35.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/README.md +31 -1
- package/dist/{GeoMap.svelte → GeoChart.svelte} +72 -72
- package/dist/{GeoMap.svelte.d.ts → GeoChart.svelte.d.ts} +44 -44
- package/dist/GeoChart.svelte.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +7 -2
- package/dist/AppChrome.test.d.ts +0 -2
- package/dist/AppChrome.test.d.ts.map +0 -1
- package/dist/AppChrome.test.js +0 -146
- package/dist/AppShell.panelCollapse.test.d.ts +0 -2
- package/dist/AppShell.panelCollapse.test.d.ts.map +0 -1
- package/dist/AppShell.panelCollapse.test.js +0 -129
- package/dist/AppShell.panelResize.test.d.ts +0 -2
- package/dist/AppShell.panelResize.test.d.ts.map +0 -1
- package/dist/AppShell.panelResize.test.js +0 -338
- package/dist/Collapsible.test.d.ts +0 -2
- package/dist/Collapsible.test.d.ts.map +0 -1
- package/dist/Collapsible.test.js +0 -76
- package/dist/ContourChart.test.d.ts +0 -2
- package/dist/ContourChart.test.d.ts.map +0 -1
- package/dist/ContourChart.test.js +0 -59
- package/dist/EventFeedPanel.test.d.ts +0 -2
- package/dist/EventFeedPanel.test.d.ts.map +0 -1
- package/dist/EventFeedPanel.test.js +0 -66
- package/dist/GeoMap.svelte.d.ts.map +0 -1
- package/dist/Icon.test.d.ts +0 -2
- package/dist/Icon.test.d.ts.map +0 -1
- package/dist/Icon.test.js +0 -38
- package/dist/PanelStack.test.d.ts +0 -2
- package/dist/PanelStack.test.d.ts.map +0 -1
- package/dist/PanelStack.test.js +0 -679
- package/dist/PanelStackFixture.svelte +0 -53
- package/dist/PointAndFigureChart.test.d.ts +0 -2
- package/dist/PointAndFigureChart.test.d.ts.map +0 -1
- package/dist/PointAndFigureChart.test.js +0 -73
- package/dist/RenkoChart.test.d.ts +0 -2
- package/dist/RenkoChart.test.d.ts.map +0 -1
- package/dist/RenkoChart.test.js +0 -66
- package/dist/TimeRangePicker.test.d.ts +0 -2
- package/dist/TimeRangePicker.test.d.ts.map +0 -1
- package/dist/TimeRangePicker.test.js +0 -482
- package/dist/VectorFieldChart.test.d.ts +0 -2
- package/dist/VectorFieldChart.test.d.ts.map +0 -1
- package/dist/VectorFieldChart.test.js +0 -59
- package/dist/WindBarbChart.test.d.ts +0 -2
- package/dist/WindBarbChart.test.d.ts.map +0 -1
- package/dist/WindBarbChart.test.js +0 -65
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# `@sentropic/design-system-svelte`
|
|
2
2
|
|
|
3
|
-
Svelte implementation of the Sentropic design-system component catalog. The package ships
|
|
3
|
+
Svelte implementation of the Sentropic design-system component catalog. The package ships TypeScript declarations, the shared component CSS, and the components themselves as **uncompiled `.svelte` source written in TypeScript** — every component file carries `<script lang="ts">`.
|
|
4
|
+
|
|
5
|
+
That last part has a consequence worth reading before you file a bug: **your build must preprocess this package's `.svelte` files, not just compile them.** See [TypeScript source, and what your build must do](#typescript-source-and-what-your-build-must-do).
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
@@ -60,3 +62,31 @@ npm --workspace @sentropic/design-system-svelte run test
|
|
|
60
62
|
```
|
|
61
63
|
|
|
62
64
|
Publishing is handled by `.github/workflows/svelte-publish.yml` with a `svelte-v*` tag.
|
|
65
|
+
|
|
66
|
+
## TypeScript source, and what your build must do
|
|
67
|
+
|
|
68
|
+
The `.svelte` files in `dist/` are **source**, not compiled output. Each one begins with `<script lang="ts">` and contains type annotations. A Svelte-aware build therefore has to do two distinct things to them:
|
|
69
|
+
|
|
70
|
+
1. **preprocess** — strip the TypeScript (`vitePreprocess()` from `@sveltejs/vite-plugin-svelte`, or an equivalent);
|
|
71
|
+
2. **compile** — turn the result into a component.
|
|
72
|
+
|
|
73
|
+
Most setups do the second to dependencies but not the first, because preprocessing is commonly scoped to your own `src/`. When that happens the compiler receives TypeScript it cannot parse, and the error points at *our* file:
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
RollupError: Parse failure: Expected ',', got '?'
|
|
77
|
+
at node_modules/@sentropic/design-system-svelte/dist/Accordion.svelte
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**That error is a build-configuration symptom, not a broken package.** If you hit it, before filing anything, compare your copy against what npm actually served:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
sha256sum node_modules/@sentropic/design-system-svelte/dist/Accordion.svelte
|
|
84
|
+
head -1 node_modules/@sentropic/design-system-svelte/dist/Accordion.svelte # <script lang="ts" module>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
If `lang="ts"` is on line 1 and the annotations are intact, the file on disk is fine and something in your pipeline is transforming it in flight. Usual suspects: a stale `node_modules/.vite` prebundle cache, the package being externalized so your Svelte plugin never sees it, or preprocessing configured only for your own sources.
|
|
88
|
+
|
|
89
|
+
This bites hardest under **vitest with jsdom**, where dependencies are externalized by default and never reach your Svelte plugin at all.
|
|
90
|
+
|
|
91
|
+
Our own packaging test preprocesses and compiles all 220 published `.svelte` files on every release (`scripts/smoke-pack.mjs`), so a genuinely unparseable file cannot ship. What that test does *not* do is reproduce every consumer bundler configuration — if you find an arrangement where a correct tarball still fails to build, that is worth reporting, and please include the `sha256sum` above.
|
|
92
|
+
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
export type
|
|
2
|
+
export type GeoChartTone =
|
|
3
3
|
| "category1" | "category2" | "category3" | "category4"
|
|
4
4
|
| "category5" | "category6" | "category7" | "category8";
|
|
5
5
|
|
|
6
6
|
/** Coordonnée géographique — même forme que `GeoCoordinate` (dataviz-core). */
|
|
7
|
-
export type
|
|
7
|
+
export type GeoChartCoordinate = {
|
|
8
8
|
latitude: number;
|
|
9
9
|
longitude: number;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
/** Emprise géographique — même forme que `GeoBounds` (dataviz-core). */
|
|
13
|
-
export type
|
|
13
|
+
export type GeoChartBounds = {
|
|
14
14
|
south: number;
|
|
15
15
|
west: number;
|
|
16
16
|
north: number;
|
|
17
17
|
east: number;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export type
|
|
20
|
+
export type GeoChartProjection = "equirectangular" | "mercator";
|
|
21
21
|
|
|
22
|
-
export type
|
|
22
|
+
export type GeoChartGeometryType =
|
|
23
23
|
| "Point"
|
|
24
24
|
| "MultiPoint"
|
|
25
25
|
| "LineString"
|
|
@@ -28,124 +28,124 @@
|
|
|
28
28
|
| "MultiPolygon";
|
|
29
29
|
|
|
30
30
|
/** Géométrie GeoJSON — même forme que `GeoJsonGeometry` (dataviz-core). */
|
|
31
|
-
export type
|
|
32
|
-
type:
|
|
31
|
+
export type GeoChartGeometry = {
|
|
32
|
+
type: GeoChartGeometryType;
|
|
33
33
|
coordinates: unknown[];
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
/** Entité géographique — sous-ensemble structurel de `GeoJsonFeature` (dataviz-core). */
|
|
37
|
-
export type
|
|
37
|
+
export type GeoChartFeature = {
|
|
38
38
|
id: string;
|
|
39
39
|
label?: string;
|
|
40
40
|
value?: number;
|
|
41
|
-
geometry:
|
|
41
|
+
geometry: GeoChartGeometry;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
/** Point géographique — sur-ensemble structurel de `GeoPoint` (dataviz-core). */
|
|
45
|
-
export type
|
|
45
|
+
export type GeoChartPoint = GeoChartCoordinate & {
|
|
46
46
|
id?: string;
|
|
47
47
|
label?: string;
|
|
48
48
|
value?: number;
|
|
49
|
-
tone?:
|
|
49
|
+
tone?: GeoChartTone;
|
|
50
50
|
/** Rayon explicite en px (prioritaire sur l'échelle par `value`), borné à 32. */
|
|
51
51
|
r?: number;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
/** Flux géographique — sous-ensemble structurel de `GeoFlowLink` (dataviz-core). */
|
|
55
|
-
export type
|
|
55
|
+
export type GeoChartFlow = {
|
|
56
56
|
id?: string;
|
|
57
57
|
label?: string;
|
|
58
|
-
source:
|
|
59
|
-
target:
|
|
58
|
+
source: GeoChartCoordinate;
|
|
59
|
+
target: GeoChartCoordinate;
|
|
60
60
|
value?: number;
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
/** Entités GeoJSON (polygones, lignes, points) ; ton par couche ou cycle de palette par entité. */
|
|
64
|
-
export type
|
|
64
|
+
export type GeoChartGeojsonLayer = {
|
|
65
65
|
type: "geojson";
|
|
66
|
-
features:
|
|
67
|
-
tone?:
|
|
66
|
+
features: GeoChartFeature[];
|
|
67
|
+
tone?: GeoChartTone;
|
|
68
68
|
label?: string;
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
/** Choroplèthe : entités + valeur par id (`regions` dataviz : `key` → `value`) → intensité color-mix. */
|
|
72
|
-
export type
|
|
72
|
+
export type GeoChartChoroplethLayer = {
|
|
73
73
|
type: "choropleth";
|
|
74
|
-
features:
|
|
74
|
+
features: GeoChartFeature[];
|
|
75
75
|
values: Record<string, number>;
|
|
76
76
|
/** Ton de base de la rampe d'intensité (défaut `category1`). */
|
|
77
|
-
tone?:
|
|
77
|
+
tone?: GeoChartTone;
|
|
78
78
|
label?: string;
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
/** Points/épingles : rayon ∝ `value` (bornes `minRadius`/`maxRadius`, défauts 5/14 comme dataviz). */
|
|
82
|
-
export type
|
|
82
|
+
export type GeoChartPointsLayer = {
|
|
83
83
|
type: "points";
|
|
84
|
-
points:
|
|
85
|
-
tone?:
|
|
84
|
+
points: GeoChartPoint[];
|
|
85
|
+
tone?: GeoChartTone;
|
|
86
86
|
minRadius?: number;
|
|
87
87
|
maxRadius?: number;
|
|
88
88
|
label?: string;
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
/** Densité : cercles translucides superposés, rayon/intensité ∝ `value` (poids). */
|
|
92
|
-
export type
|
|
92
|
+
export type GeoChartDensityLayer = {
|
|
93
93
|
type: "density";
|
|
94
|
-
points:
|
|
94
|
+
points: GeoChartPoint[];
|
|
95
95
|
/** Ton de la nappe (défaut `category3` — parité visuelle dataviz). */
|
|
96
|
-
tone?:
|
|
96
|
+
tone?: GeoChartTone;
|
|
97
97
|
maxRadius?: number;
|
|
98
98
|
label?: string;
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
/** Flux : arcs quadratiques source → target, épaisseur ∝ `value` (défaut ton `category1`). */
|
|
102
|
-
export type
|
|
102
|
+
export type GeoChartFlowLayer = {
|
|
103
103
|
type: "flow";
|
|
104
|
-
flows:
|
|
105
|
-
tone?:
|
|
104
|
+
flows: GeoChartFlow[];
|
|
105
|
+
tone?: GeoChartTone;
|
|
106
106
|
label?: string;
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
/** Hexbin : binning hexagonal des points (même binning que dataviz-core), intensité ∝ valeur agrégée. */
|
|
110
|
-
export type
|
|
110
|
+
export type GeoChartHexbinLayer = {
|
|
111
111
|
type: "hexbin";
|
|
112
|
-
points:
|
|
112
|
+
points: GeoChartPoint[];
|
|
113
113
|
/** Taille de cellule en degrés (défaut 1). */
|
|
114
114
|
cellSize?: number;
|
|
115
|
-
tone?:
|
|
115
|
+
tone?: GeoChartTone;
|
|
116
116
|
label?: string;
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
/** Clusters : regroupement glouton des points (même algo que dataviz-core), centroïdes marqueurs distinctifs. */
|
|
120
|
-
export type
|
|
120
|
+
export type GeoChartClusterLayer = {
|
|
121
121
|
type: "cluster";
|
|
122
|
-
points:
|
|
122
|
+
points: GeoChartPoint[];
|
|
123
123
|
/** Rayon de regroupement en degrés (défaut 1). */
|
|
124
124
|
radius?: number;
|
|
125
|
-
tone?:
|
|
125
|
+
tone?: GeoChartTone;
|
|
126
126
|
label?: string;
|
|
127
127
|
};
|
|
128
128
|
|
|
129
|
-
export type
|
|
130
|
-
|
|
|
131
|
-
|
|
|
132
|
-
|
|
|
133
|
-
|
|
|
134
|
-
|
|
|
135
|
-
|
|
|
136
|
-
|
|
|
129
|
+
export type GeoChartLayer =
|
|
130
|
+
| GeoChartGeojsonLayer
|
|
131
|
+
| GeoChartChoroplethLayer
|
|
132
|
+
| GeoChartPointsLayer
|
|
133
|
+
| GeoChartDensityLayer
|
|
134
|
+
| GeoChartFlowLayer
|
|
135
|
+
| GeoChartHexbinLayer
|
|
136
|
+
| GeoChartClusterLayer;
|
|
137
137
|
</script>
|
|
138
138
|
|
|
139
139
|
<script lang="ts">
|
|
140
140
|
import ChartDataList from "./ChartDataList.svelte";
|
|
141
141
|
|
|
142
|
-
type
|
|
143
|
-
layers:
|
|
142
|
+
type GeoChartProps = {
|
|
143
|
+
layers: GeoChartLayer[];
|
|
144
144
|
width?: number;
|
|
145
145
|
height?: number;
|
|
146
|
-
projection?:
|
|
146
|
+
projection?: GeoChartProjection;
|
|
147
147
|
/** Emprise explicite ; sinon auto-ajustement sur les données de toutes les couches + marge. */
|
|
148
|
-
bounds?:
|
|
148
|
+
bounds?: GeoChartBounds;
|
|
149
149
|
label: string;
|
|
150
150
|
class?: string;
|
|
151
151
|
};
|
|
@@ -158,15 +158,15 @@
|
|
|
158
158
|
bounds,
|
|
159
159
|
label,
|
|
160
160
|
class: className
|
|
161
|
-
}:
|
|
161
|
+
}: GeoChartProps = $props();
|
|
162
162
|
|
|
163
163
|
const PADDING = 24;
|
|
164
164
|
const MAX_POINT_RADIUS = 32;
|
|
165
|
-
const WORLD:
|
|
165
|
+
const WORLD: GeoChartBounds = { south: -90, west: -180, north: 90, east: 180 };
|
|
166
166
|
const TONES = ["category1","category2","category3","category4","category5","category6","category7","category8"] as const;
|
|
167
167
|
const GEOMETRY_TYPES = new Set(["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"]);
|
|
168
168
|
|
|
169
|
-
function isFiniteCoordinate<T extends
|
|
169
|
+
function isFiniteCoordinate<T extends GeoChartCoordinate>(c: T | undefined): c is T {
|
|
170
170
|
return !!c && Number.isFinite(c.latitude) && Number.isFinite(c.longitude);
|
|
171
171
|
}
|
|
172
172
|
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
return Math.round(Math.max(0, Math.min(100, value)));
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
function coordinatePair(value: unknown):
|
|
182
|
+
function coordinatePair(value: unknown): GeoChartCoordinate | undefined {
|
|
183
183
|
if (!Array.isArray(value) || value.length < 2 || Array.isArray(value[0])) return undefined;
|
|
184
184
|
const longitude = Number(value[0]);
|
|
185
185
|
const latitude = Number(value[1]);
|
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
return { latitude, longitude };
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
function collectGeometryCoordinates(value: unknown, out:
|
|
190
|
+
function collectGeometryCoordinates(value: unknown, out: GeoChartCoordinate[]): void {
|
|
191
191
|
if (!Array.isArray(value)) return;
|
|
192
192
|
const pair = coordinatePair(value);
|
|
193
193
|
if (pair) {
|
|
@@ -197,15 +197,15 @@
|
|
|
197
197
|
for (const item of value) collectGeometryCoordinates(item, out);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
function isGeometry(geometry:
|
|
200
|
+
function isGeometry(geometry: GeoChartGeometry | undefined): geometry is GeoChartGeometry {
|
|
201
201
|
return !!geometry && GEOMETRY_TYPES.has(geometry.type) && Array.isArray(geometry.coordinates);
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
function layerCoordinates(layer:
|
|
204
|
+
function layerCoordinates(layer: GeoChartLayer): GeoChartCoordinate[] {
|
|
205
205
|
switch (layer.type) {
|
|
206
206
|
case "geojson":
|
|
207
207
|
case "choropleth": {
|
|
208
|
-
const out:
|
|
208
|
+
const out: GeoChartCoordinate[] = [];
|
|
209
209
|
for (const feature of layer.features ?? []) {
|
|
210
210
|
if (isGeometry(feature.geometry)) collectGeometryCoordinates(feature.geometry.coordinates, out);
|
|
211
211
|
}
|
|
@@ -217,7 +217,7 @@
|
|
|
217
217
|
case "cluster":
|
|
218
218
|
return (layer.points ?? []).filter(isFiniteCoordinate);
|
|
219
219
|
case "flow": {
|
|
220
|
-
const out:
|
|
220
|
+
const out: GeoChartCoordinate[] = [];
|
|
221
221
|
for (const flow of layer.flows ?? []) {
|
|
222
222
|
if (isFiniteCoordinate(flow.source)) out.push(flow.source);
|
|
223
223
|
if (isFiniteCoordinate(flow.target)) out.push(flow.target);
|
|
@@ -227,7 +227,7 @@
|
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
function validBounds(candidate:
|
|
230
|
+
function validBounds(candidate: GeoChartBounds | undefined): GeoChartBounds | null {
|
|
231
231
|
return candidate &&
|
|
232
232
|
Number.isFinite(candidate.south) && Number.isFinite(candidate.west) &&
|
|
233
233
|
Number.isFinite(candidate.north) && Number.isFinite(candidate.east) &&
|
|
@@ -236,7 +236,7 @@
|
|
|
236
236
|
: null;
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
function fitBounds(all:
|
|
239
|
+
function fitBounds(all: GeoChartLayer[]): GeoChartBounds {
|
|
240
240
|
const coords = all.flatMap(layerCoordinates);
|
|
241
241
|
if (coords.length === 0) return WORLD;
|
|
242
242
|
let south = Infinity, west = Infinity, north = -Infinity, east = -Infinity;
|
|
@@ -273,7 +273,7 @@
|
|
|
273
273
|
const bottom = projY(b.south);
|
|
274
274
|
const lonSpan = b.east - b.west || 1;
|
|
275
275
|
const ySpan = top - bottom || 1;
|
|
276
|
-
return (c:
|
|
276
|
+
return (c: GeoChartCoordinate) => ({
|
|
277
277
|
x: PADDING + ((c.longitude - b.west) / lonSpan) * innerW,
|
|
278
278
|
y: PADDING + ((top - projY(c.latitude)) / ySpan) * innerH
|
|
279
279
|
});
|
|
@@ -301,7 +301,7 @@
|
|
|
301
301
|
.join(" ");
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
-
function geometryPath(geometry:
|
|
304
|
+
function geometryPath(geometry: GeoChartGeometry): string {
|
|
305
305
|
switch (geometry.type) {
|
|
306
306
|
case "Point": {
|
|
307
307
|
const pair = coordinatePair(geometry.coordinates);
|
|
@@ -331,7 +331,7 @@
|
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
function pointRadius(point:
|
|
334
|
+
function pointRadius(point: GeoChartPoint, min: number, max: number, rMin: number, rMax: number): number {
|
|
335
335
|
if (typeof point.r === "number" && Number.isFinite(point.r) && point.r >= 0) {
|
|
336
336
|
return Math.min(point.r, MAX_POINT_RADIUS);
|
|
337
337
|
}
|
|
@@ -345,7 +345,7 @@
|
|
|
345
345
|
}).join(" ");
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
-
function flowPath(source:
|
|
348
|
+
function flowPath(source: GeoChartCoordinate, target: GeoChartCoordinate): string {
|
|
349
349
|
const a = project(source);
|
|
350
350
|
const b = project(target);
|
|
351
351
|
// Arc quadratique : point de contrôle au milieu, décalé perpendiculairement.
|
|
@@ -358,9 +358,9 @@
|
|
|
358
358
|
return `M ${a.x} ${a.y} Q ${cx} ${cy} ${b.x} ${b.y}`;
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
-
type HexbinBin = { id: string; q: number; r: number; center:
|
|
361
|
+
type HexbinBin = { id: string; q: number; r: number; center: GeoChartCoordinate; count: number; value: number };
|
|
362
362
|
|
|
363
|
-
function binPoints(points:
|
|
363
|
+
function binPoints(points: GeoChartPoint[], cellSize: number): HexbinBin[] {
|
|
364
364
|
const hexHeight = cellSize * (Math.sqrt(3) / 2);
|
|
365
365
|
const bins = new Map<string, HexbinBin>();
|
|
366
366
|
for (const point of points) {
|
|
@@ -379,9 +379,9 @@
|
|
|
379
379
|
return [...bins.values()];
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
type Cluster =
|
|
382
|
+
type Cluster = GeoChartCoordinate & { id: string; count: number; value: number };
|
|
383
383
|
|
|
384
|
-
function clusterPoints(points:
|
|
384
|
+
function clusterPoints(points: GeoChartPoint[], radius: number): Cluster[] {
|
|
385
385
|
const clusters: Cluster[] = [];
|
|
386
386
|
for (const point of points) {
|
|
387
387
|
const cluster = clusters.find((item) => {
|
|
@@ -412,18 +412,18 @@
|
|
|
412
412
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
-
type FeatureMark = { key: string; d: string; tone:
|
|
415
|
+
type FeatureMark = { key: string; d: string; tone: GeoChartTone; line: boolean; text: string };
|
|
416
416
|
type RegionMark = { key: string; d: string; mix: number | null; text: string };
|
|
417
|
-
type CircleMark = { key: string; cx: number; cy: number; r: number; tone:
|
|
417
|
+
type CircleMark = { key: string; cx: number; cy: number; r: number; tone: GeoChartTone; mix?: number; text: string };
|
|
418
418
|
type FlowMark = { key: string; d: string; strokeWidth: number; text: string };
|
|
419
|
-
type HexMark = { key: string; points: string; mix: number; text: string; tone:
|
|
419
|
+
type HexMark = { key: string; points: string; mix: number; text: string; tone: GeoChartTone };
|
|
420
420
|
|
|
421
421
|
type LayerMarks =
|
|
422
422
|
| { type: "geojson"; key: string; summary: string; features: FeatureMark[] }
|
|
423
|
-
| { type: "choropleth"; key: string; summary: string; tone:
|
|
423
|
+
| { type: "choropleth"; key: string; summary: string; tone: GeoChartTone; regions: RegionMark[] }
|
|
424
424
|
| { type: "points"; key: string; summary: string; circles: CircleMark[] }
|
|
425
|
-
| { type: "density"; key: string; summary: string; tone:
|
|
426
|
-
| { type: "flow"; key: string; summary: string; tone:
|
|
425
|
+
| { type: "density"; key: string; summary: string; tone: GeoChartTone; circles: CircleMark[] }
|
|
426
|
+
| { type: "flow"; key: string; summary: string; tone: GeoChartTone; flows: FlowMark[] }
|
|
427
427
|
| { type: "hexbin"; key: string; summary: string; bins: HexMark[] }
|
|
428
428
|
| { type: "cluster"; key: string; summary: string; clusters: CircleMark[] };
|
|
429
429
|
|
|
@@ -1,118 +1,118 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type GeoChartTone = "category1" | "category2" | "category3" | "category4" | "category5" | "category6" | "category7" | "category8";
|
|
2
2
|
/** Coordonnée géographique — même forme que `GeoCoordinate` (dataviz-core). */
|
|
3
|
-
export type
|
|
3
|
+
export type GeoChartCoordinate = {
|
|
4
4
|
latitude: number;
|
|
5
5
|
longitude: number;
|
|
6
6
|
};
|
|
7
7
|
/** Emprise géographique — même forme que `GeoBounds` (dataviz-core). */
|
|
8
|
-
export type
|
|
8
|
+
export type GeoChartBounds = {
|
|
9
9
|
south: number;
|
|
10
10
|
west: number;
|
|
11
11
|
north: number;
|
|
12
12
|
east: number;
|
|
13
13
|
};
|
|
14
|
-
export type
|
|
15
|
-
export type
|
|
14
|
+
export type GeoChartProjection = "equirectangular" | "mercator";
|
|
15
|
+
export type GeoChartGeometryType = "Point" | "MultiPoint" | "LineString" | "MultiLineString" | "Polygon" | "MultiPolygon";
|
|
16
16
|
/** Géométrie GeoJSON — même forme que `GeoJsonGeometry` (dataviz-core). */
|
|
17
|
-
export type
|
|
18
|
-
type:
|
|
17
|
+
export type GeoChartGeometry = {
|
|
18
|
+
type: GeoChartGeometryType;
|
|
19
19
|
coordinates: unknown[];
|
|
20
20
|
};
|
|
21
21
|
/** Entité géographique — sous-ensemble structurel de `GeoJsonFeature` (dataviz-core). */
|
|
22
|
-
export type
|
|
22
|
+
export type GeoChartFeature = {
|
|
23
23
|
id: string;
|
|
24
24
|
label?: string;
|
|
25
25
|
value?: number;
|
|
26
|
-
geometry:
|
|
26
|
+
geometry: GeoChartGeometry;
|
|
27
27
|
};
|
|
28
28
|
/** Point géographique — sur-ensemble structurel de `GeoPoint` (dataviz-core). */
|
|
29
|
-
export type
|
|
29
|
+
export type GeoChartPoint = GeoChartCoordinate & {
|
|
30
30
|
id?: string;
|
|
31
31
|
label?: string;
|
|
32
32
|
value?: number;
|
|
33
|
-
tone?:
|
|
33
|
+
tone?: GeoChartTone;
|
|
34
34
|
/** Rayon explicite en px (prioritaire sur l'échelle par `value`), borné à 32. */
|
|
35
35
|
r?: number;
|
|
36
36
|
};
|
|
37
37
|
/** Flux géographique — sous-ensemble structurel de `GeoFlowLink` (dataviz-core). */
|
|
38
|
-
export type
|
|
38
|
+
export type GeoChartFlow = {
|
|
39
39
|
id?: string;
|
|
40
40
|
label?: string;
|
|
41
|
-
source:
|
|
42
|
-
target:
|
|
41
|
+
source: GeoChartCoordinate;
|
|
42
|
+
target: GeoChartCoordinate;
|
|
43
43
|
value?: number;
|
|
44
44
|
};
|
|
45
45
|
/** Entités GeoJSON (polygones, lignes, points) ; ton par couche ou cycle de palette par entité. */
|
|
46
|
-
export type
|
|
46
|
+
export type GeoChartGeojsonLayer = {
|
|
47
47
|
type: "geojson";
|
|
48
|
-
features:
|
|
49
|
-
tone?:
|
|
48
|
+
features: GeoChartFeature[];
|
|
49
|
+
tone?: GeoChartTone;
|
|
50
50
|
label?: string;
|
|
51
51
|
};
|
|
52
52
|
/** Choroplèthe : entités + valeur par id (`regions` dataviz : `key` → `value`) → intensité color-mix. */
|
|
53
|
-
export type
|
|
53
|
+
export type GeoChartChoroplethLayer = {
|
|
54
54
|
type: "choropleth";
|
|
55
|
-
features:
|
|
55
|
+
features: GeoChartFeature[];
|
|
56
56
|
values: Record<string, number>;
|
|
57
57
|
/** Ton de base de la rampe d'intensité (défaut `category1`). */
|
|
58
|
-
tone?:
|
|
58
|
+
tone?: GeoChartTone;
|
|
59
59
|
label?: string;
|
|
60
60
|
};
|
|
61
61
|
/** Points/épingles : rayon ∝ `value` (bornes `minRadius`/`maxRadius`, défauts 5/14 comme dataviz). */
|
|
62
|
-
export type
|
|
62
|
+
export type GeoChartPointsLayer = {
|
|
63
63
|
type: "points";
|
|
64
|
-
points:
|
|
65
|
-
tone?:
|
|
64
|
+
points: GeoChartPoint[];
|
|
65
|
+
tone?: GeoChartTone;
|
|
66
66
|
minRadius?: number;
|
|
67
67
|
maxRadius?: number;
|
|
68
68
|
label?: string;
|
|
69
69
|
};
|
|
70
70
|
/** Densité : cercles translucides superposés, rayon/intensité ∝ `value` (poids). */
|
|
71
|
-
export type
|
|
71
|
+
export type GeoChartDensityLayer = {
|
|
72
72
|
type: "density";
|
|
73
|
-
points:
|
|
73
|
+
points: GeoChartPoint[];
|
|
74
74
|
/** Ton de la nappe (défaut `category3` — parité visuelle dataviz). */
|
|
75
|
-
tone?:
|
|
75
|
+
tone?: GeoChartTone;
|
|
76
76
|
maxRadius?: number;
|
|
77
77
|
label?: string;
|
|
78
78
|
};
|
|
79
79
|
/** Flux : arcs quadratiques source → target, épaisseur ∝ `value` (défaut ton `category1`). */
|
|
80
|
-
export type
|
|
80
|
+
export type GeoChartFlowLayer = {
|
|
81
81
|
type: "flow";
|
|
82
|
-
flows:
|
|
83
|
-
tone?:
|
|
82
|
+
flows: GeoChartFlow[];
|
|
83
|
+
tone?: GeoChartTone;
|
|
84
84
|
label?: string;
|
|
85
85
|
};
|
|
86
86
|
/** Hexbin : binning hexagonal des points (même binning que dataviz-core), intensité ∝ valeur agrégée. */
|
|
87
|
-
export type
|
|
87
|
+
export type GeoChartHexbinLayer = {
|
|
88
88
|
type: "hexbin";
|
|
89
|
-
points:
|
|
89
|
+
points: GeoChartPoint[];
|
|
90
90
|
/** Taille de cellule en degrés (défaut 1). */
|
|
91
91
|
cellSize?: number;
|
|
92
|
-
tone?:
|
|
92
|
+
tone?: GeoChartTone;
|
|
93
93
|
label?: string;
|
|
94
94
|
};
|
|
95
95
|
/** Clusters : regroupement glouton des points (même algo que dataviz-core), centroïdes marqueurs distinctifs. */
|
|
96
|
-
export type
|
|
96
|
+
export type GeoChartClusterLayer = {
|
|
97
97
|
type: "cluster";
|
|
98
|
-
points:
|
|
98
|
+
points: GeoChartPoint[];
|
|
99
99
|
/** Rayon de regroupement en degrés (défaut 1). */
|
|
100
100
|
radius?: number;
|
|
101
|
-
tone?:
|
|
101
|
+
tone?: GeoChartTone;
|
|
102
102
|
label?: string;
|
|
103
103
|
};
|
|
104
|
-
export type
|
|
105
|
-
type
|
|
106
|
-
layers:
|
|
104
|
+
export type GeoChartLayer = GeoChartGeojsonLayer | GeoChartChoroplethLayer | GeoChartPointsLayer | GeoChartDensityLayer | GeoChartFlowLayer | GeoChartHexbinLayer | GeoChartClusterLayer;
|
|
105
|
+
type GeoChartProps = {
|
|
106
|
+
layers: GeoChartLayer[];
|
|
107
107
|
width?: number;
|
|
108
108
|
height?: number;
|
|
109
|
-
projection?:
|
|
109
|
+
projection?: GeoChartProjection;
|
|
110
110
|
/** Emprise explicite ; sinon auto-ajustement sur les données de toutes les couches + marge. */
|
|
111
|
-
bounds?:
|
|
111
|
+
bounds?: GeoChartBounds;
|
|
112
112
|
label: string;
|
|
113
113
|
class?: string;
|
|
114
114
|
};
|
|
115
|
-
declare const
|
|
116
|
-
type
|
|
117
|
-
export default
|
|
118
|
-
//# sourceMappingURL=
|
|
115
|
+
declare const GeoChart: import("svelte").Component<GeoChartProps, {}, "">;
|
|
116
|
+
type GeoChart = ReturnType<typeof GeoChart>;
|
|
117
|
+
export default GeoChart;
|
|
118
|
+
//# sourceMappingURL=GeoChart.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeoChart.svelte.d.ts","sourceRoot":"","sources":["../src/lib/GeoChart.svelte.ts"],"names":[],"mappings":"AAGE,MAAM,MAAM,YAAY,GACpB,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,GACrD,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;AAE1D,+EAA+E;AAC/E,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wEAAwE;AACxE,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAA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IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,aAAa,GACrB,oBAAoB,GACpB,uBAAuB,GACvB,mBAAmB,GACnB,oBAAoB,GACpB,iBAAiB,GACjB,mBAAmB,GACnB,oBAAoB,CAAC;AAMzB,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,+FAA+F;IAC/F,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AA2gBJ,QAAA,MAAM,QAAQ,mDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -121,7 +121,7 @@ export { default as FlamegraphChart } from "./FlamegraphChart.svelte";
|
|
|
121
121
|
export { default as TraceWaterfallChart } from "./TraceWaterfallChart.svelte";
|
|
122
122
|
export { default as DecompositionTreeChart } from "./DecompositionTreeChart.svelte";
|
|
123
123
|
export { default as Density2DChart } from "./Density2DChart.svelte";
|
|
124
|
-
export { default as
|
|
124
|
+
export { default as GeoChart } from "./GeoChart.svelte";
|
|
125
125
|
export { default as Header } from "./Header.svelte";
|
|
126
126
|
export { default as HeatmapChart } from "./HeatmapChart.svelte";
|
|
127
127
|
export { default as Hidden } from "./Hidden.svelte";
|
|
@@ -334,7 +334,7 @@ export type { DataImageFit } from "./DataImage.svelte";
|
|
|
334
334
|
export type { DonutChartDatum, DonutChartTone } from "./DonutChart.svelte";
|
|
335
335
|
export type { ForceGraphNode, ForceGraphEdge, ForceGraphTone, ForceGraphNodeShape, ForceGraphEdgeDash, ForceGraphLegendEntry } from "./ForceGraph.svelte";
|
|
336
336
|
export { nodeShapePath, edgeDashArray } from "./ForceGraph.svelte";
|
|
337
|
-
export type {
|
|
337
|
+
export type { GeoChartTone, GeoChartCoordinate, GeoChartBounds, GeoChartProjection, GeoChartGeometryType, GeoChartGeometry, GeoChartFeature, GeoChartPoint, GeoChartFlow, GeoChartGeojsonLayer, GeoChartChoroplethLayer, GeoChartPointsLayer, GeoChartDensityLayer, GeoChartFlowLayer, GeoChartHexbinLayer, GeoChartClusterLayer, GeoChartLayer } from "./GeoChart.svelte";
|
|
338
338
|
export type { DropdownOption } from "./Dropdown.svelte";
|
|
339
339
|
export type { HeaderAccount } from "./Header.svelte";
|
|
340
340
|
export { deriveInitials } from "./Header.svelte";
|