@opendata-ai/openchart-core 7.9.0 → 7.9.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/dist/index.d.ts +6 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/responsive/metrics.ts +10 -0
package/package.json
CHANGED
|
@@ -88,6 +88,11 @@ export const AXIS_TITLE_GAP = 7;
|
|
|
88
88
|
* visible clearance remains. Falls back to the viewport-minimum offset when the
|
|
89
89
|
* dynamic value would be smaller (short tick labels on wide containers).
|
|
90
90
|
*
|
|
91
|
+
* When `inline` is true the y-tick labels render inside the chart area (above
|
|
92
|
+
* their gridlines) rather than in a left gutter, so the title only needs to
|
|
93
|
+
* clear the chart edge — no tick-label width and no viewport-minimum floor,
|
|
94
|
+
* both of which would otherwise leave a dead gap between the title and the plot.
|
|
95
|
+
*
|
|
91
96
|
* Shared by the engine (margin reservation) and the renderer (title placement)
|
|
92
97
|
* so the reserved space always matches where the title is drawn.
|
|
93
98
|
*/
|
|
@@ -95,8 +100,13 @@ export function axisTitleOffset(
|
|
|
95
100
|
maxTickLabelWidth: number,
|
|
96
101
|
titleFontSize: number,
|
|
97
102
|
width: number,
|
|
103
|
+
inline = false,
|
|
98
104
|
): number {
|
|
99
105
|
const halfTitleGlyph = Math.ceil(titleFontSize / 2);
|
|
106
|
+
if (inline) {
|
|
107
|
+
// No gutter tick labels to clear: title edge + gap + half-glyph only.
|
|
108
|
+
return TICK_LABEL_OFFSET + AXIS_TITLE_GAP + halfTitleGlyph;
|
|
109
|
+
}
|
|
100
110
|
const dynamic = TICK_LABEL_OFFSET + maxTickLabelWidth + AXIS_TITLE_GAP + halfTitleGlyph;
|
|
101
111
|
return Math.max(dynamic, getAxisTitleOffset(width));
|
|
102
112
|
}
|