@opendata-ai/openchart-vanilla 8.9.0 → 9.0.0-rc.1
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 +4 -4
- package/dist/{chunk-2OJZBMXM.js → chunk-46E3QB6O.js} +51 -65
- package/dist/chunk-46E3QB6O.js.map +1 -0
- package/dist/{chunk-YBVDBY6P.js → chunk-5ZLSMZRM.js} +466 -332
- package/dist/chunk-5ZLSMZRM.js.map +1 -0
- package/dist/{chunk-YHZAH6EN.js → chunk-6YPRYQKD.js} +16 -50
- package/dist/chunk-6YPRYQKD.js.map +1 -0
- package/dist/{chunk-SDJHUELU.js → chunk-A5C4VCUO.js} +26 -45
- package/dist/chunk-A5C4VCUO.js.map +1 -0
- package/dist/{chunk-MGFXAROR.js → chunk-CMIJA63X.js} +5 -3
- package/dist/chunk-CMIJA63X.js.map +1 -0
- package/dist/{chunk-TP3GCWCO.js → chunk-ERPYVYFW.js} +1609 -300
- package/dist/chunk-ERPYVYFW.js.map +1 -0
- package/dist/chunk-FFP5GXIP.js +45 -0
- package/dist/chunk-FFP5GXIP.js.map +1 -0
- package/dist/chunk-NLKQ5AOA.js +448 -0
- package/dist/chunk-NLKQ5AOA.js.map +1 -0
- package/dist/{chunk-R5TZHNTG.js → chunk-RBXIZJPE.js} +17 -5
- package/dist/chunk-RBXIZJPE.js.map +1 -0
- package/dist/{chunk-6TD7GWR4.js → chunk-T6IPHUN4.js} +2359 -2101
- package/dist/chunk-T6IPHUN4.js.map +1 -0
- package/dist/export-gif.d.ts +2 -2
- package/dist/export-gif.js +4 -3
- package/dist/graph-3d/index.d.ts +1 -1
- package/dist/graph-3d/index.js +25 -7
- package/dist/graph-3d/index.js.map +1 -1
- package/dist/index.d.ts +155 -29
- package/dist/index.js +1774 -186
- package/dist/index.js.map +1 -1
- package/dist/{mount-FmUdKlCq.d.ts → mount-types-DeUCa2hy.d.ts} +38 -20
- package/dist/{renderer-registry-Cng76n8F.d.ts → renderer-registry-Bu22Roek.d.ts} +5 -22
- package/dist/simulation-worker.js +1 -0
- package/dist/static.d.ts +4 -2
- package/dist/static.js +34 -10
- package/dist/static.js.map +1 -1
- package/dist/story/index.d.ts +8 -6
- package/dist/story/index.js +15 -12
- package/dist/story/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-2OJZBMXM.js.map +0 -1
- package/dist/chunk-6TD7GWR4.js.map +0 -1
- package/dist/chunk-MGFXAROR.js.map +0 -1
- package/dist/chunk-NG7CVCI2.js +0 -58
- package/dist/chunk-NG7CVCI2.js.map +0 -1
- package/dist/chunk-R5TZHNTG.js.map +0 -1
- package/dist/chunk-SDJHUELU.js.map +0 -1
- package/dist/chunk-TP3GCWCO.js.map +0 -1
- package/dist/chunk-YBVDBY6P.js.map +0 -1
- package/dist/chunk-YHZAH6EN.js.map +0 -1
|
@@ -7,10 +7,16 @@ import {
|
|
|
7
7
|
prefersReducedMotion,
|
|
8
8
|
resolveDarkMode,
|
|
9
9
|
resolveEase
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-46E3QB6O.js";
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
renderAttributionBrand,
|
|
13
|
+
renderChromeElement,
|
|
14
|
+
stampThemeProperties
|
|
15
|
+
} from "./chunk-NLKQ5AOA.js";
|
|
16
|
+
import {
|
|
17
|
+
createSVGElement,
|
|
18
|
+
setAttrs
|
|
19
|
+
} from "./chunk-FFP5GXIP.js";
|
|
14
20
|
|
|
15
21
|
// src/graph/renderer-registry.ts
|
|
16
22
|
var registry = /* @__PURE__ */ new Map();
|
|
@@ -23,7 +29,8 @@ function getGraphRenderer(dimensions) {
|
|
|
23
29
|
var GRAPH_3D_NOT_REGISTERED_ERROR = 'createGraph: dimensions: 3 requires import "@opendata-ai/openchart-vanilla/graph-3d"';
|
|
24
30
|
|
|
25
31
|
// src/graph-mount.ts
|
|
26
|
-
import {
|
|
32
|
+
import { computeChrome } from "@opendata-ai/openchart-core";
|
|
33
|
+
import { compileGraph } from "@opendata-ai/openchart-engine";
|
|
27
34
|
|
|
28
35
|
// src/graph/camera.ts
|
|
29
36
|
import { interpolateZoom } from "d3-interpolate";
|
|
@@ -1123,6 +1130,243 @@ function categoryHighlightSet(activeCategories, nodeCategory) {
|
|
|
1123
1130
|
return set;
|
|
1124
1131
|
}
|
|
1125
1132
|
|
|
1133
|
+
// src/graph/focus-model.ts
|
|
1134
|
+
function createGraphFocusModel(ctx) {
|
|
1135
|
+
const { scheduler } = ctx;
|
|
1136
|
+
let highlightSet = null;
|
|
1137
|
+
let highlightDimOpacity = null;
|
|
1138
|
+
let activeCategories = /* @__PURE__ */ new Set();
|
|
1139
|
+
let transientHighlight = null;
|
|
1140
|
+
let transientTarget = null;
|
|
1141
|
+
let focusTransition = null;
|
|
1142
|
+
let focusAnim = null;
|
|
1143
|
+
let hoverRadiusTween = null;
|
|
1144
|
+
function hoverConnectedSet(nodeId) {
|
|
1145
|
+
if (nodeId === null) return null;
|
|
1146
|
+
if (ctx.compilation().interaction.hoverMode === "category") {
|
|
1147
|
+
const nodeCategory = ctx.nodeCategory();
|
|
1148
|
+
const cat = nodeCategory.get(nodeId);
|
|
1149
|
+
const set2 = /* @__PURE__ */ new Set([nodeId]);
|
|
1150
|
+
if (cat !== void 0) {
|
|
1151
|
+
for (const [id, c] of nodeCategory) if (c === cat) set2.add(id);
|
|
1152
|
+
}
|
|
1153
|
+
return set2;
|
|
1154
|
+
}
|
|
1155
|
+
const set = /* @__PURE__ */ new Set([nodeId]);
|
|
1156
|
+
const neighbors = ctx.adjacency().get(nodeId);
|
|
1157
|
+
if (neighbors) for (const nid of neighbors) set.add(nid);
|
|
1158
|
+
return set;
|
|
1159
|
+
}
|
|
1160
|
+
function standingSnapshot() {
|
|
1161
|
+
return composeStandingFocus(highlightSet, ctx.searchMatches(), ctx.selected(), ctx.adjacency());
|
|
1162
|
+
}
|
|
1163
|
+
function targetSnapshot() {
|
|
1164
|
+
const hovered = ctx.hovered();
|
|
1165
|
+
return layerHoverFocus(standingSnapshot(), hovered, hoverConnectedSet(hovered));
|
|
1166
|
+
}
|
|
1167
|
+
function arm(now) {
|
|
1168
|
+
const target = targetSnapshot();
|
|
1169
|
+
const hoverCfg = ctx.compilation().animation?.hover ?? null;
|
|
1170
|
+
const duration = hoverCfg && !prefersReducedMotion() ? hoverCfg.duration : 0;
|
|
1171
|
+
const ease = resolveEase(hoverCfg?.ease ?? "smooth");
|
|
1172
|
+
if (!focusTransition) {
|
|
1173
|
+
focusTransition = new FocusTransition(target, duration, ease, now);
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
focusTransition.retarget(target, now);
|
|
1177
|
+
if (focusAnim) scheduler.remove(focusAnim);
|
|
1178
|
+
focusAnim = {
|
|
1179
|
+
tick: (t) => {
|
|
1180
|
+
const running = focusTransition !== null && !focusTransition.isSettled(t);
|
|
1181
|
+
if (!running) focusAnim = null;
|
|
1182
|
+
return running;
|
|
1183
|
+
},
|
|
1184
|
+
finish: () => {
|
|
1185
|
+
focusAnim = null;
|
|
1186
|
+
},
|
|
1187
|
+
cancel: () => {
|
|
1188
|
+
focusAnim = null;
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
scheduler.add(focusAnim);
|
|
1192
|
+
}
|
|
1193
|
+
function resolveHighlightTarget2(target) {
|
|
1194
|
+
return resolveHighlightTarget(target, ctx.compilation().nodes, ctx.adjacency());
|
|
1195
|
+
}
|
|
1196
|
+
function recompute() {
|
|
1197
|
+
const filter = categoryHighlightSet(activeCategories, ctx.nodeCategory());
|
|
1198
|
+
const transient = transientHighlight !== null && transientHighlight.size > 0 ? transientHighlight : null;
|
|
1199
|
+
if (filter !== null && transient !== null) {
|
|
1200
|
+
const inter = /* @__PURE__ */ new Set();
|
|
1201
|
+
for (const id of transient) if (filter.has(id)) inter.add(id);
|
|
1202
|
+
highlightSet = inter.size > 0 ? inter : transient;
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
highlightSet = filter ?? transient;
|
|
1206
|
+
}
|
|
1207
|
+
function refreshTransientHighlight() {
|
|
1208
|
+
if (transientTarget === null) {
|
|
1209
|
+
transientHighlight = null;
|
|
1210
|
+
return;
|
|
1211
|
+
}
|
|
1212
|
+
const nextIds = new Set(ctx.compilation().nodes.map((n) => n.id));
|
|
1213
|
+
const resolved = new Set(
|
|
1214
|
+
[...resolveHighlightTarget2(transientTarget)].filter((id) => nextIds.has(id))
|
|
1215
|
+
);
|
|
1216
|
+
transientHighlight = resolved.size > 0 ? resolved : null;
|
|
1217
|
+
}
|
|
1218
|
+
function effectiveDimOpacity() {
|
|
1219
|
+
const custom = transientHighlight !== null ? highlightDimOpacity : null;
|
|
1220
|
+
return custom ?? ctx.compilation().interaction.dimOpacity;
|
|
1221
|
+
}
|
|
1222
|
+
function hoverRadius(nodeId) {
|
|
1223
|
+
const hoverCfg = ctx.compilation().animation?.hover ?? null;
|
|
1224
|
+
if (nodeId === null || !hoverCfg || prefersReducedMotion()) {
|
|
1225
|
+
hoverRadiusTween = nodeId ? { nodeId, scale: 1.15 } : null;
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
hoverRadiusTween = { nodeId, scale: 1 };
|
|
1229
|
+
const ease = resolveEase(hoverCfg.ease);
|
|
1230
|
+
const tween = createTween({
|
|
1231
|
+
duration: hoverCfg.duration,
|
|
1232
|
+
ease,
|
|
1233
|
+
apply: (t) => {
|
|
1234
|
+
if (hoverRadiusTween?.nodeId === nodeId) hoverRadiusTween.scale = 1 + 0.15 * t;
|
|
1235
|
+
ctx.invalidate();
|
|
1236
|
+
},
|
|
1237
|
+
onDone: () => {
|
|
1238
|
+
if (hoverRadiusTween?.nodeId === nodeId) hoverRadiusTween.scale = 1.15;
|
|
1239
|
+
}
|
|
1240
|
+
});
|
|
1241
|
+
scheduler.add(tween);
|
|
1242
|
+
}
|
|
1243
|
+
function frame(now) {
|
|
1244
|
+
if (!focusTransition) arm(now);
|
|
1245
|
+
const ft = focusTransition;
|
|
1246
|
+
const t = ft.progress(now);
|
|
1247
|
+
const focus = t < 1 ? { t, prev: ft.prev, next: ft.next } : void 0;
|
|
1248
|
+
const settledNext = ft.next;
|
|
1249
|
+
const hoverRadiusScale = hoverRadiusTween ? /* @__PURE__ */ new Map([[hoverRadiusTween.nodeId, hoverRadiusTween.scale]]) : void 0;
|
|
1250
|
+
return {
|
|
1251
|
+
focus: focus ?? { t: 1, prev: settledNext, next: settledNext },
|
|
1252
|
+
hoverRadiusScale,
|
|
1253
|
+
dimOpacity: effectiveDimOpacity()
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
return {
|
|
1257
|
+
get highlightSet() {
|
|
1258
|
+
return highlightSet;
|
|
1259
|
+
},
|
|
1260
|
+
get categories() {
|
|
1261
|
+
return activeCategories;
|
|
1262
|
+
},
|
|
1263
|
+
highlight(target, dimOpacity) {
|
|
1264
|
+
transientTarget = target;
|
|
1265
|
+
refreshTransientHighlight();
|
|
1266
|
+
highlightDimOpacity = dimOpacity ?? null;
|
|
1267
|
+
recompute();
|
|
1268
|
+
},
|
|
1269
|
+
clearHighlight() {
|
|
1270
|
+
transientTarget = null;
|
|
1271
|
+
transientHighlight = null;
|
|
1272
|
+
highlightDimOpacity = null;
|
|
1273
|
+
recompute();
|
|
1274
|
+
},
|
|
1275
|
+
setCategories(values) {
|
|
1276
|
+
activeCategories = new Set(values);
|
|
1277
|
+
recompute();
|
|
1278
|
+
},
|
|
1279
|
+
toggleCategory(value) {
|
|
1280
|
+
if (activeCategories.has(value)) activeCategories.delete(value);
|
|
1281
|
+
else activeCategories.add(value);
|
|
1282
|
+
recompute();
|
|
1283
|
+
},
|
|
1284
|
+
applyInitial() {
|
|
1285
|
+
const init = ctx.compilation().initialHighlight;
|
|
1286
|
+
if (!init) return;
|
|
1287
|
+
activeCategories = new Set(init.values);
|
|
1288
|
+
recompute();
|
|
1289
|
+
},
|
|
1290
|
+
reconcile() {
|
|
1291
|
+
refreshTransientHighlight();
|
|
1292
|
+
recompute();
|
|
1293
|
+
},
|
|
1294
|
+
arm,
|
|
1295
|
+
reset() {
|
|
1296
|
+
focusTransition = null;
|
|
1297
|
+
},
|
|
1298
|
+
hoverRadius,
|
|
1299
|
+
frame
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
// src/graph/graph-data.ts
|
|
1304
|
+
function buildGraphDataMaps(compilation) {
|
|
1305
|
+
const nodeData = new Map(compilation.nodes.map((n) => [n.id, n.data ?? {}]));
|
|
1306
|
+
const edgeData = new Map(
|
|
1307
|
+
compilation.edges.map((e) => [`${e.source}->${e.target}`, e.data ?? {}])
|
|
1308
|
+
);
|
|
1309
|
+
const nodeCategory = /* @__PURE__ */ new Map();
|
|
1310
|
+
const field = compilation.legendField;
|
|
1311
|
+
if (field) {
|
|
1312
|
+
for (const n of compilation.nodes) {
|
|
1313
|
+
const v = n.data?.[field];
|
|
1314
|
+
if (v != null) nodeCategory.set(n.id, String(v));
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
return { nodeData, edgeData, nodeCategory };
|
|
1318
|
+
}
|
|
1319
|
+
function buildAdjacencyMap(edges) {
|
|
1320
|
+
const map = /* @__PURE__ */ new Map();
|
|
1321
|
+
for (const edge of edges) {
|
|
1322
|
+
if (!map.has(edge.source)) map.set(edge.source, /* @__PURE__ */ new Set());
|
|
1323
|
+
if (!map.has(edge.target)) map.set(edge.target, /* @__PURE__ */ new Set());
|
|
1324
|
+
map.get(edge.source).add(edge.target);
|
|
1325
|
+
map.get(edge.target).add(edge.source);
|
|
1326
|
+
}
|
|
1327
|
+
return map;
|
|
1328
|
+
}
|
|
1329
|
+
function toSimNodes(nodes) {
|
|
1330
|
+
return nodes.map((n) => ({
|
|
1331
|
+
id: n.id,
|
|
1332
|
+
radius: n.radius,
|
|
1333
|
+
community: n.community
|
|
1334
|
+
}));
|
|
1335
|
+
}
|
|
1336
|
+
function toSimEdges(edges) {
|
|
1337
|
+
return edges.map((e) => ({
|
|
1338
|
+
source: e.source,
|
|
1339
|
+
target: e.target
|
|
1340
|
+
}));
|
|
1341
|
+
}
|
|
1342
|
+
function pointToSegmentDist(px, py, ax, ay, bx, by) {
|
|
1343
|
+
const dx = bx - ax;
|
|
1344
|
+
const dy = by - ay;
|
|
1345
|
+
const lenSq = dx * dx + dy * dy;
|
|
1346
|
+
if (lenSq === 0) return Math.hypot(px - ax, py - ay);
|
|
1347
|
+
const t = Math.max(0, Math.min(1, ((px - ax) * dx + (py - ay) * dy) / lenSq));
|
|
1348
|
+
return Math.hypot(px - (ax + t * dx), py - (ay + t * dy));
|
|
1349
|
+
}
|
|
1350
|
+
function hitTestEdge(edges, graphX, graphY, threshold) {
|
|
1351
|
+
let bestDist = threshold;
|
|
1352
|
+
let bestEdgeId = null;
|
|
1353
|
+
for (const edge of edges) {
|
|
1354
|
+
const dist = pointToSegmentDist(
|
|
1355
|
+
graphX,
|
|
1356
|
+
graphY,
|
|
1357
|
+
edge.sourceX,
|
|
1358
|
+
edge.sourceY,
|
|
1359
|
+
edge.targetX,
|
|
1360
|
+
edge.targetY
|
|
1361
|
+
);
|
|
1362
|
+
if (dist < bestDist) {
|
|
1363
|
+
bestDist = dist;
|
|
1364
|
+
bestEdgeId = `${edge.source}->${edge.target}`;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
return bestEdgeId;
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1126
1370
|
// src/graph/interaction.ts
|
|
1127
1371
|
var ZOOM_MIN = 0.05;
|
|
1128
1372
|
var ZOOM_MAX = 15;
|
|
@@ -1677,6 +1921,27 @@ function seedNodePositions(nodes, seed) {
|
|
|
1677
1921
|
}
|
|
1678
1922
|
}
|
|
1679
1923
|
|
|
1924
|
+
// src/renderers/attribution-footer.ts
|
|
1925
|
+
function createAttributionFooter(chrome, width, measureText) {
|
|
1926
|
+
if (!chrome.source && !chrome.byline && !chrome.footer && !chrome.brand && !chrome.watermark)
|
|
1927
|
+
return null;
|
|
1928
|
+
const svg = createSVGElement("svg");
|
|
1929
|
+
svg.setAttribute("class", "oc-attribution-footer");
|
|
1930
|
+
setAttrs(svg, {
|
|
1931
|
+
width: "100%",
|
|
1932
|
+
height: chrome.bottomHeight,
|
|
1933
|
+
viewBox: `0 0 ${width} ${chrome.bottomHeight}`
|
|
1934
|
+
});
|
|
1935
|
+
svg.style.display = "block";
|
|
1936
|
+
svg.style.flex = "0 0 auto";
|
|
1937
|
+
for (const key of ["source", "byline", "footer"]) {
|
|
1938
|
+
const element = chrome[key];
|
|
1939
|
+
if (element) renderChromeElement(svg, element, `oc-${key}`, key, measureText);
|
|
1940
|
+
}
|
|
1941
|
+
renderAttributionBrand(svg, chrome, 0, measureText);
|
|
1942
|
+
return svg;
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1680
1945
|
// src/graph/shell.ts
|
|
1681
1946
|
var MIN_SURFACE_HEIGHT = 200;
|
|
1682
1947
|
function getContainerDimensions(container) {
|
|
@@ -1696,16 +1961,7 @@ function createGraphShell(container, spec, compilation, options, warn) {
|
|
|
1696
1961
|
container.classList.remove("oc-dark");
|
|
1697
1962
|
}
|
|
1698
1963
|
const resolvedTheme = compilation.theme;
|
|
1699
|
-
if (resolvedTheme)
|
|
1700
|
-
const s = wrapper.style;
|
|
1701
|
-
s.setProperty("--oc-bg", resolvedSurface(resolvedTheme));
|
|
1702
|
-
s.setProperty("--oc-text", resolvedTheme.colors.text);
|
|
1703
|
-
s.setProperty("--oc-text-secondary", resolvedTheme.colors.neutral.secondary);
|
|
1704
|
-
s.setProperty("--oc-text-muted", resolvedTheme.colors.axis);
|
|
1705
|
-
s.setProperty("--oc-border", resolvedTheme.colors.neutral.border);
|
|
1706
|
-
s.setProperty("--oc-font-family", resolvedTheme.fonts.family);
|
|
1707
|
-
s.fontFamily = resolvedTheme.fonts.family;
|
|
1708
|
-
}
|
|
1964
|
+
if (resolvedTheme) stampThemeProperties(wrapper, resolvedTheme);
|
|
1709
1965
|
const chromeEl = document.createElement("div");
|
|
1710
1966
|
chromeEl.className = "oc-graph-chrome";
|
|
1711
1967
|
wrapper.appendChild(chromeEl);
|
|
@@ -1718,6 +1974,9 @@ function createGraphShell(container, spec, compilation, options, warn) {
|
|
|
1718
1974
|
}
|
|
1719
1975
|
container.appendChild(wrapper);
|
|
1720
1976
|
const tooltipManager = options?.tooltip !== false ? createTooltipManager(wrapper) : null;
|
|
1977
|
+
let footerHeight = compilation.chrome.bottomHeight;
|
|
1978
|
+
let footer = null;
|
|
1979
|
+
let surface = null;
|
|
1721
1980
|
const shell = {
|
|
1722
1981
|
container,
|
|
1723
1982
|
wrapper,
|
|
@@ -1726,6 +1985,8 @@ function createGraphShell(container, spec, compilation, options, warn) {
|
|
|
1726
1985
|
tooltipManager,
|
|
1727
1986
|
isDark,
|
|
1728
1987
|
mountSurface(el) {
|
|
1988
|
+
surface = el;
|
|
1989
|
+
el.style.height = `calc(100% - ${footerHeight}px)`;
|
|
1729
1990
|
if (legendEl) wrapper.insertBefore(el, legendEl);
|
|
1730
1991
|
else wrapper.appendChild(el);
|
|
1731
1992
|
},
|
|
@@ -1739,6 +2000,16 @@ function createGraphShell(container, spec, compilation, options, warn) {
|
|
|
1739
2000
|
}
|
|
1740
2001
|
chromeEl.innerHTML = html;
|
|
1741
2002
|
chromeEl.style.display = html ? "" : "none";
|
|
2003
|
+
footer?.remove();
|
|
2004
|
+
footer = createAttributionFooter(next.chrome, next.dimensions.width);
|
|
2005
|
+
footerHeight = footer ? next.chrome.bottomHeight : 0;
|
|
2006
|
+
if (surface) surface.style.height = `calc(100% - ${footerHeight}px)`;
|
|
2007
|
+
if (footer) {
|
|
2008
|
+
footer.style.position = "absolute";
|
|
2009
|
+
footer.style.bottom = "0";
|
|
2010
|
+
footer.style.left = "0";
|
|
2011
|
+
wrapper.appendChild(footer);
|
|
2012
|
+
}
|
|
1742
2013
|
},
|
|
1743
2014
|
/**
|
|
1744
2015
|
* Keep the chrome block out of the legend's column: the title/subtitle wrap
|
|
@@ -1751,10 +2022,10 @@ function createGraphShell(container, spec, compilation, options, warn) {
|
|
|
1751
2022
|
},
|
|
1752
2023
|
getSize() {
|
|
1753
2024
|
const { width, height } = getContainerDimensions(container);
|
|
1754
|
-
return { width, height: Math.max(height, MIN_SURFACE_HEIGHT) };
|
|
2025
|
+
return { width, height: Math.max(1, Math.max(height, MIN_SURFACE_HEIGHT) - footerHeight) };
|
|
1755
2026
|
},
|
|
1756
2027
|
observeResize(callback) {
|
|
1757
|
-
if (options?.
|
|
2028
|
+
if (options?.autoResize === false) return () => {
|
|
1758
2029
|
};
|
|
1759
2030
|
return observeResize(container, () => {
|
|
1760
2031
|
callback();
|
|
@@ -2044,6 +2315,8 @@ var SimulationManager = class _SimulationManager {
|
|
|
2044
2315
|
case "error":
|
|
2045
2316
|
console.error("[SimulationManager] Worker error:", msg.message);
|
|
2046
2317
|
break;
|
|
2318
|
+
default:
|
|
2319
|
+
msg;
|
|
2047
2320
|
}
|
|
2048
2321
|
};
|
|
2049
2322
|
worker.postMessage(initMsg);
|
|
@@ -2196,9 +2469,47 @@ var SimulationManager = class _SimulationManager {
|
|
|
2196
2469
|
}
|
|
2197
2470
|
};
|
|
2198
2471
|
|
|
2199
|
-
// src/graph/
|
|
2200
|
-
|
|
2201
|
-
|
|
2472
|
+
// src/graph/tooltip-content.ts
|
|
2473
|
+
import { buildEdgeTooltip } from "@opendata-ai/openchart-engine";
|
|
2474
|
+
function createGraphTooltips(ctx) {
|
|
2475
|
+
function tooltipFormatter() {
|
|
2476
|
+
const t = ctx.options?.tooltip;
|
|
2477
|
+
return t && typeof t === "object" ? t.formatter ?? null : null;
|
|
2478
|
+
}
|
|
2479
|
+
function applyFormatterResult(tooltipManager, result, x, y) {
|
|
2480
|
+
if (result === null) {
|
|
2481
|
+
tooltipManager.hide();
|
|
2482
|
+
} else if (typeof result === "string") {
|
|
2483
|
+
tooltipManager.show({ text: result }, x, y);
|
|
2484
|
+
} else if (result instanceof HTMLElement) {
|
|
2485
|
+
tooltipManager.show({ element: result }, x, y);
|
|
2486
|
+
} else {
|
|
2487
|
+
tooltipManager.show(result, x, y);
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
function show(kind, defaults, data, x, y) {
|
|
2491
|
+
const tooltipManager = ctx.manager();
|
|
2492
|
+
if (!tooltipManager) return;
|
|
2493
|
+
const formatter = tooltipFormatter();
|
|
2494
|
+
if (!formatter) {
|
|
2495
|
+
tooltipManager.show(defaults, x, y);
|
|
2496
|
+
return;
|
|
2497
|
+
}
|
|
2498
|
+
applyFormatterResult(tooltipManager, formatter({ kind, data }, defaults), x, y);
|
|
2499
|
+
}
|
|
2500
|
+
return {
|
|
2501
|
+
showNode(nodeId, data, x, y) {
|
|
2502
|
+
const defaults = ctx.compilation().tooltipDescriptors.get(nodeId);
|
|
2503
|
+
if (!defaults) return;
|
|
2504
|
+
show("node", defaults, data, x, y);
|
|
2505
|
+
},
|
|
2506
|
+
showEdge(edgeId, data, x, y) {
|
|
2507
|
+
const edge = ctx.compilation().edges.find((e) => `${e.source}->${e.target}` === edgeId);
|
|
2508
|
+
const defaults = edge ? buildEdgeTooltip(edge) : { title: edgeId, fields: [] };
|
|
2509
|
+
show("edge", defaults, data, x, y);
|
|
2510
|
+
}
|
|
2511
|
+
};
|
|
2512
|
+
}
|
|
2202
2513
|
|
|
2203
2514
|
// src/graph/update-diff-config.ts
|
|
2204
2515
|
function stableKey(c) {
|
|
@@ -2358,6 +2669,63 @@ function ratio(numerator, denominator) {
|
|
|
2358
2669
|
return denominator > 0 ? numerator / denominator : 0;
|
|
2359
2670
|
}
|
|
2360
2671
|
|
|
2672
|
+
// src/graph/update-fades.ts
|
|
2673
|
+
function createGraphUpdateFades(scheduler, invalidate) {
|
|
2674
|
+
let enterAlphaMap = null;
|
|
2675
|
+
let exitingGhosts = null;
|
|
2676
|
+
function start(diff, compilation) {
|
|
2677
|
+
const updateCfg = compilation.animation?.update ?? null;
|
|
2678
|
+
const exitCfg = compilation.animation?.exit ?? null;
|
|
2679
|
+
const reduced = prefersReducedMotion();
|
|
2680
|
+
if (diff.enteringIds.length > 0 && updateCfg && !reduced) {
|
|
2681
|
+
const entering = diff.enteringIds;
|
|
2682
|
+
enterAlphaMap = new Map(entering.map((id) => [id, 0]));
|
|
2683
|
+
const ease = resolveEase(updateCfg.ease);
|
|
2684
|
+
const tween = createTween({
|
|
2685
|
+
duration: updateCfg.duration,
|
|
2686
|
+
ease,
|
|
2687
|
+
apply: (t) => {
|
|
2688
|
+
const q = Math.round(t * 8) / 8;
|
|
2689
|
+
if (enterAlphaMap) for (const id of entering) enterAlphaMap.set(id, q);
|
|
2690
|
+
invalidate();
|
|
2691
|
+
},
|
|
2692
|
+
onDone: () => {
|
|
2693
|
+
enterAlphaMap = null;
|
|
2694
|
+
invalidate();
|
|
2695
|
+
}
|
|
2696
|
+
});
|
|
2697
|
+
scheduler.add(tween);
|
|
2698
|
+
}
|
|
2699
|
+
if ((diff.exitingNodes.length > 0 || diff.exitingEdges.length > 0) && exitCfg && !reduced) {
|
|
2700
|
+
exitingGhosts = { nodes: diff.exitingNodes, edges: diff.exitingEdges, alpha: 1 };
|
|
2701
|
+
const ease = resolveEase(exitCfg.ease);
|
|
2702
|
+
const tween = createTween({
|
|
2703
|
+
duration: exitCfg.duration,
|
|
2704
|
+
ease,
|
|
2705
|
+
apply: (t) => {
|
|
2706
|
+
if (exitingGhosts) exitingGhosts.alpha = 1 - t;
|
|
2707
|
+
invalidate();
|
|
2708
|
+
},
|
|
2709
|
+
onDone: () => {
|
|
2710
|
+
exitingGhosts = null;
|
|
2711
|
+
invalidate();
|
|
2712
|
+
}
|
|
2713
|
+
});
|
|
2714
|
+
scheduler.add(tween);
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
return {
|
|
2718
|
+
start,
|
|
2719
|
+
clear() {
|
|
2720
|
+
enterAlphaMap = null;
|
|
2721
|
+
exitingGhosts = null;
|
|
2722
|
+
},
|
|
2723
|
+
frame() {
|
|
2724
|
+
return { enterAlpha: enterAlphaMap ?? void 0, exiting: exitingGhosts ?? void 0 };
|
|
2725
|
+
}
|
|
2726
|
+
};
|
|
2727
|
+
}
|
|
2728
|
+
|
|
2361
2729
|
// src/graph-mount.ts
|
|
2362
2730
|
var SPRINGY_DRAG_MAX_NODES = 5e3;
|
|
2363
2731
|
var CURSOR_FORCE_MAX_NODES = 2e3;
|
|
@@ -2374,7 +2742,7 @@ function createGraph(container, spec, options) {
|
|
|
2374
2742
|
let legendController = null;
|
|
2375
2743
|
let renderer = null;
|
|
2376
2744
|
let simulation = null;
|
|
2377
|
-
const spatialIndex = new
|
|
2745
|
+
const spatialIndex = new SpatialIndex();
|
|
2378
2746
|
let interactionManager = null;
|
|
2379
2747
|
const searchManager = new GraphSearchManager();
|
|
2380
2748
|
let tooltipManager = null;
|
|
@@ -2399,17 +2767,9 @@ function createGraph(container, spec, options) {
|
|
|
2399
2767
|
let activeFollow = null;
|
|
2400
2768
|
let lastAlpha = 1;
|
|
2401
2769
|
let cameraChangePending = false;
|
|
2402
|
-
let highlightSet = null;
|
|
2403
|
-
let highlightDimOpacity = null;
|
|
2404
2770
|
let seedIds = /* @__PURE__ */ new Set();
|
|
2405
|
-
let activeCategories = /* @__PURE__ */ new Set();
|
|
2406
|
-
let transientHighlight = null;
|
|
2407
|
-
let transientTarget = null;
|
|
2408
2771
|
const seenWarnings = /* @__PURE__ */ new Set();
|
|
2409
2772
|
let nodeCategory = /* @__PURE__ */ new Map();
|
|
2410
|
-
let focusTransition = null;
|
|
2411
|
-
let focusAnim = null;
|
|
2412
|
-
let hoverRadiusTween = null;
|
|
2413
2773
|
let entranceProgress = 1;
|
|
2414
2774
|
let entranceActive = false;
|
|
2415
2775
|
let entranceStagger = false;
|
|
@@ -2418,8 +2778,9 @@ function createGraph(container, spec, options) {
|
|
|
2418
2778
|
let entranceFitInFlight = false;
|
|
2419
2779
|
let entranceReveal = null;
|
|
2420
2780
|
let suppressEntranceOnce = options?.suppressEntrance ?? false;
|
|
2421
|
-
|
|
2422
|
-
|
|
2781
|
+
const updateFades = createGraphUpdateFades(scheduler, () => {
|
|
2782
|
+
needsRender = true;
|
|
2783
|
+
});
|
|
2423
2784
|
function markGesture() {
|
|
2424
2785
|
isGesturing = true;
|
|
2425
2786
|
if (gestureTimeout !== null) clearTimeout(gestureTimeout);
|
|
@@ -2453,70 +2814,15 @@ function createGraph(container, spec, options) {
|
|
|
2453
2814
|
return compileGraph(specToCompile, compileOpts);
|
|
2454
2815
|
}
|
|
2455
2816
|
function buildDataMaps() {
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
for (const n of compilation.nodes) {
|
|
2462
|
-
const v = n.data?.[field];
|
|
2463
|
-
if (v != null) nodeCategory.set(n.id, String(v));
|
|
2464
|
-
}
|
|
2465
|
-
}
|
|
2466
|
-
}
|
|
2467
|
-
function buildAdjacencyMap(edges) {
|
|
2468
|
-
const map = /* @__PURE__ */ new Map();
|
|
2469
|
-
for (const edge of edges) {
|
|
2470
|
-
if (!map.has(edge.source)) map.set(edge.source, /* @__PURE__ */ new Set());
|
|
2471
|
-
if (!map.has(edge.target)) map.set(edge.target, /* @__PURE__ */ new Set());
|
|
2472
|
-
map.get(edge.source).add(edge.target);
|
|
2473
|
-
map.get(edge.target).add(edge.source);
|
|
2474
|
-
}
|
|
2475
|
-
return map;
|
|
2476
|
-
}
|
|
2477
|
-
function toSimNodes(nodes) {
|
|
2478
|
-
return nodes.map((n) => ({
|
|
2479
|
-
id: n.id,
|
|
2480
|
-
radius: n.radius,
|
|
2481
|
-
community: n.community
|
|
2482
|
-
}));
|
|
2483
|
-
}
|
|
2484
|
-
function toSimEdges(edges) {
|
|
2485
|
-
return edges.map((e) => ({
|
|
2486
|
-
source: e.source,
|
|
2487
|
-
target: e.target
|
|
2488
|
-
}));
|
|
2817
|
+
({
|
|
2818
|
+
nodeData: nodeDataMap,
|
|
2819
|
+
edgeData: edgeDataMap,
|
|
2820
|
+
nodeCategory
|
|
2821
|
+
} = buildGraphDataMaps(compilation));
|
|
2489
2822
|
}
|
|
2490
2823
|
function nodeDataById(nodeId) {
|
|
2491
2824
|
return nodeDataMap.get(nodeId) ?? {};
|
|
2492
2825
|
}
|
|
2493
|
-
function pointToSegmentDist(px, py, ax, ay, bx, by) {
|
|
2494
|
-
const dx = bx - ax;
|
|
2495
|
-
const dy = by - ay;
|
|
2496
|
-
const lenSq = dx * dx + dy * dy;
|
|
2497
|
-
if (lenSq === 0) return Math.hypot(px - ax, py - ay);
|
|
2498
|
-
const t = Math.max(0, Math.min(1, ((px - ax) * dx + (py - ay) * dy) / lenSq));
|
|
2499
|
-
return Math.hypot(px - (ax + t * dx), py - (ay + t * dy));
|
|
2500
|
-
}
|
|
2501
|
-
function hitTestEdge(graphX, graphY, threshold) {
|
|
2502
|
-
let bestDist = threshold;
|
|
2503
|
-
let bestEdgeId = null;
|
|
2504
|
-
for (const edge of positionedEdges) {
|
|
2505
|
-
const dist = pointToSegmentDist(
|
|
2506
|
-
graphX,
|
|
2507
|
-
graphY,
|
|
2508
|
-
edge.sourceX,
|
|
2509
|
-
edge.sourceY,
|
|
2510
|
-
edge.targetX,
|
|
2511
|
-
edge.targetY
|
|
2512
|
-
);
|
|
2513
|
-
if (dist < bestDist) {
|
|
2514
|
-
bestDist = dist;
|
|
2515
|
-
bestEdgeId = `${edge.source}->${edge.target}`;
|
|
2516
|
-
}
|
|
2517
|
-
}
|
|
2518
|
-
return bestEdgeId;
|
|
2519
|
-
}
|
|
2520
2826
|
function edgeDataById(edgeId) {
|
|
2521
2827
|
return edgeDataMap.get(edgeId) ?? null;
|
|
2522
2828
|
}
|
|
@@ -2538,6 +2844,10 @@ function createGraph(container, spec, options) {
|
|
|
2538
2844
|
}
|
|
2539
2845
|
function renderChrome() {
|
|
2540
2846
|
shell?.renderChrome(compilation);
|
|
2847
|
+
if (shell && renderer) {
|
|
2848
|
+
const size = shell.getSize();
|
|
2849
|
+
renderer.resize(size.width, size.height);
|
|
2850
|
+
}
|
|
2541
2851
|
}
|
|
2542
2852
|
function legendSetting() {
|
|
2543
2853
|
return options?.legend ?? currentSpec.legend;
|
|
@@ -2735,176 +3045,42 @@ function createGraph(container, spec, options) {
|
|
|
2735
3045
|
if (animFrameId !== null || destroyed) return;
|
|
2736
3046
|
animFrameId = requestAnimationFrame(renderFrame);
|
|
2737
3047
|
}
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
const set = /* @__PURE__ */ new Set([nodeId]);
|
|
2749
|
-
const neighbors = adjacencyMap.get(nodeId);
|
|
2750
|
-
if (neighbors) for (const nid of neighbors) set.add(nid);
|
|
2751
|
-
return set;
|
|
2752
|
-
}
|
|
2753
|
-
function standingSnapshot() {
|
|
2754
|
-
return composeStandingFocus(
|
|
2755
|
-
highlightSet,
|
|
2756
|
-
searchManager.getMatches(),
|
|
2757
|
-
selectedNodeIds,
|
|
2758
|
-
adjacencyMap
|
|
2759
|
-
);
|
|
2760
|
-
}
|
|
2761
|
-
function targetSnapshot() {
|
|
2762
|
-
return layerHoverFocus(standingSnapshot(), hoveredNodeId, hoverConnectedSet(hoveredNodeId));
|
|
2763
|
-
}
|
|
2764
|
-
function armFocus(now) {
|
|
2765
|
-
const target = targetSnapshot();
|
|
2766
|
-
const hoverCfg = compilation.animation?.hover ?? null;
|
|
2767
|
-
const duration = hoverCfg && !prefersReducedMotion() ? hoverCfg.duration : 0;
|
|
2768
|
-
const ease = resolveEase(hoverCfg?.ease ?? "smooth");
|
|
2769
|
-
if (!focusTransition) {
|
|
2770
|
-
focusTransition = new FocusTransition(target, duration, ease, now);
|
|
2771
|
-
return;
|
|
3048
|
+
const focus = createGraphFocusModel({
|
|
3049
|
+
compilation: () => compilation,
|
|
3050
|
+
adjacency: () => adjacencyMap,
|
|
3051
|
+
nodeCategory: () => nodeCategory,
|
|
3052
|
+
searchMatches: () => searchManager.getMatches(),
|
|
3053
|
+
selected: () => selectedNodeIds,
|
|
3054
|
+
hovered: () => hoveredNodeId,
|
|
3055
|
+
scheduler,
|
|
3056
|
+
invalidate: () => {
|
|
3057
|
+
needsRender = true;
|
|
2772
3058
|
}
|
|
2773
|
-
|
|
2774
|
-
if (focusAnim) scheduler.remove(focusAnim);
|
|
2775
|
-
focusAnim = {
|
|
2776
|
-
tick: (t) => {
|
|
2777
|
-
const running = focusTransition !== null && !focusTransition.isSettled(t);
|
|
2778
|
-
if (!running) focusAnim = null;
|
|
2779
|
-
return running;
|
|
2780
|
-
},
|
|
2781
|
-
finish: () => {
|
|
2782
|
-
focusAnim = null;
|
|
2783
|
-
},
|
|
2784
|
-
cancel: () => {
|
|
2785
|
-
focusAnim = null;
|
|
2786
|
-
}
|
|
2787
|
-
};
|
|
2788
|
-
scheduler.add(focusAnim);
|
|
2789
|
-
}
|
|
3059
|
+
});
|
|
2790
3060
|
function refreshFocus() {
|
|
2791
|
-
|
|
3061
|
+
focus.arm(performance.now());
|
|
2792
3062
|
needsRender = true;
|
|
2793
3063
|
scheduleRender();
|
|
2794
3064
|
}
|
|
2795
|
-
function resolveHighlightTarget2(target) {
|
|
2796
|
-
return resolveHighlightTarget(target, compilation.nodes, adjacencyMap);
|
|
2797
|
-
}
|
|
2798
|
-
function categoryHighlightSet2() {
|
|
2799
|
-
return categoryHighlightSet(activeCategories, nodeCategory);
|
|
2800
|
-
}
|
|
2801
|
-
function recomputeHighlight() {
|
|
2802
|
-
const filter = categoryHighlightSet2();
|
|
2803
|
-
const transient = transientHighlight !== null && transientHighlight.size > 0 ? transientHighlight : null;
|
|
2804
|
-
if (filter !== null && transient !== null) {
|
|
2805
|
-
const inter = /* @__PURE__ */ new Set();
|
|
2806
|
-
for (const id of transient) if (filter.has(id)) inter.add(id);
|
|
2807
|
-
highlightSet = inter.size > 0 ? inter : transient;
|
|
2808
|
-
return;
|
|
2809
|
-
}
|
|
2810
|
-
highlightSet = filter ?? transient;
|
|
2811
|
-
}
|
|
2812
|
-
function refreshTransientHighlight() {
|
|
2813
|
-
if (transientTarget === null) {
|
|
2814
|
-
transientHighlight = null;
|
|
2815
|
-
return;
|
|
2816
|
-
}
|
|
2817
|
-
const nextIds = new Set(compilation.nodes.map((n) => n.id));
|
|
2818
|
-
const resolved = new Set(
|
|
2819
|
-
[...resolveHighlightTarget2(transientTarget)].filter((id) => nextIds.has(id))
|
|
2820
|
-
);
|
|
2821
|
-
transientHighlight = resolved.size > 0 ? resolved : null;
|
|
2822
|
-
}
|
|
2823
|
-
function effectiveDimOpacity() {
|
|
2824
|
-
const custom = transientHighlight !== null ? highlightDimOpacity : null;
|
|
2825
|
-
return custom ?? compilation.interaction.dimOpacity;
|
|
2826
|
-
}
|
|
2827
3065
|
function emitHighlightChange() {
|
|
3066
|
+
const highlightSet = focus.highlightSet;
|
|
2828
3067
|
options?.onHighlightChange?.(highlightSet ? [...highlightSet] : null);
|
|
2829
3068
|
}
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
}
|
|
2836
|
-
function startHoverRadiusTween(nodeId) {
|
|
2837
|
-
const hoverCfg = compilation.animation?.hover ?? null;
|
|
2838
|
-
if (nodeId === null || !hoverCfg || prefersReducedMotion()) {
|
|
2839
|
-
hoverRadiusTween = nodeId ? { nodeId, scale: 1.15 } : null;
|
|
2840
|
-
return;
|
|
2841
|
-
}
|
|
2842
|
-
hoverRadiusTween = { nodeId, scale: 1 };
|
|
2843
|
-
const ease = resolveEase(hoverCfg.ease);
|
|
2844
|
-
const tween = createTween({
|
|
2845
|
-
duration: hoverCfg.duration,
|
|
2846
|
-
ease,
|
|
2847
|
-
apply: (t) => {
|
|
2848
|
-
if (hoverRadiusTween?.nodeId === nodeId) hoverRadiusTween.scale = 1 + 0.15 * t;
|
|
2849
|
-
needsRender = true;
|
|
2850
|
-
},
|
|
2851
|
-
onDone: () => {
|
|
2852
|
-
if (hoverRadiusTween?.nodeId === nodeId) hoverRadiusTween.scale = 1.15;
|
|
2853
|
-
}
|
|
2854
|
-
});
|
|
2855
|
-
scheduler.add(tween);
|
|
2856
|
-
}
|
|
3069
|
+
const tooltips = createGraphTooltips({
|
|
3070
|
+
options,
|
|
3071
|
+
manager: () => tooltipManager,
|
|
3072
|
+
compilation: () => compilation
|
|
3073
|
+
});
|
|
2857
3074
|
function showNodeTooltip(nodeId) {
|
|
2858
3075
|
if (!tooltipManager || !interactionManager) return;
|
|
2859
|
-
const defaults = compilation.tooltipDescriptors.get(nodeId);
|
|
2860
|
-
if (!defaults) return;
|
|
2861
3076
|
const node = positionedNodes.find((n) => n.id === nodeId);
|
|
2862
3077
|
if (!node) return;
|
|
2863
3078
|
const screen = interactionManager.getTransform().graphToScreen(node.x, node.y);
|
|
2864
|
-
|
|
2865
|
-
if (!formatter) {
|
|
2866
|
-
tooltipManager.show(defaults, screen.x, screen.y);
|
|
2867
|
-
return;
|
|
2868
|
-
}
|
|
2869
|
-
const result = formatter({ kind: "node", data: nodeDataById(nodeId) }, defaults);
|
|
2870
|
-
applyFormatterResult(result, screen.x, screen.y);
|
|
2871
|
-
}
|
|
2872
|
-
function showEdgeTooltip(edgeId, data, screenX, screenY) {
|
|
2873
|
-
if (!tooltipManager) return;
|
|
2874
|
-
const edge = compilation.edges.find((e) => `${e.source}->${e.target}` === edgeId);
|
|
2875
|
-
const defaults = edge ? buildEdgeTooltip(edge) : { title: edgeId, fields: [] };
|
|
2876
|
-
const formatter = tooltipFormatter();
|
|
2877
|
-
if (!formatter) {
|
|
2878
|
-
tooltipManager.show(defaults, screenX, screenY);
|
|
2879
|
-
return;
|
|
2880
|
-
}
|
|
2881
|
-
const result = formatter({ kind: "edge", data }, defaults);
|
|
2882
|
-
applyFormatterResult(result, screenX, screenY);
|
|
2883
|
-
}
|
|
2884
|
-
function tooltipFormatter() {
|
|
2885
|
-
const t = options?.tooltip;
|
|
2886
|
-
return t && typeof t === "object" ? t.formatter ?? null : null;
|
|
2887
|
-
}
|
|
2888
|
-
function applyFormatterResult(result, x, y) {
|
|
2889
|
-
if (!tooltipManager) return;
|
|
2890
|
-
if (result === null) {
|
|
2891
|
-
tooltipManager.hide();
|
|
2892
|
-
} else if (typeof result === "string") {
|
|
2893
|
-
tooltipManager.show({ text: result }, x, y);
|
|
2894
|
-
} else if (result instanceof HTMLElement) {
|
|
2895
|
-
tooltipManager.show({ element: result }, x, y);
|
|
2896
|
-
} else {
|
|
2897
|
-
tooltipManager.show(result, x, y);
|
|
2898
|
-
}
|
|
3079
|
+
tooltips.showNode(nodeId, nodeDataById(nodeId), screen.x, screen.y);
|
|
2899
3080
|
}
|
|
2900
3081
|
function buildRenderState(now) {
|
|
2901
3082
|
const transform = interactionManager.getTransform();
|
|
2902
|
-
|
|
2903
|
-
const ft = focusTransition;
|
|
2904
|
-
const t = ft.progress(now);
|
|
2905
|
-
const focus = t < 1 ? { t, prev: ft.prev, next: ft.next } : void 0;
|
|
2906
|
-
const settledNext = ft.next;
|
|
2907
|
-
const hoverRadiusScale = hoverRadiusTween ? /* @__PURE__ */ new Map([[hoverRadiusTween.nodeId, hoverRadiusTween.scale]]) : void 0;
|
|
3083
|
+
const focusState = focus.frame(now);
|
|
2908
3084
|
return {
|
|
2909
3085
|
nodes: positionedNodes,
|
|
2910
3086
|
edges: positionedEdges,
|
|
@@ -2917,18 +3093,16 @@ function createGraph(container, spec, options) {
|
|
|
2917
3093
|
searchMatches: searchManager.getMatches(),
|
|
2918
3094
|
exemptIds: seedIds,
|
|
2919
3095
|
isGesturing,
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
dimOpacity: effectiveDimOpacity(),
|
|
3096
|
+
// Shared shell paints the complete measured attribution footer.
|
|
3097
|
+
watermark: false,
|
|
3098
|
+
...focusState,
|
|
2924
3099
|
entrance: entranceActive && entranceProgress < 1 ? {
|
|
2925
3100
|
t: entranceProgress,
|
|
2926
3101
|
stagger: entranceStagger,
|
|
2927
3102
|
order: entranceOrderMap ?? void 0,
|
|
2928
3103
|
offsets: entranceOffsetMap ?? void 0
|
|
2929
3104
|
} : void 0,
|
|
2930
|
-
|
|
2931
|
-
exiting: exitingGhosts ?? void 0
|
|
3105
|
+
...updateFades.frame()
|
|
2932
3106
|
};
|
|
2933
3107
|
}
|
|
2934
3108
|
function renderFrame(now) {
|
|
@@ -3024,8 +3198,8 @@ function createGraph(container, spec, options) {
|
|
|
3024
3198
|
onHoverChange(nodeId) {
|
|
3025
3199
|
if (nodeId === hoveredNodeId) return;
|
|
3026
3200
|
hoveredNodeId = nodeId;
|
|
3027
|
-
|
|
3028
|
-
|
|
3201
|
+
focus.arm(performance.now());
|
|
3202
|
+
focus.hoverRadius(nodeId);
|
|
3029
3203
|
needsRender = true;
|
|
3030
3204
|
scheduleRender();
|
|
3031
3205
|
if (nodeId && hoveredEdgeId) {
|
|
@@ -3056,7 +3230,7 @@ function createGraph(container, spec, options) {
|
|
|
3056
3230
|
lastEdgeHitTime = now;
|
|
3057
3231
|
const transform = interactionManager?.getTransform();
|
|
3058
3232
|
const threshold = 5 / (transform?.k ?? 1);
|
|
3059
|
-
const edgeId = hitTestEdge(graphX, graphY, threshold);
|
|
3233
|
+
const edgeId = hitTestEdge(positionedEdges, graphX, graphY, threshold);
|
|
3060
3234
|
if (edgeId !== hoveredEdgeId) {
|
|
3061
3235
|
hoveredEdgeId = edgeId;
|
|
3062
3236
|
needsRender = true;
|
|
@@ -3064,7 +3238,7 @@ function createGraph(container, spec, options) {
|
|
|
3064
3238
|
if (edgeId) {
|
|
3065
3239
|
const data = edgeDataById(edgeId);
|
|
3066
3240
|
options?.onEdgeHover?.(data);
|
|
3067
|
-
if (tooltipManager && data)
|
|
3241
|
+
if (tooltipManager && data) tooltips.showEdge(edgeId, data, screenX, screenY);
|
|
3068
3242
|
} else {
|
|
3069
3243
|
options?.onEdgeHover?.(null);
|
|
3070
3244
|
tooltipManager?.hide();
|
|
@@ -3073,7 +3247,7 @@ function createGraph(container, spec, options) {
|
|
|
3073
3247
|
},
|
|
3074
3248
|
onSelectionChange(nodeIds) {
|
|
3075
3249
|
selectedNodeIds = new Set(nodeIds);
|
|
3076
|
-
|
|
3250
|
+
focus.arm(performance.now());
|
|
3077
3251
|
needsRender = true;
|
|
3078
3252
|
scheduleRender();
|
|
3079
3253
|
options?.onSelectionChange?.(nodeIds);
|
|
@@ -3119,7 +3293,7 @@ function createGraph(container, spec, options) {
|
|
|
3119
3293
|
onSelect(nodeId) {
|
|
3120
3294
|
selectedNodeIds = /* @__PURE__ */ new Set([nodeId]);
|
|
3121
3295
|
interactionManager?.setSelection([nodeId]);
|
|
3122
|
-
|
|
3296
|
+
focus.arm(performance.now());
|
|
3123
3297
|
needsRender = true;
|
|
3124
3298
|
scheduleRender();
|
|
3125
3299
|
options?.onNodeClick?.(nodeDataById(nodeId));
|
|
@@ -3128,7 +3302,7 @@ function createGraph(container, spec, options) {
|
|
|
3128
3302
|
onDeselect() {
|
|
3129
3303
|
selectedNodeIds.clear();
|
|
3130
3304
|
interactionManager?.setSelection([]);
|
|
3131
|
-
|
|
3305
|
+
focus.arm(performance.now());
|
|
3132
3306
|
needsRender = true;
|
|
3133
3307
|
scheduleRender();
|
|
3134
3308
|
options?.onSelectionChange?.([]);
|
|
@@ -3149,7 +3323,7 @@ function createGraph(container, spec, options) {
|
|
|
3149
3323
|
}
|
|
3150
3324
|
function search(query) {
|
|
3151
3325
|
if (destroyed) return;
|
|
3152
|
-
searchManager.search(query,
|
|
3326
|
+
searchManager.search(query, compilation.nodes);
|
|
3153
3327
|
needsRender = true;
|
|
3154
3328
|
scheduleRender();
|
|
3155
3329
|
}
|
|
@@ -3215,23 +3389,18 @@ function createGraph(container, spec, options) {
|
|
|
3215
3389
|
}
|
|
3216
3390
|
function highlight(target, opts) {
|
|
3217
3391
|
if (destroyed) return;
|
|
3218
|
-
|
|
3219
|
-
refreshTransientHighlight();
|
|
3220
|
-
highlightDimOpacity = opts?.dimOpacity ?? null;
|
|
3221
|
-
recomputeHighlight();
|
|
3392
|
+
focus.highlight(target, opts?.dimOpacity);
|
|
3222
3393
|
refreshFocus();
|
|
3223
3394
|
emitHighlightChange();
|
|
3224
3395
|
}
|
|
3225
3396
|
function clearHighlight() {
|
|
3226
3397
|
if (destroyed) return;
|
|
3227
|
-
|
|
3228
|
-
transientHighlight = null;
|
|
3229
|
-
highlightDimOpacity = null;
|
|
3230
|
-
recomputeHighlight();
|
|
3398
|
+
focus.clearHighlight();
|
|
3231
3399
|
refreshFocus();
|
|
3232
3400
|
emitHighlightChange();
|
|
3233
3401
|
}
|
|
3234
3402
|
function getHighlight() {
|
|
3403
|
+
const highlightSet = focus.highlightSet;
|
|
3235
3404
|
return highlightSet ? [...highlightSet] : null;
|
|
3236
3405
|
}
|
|
3237
3406
|
function getLegend() {
|
|
@@ -3242,7 +3411,7 @@ function createGraph(container, spec, options) {
|
|
|
3242
3411
|
label: e.label,
|
|
3243
3412
|
color: e.color,
|
|
3244
3413
|
count: e.count,
|
|
3245
|
-
active:
|
|
3414
|
+
active: focus.categories.size === 0 || focus.categories.has(e.label)
|
|
3246
3415
|
})),
|
|
3247
3416
|
edges: (compilation.edgeLegend ?? []).map((e) => ({
|
|
3248
3417
|
label: e.label,
|
|
@@ -3253,26 +3422,38 @@ function createGraph(container, spec, options) {
|
|
|
3253
3422
|
}
|
|
3254
3423
|
function setActiveCategories(values) {
|
|
3255
3424
|
if (destroyed) return;
|
|
3256
|
-
|
|
3257
|
-
recomputeHighlight();
|
|
3425
|
+
focus.setCategories(values);
|
|
3258
3426
|
syncLegendActiveState();
|
|
3259
3427
|
refreshFocus();
|
|
3260
3428
|
emitHighlightChange();
|
|
3261
3429
|
}
|
|
3262
3430
|
function getActiveCategories() {
|
|
3263
|
-
return [...
|
|
3431
|
+
return [...focus.categories];
|
|
3264
3432
|
}
|
|
3265
3433
|
function toggleLegendCategory(value) {
|
|
3266
|
-
|
|
3267
|
-
else activeCategories.add(value);
|
|
3268
|
-
recomputeHighlight();
|
|
3434
|
+
focus.toggleCategory(value);
|
|
3269
3435
|
syncLegendActiveState();
|
|
3270
3436
|
refreshFocus();
|
|
3271
|
-
options?.onLegendToggle?.([...
|
|
3437
|
+
options?.onLegendToggle?.([...focus.categories]);
|
|
3272
3438
|
emitHighlightChange();
|
|
3273
3439
|
}
|
|
3274
3440
|
function doResize() {
|
|
3275
3441
|
if (destroyed || !canvas || !renderer || !shell) return;
|
|
3442
|
+
const dimensions = getContainerDimensions2();
|
|
3443
|
+
compilation = {
|
|
3444
|
+
...compilation,
|
|
3445
|
+
dimensions,
|
|
3446
|
+
chrome: computeChrome(
|
|
3447
|
+
currentSpec.chrome,
|
|
3448
|
+
compilation.theme,
|
|
3449
|
+
dimensions.width,
|
|
3450
|
+
void 0,
|
|
3451
|
+
"full",
|
|
3452
|
+
void 0,
|
|
3453
|
+
compilation.watermark
|
|
3454
|
+
)
|
|
3455
|
+
};
|
|
3456
|
+
shell.renderChrome(compilation);
|
|
3276
3457
|
const { width, height } = shell.getSize();
|
|
3277
3458
|
renderer.resize(width, height);
|
|
3278
3459
|
syncChromeInset();
|
|
@@ -3298,8 +3479,7 @@ function createGraph(container, spec, options) {
|
|
|
3298
3479
|
entranceProgress = 1;
|
|
3299
3480
|
entranceFitInFlight = false;
|
|
3300
3481
|
entranceReveal = null;
|
|
3301
|
-
|
|
3302
|
-
exitingGhosts = null;
|
|
3482
|
+
updateFades.clear();
|
|
3303
3483
|
const prevNodes = positionedNodes;
|
|
3304
3484
|
const prevEdges = positionedEdges;
|
|
3305
3485
|
const prevConfig = compilation.simulationConfig;
|
|
@@ -3335,8 +3515,7 @@ function createGraph(container, spec, options) {
|
|
|
3335
3515
|
return { ...edge, sourceX: src.x, sourceY: src.y, targetX: tgt.x, targetY: tgt.y };
|
|
3336
3516
|
});
|
|
3337
3517
|
spatialIndex.rebuild(positionedNodes);
|
|
3338
|
-
|
|
3339
|
-
recomputeHighlight();
|
|
3518
|
+
focus.reconcile();
|
|
3340
3519
|
reRunSearch();
|
|
3341
3520
|
renderChrome();
|
|
3342
3521
|
renderLegend();
|
|
@@ -3372,7 +3551,7 @@ function createGraph(container, spec, options) {
|
|
|
3372
3551
|
renderChrome();
|
|
3373
3552
|
renderLegend();
|
|
3374
3553
|
reconcileStateAfterUpdate();
|
|
3375
|
-
|
|
3554
|
+
updateFades.start(diff, compilation);
|
|
3376
3555
|
needsRender = true;
|
|
3377
3556
|
scheduleRender();
|
|
3378
3557
|
}
|
|
@@ -3389,61 +3568,16 @@ function createGraph(container, spec, options) {
|
|
|
3389
3568
|
const survivingSelection = [...selectedNodeIds].filter((id) => nextIds.has(id));
|
|
3390
3569
|
selectedNodeIds = new Set(survivingSelection);
|
|
3391
3570
|
interactionManager?.setSelection(survivingSelection);
|
|
3392
|
-
|
|
3393
|
-
recomputeHighlight();
|
|
3571
|
+
focus.reconcile();
|
|
3394
3572
|
syncLegendActiveState();
|
|
3395
3573
|
reRunSearch();
|
|
3396
|
-
|
|
3397
|
-
|
|
3574
|
+
focus.reset();
|
|
3575
|
+
focus.arm(performance.now());
|
|
3398
3576
|
}
|
|
3399
3577
|
function reRunSearch() {
|
|
3400
3578
|
const q = searchManager.getQuery();
|
|
3401
3579
|
if (q !== null) searchManager.search(q, positionedNodes);
|
|
3402
3580
|
}
|
|
3403
|
-
function startUpdateTransitions(diff) {
|
|
3404
|
-
const updateCfg = compilation.animation?.update ?? null;
|
|
3405
|
-
const exitCfg = compilation.animation?.exit ?? null;
|
|
3406
|
-
const reduced = prefersReducedMotion();
|
|
3407
|
-
if (diff.enteringIds.length > 0 && updateCfg && !reduced) {
|
|
3408
|
-
const entering = diff.enteringIds;
|
|
3409
|
-
enterAlphaMap = new Map(entering.map((id) => [id, 0]));
|
|
3410
|
-
const ease = resolveEase(updateCfg.ease);
|
|
3411
|
-
const tween = createTween({
|
|
3412
|
-
duration: updateCfg.duration,
|
|
3413
|
-
ease,
|
|
3414
|
-
apply: (t) => {
|
|
3415
|
-
const q = Math.round(t * 8) / 8;
|
|
3416
|
-
if (enterAlphaMap) for (const id of entering) enterAlphaMap.set(id, q);
|
|
3417
|
-
needsRender = true;
|
|
3418
|
-
},
|
|
3419
|
-
onDone: () => {
|
|
3420
|
-
enterAlphaMap = null;
|
|
3421
|
-
needsRender = true;
|
|
3422
|
-
}
|
|
3423
|
-
});
|
|
3424
|
-
scheduler.add(tween);
|
|
3425
|
-
}
|
|
3426
|
-
if ((diff.exitingNodes.length > 0 || diff.exitingEdges.length > 0) && exitCfg && !reduced) {
|
|
3427
|
-
exitingGhosts = { nodes: diff.exitingNodes, edges: diff.exitingEdges, alpha: 1 };
|
|
3428
|
-
const ease = resolveEase(exitCfg.ease);
|
|
3429
|
-
const tween = createTween({
|
|
3430
|
-
duration: exitCfg.duration,
|
|
3431
|
-
ease,
|
|
3432
|
-
apply: (t) => {
|
|
3433
|
-
if (exitingGhosts) exitingGhosts.alpha = 1 - t;
|
|
3434
|
-
needsRender = true;
|
|
3435
|
-
},
|
|
3436
|
-
onDone: () => {
|
|
3437
|
-
exitingGhosts = null;
|
|
3438
|
-
needsRender = true;
|
|
3439
|
-
}
|
|
3440
|
-
});
|
|
3441
|
-
scheduler.add(tween);
|
|
3442
|
-
}
|
|
3443
|
-
}
|
|
3444
|
-
function updateVisuals(newSpec) {
|
|
3445
|
-
update(newSpec);
|
|
3446
|
-
}
|
|
3447
3581
|
function teardownSimOnly() {
|
|
3448
3582
|
simulation?.destroy();
|
|
3449
3583
|
simulation = null;
|
|
@@ -3456,8 +3590,7 @@ function createGraph(container, spec, options) {
|
|
|
3456
3590
|
entranceActive = false;
|
|
3457
3591
|
entranceProgress = 1;
|
|
3458
3592
|
entranceFitInFlight = false;
|
|
3459
|
-
|
|
3460
|
-
exitingGhosts = null;
|
|
3593
|
+
updateFades.clear();
|
|
3461
3594
|
if (animFrameId !== null) {
|
|
3462
3595
|
cancelAnimationFrame(animFrameId);
|
|
3463
3596
|
animFrameId = null;
|
|
@@ -3531,7 +3664,7 @@ function createGraph(container, spec, options) {
|
|
|
3531
3664
|
seedIds = new Set(compilation.seedNodeIds);
|
|
3532
3665
|
adjacencyMap = buildAdjacencyMap(compilation.edges);
|
|
3533
3666
|
buildDataMaps();
|
|
3534
|
-
|
|
3667
|
+
focus.applyInitial();
|
|
3535
3668
|
createSurface();
|
|
3536
3669
|
initSimulation();
|
|
3537
3670
|
initInteraction();
|
|
@@ -3544,7 +3677,6 @@ function createGraph(container, spec, options) {
|
|
|
3544
3677
|
});
|
|
3545
3678
|
return {
|
|
3546
3679
|
update,
|
|
3547
|
-
updateVisuals,
|
|
3548
3680
|
search,
|
|
3549
3681
|
clearSearch,
|
|
3550
3682
|
zoomToFit,
|
|
@@ -3580,8 +3712,10 @@ export {
|
|
|
3580
3712
|
createGraphLegend,
|
|
3581
3713
|
GraphSearchManager,
|
|
3582
3714
|
seedNodePositions,
|
|
3715
|
+
createAttributionFooter,
|
|
3716
|
+
getContainerDimensions,
|
|
3583
3717
|
diffGraphUpdate,
|
|
3584
3718
|
reheatAlpha,
|
|
3585
3719
|
createGraph
|
|
3586
3720
|
};
|
|
3587
|
-
//# sourceMappingURL=chunk-
|
|
3721
|
+
//# sourceMappingURL=chunk-5ZLSMZRM.js.map
|