@opendata-ai/openchart-svelte 8.9.1 → 9.0.0-rc.2
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 +1 -1
- package/dist/BarList.svelte +3 -2
- package/dist/BarList.svelte.d.ts.map +1 -1
- package/dist/Chart.svelte +85 -56
- package/dist/Chart.svelte.d.ts +16 -13
- package/dist/Chart.svelte.d.ts.map +1 -1
- package/dist/ChartStory.svelte +2 -2
- package/dist/ChartStory.svelte.d.ts +2 -2
- package/dist/ChartStory.svelte.d.ts.map +1 -1
- package/dist/DataTable.svelte +3 -2
- package/dist/DataTable.svelte.d.ts.map +1 -1
- package/dist/GeoMap.svelte +61 -7
- package/dist/GeoMap.svelte.d.ts +10 -4
- package/dist/GeoMap.svelte.d.ts.map +1 -1
- package/dist/Graph.svelte +5 -5
- package/dist/Graph.svelte.d.ts +1 -1
- package/dist/Graph.svelte.d.ts.map +1 -1
- package/dist/Sankey.svelte +3 -2
- package/dist/Sankey.svelte.d.ts.map +1 -1
- package/dist/TileMap.svelte +3 -2
- package/dist/TileMap.svelte.d.ts.map +1 -1
- package/dist/__tests__/Chart.test.js +107 -7
- package/dist/__tests__/GeoMap.test.js +148 -0
- package/dist/__tests__/Graph.dimensions.test.js +51 -47
- package/dist/__tests__/Graph.test.js +0 -1
- package/dist/__tests__/ThemeContext.test.js +18 -0
- package/dist/__tests__/update-count.test.js +40 -0
- package/dist/composables/useChart.svelte.d.ts +4 -6
- package/dist/composables/useChart.svelte.d.ts.map +1 -1
- package/dist/composables/useChart.svelte.js +1 -2
- package/dist/composables/useGraph.svelte.d.ts +2 -2
- package/dist/composables/useGraph.svelte.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/dist/types.d.ts +19 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Graph.svelte.d.ts","sourceRoot":"","sources":["../src/Graph.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"Graph.svelte.d.ts","sourceRoot":"","sources":["../src/Graph.svelte.ts"],"names":[],"mappings":"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"}
|
package/dist/Sankey.svelte
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
-->
|
|
8
8
|
<script lang="ts">
|
|
9
9
|
import type { DarkMode, SankeySpec, ThemeConfig } from '@opendata-ai/openchart-core';
|
|
10
|
+
import { mergeThemeConfig } from '@opendata-ai/openchart-core';
|
|
10
11
|
import {
|
|
11
12
|
createSankey,
|
|
12
13
|
type SankeyInstance,
|
|
@@ -54,7 +55,7 @@ let prevSpec = '';
|
|
|
54
55
|
|
|
55
56
|
// Effect 1: Mount/recreate sankey on theme/darkMode changes.
|
|
56
57
|
$effect(() => {
|
|
57
|
-
const resolvedTheme =
|
|
58
|
+
const resolvedTheme = mergeThemeConfig(ctxTheme?.(), theme);
|
|
58
59
|
const resolvedDarkMode = darkMode ?? ctxDarkMode?.();
|
|
59
60
|
const currentSpec = untrack(() => spec);
|
|
60
61
|
|
|
@@ -67,7 +68,7 @@ $effect(() => {
|
|
|
67
68
|
onLinkClick: (link: Record<string, unknown>) => untrack(() => onlinkclick)?.(link),
|
|
68
69
|
onNodeHover: (node: Record<string, unknown> | null) => untrack(() => onnodehover)?.(node),
|
|
69
70
|
onLinkHover: (link: Record<string, unknown> | null) => untrack(() => onlinkhover)?.(link),
|
|
70
|
-
|
|
71
|
+
autoResize: true,
|
|
71
72
|
};
|
|
72
73
|
|
|
73
74
|
instance = createSankey(containerEl, currentSpec, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sankey.svelte.d.ts","sourceRoot":"","sources":["../src/Sankey.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"Sankey.svelte.d.ts","sourceRoot":"","sources":["../src/Sankey.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAUpF,KAAK,gBAAgB,GAAI;IACxB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACtD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACtD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7D,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AA2EF,QAAA,MAAM,MAAM,sDAAwC,CAAC;AACrD,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AACxC,eAAe,MAAM,CAAC"}
|
package/dist/TileMap.svelte
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
-->
|
|
8
8
|
<script lang="ts">
|
|
9
9
|
import type { DarkMode, ThemeConfig, TileMapSpec } from '@opendata-ai/openchart-core';
|
|
10
|
+
import { mergeThemeConfig } from '@opendata-ai/openchart-core';
|
|
10
11
|
import {
|
|
11
12
|
createTileMap,
|
|
12
13
|
type TileMapInstance,
|
|
@@ -62,7 +63,7 @@ let prevSpec = '';
|
|
|
62
63
|
|
|
63
64
|
// Effect 1: Mount/recreate tilemap on theme/darkMode changes.
|
|
64
65
|
$effect(() => {
|
|
65
|
-
const resolvedTheme =
|
|
66
|
+
const resolvedTheme = mergeThemeConfig(ctxTheme?.(), theme);
|
|
66
67
|
const resolvedDarkMode = darkMode ?? ctxDarkMode?.();
|
|
67
68
|
const currentSpec = untrack(() => spec);
|
|
68
69
|
|
|
@@ -85,7 +86,7 @@ $effect(() => {
|
|
|
85
86
|
data: Record<string, unknown>;
|
|
86
87
|
} | null,
|
|
87
88
|
) => untrack(() => ontilehover)?.(tile),
|
|
88
|
-
|
|
89
|
+
autoResize: true,
|
|
89
90
|
};
|
|
90
91
|
|
|
91
92
|
instance = createTileMap(containerEl, currentSpec, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileMap.svelte.d.ts","sourceRoot":"","sources":["../src/TileMap.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"TileMap.svelte.d.ts","sourceRoot":"","sources":["../src/TileMap.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAUrF,KAAK,gBAAgB,GAAI;IACxB,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC/B,KAAK,IAAI,CAAC;IACX,WAAW,CAAC,EAAE,CACZ,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC/B,GAAG,IAAI,KACL,IAAI,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAmFF,QAAA,MAAM,OAAO,sDAAwC,CAAC;AACtD,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C,eAAe,OAAO,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cleanup, render, waitFor } from '@testing-library/svelte';
|
|
2
|
-
import { afterEach, describe, expect, it } from 'vitest';
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
3
3
|
import Chart from '../Chart.svelte';
|
|
4
4
|
// ---------------------------------------------------------------------------
|
|
5
5
|
// Test data
|
|
@@ -124,17 +124,17 @@ describe('annotation transactions', () => {
|
|
|
124
124
|
const transactions = [];
|
|
125
125
|
const { container, rerender } = await renderChart({
|
|
126
126
|
spec,
|
|
127
|
-
|
|
127
|
+
interaction: 'edit',
|
|
128
128
|
autoResize: false,
|
|
129
129
|
revision: 'one',
|
|
130
|
-
|
|
130
|
+
onedit: (tx) => transactions.push(tx),
|
|
131
131
|
});
|
|
132
132
|
await rerender({
|
|
133
133
|
spec,
|
|
134
|
-
|
|
134
|
+
interaction: 'edit',
|
|
135
135
|
autoResize: false,
|
|
136
136
|
revision: 'two',
|
|
137
|
-
|
|
137
|
+
onedit: (tx) => transactions.push(tx),
|
|
138
138
|
});
|
|
139
139
|
container
|
|
140
140
|
.querySelector('[data-annotation-index="0"]')
|
|
@@ -168,7 +168,7 @@ it('reacts to transaction listener presence without enabling all charts for edit
|
|
|
168
168
|
const { container, rerender } = await renderChart({ spec });
|
|
169
169
|
const cursor = () => container.querySelector('[data-annotation-index="0"]').style.cursor;
|
|
170
170
|
expect(cursor()).not.toBe('grab');
|
|
171
|
-
await rerender({ spec,
|
|
171
|
+
await rerender({ spec, onedit: (tx) => transactions.push(tx) });
|
|
172
172
|
expect(cursor()).toBe('grab');
|
|
173
173
|
container
|
|
174
174
|
.querySelector('[data-annotation-index="0"]')
|
|
@@ -177,7 +177,7 @@ it('reacts to transaction listener presence without enabling all charts for edit
|
|
|
177
177
|
.querySelector('svg')
|
|
178
178
|
.dispatchEvent(new KeyboardEvent('keydown', { key: 'Delete', bubbles: true }));
|
|
179
179
|
expect(transactions).toHaveLength(1);
|
|
180
|
-
await rerender({ spec,
|
|
180
|
+
await rerender({ spec, onedit: undefined });
|
|
181
181
|
expect(cursor()).not.toBe('grab');
|
|
182
182
|
});
|
|
183
183
|
it.each([
|
|
@@ -208,3 +208,103 @@ it.each([
|
|
|
208
208
|
unmount();
|
|
209
209
|
expect(container.querySelector('svg')).toBeNull();
|
|
210
210
|
});
|
|
211
|
+
describe('interaction mode and listener parity', () => {
|
|
212
|
+
const clickTitle = (container) => container
|
|
213
|
+
.querySelector('[data-chrome-key="title"]')
|
|
214
|
+
.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
215
|
+
it('re-infers select mode when onselect is added later', async () => {
|
|
216
|
+
const onselect = vi.fn();
|
|
217
|
+
const { container, rerender } = await renderChart({ spec: lineSpec, autoResize: false });
|
|
218
|
+
clickTitle(container);
|
|
219
|
+
await rerender({ spec: lineSpec, autoResize: false, onselect });
|
|
220
|
+
clickTitle(container);
|
|
221
|
+
expect(onselect).toHaveBeenCalledTimes(1);
|
|
222
|
+
expect(onselect.mock.calls[0][0]).toMatchObject({ type: 'chrome', path: '/chrome/title' });
|
|
223
|
+
});
|
|
224
|
+
it("interaction='read' suppresses selection; switching to 'select' recreates", async () => {
|
|
225
|
+
const onselect = vi.fn();
|
|
226
|
+
const { container, rerender } = await renderChart({
|
|
227
|
+
spec: lineSpec,
|
|
228
|
+
autoResize: false,
|
|
229
|
+
interaction: 'read',
|
|
230
|
+
onselect,
|
|
231
|
+
});
|
|
232
|
+
clickTitle(container);
|
|
233
|
+
expect(onselect).not.toHaveBeenCalled();
|
|
234
|
+
await rerender({ spec: lineSpec, autoResize: false, interaction: 'select', onselect });
|
|
235
|
+
clickTitle(container);
|
|
236
|
+
expect(onselect).toHaveBeenCalledTimes(1);
|
|
237
|
+
});
|
|
238
|
+
it('forwards onreveal and exposes the instance via getInstance()', async () => {
|
|
239
|
+
const onreveal = vi.fn();
|
|
240
|
+
const spec = {
|
|
241
|
+
mark: 'line',
|
|
242
|
+
data: [2000, 2005, 2010, 2015, 2020].map((year, i) => ({ year: `${year}`, value: i })),
|
|
243
|
+
encoding: {
|
|
244
|
+
x: { field: 'year', type: 'temporal' },
|
|
245
|
+
y: { field: 'value', type: 'quantitative' },
|
|
246
|
+
},
|
|
247
|
+
youDrawIt: { from: '2010' },
|
|
248
|
+
animation: false,
|
|
249
|
+
};
|
|
250
|
+
const { component } = await renderChart({ spec, autoResize: false, onreveal });
|
|
251
|
+
const instance = component.getInstance();
|
|
252
|
+
expect(instance).not.toBeNull();
|
|
253
|
+
instance.revealDrawing();
|
|
254
|
+
expect(onreveal).toHaveBeenCalledTimes(1);
|
|
255
|
+
});
|
|
256
|
+
it('forwards onhighlightchange from the series search', async () => {
|
|
257
|
+
const onhighlightchange = vi.fn();
|
|
258
|
+
const spec = {
|
|
259
|
+
mark: 'line',
|
|
260
|
+
data: ['Germany', 'France'].flatMap((country, i) => [
|
|
261
|
+
{ year: '2020-01-01', value: i, country },
|
|
262
|
+
{ year: '2021-01-01', value: i + 1, country },
|
|
263
|
+
]),
|
|
264
|
+
encoding: {
|
|
265
|
+
x: { field: 'year', type: 'temporal' },
|
|
266
|
+
y: { field: 'value', type: 'quantitative' },
|
|
267
|
+
color: { field: 'country', type: 'nominal' },
|
|
268
|
+
},
|
|
269
|
+
seriesSearch: true,
|
|
270
|
+
};
|
|
271
|
+
const { container } = await renderChart({ spec, autoResize: false, onhighlightchange });
|
|
272
|
+
const input = container.querySelector('.oc-series-search-input');
|
|
273
|
+
input.value = 'ger';
|
|
274
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
275
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));
|
|
276
|
+
expect(onhighlightchange).toHaveBeenCalledWith(['Germany']);
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
it('forwards rowHover and removes it when toggled off', async () => {
|
|
280
|
+
const { container, rerender } = await renderChart({ spec: barSpec, rowHover: true });
|
|
281
|
+
expect(container.querySelector('.oc-row-hover')).not.toBeNull();
|
|
282
|
+
await rerender({ spec: barSpec, rowHover: false });
|
|
283
|
+
await waitFor(() => expect(container.querySelector('.oc-row-hover')).toBeNull());
|
|
284
|
+
});
|
|
285
|
+
it('moves a slice readout and changes callbacks without remounting or controlled echoes', async () => {
|
|
286
|
+
const first = document.createElement('aside'), second = document.createElement('aside'), before = vi.fn(), after = vi.fn();
|
|
287
|
+
const result = await renderChart({
|
|
288
|
+
spec: lineSpec,
|
|
289
|
+
reader: { mode: 'slices', panel: { container: first } },
|
|
290
|
+
onreaderchange: before,
|
|
291
|
+
});
|
|
292
|
+
const root = result.container.querySelector('.oc-root');
|
|
293
|
+
root.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true }));
|
|
294
|
+
root.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));
|
|
295
|
+
const state = before.mock.calls.at(-1)[0];
|
|
296
|
+
expect(state.pinned).toHaveLength(1);
|
|
297
|
+
const svg = result.container.querySelector('svg');
|
|
298
|
+
await result.rerender({
|
|
299
|
+
spec: lineSpec,
|
|
300
|
+
reader: { mode: 'slices', panel: { container: second } },
|
|
301
|
+
readerSelection: state,
|
|
302
|
+
onreaderchange: after,
|
|
303
|
+
});
|
|
304
|
+
expect(result.container.querySelector('svg')).toBe(svg);
|
|
305
|
+
expect(after).not.toHaveBeenCalled();
|
|
306
|
+
expect(first.querySelector('.oc-reader-panel')).toBeNull();
|
|
307
|
+
expect(second.textContent).toContain('A:');
|
|
308
|
+
result.unmount();
|
|
309
|
+
expect(second.querySelector('.oc-reader-panel')).toBeNull();
|
|
310
|
+
});
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { cleanup, render, waitFor } from '@testing-library/svelte';
|
|
2
|
+
import { afterEach, expect, it, vi } from 'vitest';
|
|
3
|
+
import GeoMap from '../GeoMap.svelte';
|
|
4
|
+
afterEach(cleanup);
|
|
5
|
+
it('forwards and replaces inventory hosts without replacing the SVG', async () => {
|
|
6
|
+
const spec = {
|
|
7
|
+
type: 'map',
|
|
8
|
+
animation: false,
|
|
9
|
+
geo: {
|
|
10
|
+
projection: 'identity',
|
|
11
|
+
features: {
|
|
12
|
+
type: 'Topology',
|
|
13
|
+
objects: {
|
|
14
|
+
regions: {
|
|
15
|
+
type: 'GeometryCollection',
|
|
16
|
+
geometries: [{ type: 'Polygon', id: 'a', properties: {}, arcs: [[0]] }],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
arcs: [
|
|
20
|
+
[
|
|
21
|
+
[0, 0],
|
|
22
|
+
[100, 0],
|
|
23
|
+
[100, 100],
|
|
24
|
+
[0, 100],
|
|
25
|
+
[0, 0],
|
|
26
|
+
],
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
data: [{ id: 'a', value: 3 }],
|
|
31
|
+
encoding: {
|
|
32
|
+
key: { field: 'id', type: 'nominal' },
|
|
33
|
+
color: { field: 'value', type: 'quantitative' },
|
|
34
|
+
},
|
|
35
|
+
callouts: [
|
|
36
|
+
{
|
|
37
|
+
id: 'note',
|
|
38
|
+
anchor: { kind: 'coordinate', space: 'source', x: 50, y: 50 },
|
|
39
|
+
text: 'Exact custom text',
|
|
40
|
+
minZoom: 2,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
const first = document.createElement('aside'), second = document.createElement('aside');
|
|
45
|
+
const result = render(GeoMap, { props: { spec, labelInventory: { container: first } } });
|
|
46
|
+
await waitFor(() => expect(first.querySelector('details')).not.toBeNull());
|
|
47
|
+
const instance = result.component.getInstance();
|
|
48
|
+
expect(instance?.getCameras().root).toEqual(instance?.getCamera());
|
|
49
|
+
const svg = result.container.querySelector('svg');
|
|
50
|
+
await result.rerender({ spec, labelInventory: { container: second } });
|
|
51
|
+
await waitFor(() => expect(second.querySelector('details')).not.toBeNull());
|
|
52
|
+
expect(first.querySelector('details')).toBeNull();
|
|
53
|
+
expect(result.container.querySelector('svg')).toBe(svg);
|
|
54
|
+
expect(result.container.querySelectorAll('.oc-map-label-inventory')).toHaveLength(1);
|
|
55
|
+
result.unmount();
|
|
56
|
+
expect(second.querySelector('details')).toBeNull();
|
|
57
|
+
expect(result.component.getInstance()).toBeNull();
|
|
58
|
+
});
|
|
59
|
+
const readerMapSpec = {
|
|
60
|
+
type: 'map',
|
|
61
|
+
animation: false,
|
|
62
|
+
geo: {
|
|
63
|
+
projection: 'identity',
|
|
64
|
+
features: {
|
|
65
|
+
type: 'Topology',
|
|
66
|
+
objects: {
|
|
67
|
+
regions: {
|
|
68
|
+
type: 'GeometryCollection',
|
|
69
|
+
geometries: [{ type: 'Polygon', id: 'a', properties: {}, arcs: [[0]] }],
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
arcs: [
|
|
73
|
+
[
|
|
74
|
+
[0, 0],
|
|
75
|
+
[100, 0],
|
|
76
|
+
[100, 100],
|
|
77
|
+
[0, 100],
|
|
78
|
+
[0, 0],
|
|
79
|
+
],
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
data: [{ id: 'a', value: 3 }],
|
|
84
|
+
encoding: {
|
|
85
|
+
key: { field: 'id', type: 'nominal' },
|
|
86
|
+
color: { field: 'value', type: 'quantitative' },
|
|
87
|
+
},
|
|
88
|
+
callouts: [
|
|
89
|
+
{
|
|
90
|
+
id: 'note',
|
|
91
|
+
anchor: { kind: 'coordinate', space: 'source', x: 50, y: 50 },
|
|
92
|
+
text: 'Exact custom text',
|
|
93
|
+
minZoom: 2,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
};
|
|
97
|
+
it('keeps map reader pins through host and callback replacement without controlled echo', async () => {
|
|
98
|
+
const first = document.createElement('aside'), second = document.createElement('aside'), before = vi.fn(), after = vi.fn();
|
|
99
|
+
const result = render(GeoMap, {
|
|
100
|
+
props: { spec: readerMapSpec, reader: { panel: { container: first } }, onreaderchange: before },
|
|
101
|
+
});
|
|
102
|
+
await waitFor(() => expect(first.querySelector('.oc-reader-panel')).not.toBeNull());
|
|
103
|
+
const root = result.container.querySelector('.oc-map-inspect-places');
|
|
104
|
+
root.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true }));
|
|
105
|
+
root.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));
|
|
106
|
+
const state = before.mock.calls.at(-1)[0];
|
|
107
|
+
expect(state.pinned).toHaveLength(1);
|
|
108
|
+
const svg = result.container.querySelector('svg');
|
|
109
|
+
await result.rerender({
|
|
110
|
+
spec: readerMapSpec,
|
|
111
|
+
reader: { panel: { container: second } },
|
|
112
|
+
readerSelection: state,
|
|
113
|
+
onreaderchange: after,
|
|
114
|
+
});
|
|
115
|
+
expect(result.container.querySelector('svg')).toBe(svg);
|
|
116
|
+
expect(after).not.toHaveBeenCalled();
|
|
117
|
+
expect(first.querySelector('.oc-reader-panel')).toBeNull();
|
|
118
|
+
expect(second.textContent).toContain('A:');
|
|
119
|
+
result.unmount();
|
|
120
|
+
expect(second.querySelector('.oc-reader-panel')).toBeNull();
|
|
121
|
+
});
|
|
122
|
+
it('forwards scoped camera metadata through getInstance and cleans up the handle', async () => {
|
|
123
|
+
const changed = vi.fn();
|
|
124
|
+
const spec = {
|
|
125
|
+
...readerMapSpec,
|
|
126
|
+
geo: {
|
|
127
|
+
...readerMapSpec.geo,
|
|
128
|
+
insets: [
|
|
129
|
+
{
|
|
130
|
+
id: 'copy',
|
|
131
|
+
label: 'Copy',
|
|
132
|
+
featureIds: ['a'],
|
|
133
|
+
placement: 'bottom-left',
|
|
134
|
+
width: 120,
|
|
135
|
+
removeFromMain: false,
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
const result = render(GeoMap, { props: { spec, oncamerachange: changed } });
|
|
141
|
+
await waitFor(() => expect(result.component.getInstance()?.getCameras().copy).toBeDefined());
|
|
142
|
+
const instance = result.component.getInstance();
|
|
143
|
+
const camera = { ...instance.getCamera('copy'), k: 2 };
|
|
144
|
+
instance.setCamera(camera, { viewId: 'copy' });
|
|
145
|
+
expect(changed).toHaveBeenLastCalledWith(camera, { viewId: 'copy' });
|
|
146
|
+
result.unmount();
|
|
147
|
+
expect(result.component.getInstance()).toBeNull();
|
|
148
|
+
});
|
|
@@ -3,69 +3,73 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 2D and 3D are different renderers and the renderer is chosen once, at mount,
|
|
5
5
|
* so vanilla `update()` refuses a dimension change and the wrapper has to
|
|
6
|
-
* destroy and recreate instead.
|
|
6
|
+
* destroy and recreate instead. This renders the real vanilla graph and the
|
|
7
|
+
* real 3D renderer; only the WebGL libraries underneath it are faked.
|
|
7
8
|
*/
|
|
8
9
|
import { cleanup, render, waitFor } from '@testing-library/svelte';
|
|
9
|
-
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
selectNode: vi.fn(),
|
|
22
|
-
getSelectedNodes: vi.fn(() => []),
|
|
23
|
-
highlight: vi.fn(),
|
|
24
|
-
clearHighlight: vi.fn(),
|
|
25
|
-
getHighlight: vi.fn(() => null),
|
|
26
|
-
getLegend: vi.fn(() => null),
|
|
27
|
-
setActiveCategories: vi.fn(),
|
|
28
|
-
getActiveCategories: vi.fn(() => []),
|
|
29
|
-
resize: vi.fn(),
|
|
30
|
-
destroy: vi.fn(),
|
|
31
|
-
};
|
|
32
|
-
const createGraphMock = vi.fn(() => instanceStub);
|
|
33
|
-
vi.mock('@opendata-ai/openchart-vanilla', () => ({
|
|
34
|
-
createGraph: createGraphMock,
|
|
35
|
-
}));
|
|
10
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
11
|
+
// happy-dom has no WebGL, so three.js and 3d-force-graph can't run; swap in the
|
|
12
|
+
// vanilla package's recording fakes for those third-party libraries.
|
|
13
|
+
vi.mock('three', async () => await import('../../../vanilla/src/graph-3d/__tests__/three-fake'));
|
|
14
|
+
vi.mock('three-spritetext', async () => await import('../../../vanilla/src/graph-3d/__tests__/spritetext-fake'));
|
|
15
|
+
vi.mock('3d-force-graph', async () => {
|
|
16
|
+
const mod = await import('../../../vanilla/src/graph-3d/__tests__/force-graph-fake');
|
|
17
|
+
return { default: mod.FakeForceGraph3D };
|
|
18
|
+
});
|
|
19
|
+
// Registers the 3D renderer, as an app importing the graph-3d subpath would.
|
|
20
|
+
await import('../../../vanilla/src/graph-3d/index');
|
|
21
|
+
const { forceGraphInstances, resetForceGraphFakes } = await import('../../../vanilla/src/graph-3d/__tests__/force-graph-fake');
|
|
36
22
|
const Harness = (await import('./GraphSpecHarness.svelte')).default;
|
|
37
23
|
const spec = {
|
|
38
24
|
type: 'graph',
|
|
39
25
|
nodes: [{ id: 'a', label: 'A' }],
|
|
40
26
|
edges: [],
|
|
27
|
+
chrome: { title: 'First' },
|
|
41
28
|
};
|
|
29
|
+
/** Opacity of a 3D node's material: 0 while its entrance is still to play. */
|
|
30
|
+
function node3DOpacity(id) {
|
|
31
|
+
const fake = forceGraphInstances.at(-1);
|
|
32
|
+
if (!fake)
|
|
33
|
+
throw new Error('no 3D graph mounted');
|
|
34
|
+
fake.flush();
|
|
35
|
+
const datum = fake.graph.nodes.find((n) => n.id === id);
|
|
36
|
+
const accessor = fake.props.nodeThreeObject;
|
|
37
|
+
return accessor(datum).children[0].material.opacity;
|
|
38
|
+
}
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
resetForceGraphFakes();
|
|
41
|
+
});
|
|
42
42
|
afterEach(() => {
|
|
43
43
|
cleanup();
|
|
44
|
-
createGraphMock.mockClear();
|
|
45
|
-
for (const fn of Object.values(instanceStub))
|
|
46
|
-
fn.mockClear?.();
|
|
47
44
|
});
|
|
48
45
|
describe('Graph dimensions', () => {
|
|
49
|
-
it('recreates the
|
|
46
|
+
it('recreates the graph with the 3D renderer when dimensions change and plays the entrance', async () => {
|
|
50
47
|
const controller = {};
|
|
51
|
-
render(Harness, { props: { initialSpec: spec, controller } });
|
|
52
|
-
await waitFor(() => expect(
|
|
48
|
+
const { container } = render(Harness, { props: { initialSpec: spec, controller } });
|
|
49
|
+
await waitFor(() => expect(container.querySelector('canvas.oc-graph-canvas')).not.toBeNull());
|
|
50
|
+
const first = container.querySelector('.oc-graph-wrapper');
|
|
53
51
|
controller.setSpec?.({ ...spec, dimensions: 3 });
|
|
54
|
-
await waitFor(() => expect(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
expect(
|
|
58
|
-
expect(
|
|
59
|
-
|
|
60
|
-
expect(
|
|
52
|
+
await waitFor(() => expect(container.querySelector('.oc-graph-3d')).not.toBeNull());
|
|
53
|
+
// The 2D graph was torn down and a single 3D graph mounted from the new spec.
|
|
54
|
+
expect(first?.isConnected).toBe(false);
|
|
55
|
+
expect(container.querySelectorAll('.oc-graph-wrapper')).toHaveLength(1);
|
|
56
|
+
expect(container.querySelector('canvas.oc-graph-canvas')).toBeNull();
|
|
57
|
+
// A suppressed entrance would have snapped the node to full opacity.
|
|
58
|
+
expect(node3DOpacity('a')).toBe(0);
|
|
61
59
|
});
|
|
62
60
|
it('updates in place when the spec changes at the same dimensions', async () => {
|
|
63
61
|
const controller = {};
|
|
64
|
-
render(Harness, { props: { initialSpec: spec, controller } });
|
|
65
|
-
await waitFor(() => expect(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
const { container } = render(Harness, { props: { initialSpec: spec, controller } });
|
|
63
|
+
await waitFor(() => expect(container.querySelector('.oc-graph-wrapper')).not.toBeNull());
|
|
64
|
+
const graphWrapper = container.querySelector('.oc-graph-wrapper');
|
|
65
|
+
controller.setSpec?.({
|
|
66
|
+
...spec,
|
|
67
|
+
nodes: [{ id: 'a' }, { id: 'b' }],
|
|
68
|
+
chrome: { title: 'Second' },
|
|
69
|
+
});
|
|
70
|
+
// The update reached the live graph, in the same wrapper it mounted.
|
|
71
|
+
await waitFor(() => expect(container.querySelector('.oc-title')?.textContent).toBe('Second'));
|
|
72
|
+
expect(container.querySelector('.oc-graph-wrapper')).toBe(graphWrapper);
|
|
73
|
+
expect(container.querySelectorAll('.oc-graph-wrapper')).toHaveLength(1);
|
|
70
74
|
});
|
|
71
75
|
});
|
|
@@ -87,3 +87,21 @@ describe('Theme context', () => {
|
|
|
87
87
|
});
|
|
88
88
|
});
|
|
89
89
|
});
|
|
90
|
+
it('merges spec, provider, and prop themes at authored leaves', async () => {
|
|
91
|
+
const { container } = render(Chart, {
|
|
92
|
+
props: {
|
|
93
|
+
spec: {
|
|
94
|
+
...minimalSpec,
|
|
95
|
+
chrome: { title: 'Title', source: 'Source' },
|
|
96
|
+
theme: { fonts: { family: 'Georgia' } },
|
|
97
|
+
},
|
|
98
|
+
theme: { fonts: { sizes: { small: 15 } } },
|
|
99
|
+
},
|
|
100
|
+
context: new Map([[THEME_KEY, () => ({ fonts: { sizes: { title: 33 } } })]]),
|
|
101
|
+
});
|
|
102
|
+
await waitFor(() => expect(container.querySelector('.oc-title')).not.toBeNull());
|
|
103
|
+
const title = container.querySelector('.oc-title');
|
|
104
|
+
expect(title.style.fontSize).toBe('33px');
|
|
105
|
+
expect(title.style.fontFamily).toBe('Georgia');
|
|
106
|
+
expect(container.querySelector('.oc-source').style.fontSize).toBe('15px');
|
|
107
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { cleanup, render, waitFor } from '@testing-library/svelte';
|
|
2
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
3
|
+
import Chart from '../Chart.svelte';
|
|
4
|
+
const spec = {
|
|
5
|
+
mark: 'bar',
|
|
6
|
+
data: [{ name: 'A', value: 10 }],
|
|
7
|
+
encoding: {
|
|
8
|
+
x: { field: 'value', type: 'quantitative' },
|
|
9
|
+
y: { field: 'name', type: 'nominal' },
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
/** Every chart render rebuilds its screen-reader data table, so each addition is one render. */
|
|
13
|
+
function renderCount(records) {
|
|
14
|
+
let renders = 0;
|
|
15
|
+
for (const record of records) {
|
|
16
|
+
for (const node of record.addedNodes) {
|
|
17
|
+
if (node instanceof HTMLElement && node.classList.contains('oc-sr-only'))
|
|
18
|
+
renders++;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return renders;
|
|
22
|
+
}
|
|
23
|
+
afterEach(() => cleanup());
|
|
24
|
+
describe('mount with revision', () => {
|
|
25
|
+
it('does not issue a redundant update right after mount', async () => {
|
|
26
|
+
const target = document.body.appendChild(document.createElement('div'));
|
|
27
|
+
const records = [];
|
|
28
|
+
const observer = new MutationObserver((batch) => records.push(...batch));
|
|
29
|
+
observer.observe(target, { childList: true, subtree: true });
|
|
30
|
+
const { container } = render(Chart, {
|
|
31
|
+
target,
|
|
32
|
+
props: { spec, revision: 1, autoResize: false },
|
|
33
|
+
});
|
|
34
|
+
await waitFor(() => expect(container.querySelector('svg')).not.toBeNull());
|
|
35
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
36
|
+
// The mount render only; a redundant update() would render a second time.
|
|
37
|
+
expect(renderCount([...records, ...observer.takeRecords()])).toBe(1);
|
|
38
|
+
observer.disconnect();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -15,17 +15,15 @@
|
|
|
15
15
|
* Uses .svelte.ts extension so runes ($state, $effect) work outside
|
|
16
16
|
* .svelte components.
|
|
17
17
|
*/
|
|
18
|
-
import type { ChartLayout, ChartSpec,
|
|
18
|
+
import type { ChartLayout, ChartSpec, LayerSpec } from '@opendata-ai/openchart-core';
|
|
19
19
|
import { type ChartInstance, type MountOptions } from '@opendata-ai/openchart-vanilla';
|
|
20
20
|
export interface UseChartOptions {
|
|
21
21
|
/** Theme overrides. */
|
|
22
22
|
theme?: MountOptions['theme'];
|
|
23
23
|
/** Dark mode setting. */
|
|
24
24
|
darkMode?: MountOptions['darkMode'];
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
/** Enable responsive resizing. Defaults to true. */
|
|
28
|
-
responsive?: boolean;
|
|
25
|
+
/** Observe container resizes. Defaults to true. */
|
|
26
|
+
autoResize?: boolean;
|
|
29
27
|
/** Rendering backend for point marks; see the vanilla `MountOptions.renderer`. */
|
|
30
28
|
renderer?: MountOptions['renderer'];
|
|
31
29
|
}
|
|
@@ -39,5 +37,5 @@ export interface UseChartReturn {
|
|
|
39
37
|
/** The current compiled layout (null until mounted). */
|
|
40
38
|
readonly layout: ChartLayout | null;
|
|
41
39
|
}
|
|
42
|
-
export declare function useChart(spec: () => ChartSpec | LayerSpec
|
|
40
|
+
export declare function useChart(spec: () => ChartSpec | LayerSpec, options?: () => UseChartOptions | undefined): UseChartReturn;
|
|
43
41
|
//# sourceMappingURL=useChart.svelte.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChart.svelte.d.ts","sourceRoot":"","sources":["../../src/composables/useChart.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"useChart.svelte.d.ts","sourceRoot":"","sources":["../../src/composables/useChart.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAE,KAAK,aAAa,EAAe,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGpG,MAAM,WAAW,eAAe;IAC9B,uBAAuB;IACvB,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAC9B,yBAAyB;IACzB,QAAQ,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IACpC,mDAAmD;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,cAAc;IAC7B,kDAAkD;IAClD,MAAM,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK;QAAE,OAAO,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;IACvD,+CAA+C;IAC/C,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IACrC,wDAAwD;IACxD,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;CACrC;AAED,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,SAAS,GAAG,SAAS,EACjC,OAAO,CAAC,EAAE,MAAM,eAAe,GAAG,SAAS,GAC1C,cAAc,CA8DhB"}
|
|
@@ -28,8 +28,7 @@ export function useChart(spec, options) {
|
|
|
28
28
|
const mountOpts = {
|
|
29
29
|
theme: opts?.theme,
|
|
30
30
|
darkMode: opts?.darkMode,
|
|
31
|
-
|
|
32
|
-
responsive: opts?.responsive ?? true,
|
|
31
|
+
autoResize: opts?.autoResize ?? true,
|
|
33
32
|
renderer: opts?.renderer,
|
|
34
33
|
};
|
|
35
34
|
// Read spec without tracking
|
|
@@ -50,8 +50,8 @@ export interface UseGraphOptions {
|
|
|
50
50
|
onHighlightChange?: GraphMountOptions['onHighlightChange'];
|
|
51
51
|
/** Camera change handler. */
|
|
52
52
|
onCameraChange?: GraphMountOptions['onCameraChange'];
|
|
53
|
-
/**
|
|
54
|
-
|
|
53
|
+
/** Observe container resizing. Defaults to true. */
|
|
54
|
+
autoResize?: boolean;
|
|
55
55
|
}
|
|
56
56
|
export interface UseGraphReturn {
|
|
57
57
|
/** Svelte action to attach to a container div. */
|
|
@@ -39,7 +39,7 @@ export function useGraph(spec, options) {
|
|
|
39
39
|
onLegendToggle: opts?.onLegendToggle,
|
|
40
40
|
onHighlightChange: opts?.onHighlightChange,
|
|
41
41
|
onCameraChange: opts?.onCameraChange,
|
|
42
|
-
|
|
42
|
+
autoResize: opts?.autoResize ?? true,
|
|
43
43
|
};
|
|
44
44
|
const graph = createGraph(node, currentSpec, mountOpts);
|
|
45
45
|
instance = graph;
|