@opendata-ai/openchart-vanilla 8.6.3 → 8.7.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.
Files changed (34) hide show
  1. package/dist/{chunk-273EHRBC.js → chunk-5IMVUHVC.js} +4 -2
  2. package/dist/chunk-5IMVUHVC.js.map +1 -0
  3. package/dist/{chunk-W3WPGHYV.js → chunk-5O624XON.js} +216 -102
  4. package/dist/chunk-5O624XON.js.map +1 -0
  5. package/dist/{chunk-RYVV3YIG.js → chunk-DFKLAB67.js} +3 -3
  6. package/dist/chunk-DFKLAB67.js.map +1 -0
  7. package/dist/{chunk-CPULCRVF.js → chunk-EZQDCLZN.js} +2 -2
  8. package/dist/{chunk-6B5OBGIO.js → chunk-I73B3DJI.js} +2 -2
  9. package/dist/chunk-I73B3DJI.js.map +1 -0
  10. package/dist/{chunk-5RX6ZQGZ.js → chunk-SDJHUELU.js} +1 -2
  11. package/dist/chunk-SDJHUELU.js.map +1 -0
  12. package/dist/{chunk-MDK6AILK.js → chunk-SXTHPXG6.js} +2 -2
  13. package/dist/{chunk-MDK6AILK.js.map → chunk-SXTHPXG6.js.map} +1 -1
  14. package/dist/export-gif.d.ts +1 -1
  15. package/dist/export-gif.js +3 -3
  16. package/dist/graph-3d/index.d.ts +1 -1
  17. package/dist/graph-3d/index.js +16 -15
  18. package/dist/graph-3d/index.js.map +1 -1
  19. package/dist/index.d.ts +9 -3
  20. package/dist/index.js +7 -7
  21. package/dist/{mount-Bs8nFSf1.d.ts → mount-WiY9BIr9.d.ts} +1 -1
  22. package/dist/{renderer-registry-B5tW6yAZ.d.ts → renderer-registry-Cng76n8F.d.ts} +7 -0
  23. package/dist/static.js +3 -3
  24. package/dist/story/index.d.ts +2 -2
  25. package/dist/story/index.js +4 -4
  26. package/dist/styles.css +1 -1
  27. package/dist/styles.css.map +1 -1
  28. package/package.json +3 -3
  29. package/dist/chunk-273EHRBC.js.map +0 -1
  30. package/dist/chunk-5RX6ZQGZ.js.map +0 -1
  31. package/dist/chunk-6B5OBGIO.js.map +0 -1
  32. package/dist/chunk-RYVV3YIG.js.map +0 -1
  33. package/dist/chunk-W3WPGHYV.js.map +0 -1
  34. /package/dist/{chunk-CPULCRVF.js.map → chunk-EZQDCLZN.js.map} +0 -0
@@ -48,7 +48,7 @@ interface GIFExportOptions {
48
48
  backgroundColor?: string;
49
49
  /**
50
50
  * Resolved theme to inline as a `<style>` block so class-based fills (metric
51
- * cells, brand watermark dot, legend text) survive serialization. Omit to skip.
51
+ * cells, eyebrow dot, legend text) survive serialization. Omit to skip.
52
52
  */
53
53
  theme?: ResolvedTheme;
54
54
  }
@@ -6,9 +6,9 @@ import {
6
6
  exportGIF,
7
7
  isModuleNotFound,
8
8
  resolveRepeat
9
- } from "./chunk-RYVV3YIG.js";
10
- import "./chunk-6B5OBGIO.js";
11
- import "./chunk-5RX6ZQGZ.js";
9
+ } from "./chunk-DFKLAB67.js";
10
+ import "./chunk-I73B3DJI.js";
11
+ import "./chunk-SDJHUELU.js";
12
12
  export {
13
13
  EASE_SMOOTH_SAMPLES,
14
14
  applyFrameState,
@@ -1,5 +1,5 @@
1
1
  import { GraphSpec } from '@opendata-ai/openchart-core';
2
- import { a as GraphCamera, b as GraphFlyTarget, g as GraphRendererContext, d as GraphInstance, f as GraphMountOptions } from '../renderer-registry-B5tW6yAZ.js';
2
+ import { a as GraphCamera, b as GraphFlyTarget, g as GraphRendererContext, d as GraphInstance, f as GraphMountOptions } from '../renderer-registry-Cng76n8F.js';
3
3
  import '@opendata-ai/openchart-engine';
4
4
  import '@floating-ui/dom';
5
5
 
@@ -14,7 +14,7 @@ import {
14
14
  reheatAlpha,
15
15
  resolveHighlightTarget,
16
16
  seedNodePositions
17
- } from "../chunk-273EHRBC.js";
17
+ } from "../chunk-5IMVUHVC.js";
18
18
  import {
19
19
  AnimationScheduler,
20
20
  createTween,
@@ -169,7 +169,7 @@ function computeFit(points, view) {
169
169
  halfRight * slack / Math.tan(hFov / 2),
170
170
  MIN_FIT_DISTANCE
171
171
  ) + Math.max(0, nearDepth);
172
- return { center, dir, distance };
172
+ return { center, dir, distance, nearDepth: Math.max(0, nearDepth) };
173
173
  }
174
174
 
175
175
  // src/graph-3d/forces.ts
@@ -512,7 +512,7 @@ var LABEL_SCALE_MIN = 0.4;
512
512
  var LABEL_SCALE_MAX = 8;
513
513
  var MAX_PIXEL_RATIO = 2;
514
514
  var DEFAULT_FOV_DEG = 50;
515
- var AUTO_FIT_INTERVAL_MS = 250;
515
+ var NEAR_CLEARANCE = 60;
516
516
  var NODE_FOCUS_DISTANCE = 120;
517
517
  var AUTO_FLIGHT_MS = 800;
518
518
  var ENTRANCE_MIN_SCALE = 0.01;
@@ -582,7 +582,7 @@ function createGraph3DRenderer(ctx) {
582
582
  });
583
583
  }
584
584
  let autoFit = true;
585
- let lastAutoFit = 0;
585
+ let firstAutoFitDone = false;
586
586
  let cameraChangeQueued = false;
587
587
  const labelShown = /* @__PURE__ */ new Set();
588
588
  let lastLabelRank = 0;
@@ -947,7 +947,11 @@ function createGraph3DRenderer(ctx) {
947
947
  autoFit = false;
948
948
  fitNow(opts);
949
949
  }
950
- function fitNow(opts) {
950
+ function autoFitNow() {
951
+ firstAutoFitDone = true;
952
+ fitNow({ duration: 0 }, options?.initialZoom ?? 1);
953
+ }
954
+ function fitNow(opts, zoom = 1) {
951
955
  if (destroyed || nodeData.length === 0) return;
952
956
  const camera = graph.camera();
953
957
  const fit = computeFit(
@@ -966,7 +970,8 @@ function createGraph3DRenderer(ctx) {
966
970
  }
967
971
  );
968
972
  if (!fit) return;
969
- const distance = fit.distance * entranceCameraPull;
973
+ const framed = zoom > 0 && zoom !== 1 ? Math.max(fit.distance / zoom, fit.nearDepth + NEAR_CLEARANCE) : fit.distance;
974
+ const distance = framed * entranceCameraPull;
970
975
  graph.cameraPosition(
971
976
  {
972
977
  x: fit.center.x + fit.dir.x * distance,
@@ -1224,7 +1229,7 @@ function createGraph3DRenderer(ctx) {
1224
1229
  }
1225
1230
  if (enter.cameraFit) {
1226
1231
  entranceCameraPull = ENTRANCE_CAMERA_PULLBACK + (1 - ENTRANCE_CAMERA_PULLBACK) * ease(t);
1227
- if (autoFit && options?.fitOnLoad !== false) fitNow({ duration: 0 });
1232
+ if (autoFit && options?.fitOnLoad !== false) autoFitNow();
1228
1233
  }
1229
1234
  paint();
1230
1235
  },
@@ -1648,13 +1653,9 @@ function createGraph3DRenderer(ctx) {
1648
1653
  }).onEngineTick(() => {
1649
1654
  if (destroyed) return;
1650
1655
  anchorTooltip();
1651
- if (autoFit && options?.fitOnLoad !== false) {
1652
- const now = performance.now();
1653
- if (now - lastAutoFit > AUTO_FIT_INTERVAL_MS) {
1654
- lastAutoFit = now;
1655
- fitNow({ duration: 0 });
1656
- refreshLabels();
1657
- }
1656
+ if (autoFit && options?.fitOnLoad !== false && (!firstAutoFitDone || !prefersReducedMotion())) {
1657
+ autoFitNow();
1658
+ if (performance.now() - lastLabelRank >= LABEL_RERANK_MS) refreshLabels();
1658
1659
  }
1659
1660
  }).onEngineStop(() => {
1660
1661
  if (destroyed) return;
@@ -1664,7 +1665,7 @@ function createGraph3DRenderer(ctx) {
1664
1665
  }
1665
1666
  if (autoFit && options?.fitOnLoad !== false) {
1666
1667
  autoFit = false;
1667
- fitNow({ duration: 0 });
1668
+ autoFitNow();
1668
1669
  }
1669
1670
  refreshLabels();
1670
1671
  });