@opendata-ai/openchart-core 7.9.2 → 7.9.3
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 +15 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/responsive/index.ts +2 -0
- package/src/responsive/metrics.ts +18 -2
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -112,9 +112,11 @@ export {
|
|
|
112
112
|
MAX_LEFT_LABEL_FRACTION_MEDIUM_MAX,
|
|
113
113
|
NARROW_VIEWPORT_MAX,
|
|
114
114
|
TICK_LABEL_OFFSET,
|
|
115
|
+
TICK_LINE_HEIGHT_FACTOR,
|
|
115
116
|
TOP_PAD_EXTRA_NARROW,
|
|
116
117
|
TOP_PAD_NARROW_MAX,
|
|
117
118
|
X_AXIS_BAND_HEIGHT,
|
|
119
|
+
X_AXIS_ROTATED_EXTENT_CAP,
|
|
118
120
|
X_AXIS_TITLE_BAND,
|
|
119
121
|
X_AXIS_TITLE_BAND_ROTATED,
|
|
120
122
|
} from './responsive/index';
|
package/src/responsive/index.ts
CHANGED
|
@@ -41,9 +41,11 @@ export {
|
|
|
41
41
|
MAX_LEFT_LABEL_FRACTION_MEDIUM_MAX,
|
|
42
42
|
NARROW_VIEWPORT_MAX,
|
|
43
43
|
TICK_LABEL_OFFSET,
|
|
44
|
+
TICK_LINE_HEIGHT_FACTOR,
|
|
44
45
|
TOP_PAD_EXTRA_NARROW,
|
|
45
46
|
TOP_PAD_NARROW_MAX,
|
|
46
47
|
X_AXIS_BAND_HEIGHT,
|
|
48
|
+
X_AXIS_ROTATED_EXTENT_CAP,
|
|
47
49
|
X_AXIS_TITLE_BAND,
|
|
48
50
|
X_AXIS_TITLE_BAND_ROTATED,
|
|
49
51
|
} from './metrics';
|
|
@@ -173,6 +173,22 @@ export const X_AXIS_BAND_HEIGHT = 26;
|
|
|
173
173
|
export const X_AXIS_TITLE_BAND = 22;
|
|
174
174
|
export const X_AXIS_TITLE_BAND_ROTATED = 20;
|
|
175
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Ceiling on the vertical extent reserved for rotated x tick labels. Labels
|
|
178
|
+
* whose rotated projection exceeds this clip at the reservation edge, so the
|
|
179
|
+
* angle ladder (engine layout/axes/rotation) avoids -90° for labels longer
|
|
180
|
+
* than this.
|
|
181
|
+
*/
|
|
182
|
+
export const X_AXIS_ROTATED_EXTENT_CAP = 120;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Line-height multiplier for a tick label's text ribbon. Shared by the
|
|
186
|
+
* rotated-extent reservation below and the engine's rotation collision test
|
|
187
|
+
* (layout/axes/rotation) so the reserved space and the fit threshold can't
|
|
188
|
+
* drift apart.
|
|
189
|
+
*/
|
|
190
|
+
export const TICK_LINE_HEIGHT_FACTOR = 1.2;
|
|
191
|
+
|
|
176
192
|
export interface XAxisExtentInput {
|
|
177
193
|
labels: string[];
|
|
178
194
|
tickAngle?: number;
|
|
@@ -199,7 +215,7 @@ export function computeXAxisExtentFromLabels(input: XAxisExtentInput): number {
|
|
|
199
215
|
// lineHeight*|cos θ| (the label's own height, which still contributes
|
|
200
216
|
// unless the text is fully vertical). Measuring only the sin term
|
|
201
217
|
// under-reserved space, letting rotated ticks spill into the source line.
|
|
202
|
-
const lineHeight = input.tickFontSize *
|
|
218
|
+
const lineHeight = input.tickFontSize * TICK_LINE_HEIGHT_FACTOR;
|
|
203
219
|
// Small gap between the axis line and the top of the rotated label band.
|
|
204
220
|
// Mirrors the tick-mark-to-label offset used for flat labels; keeps the
|
|
205
221
|
// reservation matched to the drawn footprint across Blink and WebKit,
|
|
@@ -207,7 +223,7 @@ export function computeXAxisExtentFromLabels(input: XAxisExtentInput): number {
|
|
|
207
223
|
const AXIS_TO_LABEL_GAP = 3;
|
|
208
224
|
const rotatedHeight = Math.min(
|
|
209
225
|
maxLabelWidth * Math.sin(angleRad) + lineHeight * Math.cos(angleRad) + AXIS_TO_LABEL_GAP,
|
|
210
|
-
|
|
226
|
+
X_AXIS_ROTATED_EXTENT_CAP,
|
|
211
227
|
);
|
|
212
228
|
return input.hasTitle ? rotatedHeight + X_AXIS_TITLE_BAND_ROTATED : rotatedHeight;
|
|
213
229
|
}
|