@opendata-ai/openchart-vanilla 9.0.0-rc.1 → 9.0.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 +10 -0
- package/dist/{chunk-T6IPHUN4.js → chunk-42WVDS3V.js} +186 -38
- package/dist/chunk-42WVDS3V.js.map +1 -0
- package/dist/{chunk-46E3QB6O.js → chunk-6GRMMSQA.js} +2 -2
- package/dist/{chunk-A5C4VCUO.js → chunk-7XFFPRQ7.js} +13 -4
- package/dist/chunk-7XFFPRQ7.js.map +1 -0
- package/dist/chunk-E3ETKTJQ.js +130 -0
- package/dist/chunk-E3ETKTJQ.js.map +1 -0
- package/dist/{chunk-5ZLSMZRM.js → chunk-HQ5GADZ4.js} +9 -8
- package/dist/{chunk-5ZLSMZRM.js.map → chunk-HQ5GADZ4.js.map} +1 -1
- package/dist/{chunk-ERPYVYFW.js → chunk-NGNHQOXO.js} +1065 -972
- package/dist/chunk-NGNHQOXO.js.map +1 -0
- package/dist/{chunk-RBXIZJPE.js → chunk-OEJHSKFZ.js} +2 -2
- package/dist/{chunk-CMIJA63X.js → chunk-RWP23N4D.js} +3 -3
- package/dist/chunk-SKQAAHHR.js +533 -0
- package/dist/chunk-SKQAAHHR.js.map +1 -0
- package/dist/{chunk-NLKQ5AOA.js → chunk-XR4B3SPC.js} +70 -30
- package/dist/chunk-XR4B3SPC.js.map +1 -0
- package/dist/export-gif.js +4 -4
- package/dist/graph-3d/index.js +4 -4
- package/dist/index.d.ts +41 -51
- package/dist/index.js +85 -216
- package/dist/index.js.map +1 -1
- package/dist/simulation-worker.js +26 -26
- package/dist/static.d.ts +10 -21
- package/dist/static.js +417 -118
- package/dist/static.js.map +1 -1
- package/dist/story/index.js +7 -7
- package/dist/styles.css.map +1 -1
- package/package.json +4 -7
- package/dist/chunk-6YPRYQKD.js +0 -297
- package/dist/chunk-6YPRYQKD.js.map +0 -1
- package/dist/chunk-A5C4VCUO.js.map +0 -1
- package/dist/chunk-ERPYVYFW.js.map +0 -1
- package/dist/chunk-FFP5GXIP.js +0 -45
- package/dist/chunk-FFP5GXIP.js.map +0 -1
- package/dist/chunk-NLKQ5AOA.js.map +0 -1
- package/dist/chunk-T6IPHUN4.js.map +0 -1
- /package/dist/{chunk-46E3QB6O.js.map → chunk-6GRMMSQA.js.map} +0 -0
- /package/dist/{chunk-RBXIZJPE.js.map → chunk-OEJHSKFZ.js.map} +0 -0
- /package/dist/{chunk-CMIJA63X.js.map → chunk-RWP23N4D.js.map} +0 -0
package/README.md
CHANGED
|
@@ -159,3 +159,13 @@ import { exportSVG, exportPNG, exportCSV } from '@opendata-ai/openchart-vanilla'
|
|
|
159
159
|
- [Getting started](../../docs/getting-started.md) for a hands-on tutorial
|
|
160
160
|
- [Integration guide](../../docs/integration-guide.md) for lifecycle management and events
|
|
161
161
|
- [Spec reference](../../docs/spec-reference.md) for field-by-field type details
|
|
162
|
+
|
|
163
|
+
## Static SVG
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
import { renderStaticSVG } from '@opendata-ai/openchart-vanilla/static';
|
|
167
|
+
|
|
168
|
+
const svg = renderStaticSVG(spec, { idPrefix: 'figure-light', darkMode: 'off' });
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Server rendering supports charts, layers, bar lists and maps without a browser or DOM shim. Render each theme separately with distinct stable prefixes. See [static rendering](../../docs/static-rendering.md) for options, authored descriptions and host-owned tables.
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
exportPNG,
|
|
5
5
|
exportSVG,
|
|
6
6
|
exportSVGWithFonts
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-OEJHSKFZ.js";
|
|
8
8
|
import {
|
|
9
9
|
FOCUS_DIM_OPACITY,
|
|
10
10
|
applyGeoDetailVisibility,
|
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
interpolateCamera,
|
|
27
27
|
mapLabelAffine,
|
|
28
28
|
mergeGeoLabelInventory,
|
|
29
|
-
nextSvgId,
|
|
30
29
|
panCamera,
|
|
31
30
|
projectAcceptedGeoOverlay,
|
|
32
31
|
rectPathWithCorners,
|
|
@@ -42,10 +41,10 @@ import {
|
|
|
42
41
|
updateAnnotationGeometry,
|
|
43
42
|
wheelZoomFactor,
|
|
44
43
|
zoomCameraAt
|
|
45
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-NGNHQOXO.js";
|
|
46
45
|
import {
|
|
47
46
|
prepareSettledExportTheme
|
|
48
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-7XFFPRQ7.js";
|
|
49
48
|
import {
|
|
50
49
|
AnimationScheduler,
|
|
51
50
|
SpatialIndex,
|
|
@@ -55,17 +54,19 @@ import {
|
|
|
55
54
|
prefersReducedMotion,
|
|
56
55
|
resolveDarkMode,
|
|
57
56
|
resolveEase
|
|
58
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-6GRMMSQA.js";
|
|
59
58
|
import {
|
|
59
|
+
createRenderContext,
|
|
60
60
|
cubicOut,
|
|
61
|
+
pageIdScope,
|
|
61
62
|
readWithoutThemeStamp,
|
|
62
63
|
stampThemeProperties
|
|
63
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-XR4B3SPC.js";
|
|
64
65
|
import {
|
|
65
66
|
SVG_NS,
|
|
66
67
|
createSVGElement,
|
|
67
68
|
setAttrs
|
|
68
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-E3ETKTJQ.js";
|
|
69
70
|
|
|
70
71
|
// src/scatter-canvas/renderer.ts
|
|
71
72
|
var TWO_PI = Math.PI * 2;
|
|
@@ -485,6 +486,10 @@ function materializeCanvasModeSVG(layout, opts) {
|
|
|
485
486
|
return materializeRasterMarkSVG(layout);
|
|
486
487
|
}
|
|
487
488
|
|
|
489
|
+
// src/transition/gate.ts
|
|
490
|
+
import { isLayerSpec } from "@opendata-ai/openchart-core";
|
|
491
|
+
import { flattenLayers } from "@opendata-ai/openchart-engine";
|
|
492
|
+
|
|
488
493
|
// src/transition/keys.ts
|
|
489
494
|
function annotationKey(a) {
|
|
490
495
|
if (a.id) return `id:${a.id}`;
|
|
@@ -506,6 +511,7 @@ var TRANSITIONABLE_MARKS = /* @__PURE__ */ new Set([
|
|
|
506
511
|
"line",
|
|
507
512
|
"area",
|
|
508
513
|
"point",
|
|
514
|
+
"rule",
|
|
509
515
|
"beeswarm",
|
|
510
516
|
"arc",
|
|
511
517
|
"histogram",
|
|
@@ -516,7 +522,15 @@ var CANVAS_DEFAULT_UPDATE_MAX_MARKS = 2e4;
|
|
|
516
522
|
function canTransitionSpecShape(prevSpec, nextSpec) {
|
|
517
523
|
const prev = prevSpec;
|
|
518
524
|
const next = nextSpec;
|
|
519
|
-
if (!prev || !next
|
|
525
|
+
if (!prev || !next) return false;
|
|
526
|
+
if (isLayerSpec(prev) || isLayerSpec(next)) {
|
|
527
|
+
if (!isLayerSpec(prev) || !isLayerSpec(next)) return false;
|
|
528
|
+
if (JSON.stringify(prev.resolve) !== JSON.stringify(next.resolve)) return false;
|
|
529
|
+
const prevLeaves = flattenLayers(prev);
|
|
530
|
+
const nextLeaves = flattenLayers(next);
|
|
531
|
+
return prevLeaves.length > 0 && prevLeaves.length === nextLeaves.length && prevLeaves.every((leaf, index) => canTransitionSpecShape(leaf, nextLeaves[index]));
|
|
532
|
+
}
|
|
533
|
+
if (!("mark" in prev) || !("mark" in next)) return false;
|
|
520
534
|
const prevMark = typeof prev.mark === "string" ? prev.mark : prev.mark?.type;
|
|
521
535
|
const nextMark = typeof next.mark === "string" ? next.mark : next.mark?.type;
|
|
522
536
|
if (prevMark !== nextMark) return false;
|
|
@@ -3246,7 +3260,7 @@ function buildLinearPath(points) {
|
|
|
3246
3260
|
function round2(n) {
|
|
3247
3261
|
return Math.round(n * 100) / 100;
|
|
3248
3262
|
}
|
|
3249
|
-
function createYouDrawIt(options) {
|
|
3263
|
+
function createYouDrawIt(options, ctx = createRenderContext()) {
|
|
3250
3264
|
const { container, onReveal } = options;
|
|
3251
3265
|
let destroyed = false;
|
|
3252
3266
|
let revealed = false;
|
|
@@ -3286,9 +3300,9 @@ function createYouDrawIt(options) {
|
|
|
3286
3300
|
const { area, fromX } = cfg;
|
|
3287
3301
|
const regionWidth = Math.max(0, area.x + area.width - fromX);
|
|
3288
3302
|
const defs = createSVGElement("defs");
|
|
3289
|
-
const patternId =
|
|
3303
|
+
const patternId = ctx.ids.next("oc-ydi-hatch");
|
|
3290
3304
|
defs.appendChild(buildHatchPattern(patternId, cfg.lineColor));
|
|
3291
|
-
const clipId =
|
|
3305
|
+
const clipId = ctx.ids.next("oc-ydi-clip");
|
|
3292
3306
|
const clipPath = createSVGElement("clipPath");
|
|
3293
3307
|
clipPath.setAttribute("id", clipId);
|
|
3294
3308
|
const clipRect = createSVGElement("rect");
|
|
@@ -4001,7 +4015,7 @@ function sampleLayout(layout, snapshot) {
|
|
|
4001
4015
|
}
|
|
4002
4016
|
|
|
4003
4017
|
// src/mount.ts
|
|
4004
|
-
import { isLayerSpec as
|
|
4018
|
+
import { isLayerSpec as isLayerSpec4 } from "@opendata-ai/openchart-core";
|
|
4005
4019
|
import { resolveLayerTheme } from "@opendata-ai/openchart-engine";
|
|
4006
4020
|
|
|
4007
4021
|
// src/animation.ts
|
|
@@ -4378,6 +4392,9 @@ function wireChartEvents(svg, layout, specAnnotations, handlers) {
|
|
|
4378
4392
|
// src/interactions/crosshair.ts
|
|
4379
4393
|
import { getRepresentativeColor } from "@opendata-ai/openchart-core";
|
|
4380
4394
|
import { sharedTooltipFields } from "@opendata-ai/openchart-engine";
|
|
4395
|
+
function isTrendObservation(mark) {
|
|
4396
|
+
return mark.type === "point" || mark.type === "rule" && mark.markType === "area";
|
|
4397
|
+
}
|
|
4381
4398
|
var EMPHASIS_PROXIMITY_PX = 18;
|
|
4382
4399
|
var SNAP_DOT_RADIUS = 4.5;
|
|
4383
4400
|
function snapKey(x) {
|
|
@@ -4385,11 +4402,22 @@ function snapKey(x) {
|
|
|
4385
4402
|
}
|
|
4386
4403
|
function collectSeriesGroups(layout) {
|
|
4387
4404
|
const byKey = /* @__PURE__ */ new Map();
|
|
4405
|
+
const connectedRows = /* @__PURE__ */ new Map();
|
|
4388
4406
|
const markTypeByKey = /* @__PURE__ */ new Map();
|
|
4389
4407
|
for (let i = 0; i < layout.marks.length; i++) {
|
|
4390
4408
|
const mark = layout.marks[i];
|
|
4391
4409
|
if ((mark.type === "line" || mark.type === "area") && mark.dataPoints?.length) {
|
|
4392
4410
|
const scope = mark.key?.match(/^layer:\d+:/)?.[0] ?? "";
|
|
4411
|
+
const segmentOf = (point) => typeof point.segment === "number" ? point.segment : 0;
|
|
4412
|
+
const segments = /* @__PURE__ */ new Map();
|
|
4413
|
+
for (const point of mark.dataPoints) {
|
|
4414
|
+
const segment = segmentOf(point);
|
|
4415
|
+
segments.set(segment, (segments.get(segment) ?? 0) + 1);
|
|
4416
|
+
}
|
|
4417
|
+
const connected = connectedRows.get(scope) ?? /* @__PURE__ */ new Set();
|
|
4418
|
+
for (const point of mark.dataPoints)
|
|
4419
|
+
if (segments.get(segmentOf(point)) > 1) connected.add(point.datum);
|
|
4420
|
+
connectedRows.set(scope, connected);
|
|
4393
4421
|
const seriesKey = mark.seriesKey ?? "__default__";
|
|
4394
4422
|
const key = `${scope}${seriesKey}`;
|
|
4395
4423
|
const existingType = markTypeByKey.get(key);
|
|
@@ -4403,6 +4431,36 @@ function collectSeriesGroups(layout) {
|
|
|
4403
4431
|
markTypeByKey.set(key, mark.type);
|
|
4404
4432
|
}
|
|
4405
4433
|
}
|
|
4434
|
+
for (const [index, mark] of layout.marks.entries()) {
|
|
4435
|
+
if (mark.type !== "point" && !(mark.type === "rule" && isTrendObservation(mark)) || mark.aria.decorative)
|
|
4436
|
+
continue;
|
|
4437
|
+
const markId = `${mark.type}-${index}`;
|
|
4438
|
+
const scope = mark.key?.match(/^layer:\d+:/)?.[0] ?? "";
|
|
4439
|
+
const tooltip = layout.tooltipDescriptors.get(markId);
|
|
4440
|
+
if (!tooltip) continue;
|
|
4441
|
+
if (connectedRows.get(scope)?.has(mark.data)) continue;
|
|
4442
|
+
const seriesKey = (mark.type === "point" ? mark.seriesKey : void 0) ?? "__default__";
|
|
4443
|
+
let key = `${scope}${seriesKey}`;
|
|
4444
|
+
let group = byKey.get(key);
|
|
4445
|
+
const observationX = mark.type === "point" ? mark.cx : mark.x1;
|
|
4446
|
+
const observationY = mark.type === "point" ? mark.cy : (mark.y1 + mark.y2) / 2;
|
|
4447
|
+
const x = snapKey(observationX);
|
|
4448
|
+
if (group?.pointsByX.has(x) && group.pointsByX.get(x).datum !== mark.data) {
|
|
4449
|
+
key = `${key}:point:${mark.key ?? index}`;
|
|
4450
|
+
group = byKey.get(key);
|
|
4451
|
+
}
|
|
4452
|
+
if (!group) {
|
|
4453
|
+
group = {
|
|
4454
|
+
key,
|
|
4455
|
+
seriesKey,
|
|
4456
|
+
markId,
|
|
4457
|
+
color: mark.type === "point" ? getRepresentativeColor(mark.fill) : mark.stroke,
|
|
4458
|
+
pointsByX: /* @__PURE__ */ new Map()
|
|
4459
|
+
};
|
|
4460
|
+
byKey.set(key, group);
|
|
4461
|
+
}
|
|
4462
|
+
group.pointsByX.set(x, { x: observationX, y: observationY, datum: mark.data, tooltip, markId });
|
|
4463
|
+
}
|
|
4406
4464
|
return Array.from(byKey.values());
|
|
4407
4465
|
}
|
|
4408
4466
|
function collectSnapXs(groups) {
|
|
@@ -4518,7 +4576,11 @@ function wireVoronoiTooltipEvents(svg, layout, tooltipManager, emphasis) {
|
|
|
4518
4576
|
currentEmphasis = emphasisKey;
|
|
4519
4577
|
const emphasizedGroup = groups.find((group) => group.key === emphasisKey);
|
|
4520
4578
|
if (emphasizedGroup) {
|
|
4521
|
-
emphasis?.setMark(
|
|
4579
|
+
emphasis?.setMark(
|
|
4580
|
+
svg.querySelector(
|
|
4581
|
+
`[data-mark-id="${emphasizedGroup.pointsByX.get(snappedX)?.markId ?? emphasizedGroup.markId}"]`
|
|
4582
|
+
)
|
|
4583
|
+
);
|
|
4522
4584
|
} else emphasis?.clear();
|
|
4523
4585
|
const tooltip = buildSliceTooltip(hits, emphasisKey);
|
|
4524
4586
|
if (!tooltip) return false;
|
|
@@ -4614,6 +4676,14 @@ function wireVoronoiTooltipEvents(svg, layout, tooltipManager, emphasis) {
|
|
|
4614
4676
|
get currentIndex() {
|
|
4615
4677
|
return currentIndex;
|
|
4616
4678
|
},
|
|
4679
|
+
get focusedMark() {
|
|
4680
|
+
if (currentIndex < 0) return null;
|
|
4681
|
+
const x = snapXs[currentIndex];
|
|
4682
|
+
const candidates = groups.filter((group2) => group2.pointsByX.has(x));
|
|
4683
|
+
const group = candidates.find((candidate) => candidate.key === currentEmphasis) ?? candidates[0];
|
|
4684
|
+
const point = group?.pointsByX.get(x);
|
|
4685
|
+
return group && point ? { markId: point.markId ?? group.markId, datum: point.datum, series: group.seriesKey } : null;
|
|
4686
|
+
},
|
|
4617
4687
|
stepTo,
|
|
4618
4688
|
cycleSeries(delta) {
|
|
4619
4689
|
if (currentIndex < 0) {
|
|
@@ -5306,11 +5376,55 @@ function wireEndpointLabelHover(svg, emphasis) {
|
|
|
5306
5376
|
}
|
|
5307
5377
|
|
|
5308
5378
|
// src/interactions/keyboard-nav.ts
|
|
5309
|
-
function wireKeyboardNav(svg, container, tooltipDescriptors, tooltipManager, layout,
|
|
5379
|
+
function wireKeyboardNav(svg, container, tooltipDescriptors, tooltipManager, layout, options = {}) {
|
|
5380
|
+
const { crosshair, onFocus } = options;
|
|
5310
5381
|
container.setAttribute("tabindex", "0");
|
|
5311
5382
|
container.setAttribute("aria-roledescription", "chart");
|
|
5312
5383
|
container.setAttribute("aria-label", layout.a11y.altText);
|
|
5313
|
-
|
|
5384
|
+
let pointerFocus = false;
|
|
5385
|
+
const handlePointerDown = () => {
|
|
5386
|
+
pointerFocus = true;
|
|
5387
|
+
};
|
|
5388
|
+
const clearPointerFocus = () => {
|
|
5389
|
+
pointerFocus = false;
|
|
5390
|
+
};
|
|
5391
|
+
const pointerEvents = ["click", "pointercancel"];
|
|
5392
|
+
container.addEventListener("pointerdown", handlePointerDown);
|
|
5393
|
+
for (const type of pointerEvents) container.addEventListener(type, clearPointerFocus);
|
|
5394
|
+
const removePointerListeners = () => {
|
|
5395
|
+
container.removeEventListener("pointerdown", handlePointerDown);
|
|
5396
|
+
for (const type of pointerEvents) container.removeEventListener(type, clearPointerFocus);
|
|
5397
|
+
};
|
|
5398
|
+
const trendDescriptorsOnly = [...tooltipDescriptors.keys()].every((key) => {
|
|
5399
|
+
const mark = layout.marks[Number(key.slice(key.lastIndexOf("-") + 1))];
|
|
5400
|
+
return mark && isTrendObservation(mark);
|
|
5401
|
+
});
|
|
5402
|
+
if (trendDescriptorsOnly && crosshair) {
|
|
5403
|
+
let lastFocus = null;
|
|
5404
|
+
const announceCrosshair = (event) => {
|
|
5405
|
+
const focused = crosshair.focusedMark;
|
|
5406
|
+
if (!focused || lastFocus?.datum === focused.datum && lastFocus.series === focused.series && lastFocus.markId === focused.markId)
|
|
5407
|
+
return;
|
|
5408
|
+
lastFocus = focused;
|
|
5409
|
+
const element = svg.querySelector(`[data-mark-id="${focused.markId}"]`);
|
|
5410
|
+
const mark = layout.marks[Number(focused.markId.slice(focused.markId.lastIndexOf("-") + 1))];
|
|
5411
|
+
if (element && mark)
|
|
5412
|
+
onFocus?.({
|
|
5413
|
+
datum: focused.datum,
|
|
5414
|
+
series: focused.series === "__default__" ? void 0 : focused.series,
|
|
5415
|
+
key: `${mark.key ?? focused.markId}:${crosshair.currentIndex}`,
|
|
5416
|
+
description: element.getAttribute("aria-label") ?? void 0,
|
|
5417
|
+
element,
|
|
5418
|
+
event
|
|
5419
|
+
});
|
|
5420
|
+
};
|
|
5421
|
+
const handleCrosshairFocus = (event) => {
|
|
5422
|
+
if (pointerFocus) return clearPointerFocus();
|
|
5423
|
+
crosshair.hide(true);
|
|
5424
|
+
crosshair.stepTo(0);
|
|
5425
|
+
crosshair.cycleSeries(1);
|
|
5426
|
+
announceCrosshair(event);
|
|
5427
|
+
};
|
|
5314
5428
|
const handleCrosshairKeys = (e) => {
|
|
5315
5429
|
const step = crosshair.currentIndex;
|
|
5316
5430
|
switch (e.key) {
|
|
@@ -5339,18 +5453,24 @@ function wireKeyboardNav(svg, container, tooltipDescriptors, tooltipManager, lay
|
|
|
5339
5453
|
break;
|
|
5340
5454
|
case "Escape":
|
|
5341
5455
|
e.preventDefault();
|
|
5456
|
+
lastFocus = null;
|
|
5342
5457
|
crosshair.hide(true);
|
|
5343
5458
|
break;
|
|
5344
5459
|
}
|
|
5460
|
+
announceCrosshair(e);
|
|
5345
5461
|
};
|
|
5346
5462
|
const handleCrosshairBlur = () => {
|
|
5347
5463
|
crosshair.hide(true);
|
|
5464
|
+
lastFocus = null;
|
|
5348
5465
|
};
|
|
5466
|
+
container.addEventListener("focus", handleCrosshairFocus);
|
|
5349
5467
|
container.addEventListener("keydown", handleCrosshairKeys);
|
|
5350
5468
|
container.addEventListener("blur", handleCrosshairBlur);
|
|
5351
5469
|
return () => {
|
|
5470
|
+
container.removeEventListener("focus", handleCrosshairFocus);
|
|
5352
5471
|
container.removeEventListener("keydown", handleCrosshairKeys);
|
|
5353
5472
|
container.removeEventListener("blur", handleCrosshairBlur);
|
|
5473
|
+
removePointerListeners();
|
|
5354
5474
|
container.removeAttribute("tabindex");
|
|
5355
5475
|
container.removeAttribute("aria-roledescription");
|
|
5356
5476
|
container.removeAttribute("aria-label");
|
|
@@ -5365,7 +5485,8 @@ function wireKeyboardNav(svg, container, tooltipDescriptors, tooltipManager, lay
|
|
|
5365
5485
|
}
|
|
5366
5486
|
}
|
|
5367
5487
|
let focusIndex = -1;
|
|
5368
|
-
function highlightMark(index) {
|
|
5488
|
+
function highlightMark(index, event) {
|
|
5489
|
+
const changed = focusIndex !== index;
|
|
5369
5490
|
if (focusIndex >= 0 && focusIndex < markElements.length) {
|
|
5370
5491
|
markElements[focusIndex].classList.remove("oc-mark-focused");
|
|
5371
5492
|
markElements[focusIndex].removeAttribute("aria-selected");
|
|
@@ -5375,6 +5496,19 @@ function wireKeyboardNav(svg, container, tooltipDescriptors, tooltipManager, lay
|
|
|
5375
5496
|
const el = markElements[focusIndex];
|
|
5376
5497
|
el.classList.add("oc-mark-focused");
|
|
5377
5498
|
el.setAttribute("aria-selected", "true");
|
|
5499
|
+
if (changed && event && onFocus) {
|
|
5500
|
+
const id = el.getAttribute("data-mark-id");
|
|
5501
|
+
const mark = layout.marks[Number(id.slice(id.lastIndexOf("-") + 1))];
|
|
5502
|
+
if (mark)
|
|
5503
|
+
onFocus({
|
|
5504
|
+
datum: Array.isArray(mark.data) ? mark.data[0] ?? {} : mark.data,
|
|
5505
|
+
series: ("seriesKey" in mark ? mark.seriesKey : void 0) ?? el.getAttribute("data-series") ?? void 0,
|
|
5506
|
+
key: mark.key ?? id,
|
|
5507
|
+
description: el.getAttribute("aria-label") ?? void 0,
|
|
5508
|
+
element: el,
|
|
5509
|
+
event
|
|
5510
|
+
});
|
|
5511
|
+
}
|
|
5378
5512
|
}
|
|
5379
5513
|
}
|
|
5380
5514
|
function showTooltipForFocused() {
|
|
@@ -5397,7 +5531,7 @@ function wireKeyboardNav(svg, container, tooltipDescriptors, tooltipManager, lay
|
|
|
5397
5531
|
case "ArrowDown": {
|
|
5398
5532
|
e.preventDefault();
|
|
5399
5533
|
const next = focusIndex < markElements.length - 1 ? focusIndex + 1 : 0;
|
|
5400
|
-
highlightMark(next);
|
|
5534
|
+
highlightMark(next, e);
|
|
5401
5535
|
showTooltipForFocused();
|
|
5402
5536
|
break;
|
|
5403
5537
|
}
|
|
@@ -5405,7 +5539,7 @@ function wireKeyboardNav(svg, container, tooltipDescriptors, tooltipManager, lay
|
|
|
5405
5539
|
case "ArrowUp": {
|
|
5406
5540
|
e.preventDefault();
|
|
5407
5541
|
const prev = focusIndex > 0 ? focusIndex - 1 : markElements.length - 1;
|
|
5408
|
-
highlightMark(prev);
|
|
5542
|
+
highlightMark(prev, e);
|
|
5409
5543
|
showTooltipForFocused();
|
|
5410
5544
|
break;
|
|
5411
5545
|
}
|
|
@@ -5415,7 +5549,7 @@ function wireKeyboardNav(svg, container, tooltipDescriptors, tooltipManager, lay
|
|
|
5415
5549
|
if (focusIndex >= 0) {
|
|
5416
5550
|
showTooltipForFocused();
|
|
5417
5551
|
} else if (markElements.length > 0) {
|
|
5418
|
-
highlightMark(0);
|
|
5552
|
+
highlightMark(0, e);
|
|
5419
5553
|
showTooltipForFocused();
|
|
5420
5554
|
}
|
|
5421
5555
|
break;
|
|
@@ -5432,11 +5566,18 @@ function wireKeyboardNav(svg, container, tooltipDescriptors, tooltipManager, lay
|
|
|
5432
5566
|
tooltipManager.hide();
|
|
5433
5567
|
highlightMark(-1);
|
|
5434
5568
|
};
|
|
5569
|
+
const handleFocus = (event) => {
|
|
5570
|
+
if (pointerFocus) return clearPointerFocus();
|
|
5571
|
+
if (markElements.length) highlightMark(0, event);
|
|
5572
|
+
};
|
|
5573
|
+
container.addEventListener("focus", handleFocus);
|
|
5435
5574
|
container.addEventListener("keydown", handleKeyDown);
|
|
5436
5575
|
container.addEventListener("blur", handleBlur);
|
|
5437
5576
|
return () => {
|
|
5577
|
+
container.removeEventListener("focus", handleFocus);
|
|
5438
5578
|
container.removeEventListener("keydown", handleKeyDown);
|
|
5439
5579
|
container.removeEventListener("blur", handleBlur);
|
|
5580
|
+
removePointerListeners();
|
|
5440
5581
|
container.removeAttribute("tabindex");
|
|
5441
5582
|
container.removeAttribute("aria-roledescription");
|
|
5442
5583
|
container.removeAttribute("aria-label");
|
|
@@ -6040,7 +6181,7 @@ function createChartExporter(state) {
|
|
|
6040
6181
|
}
|
|
6041
6182
|
|
|
6042
6183
|
// src/chart-sizing.ts
|
|
6043
|
-
import { isLayerSpec } from "@opendata-ai/openchart-core";
|
|
6184
|
+
import { isLayerSpec as isLayerSpec2 } from "@opendata-ai/openchart-core";
|
|
6044
6185
|
import {
|
|
6045
6186
|
compileChart,
|
|
6046
6187
|
compileLayer,
|
|
@@ -6084,12 +6225,12 @@ function createChartSizer(container) {
|
|
|
6084
6225
|
}
|
|
6085
6226
|
function compileAt(width, height, candidate, options) {
|
|
6086
6227
|
const compileOpts = { width, height, ...options };
|
|
6087
|
-
if (
|
|
6228
|
+
if (isLayerSpec2(candidate)) return compileLayer(candidate, compileOpts);
|
|
6088
6229
|
return compileChart(candidate, compileOpts);
|
|
6089
6230
|
}
|
|
6090
6231
|
function compile(candidate, options) {
|
|
6091
6232
|
const { width, height } = dimensions(candidate);
|
|
6092
|
-
const growsWithChrome = isAutoHeight === true && !
|
|
6233
|
+
const growsWithChrome = isAutoHeight === true && !isLayerSpec2(candidate) && candidate.display !== "sparkline";
|
|
6093
6234
|
if (!growsWithChrome) {
|
|
6094
6235
|
return compileAt(width, height, candidate, options);
|
|
6095
6236
|
}
|
|
@@ -6751,7 +6892,7 @@ function createSeriesSearch(options) {
|
|
|
6751
6892
|
}
|
|
6752
6893
|
|
|
6753
6894
|
// src/series-visibility.ts
|
|
6754
|
-
import { isLayerSpec as
|
|
6895
|
+
import { isLayerSpec as isLayerSpec3 } from "@opendata-ai/openchart-core";
|
|
6755
6896
|
function createSeriesVisibility() {
|
|
6756
6897
|
const runtimeHiddenSeries = /* @__PURE__ */ new Set();
|
|
6757
6898
|
const runtimeShownSeries = /* @__PURE__ */ new Set();
|
|
@@ -6812,7 +6953,7 @@ function createSeriesVisibility() {
|
|
|
6812
6953
|
return { apply, toggle, clear };
|
|
6813
6954
|
}
|
|
6814
6955
|
function seriesField(spec) {
|
|
6815
|
-
if (
|
|
6956
|
+
if (isLayerSpec3(spec)) return void 0;
|
|
6816
6957
|
const { encoding, mark } = spec;
|
|
6817
6958
|
const color = encoding?.color;
|
|
6818
6959
|
if (color && !("condition" in color) && "field" in color && color.type !== "quantitative")
|
|
@@ -6825,7 +6966,7 @@ function seriesField(spec) {
|
|
|
6825
6966
|
|
|
6826
6967
|
// src/mount.ts
|
|
6827
6968
|
function authoredHighlight(spec) {
|
|
6828
|
-
if (
|
|
6969
|
+
if (isLayerSpec4(spec)) return [];
|
|
6829
6970
|
const colorEnc = spec.encoding?.color;
|
|
6830
6971
|
if (!colorEnc || typeof colorEnc !== "object" || !("field" in colorEnc)) return [];
|
|
6831
6972
|
const raw = colorEnc.highlight;
|
|
@@ -6833,11 +6974,11 @@ function authoredHighlight(spec) {
|
|
|
6833
6974
|
return Array.isArray(raw) ? [...raw] : [raw];
|
|
6834
6975
|
}
|
|
6835
6976
|
function wantsSeriesSearch(spec) {
|
|
6836
|
-
if (
|
|
6977
|
+
if (isLayerSpec4(spec)) return false;
|
|
6837
6978
|
return !!spec.seriesSearch;
|
|
6838
6979
|
}
|
|
6839
6980
|
function wantsYouDrawIt(spec) {
|
|
6840
|
-
if (
|
|
6981
|
+
if (isLayerSpec4(spec)) return false;
|
|
6841
6982
|
return !!spec.youDrawIt;
|
|
6842
6983
|
}
|
|
6843
6984
|
function createChart(container, spec, options) {
|
|
@@ -6876,7 +7017,7 @@ function createChart(container, spec, options) {
|
|
|
6876
7017
|
let ydiEditSuppressWarned = false;
|
|
6877
7018
|
container.classList.add("oc-root");
|
|
6878
7019
|
function resolveEffectiveFont(candidate = currentSpec) {
|
|
6879
|
-
const theme =
|
|
7020
|
+
const theme = isLayerSpec4(candidate) ? resolveLayerTheme(candidate) : candidate.theme;
|
|
6880
7021
|
return options?.theme?.fonts?.family ?? theme?.fonts?.family ?? readWithoutThemeStamp(container, "--oc-font-family", () => resolveFontFamily(container));
|
|
6881
7022
|
}
|
|
6882
7023
|
let fontFamily = resolveEffectiveFont();
|
|
@@ -6976,6 +7117,7 @@ function createChart(container, spec, options) {
|
|
|
6976
7117
|
}
|
|
6977
7118
|
const sceneHost = retainedSVG ? document.createElement("div") : container;
|
|
6978
7119
|
svgElement = renderChartSVG(currentLayout, sceneHost, {
|
|
7120
|
+
context: createRenderContext({ ids: pageIdScope }),
|
|
6979
7121
|
animate: shouldAnimate,
|
|
6980
7122
|
crosshair,
|
|
6981
7123
|
canvasMarks: canvasMode
|
|
@@ -7025,7 +7167,7 @@ function createChart(container, spec, options) {
|
|
|
7025
7167
|
currentLayout.tooltipDescriptors,
|
|
7026
7168
|
tooltipManager,
|
|
7027
7169
|
currentLayout,
|
|
7028
|
-
crosshairController
|
|
7170
|
+
{ crosshair: crosshairController, onFocus: options?.onMarkFocus }
|
|
7029
7171
|
)
|
|
7030
7172
|
);
|
|
7031
7173
|
disposeNavigation = () => {
|
|
@@ -7122,7 +7264,7 @@ function createChart(container, spec, options) {
|
|
|
7122
7264
|
if (!editSuppressed && selectable) {
|
|
7123
7265
|
edits.attach(svgElement);
|
|
7124
7266
|
}
|
|
7125
|
-
if (!currentLayout.a11y.hidden) {
|
|
7267
|
+
if (!currentLayout.a11y.hidden && (!("a11y" in currentSpec) || currentSpec.a11y?.table !== false)) {
|
|
7126
7268
|
srTableWrapper = createScreenReaderTable(currentLayout, container);
|
|
7127
7269
|
}
|
|
7128
7270
|
if (currentLayout.seriesSearch) {
|
|
@@ -7301,7 +7443,7 @@ function createChart(container, spec, options) {
|
|
|
7301
7443
|
}
|
|
7302
7444
|
function setHighlight(values) {
|
|
7303
7445
|
if (destroyed) return;
|
|
7304
|
-
if (
|
|
7446
|
+
if (isLayerSpec4(currentSpec)) return;
|
|
7305
7447
|
const spec2 = currentSpec;
|
|
7306
7448
|
const colorEnc = spec2.encoding?.color;
|
|
7307
7449
|
if (!colorEnc || typeof colorEnc !== "object" || !("field" in colorEnc)) return;
|
|
@@ -7515,7 +7657,8 @@ function wireMarkNavigation(svg, marks) {
|
|
|
7515
7657
|
}
|
|
7516
7658
|
event.preventDefault();
|
|
7517
7659
|
event.stopPropagation();
|
|
7518
|
-
if (next !== void 0
|
|
7660
|
+
if (next !== void 0 && next !== index)
|
|
7661
|
+
marks[next].element.focus({ preventScroll: true });
|
|
7519
7662
|
};
|
|
7520
7663
|
element.addEventListener("focus", focus);
|
|
7521
7664
|
element.addEventListener("blur", mark.leave);
|
|
@@ -7651,7 +7794,6 @@ var KEY_PAN_FRACTION = 0.1;
|
|
|
7651
7794
|
var DRAG_THRESHOLD = 3;
|
|
7652
7795
|
var HINT_MS = 1500;
|
|
7653
7796
|
var EPS = 1e-3;
|
|
7654
|
-
var clipIdCounter = 0;
|
|
7655
7797
|
var ICONS = {
|
|
7656
7798
|
in: '<path d="M8 3v10M3 8h10"/>',
|
|
7657
7799
|
out: '<path d="M3 8h10"/>',
|
|
@@ -7661,9 +7803,9 @@ function isMacLike() {
|
|
|
7661
7803
|
if (typeof navigator === "undefined") return false;
|
|
7662
7804
|
return /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || "");
|
|
7663
7805
|
}
|
|
7664
|
-
function createMapZoomController(host) {
|
|
7806
|
+
function createMapZoomController(host, ctx = createRenderContext()) {
|
|
7665
7807
|
const { container } = host;
|
|
7666
|
-
const clipId =
|
|
7808
|
+
const clipId = ctx.ids.next("oc-map-zoom-clip");
|
|
7667
7809
|
let overlay = null;
|
|
7668
7810
|
let buttons = null;
|
|
7669
7811
|
let hint = null;
|
|
@@ -8771,7 +8913,10 @@ function createGeoMap(container, spec, options) {
|
|
|
8771
8913
|
const oldSvgHadFocus = !!oldSvg && document.activeElement === oldSvg;
|
|
8772
8914
|
viewCameras.update(currentLayout.views ?? []);
|
|
8773
8915
|
for (const id of viewOverlays.keys()) if (!viewCameras.has(id)) viewOverlays.delete(id);
|
|
8774
|
-
const newSvg = renderMapSVG(currentLayout, {
|
|
8916
|
+
const newSvg = renderMapSVG(currentLayout, {
|
|
8917
|
+
context: createRenderContext({ ids: pageIdScope }),
|
|
8918
|
+
animate
|
|
8919
|
+
});
|
|
8775
8920
|
if (oldSvg) {
|
|
8776
8921
|
if (cleanupTooltipEvents) {
|
|
8777
8922
|
cleanupTooltipEvents();
|
|
@@ -8913,7 +9058,10 @@ function createGeoMap(container, spec, options) {
|
|
|
8913
9058
|
}
|
|
8914
9059
|
function exportChart(format, options_) {
|
|
8915
9060
|
if (!svgElement) return "";
|
|
8916
|
-
const terminalSvg = renderMapSVG(currentLayout, {
|
|
9061
|
+
const terminalSvg = renderMapSVG(currentLayout, {
|
|
9062
|
+
context: createRenderContext({ ids: pageIdScope }),
|
|
9063
|
+
animate: false
|
|
9064
|
+
});
|
|
8917
9065
|
if (currentLayout.views) {
|
|
8918
9066
|
const overlays = /* @__PURE__ */ new Map();
|
|
8919
9067
|
const inventory = [];
|
|
@@ -9214,4 +9362,4 @@ export {
|
|
|
9214
9362
|
createChart,
|
|
9215
9363
|
createGeoMap
|
|
9216
9364
|
};
|
|
9217
|
-
//# sourceMappingURL=chunk-
|
|
9365
|
+
//# sourceMappingURL=chunk-42WVDS3V.js.map
|