@opendata-ai/openchart-core 6.19.0 → 6.19.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/package.json
CHANGED
|
@@ -104,7 +104,7 @@ describe('computeChrome', () => {
|
|
|
104
104
|
const chrome: Chrome = { title: 'Title' };
|
|
105
105
|
const result = computeChrome(chrome, theme, 600);
|
|
106
106
|
|
|
107
|
-
const expectedMaxWidth = 600 - theme.spacing.padding * 2;
|
|
107
|
+
const expectedMaxWidth = 600 - theme.spacing.padding * 2 - 5;
|
|
108
108
|
expect(result.title!.maxWidth).toBe(expectedMaxWidth);
|
|
109
109
|
});
|
|
110
110
|
|
package/src/layout/chrome.ts
CHANGED
|
@@ -182,7 +182,10 @@ export function computeChrome(
|
|
|
182
182
|
|
|
183
183
|
const pad = padding ?? theme.spacing.padding;
|
|
184
184
|
const chromeGap = theme.spacing.chromeGap;
|
|
185
|
-
|
|
185
|
+
// Subtract a small buffer beyond padding so the heuristic char-width
|
|
186
|
+
// estimate triggers word-wrap before the real font overflows the container.
|
|
187
|
+
const WRAP_SAFETY_BUFFER = 5;
|
|
188
|
+
const maxWidth = width - pad * 2 - WRAP_SAFETY_BUFFER;
|
|
186
189
|
const fontFamily = theme.fonts.family;
|
|
187
190
|
|
|
188
191
|
// Track vertical cursor for top elements
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* Inter is slightly wider than Helvetica, narrower than Courier.
|
|
13
13
|
* This is a reasonable middle ground.
|
|
14
14
|
*/
|
|
15
|
-
const AVG_CHAR_WIDTH_RATIO = 0.
|
|
15
|
+
const AVG_CHAR_WIDTH_RATIO = 0.57;
|
|
16
16
|
|
|
17
17
|
/** Narrower characters (i, l, t, etc.) bring the average down. */
|
|
18
18
|
const WEIGHT_ADJUSTMENT: Record<number, number> = {
|
|
@@ -65,7 +65,7 @@ export function estimateTextWidth(text: string, fontSize: number, fontWeight = 4
|
|
|
65
65
|
* so adjacent text doesn't crowd it. Used by chrome and legend layout to avoid
|
|
66
66
|
* overlapping the brand.
|
|
67
67
|
*/
|
|
68
|
-
export const BRAND_RESERVE_WIDTH =
|
|
68
|
+
export const BRAND_RESERVE_WIDTH = 130;
|
|
69
69
|
|
|
70
70
|
/** Font size of the brand watermark (px). Shared between layout and renderer. */
|
|
71
71
|
export const BRAND_FONT_SIZE = 12;
|