@opendata-ai/openchart-core 6.23.1 → 6.24.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/dist/index.d.ts +10 -3
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/layout/chrome.ts +6 -2
- package/src/layout/index.ts +1 -0
- package/src/layout/text-measure.ts +10 -0
- package/src/layout/text-wrap.ts +2 -2
- package/src/types/layout.ts +2 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/layout/chrome.ts
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
BRAND_FONT_SIZE,
|
|
27
27
|
BRAND_MIN_WIDTH,
|
|
28
28
|
BRAND_RESERVE_WIDTH,
|
|
29
|
+
COMPACT_WIDTH,
|
|
29
30
|
estimateCharWidth,
|
|
30
31
|
estimateTextHeight,
|
|
31
32
|
} from './text-measure';
|
|
@@ -236,9 +237,12 @@ export function computeChrome(
|
|
|
236
237
|
topY += estimateTextHeight(style.fontSize, lineCount, style.lineHeight) + chromeGap;
|
|
237
238
|
}
|
|
238
239
|
|
|
239
|
-
// Add chromeToChart gap if there are any top elements
|
|
240
|
+
// Add chromeToChart gap if there are any top elements. Tighten on narrow
|
|
241
|
+
// viewports so the subtitle doesn't float far above a legend or chart area.
|
|
240
242
|
const hasTopChrome = titleNorm || subtitleNorm;
|
|
241
|
-
const
|
|
243
|
+
const chromeToChart =
|
|
244
|
+
width < COMPACT_WIDTH ? Math.min(theme.spacing.chromeToChart, 2) : theme.spacing.chromeToChart;
|
|
245
|
+
const topHeight = hasTopChrome ? topY - pad + chromeToChart - chromeGap : 0;
|
|
242
246
|
|
|
243
247
|
// Bottom chrome text hidden in compact mode, but brand watermark still
|
|
244
248
|
// renders for wide-enough charts. Reserve space so it doesn't overflow.
|
package/src/layout/index.ts
CHANGED
|
@@ -73,6 +73,16 @@ export const BRAND_FONT_SIZE = 12;
|
|
|
73
73
|
/** Minimum chart width to render the brand watermark (px). */
|
|
74
74
|
export const BRAND_MIN_WIDTH = 120;
|
|
75
75
|
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
// Responsive breakpoints
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Width threshold below which layout tightens spacing (legend gaps, chrome
|
|
82
|
+
* padding, label gaps) to maximize data area on small screens.
|
|
83
|
+
*/
|
|
84
|
+
export const COMPACT_WIDTH = 420;
|
|
85
|
+
|
|
76
86
|
/**
|
|
77
87
|
* Estimate the rendered height of a text block.
|
|
78
88
|
*
|
package/src/layout/text-wrap.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* accurate wrapping. Otherwise falls back to a character-width
|
|
7
7
|
* heuristic driven by `estimateCharWidth` from text-measure.ts.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
* the
|
|
9
|
+
* Non-browser callers (SSR, tests) omit the measureText argument to
|
|
10
|
+
* use the heuristic fallback. Do not change the signature without
|
|
11
11
|
* re-verifying visual baselines for every caller.
|
|
12
12
|
*/
|
|
13
13
|
|
package/src/types/layout.ts
CHANGED
|
@@ -1030,6 +1030,8 @@ export interface SankeyLayout {
|
|
|
1030
1030
|
animation?: ResolvedAnimation;
|
|
1031
1031
|
/** Whether the tryOpenData.ai watermark is enabled. */
|
|
1032
1032
|
watermark: boolean;
|
|
1033
|
+
/** Real text measurement function from the adapter (for accurate SVG text wrapping). */
|
|
1034
|
+
measureText?: MeasureTextFn;
|
|
1033
1035
|
}
|
|
1034
1036
|
|
|
1035
1037
|
// ---------------------------------------------------------------------------
|