@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.101 → 2.0.0-next.103
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/bundle/openbridge-webcomponents.bundle.js +580 -143
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +629 -407
- package/dist/bars-graphs/donut-chart/donut-chart.d.ts +18 -16
- package/dist/bars-graphs/donut-chart/donut-chart.d.ts.map +1 -1
- package/dist/bars-graphs/donut-chart/donut-chart.js.map +1 -1
- package/dist/bars-graphs/pie-chart/pie-chart.d.ts +14 -12
- package/dist/bars-graphs/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/bars-graphs/pie-chart/pie-chart.js.map +1 -1
- package/dist/bars-graphs/polar-chart/polar-chart.d.ts +19 -16
- package/dist/bars-graphs/polar-chart/polar-chart.d.ts.map +1 -1
- package/dist/bars-graphs/polar-chart/polar-chart.js.map +1 -1
- package/dist/bars-graphs/radial-bar-chart/radial-bar-chart.d.ts +8 -8
- package/dist/bars-graphs/radial-bar-chart/radial-bar-chart.d.ts.map +1 -1
- package/dist/bars-graphs/radial-bar-chart/radial-bar-chart.js.map +1 -1
- package/dist/building-blocks/chart-line/chart-line-base.d.ts +8 -25
- package/dist/building-blocks/chart-line/chart-line-base.d.ts.map +1 -1
- package/dist/building-blocks/chart-line/chart-line-base.js.map +1 -1
- package/dist/building-blocks/instrument-radial/instrument-radial.d.ts +22 -2
- package/dist/building-blocks/instrument-radial/instrument-radial.d.ts.map +1 -1
- package/dist/building-blocks/instrument-radial/instrument-radial.js +61 -37
- package/dist/building-blocks/instrument-radial/instrument-radial.js.map +1 -1
- package/dist/integration-systems/integration-bar/integration-bar.d.ts +20 -24
- package/dist/integration-systems/integration-bar/integration-bar.d.ts.map +1 -1
- package/dist/integration-systems/integration-bar/integration-bar.js.map +1 -1
- package/dist/integration-systems/integration-button/integration-button.d.ts +15 -13
- package/dist/integration-systems/integration-button/integration-button.d.ts.map +1 -1
- package/dist/integration-systems/integration-button/integration-button.js.map +1 -1
- package/dist/navigation-instruments/azimuth-thruster/azimuth-thruster.d.ts +14 -0
- package/dist/navigation-instruments/azimuth-thruster/azimuth-thruster.d.ts.map +1 -1
- package/dist/navigation-instruments/azimuth-thruster/azimuth-thruster.js +30 -11
- package/dist/navigation-instruments/azimuth-thruster/azimuth-thruster.js.map +1 -1
- package/dist/navigation-instruments/compass/compass.d.ts +68 -31
- package/dist/navigation-instruments/compass/compass.d.ts.map +1 -1
- package/dist/navigation-instruments/compass/compass.js +36 -16
- package/dist/navigation-instruments/compass/compass.js.map +1 -1
- package/dist/navigation-instruments/compass-flat/compass-flat.d.ts +8 -9
- package/dist/navigation-instruments/compass-flat/compass-flat.d.ts.map +1 -1
- package/dist/navigation-instruments/compass-flat/compass-flat.js.map +1 -1
- package/dist/navigation-instruments/compass-sector/compass-sector.d.ts.map +1 -1
- package/dist/navigation-instruments/compass-sector/compass-sector.js.map +1 -1
- package/dist/navigation-instruments/gauge-radial/gauge-radial.css.js +34 -2
- package/dist/navigation-instruments/gauge-radial/gauge-radial.css.js.map +1 -1
- package/dist/navigation-instruments/gauge-radial/gauge-radial.d.ts +15 -0
- package/dist/navigation-instruments/gauge-radial/gauge-radial.d.ts.map +1 -1
- package/dist/navigation-instruments/gauge-radial/gauge-radial.js +35 -1
- package/dist/navigation-instruments/gauge-radial/gauge-radial.js.map +1 -1
- package/dist/navigation-instruments/gauge-trend/gauge-trend.d.ts +0 -5
- package/dist/navigation-instruments/gauge-trend/gauge-trend.d.ts.map +1 -1
- package/dist/navigation-instruments/gauge-trend/gauge-trend.js.map +1 -1
- package/dist/navigation-instruments/graph-mini/graph-mini.d.ts +1 -1
- package/dist/navigation-instruments/graph-mini/graph-mini.d.ts.map +1 -1
- package/dist/navigation-instruments/graph-mini/graph-mini.js.map +1 -1
- package/dist/navigation-instruments/heading/heading.d.ts +19 -1
- package/dist/navigation-instruments/heading/heading.d.ts.map +1 -1
- package/dist/navigation-instruments/heading/heading.js +34 -16
- package/dist/navigation-instruments/heading/heading.js.map +1 -1
- package/dist/navigation-instruments/indicator-graph/indicator-graph.d.ts +1 -1
- package/dist/navigation-instruments/indicator-graph/indicator-graph.d.ts.map +1 -1
- package/dist/navigation-instruments/indicator-graph/indicator-graph.js.map +1 -1
- package/dist/navigation-instruments/rudder/rudder.d.ts +15 -2
- package/dist/navigation-instruments/rudder/rudder.d.ts.map +1 -1
- package/dist/navigation-instruments/rudder/rudder.js +36 -26
- package/dist/navigation-instruments/rudder/rudder.js.map +1 -1
- package/dist/navigation-instruments/speed-gauge/speed-gauge.d.ts +15 -1
- package/dist/navigation-instruments/speed-gauge/speed-gauge.d.ts.map +1 -1
- package/dist/navigation-instruments/speed-gauge/speed-gauge.js +31 -3
- package/dist/navigation-instruments/speed-gauge/speed-gauge.js.map +1 -1
- package/dist/navigation-instruments/watch/watch.d.ts +45 -17
- package/dist/navigation-instruments/watch/watch.d.ts.map +1 -1
- package/dist/navigation-instruments/watch/watch.js +53 -38
- package/dist/navigation-instruments/watch/watch.js.map +1 -1
- package/dist/svghelpers/radial-frame.d.ts +122 -0
- package/dist/svghelpers/radial-frame.d.ts.map +1 -0
- package/dist/svghelpers/radial-frame.js +259 -0
- package/dist/svghelpers/radial-frame.js.map +1 -0
- package/package.json +1 -1
- package/script/check-slot-event-docs.ts +35 -0
- package/src/bars-graphs/donut-chart/donut-chart.ts +18 -16
- package/src/bars-graphs/pie-chart/pie-chart.ts +14 -12
- package/src/bars-graphs/polar-chart/polar-chart.ts +19 -16
- package/src/bars-graphs/radial-bar-chart/radial-bar-chart.ts +8 -8
- package/src/building-blocks/chart-line/chart-line-base.ts +8 -25
- package/src/building-blocks/instrument-radial/instrument-radial.stories.ts +187 -6
- package/src/building-blocks/instrument-radial/instrument-radial.ts +98 -47
- package/src/integration-systems/integration-bar/integration-bar.ts +20 -24
- package/src/integration-systems/integration-button/integration-button.ts +15 -13
- package/src/navigation-instruments/azimuth-thruster/azimuth-thruster.stories.ts +78 -1
- package/src/navigation-instruments/azimuth-thruster/azimuth-thruster.ts +55 -11
- package/src/navigation-instruments/compass/compass.stories.ts +88 -1
- package/src/navigation-instruments/compass/compass.ts +99 -46
- package/src/navigation-instruments/compass-flat/compass-flat.ts +8 -9
- package/src/navigation-instruments/compass-sector/compass-sector.ts +7 -0
- package/src/navigation-instruments/gauge-radial/gauge-radial.css +32 -2
- package/src/navigation-instruments/gauge-radial/gauge-radial.stories.ts +265 -1
- package/src/navigation-instruments/gauge-radial/gauge-radial.ts +59 -1
- package/src/navigation-instruments/gauge-trend/gauge-trend.ts +0 -5
- package/src/navigation-instruments/graph-mini/graph-mini.ts +1 -1
- package/src/navigation-instruments/heading/heading.stories.ts +92 -1
- package/src/navigation-instruments/heading/heading.ts +50 -16
- package/src/navigation-instruments/indicator-graph/indicator-graph.ts +1 -1
- package/src/navigation-instruments/rudder/rudder.stories.ts +83 -1
- package/src/navigation-instruments/rudder/rudder.ts +61 -34
- package/src/navigation-instruments/speed-gauge/speed-gauge.stories.ts +94 -1
- package/src/navigation-instruments/speed-gauge/speed-gauge.ts +57 -4
- package/src/navigation-instruments/watch/watch.stories.ts +140 -1
- package/src/navigation-instruments/watch/watch.ts +100 -60
- package/src/storybook-util.ts +59 -0
- package/src/svghelpers/radial-frame.spec.ts +307 -0
- package/src/svghelpers/radial-frame.ts +508 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import {describe, expect, it} from 'vitest';
|
|
2
|
+
import {computeZoomToFitArcFrame} from './arc-frame.js';
|
|
3
|
+
import {
|
|
4
|
+
computeRadialFrame,
|
|
5
|
+
estimateLabelWidthPx,
|
|
6
|
+
LABEL_RESERVE_MAX_FRACTION,
|
|
7
|
+
} from './radial-frame.js';
|
|
8
|
+
|
|
9
|
+
const ZOOM_AREAS = [
|
|
10
|
+
{
|
|
11
|
+
startAngle: -135,
|
|
12
|
+
endAngle: 135,
|
|
13
|
+
roundInsideCut: true,
|
|
14
|
+
roundOutsideCut: true,
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
describe('computeRadialFrame — back-compat identity', () => {
|
|
19
|
+
it('no labels reproduces the legacy (176+padding)*2 box', () => {
|
|
20
|
+
const f = computeRadialFrame({basePadding: 48});
|
|
21
|
+
expect(f.viewBox).toBe('-224 -224 448 448');
|
|
22
|
+
expect(f.width).toBe(448);
|
|
23
|
+
expect(f.height).toBe(448);
|
|
24
|
+
expect(f.x).toBe(-224);
|
|
25
|
+
expect(f.y).toBe(-224);
|
|
26
|
+
expect(f.radiusOffset).toBe(0);
|
|
27
|
+
expect(f.labelReserve).toBe(0);
|
|
28
|
+
expect(f.labelsHidden).toBe(false);
|
|
29
|
+
expect(f.hostWidthPx).toBeUndefined();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('no labels + clips reproduces the legacy clipped box (rudder: top 40%)', () => {
|
|
33
|
+
const f = computeRadialFrame({
|
|
34
|
+
basePadding: 48,
|
|
35
|
+
clips: {top: 40, bottom: 0, left: 0, right: 0},
|
|
36
|
+
});
|
|
37
|
+
expect(f.x).toBe(-224);
|
|
38
|
+
expect(f.y).toBeCloseTo(-44.8);
|
|
39
|
+
expect(f.width).toBe(448);
|
|
40
|
+
expect(f.height).toBeCloseTo(268.8);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('labels with a generous container never shrink below the base box', () => {
|
|
44
|
+
const f = computeRadialFrame({
|
|
45
|
+
basePadding: 48,
|
|
46
|
+
labelWidthPx: 14,
|
|
47
|
+
containerPx: {width: 2000, height: 2000},
|
|
48
|
+
});
|
|
49
|
+
expect(f.width).toBe(448);
|
|
50
|
+
expect(f.labelReserve).toBe(0);
|
|
51
|
+
expect(f.labelsHidden).toBe(false);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('computeRadialFrame — mode (a) label reserve', () => {
|
|
56
|
+
it('grows the box for 4-digit labels in a shrunk container', () => {
|
|
57
|
+
const f = computeRadialFrame({
|
|
58
|
+
basePadding: 48,
|
|
59
|
+
labelWidthPx: 28,
|
|
60
|
+
containerPx: {width: 200, height: 200},
|
|
61
|
+
});
|
|
62
|
+
// P = 9 + 28 + 4 = 41; side = 374 / (1 - 82/200)
|
|
63
|
+
expect(f.width).toBeCloseTo(374 / (1 - 82 / 200), 6);
|
|
64
|
+
expect(f.width).toBeGreaterThan(448);
|
|
65
|
+
expect(f.labelsHidden).toBe(false);
|
|
66
|
+
expect(f.labelReserve).toBeCloseTo((f.width - 448) / 2, 6);
|
|
67
|
+
// The label's far edge must fit inside the box at the implied scale.
|
|
68
|
+
const scale = 200 / f.width;
|
|
69
|
+
expect(f.scale).toBeCloseTo(scale, 6);
|
|
70
|
+
expect(187 + 41 / scale).toBeLessThanOrEqual(f.width / 2 + 1e-6);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('hides labels past the reserve cap instead of growing unboundedly', () => {
|
|
74
|
+
const f = computeRadialFrame({
|
|
75
|
+
basePadding: 48,
|
|
76
|
+
labelWidthPx: 28,
|
|
77
|
+
containerPx: {width: 120, height: 120},
|
|
78
|
+
});
|
|
79
|
+
expect((2 * 41) / 120).toBeGreaterThan(LABEL_RESERVE_MAX_FRACTION);
|
|
80
|
+
expect(f.labelsHidden).toBe(true);
|
|
81
|
+
expect(f.labelReserve).toBe(0);
|
|
82
|
+
expect(f.width).toBe(448);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('uses the binding axis with clips (180° sector in a short wide cell)', () => {
|
|
86
|
+
const f = computeRadialFrame({
|
|
87
|
+
basePadding: 48,
|
|
88
|
+
labelWidthPx: 21,
|
|
89
|
+
clips: {top: 0, bottom: 44, left: 0, right: 0},
|
|
90
|
+
containerPx: {width: 600, height: 120},
|
|
91
|
+
});
|
|
92
|
+
// fy = 0.56 → Ceff = min(600/1, 120/0.56); P = 34
|
|
93
|
+
const ceff = 120 / 0.56;
|
|
94
|
+
const side = 374 / (1 - 68 / ceff);
|
|
95
|
+
expect(f.width).toBeCloseTo(side, 6);
|
|
96
|
+
expect(f.height).toBeCloseTo(side * 0.56, 6);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('falls back to scale 1 for a zero-size container (first paint)', () => {
|
|
100
|
+
const f = computeRadialFrame({
|
|
101
|
+
basePadding: 48,
|
|
102
|
+
labelWidthPx: 28,
|
|
103
|
+
containerPx: {width: 0, height: 0},
|
|
104
|
+
});
|
|
105
|
+
expect(Number.isFinite(f.width)).toBe(true);
|
|
106
|
+
expect(f.labelsHidden).toBe(false);
|
|
107
|
+
expect(f.width).toBeCloseTo(2 * (187 + 41), 6);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('computeRadialFrame — labelDropPx clip adjustment', () => {
|
|
112
|
+
const SECTOR_180 = {top: 0, bottom: 44, left: 0, right: 0};
|
|
113
|
+
|
|
114
|
+
it('leaves the requested clips untouched when the drop already fits', () => {
|
|
115
|
+
const plain = computeRadialFrame({
|
|
116
|
+
basePadding: 48,
|
|
117
|
+
labelWidthPx: 21,
|
|
118
|
+
clips: SECTOR_180,
|
|
119
|
+
containerPx: {width: 400, height: 224},
|
|
120
|
+
});
|
|
121
|
+
const withDrop = computeRadialFrame({
|
|
122
|
+
basePadding: 48,
|
|
123
|
+
labelWidthPx: 21,
|
|
124
|
+
clips: SECTOR_180,
|
|
125
|
+
labelDropPx: 21,
|
|
126
|
+
containerPx: {width: 400, height: 224},
|
|
127
|
+
});
|
|
128
|
+
expect(withDrop.viewBox).toBe(plain.viewBox);
|
|
129
|
+
expect(withDrop.clipsAdjusted).toBe(false);
|
|
130
|
+
expect(plain.clipsAdjusted).toBe(false);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('lowers the bottom clip when a pinned face would cut the end labels', () => {
|
|
134
|
+
const plain = computeRadialFrame({
|
|
135
|
+
basePadding: 48,
|
|
136
|
+
labelWidthPx: 21,
|
|
137
|
+
clips: SECTOR_180,
|
|
138
|
+
faceDiameter: 180,
|
|
139
|
+
});
|
|
140
|
+
const f = computeRadialFrame({
|
|
141
|
+
basePadding: 48,
|
|
142
|
+
labelWidthPx: 21,
|
|
143
|
+
clips: SECTOR_180,
|
|
144
|
+
labelDropPx: 21,
|
|
145
|
+
faceDiameter: 180,
|
|
146
|
+
});
|
|
147
|
+
expect(f.clipsAdjusted).toBe(true);
|
|
148
|
+
expect(f.height).toBeGreaterThan(plain.height);
|
|
149
|
+
// The box bottom must sit at least labelDropPx/scale below the center.
|
|
150
|
+
const bottomExtentUnits = f.y + f.height;
|
|
151
|
+
expect(bottomExtentUnits).toBeGreaterThanOrEqual(21 / f.scale - 1e-6);
|
|
152
|
+
// The width (and thus the ring scale) is not affected.
|
|
153
|
+
expect(f.width).toBeCloseTo(plain.width, 6);
|
|
154
|
+
expect(f.scale).toBeCloseTo(plain.scale, 6);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('adjusts symmetrically for a top clip (rudder-style windows)', () => {
|
|
158
|
+
const f = computeRadialFrame({
|
|
159
|
+
basePadding: 48,
|
|
160
|
+
labelWidthPx: 21,
|
|
161
|
+
clips: {top: 47, bottom: 0, left: 0, right: 0},
|
|
162
|
+
labelDropPx: 21,
|
|
163
|
+
faceDiameter: 180,
|
|
164
|
+
});
|
|
165
|
+
expect(f.clipsAdjusted).toBe(true);
|
|
166
|
+
// The box top must sit at least labelDropPx/scale above the center.
|
|
167
|
+
expect(-f.y).toBeGreaterThanOrEqual(21 / f.scale - 1e-6);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('does nothing without clips or when labels are hidden', () => {
|
|
171
|
+
const noClips = computeRadialFrame({
|
|
172
|
+
basePadding: 48,
|
|
173
|
+
labelWidthPx: 21,
|
|
174
|
+
labelDropPx: 21,
|
|
175
|
+
containerPx: {width: 400, height: 400},
|
|
176
|
+
});
|
|
177
|
+
expect(noClips.clipsAdjusted).toBe(false);
|
|
178
|
+
|
|
179
|
+
const hidden = computeRadialFrame({
|
|
180
|
+
basePadding: 48,
|
|
181
|
+
labelWidthPx: 28,
|
|
182
|
+
clips: SECTOR_180,
|
|
183
|
+
labelDropPx: 21,
|
|
184
|
+
containerPx: {width: 100, height: 56},
|
|
185
|
+
});
|
|
186
|
+
expect(hidden.labelsHidden).toBe(true);
|
|
187
|
+
expect(hidden.clipsAdjusted).toBe(false);
|
|
188
|
+
expect(hidden.height).toBeCloseTo(hidden.width * 0.56, 6);
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
describe('computeRadialFrame — mode (b) faceDiameter', () => {
|
|
193
|
+
it('pins the scale and emits fixed host px', () => {
|
|
194
|
+
const f = computeRadialFrame({basePadding: 48, faceDiameter: 368});
|
|
195
|
+
expect(f.scale).toBe(1);
|
|
196
|
+
expect(f.hostWidthPx).toBeCloseTo(448);
|
|
197
|
+
expect(f.hostHeightPx).toBeCloseTo(448);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it('same faceDiameter, wider labels → same ring scale, wider box', () => {
|
|
201
|
+
const a = computeRadialFrame({
|
|
202
|
+
basePadding: 48,
|
|
203
|
+
faceDiameter: 200,
|
|
204
|
+
labelWidthPx: 14,
|
|
205
|
+
});
|
|
206
|
+
const b = computeRadialFrame({
|
|
207
|
+
basePadding: 48,
|
|
208
|
+
faceDiameter: 200,
|
|
209
|
+
labelWidthPx: 28,
|
|
210
|
+
});
|
|
211
|
+
expect(a.scale).toBeCloseTo(b.scale, 6);
|
|
212
|
+
expect(b.hostWidthPx!).toBeGreaterThan(a.hostWidthPx!);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('treats zero/negative/non-finite faceDiameter as unset (no host pin)', () => {
|
|
216
|
+
for (const bad of [0, -100, NaN, Infinity]) {
|
|
217
|
+
const f = computeRadialFrame({
|
|
218
|
+
basePadding: 48,
|
|
219
|
+
faceDiameter: bad,
|
|
220
|
+
containerPx: {width: 300, height: 300},
|
|
221
|
+
});
|
|
222
|
+
expect(f.hostWidthPx).toBeUndefined();
|
|
223
|
+
expect(f.hostHeightPx).toBeUndefined();
|
|
224
|
+
expect(f.viewBox).toBe('-224 -224 448 448');
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('treats an unusable faceDiameter as unset on the zoom path too', () => {
|
|
229
|
+
const f = computeRadialFrame({
|
|
230
|
+
basePadding: 48,
|
|
231
|
+
faceDiameter: NaN,
|
|
232
|
+
zoomToFitArc: true,
|
|
233
|
+
areas: ZOOM_AREAS,
|
|
234
|
+
innerRadius: 112,
|
|
235
|
+
containerPx: {width: 300, height: 300},
|
|
236
|
+
});
|
|
237
|
+
expect(f.hostWidthPx).toBeUndefined();
|
|
238
|
+
expect(f.hostHeightPx).toBeUndefined();
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('faceDiameter + 180° clips yields a shorter host box at the same scale', () => {
|
|
242
|
+
const full = computeRadialFrame({basePadding: 48, faceDiameter: 200});
|
|
243
|
+
const half = computeRadialFrame({
|
|
244
|
+
basePadding: 48,
|
|
245
|
+
faceDiameter: 200,
|
|
246
|
+
clips: {top: 0, bottom: 44, left: 0, right: 0},
|
|
247
|
+
});
|
|
248
|
+
expect(half.scale).toBeCloseTo(full.scale, 6);
|
|
249
|
+
expect(half.hostWidthPx!).toBeCloseTo(full.hostWidthPx!, 6);
|
|
250
|
+
expect(half.hostHeightPx!).toBeCloseTo(full.hostHeightPx! * 0.56, 6);
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
describe('computeRadialFrame — zoom path', () => {
|
|
255
|
+
it('matches computeZoomToFitArcFrame exactly when no labels', () => {
|
|
256
|
+
const f = computeRadialFrame({
|
|
257
|
+
basePadding: 48,
|
|
258
|
+
zoomToFitArc: true,
|
|
259
|
+
areas: ZOOM_AREAS,
|
|
260
|
+
innerRadius: 112,
|
|
261
|
+
});
|
|
262
|
+
const direct = computeZoomToFitArcFrame({
|
|
263
|
+
areas: ZOOM_AREAS,
|
|
264
|
+
outerRadius: 184,
|
|
265
|
+
innerRadius: 112,
|
|
266
|
+
extension: 48,
|
|
267
|
+
targetSize: 448,
|
|
268
|
+
});
|
|
269
|
+
expect(f.viewBox).toBe(direct.viewBox);
|
|
270
|
+
expect(f.width).toBe(direct.width);
|
|
271
|
+
expect(f.height).toBe(direct.height);
|
|
272
|
+
expect(f.radiusOffset).toBe(direct.radiusOffset);
|
|
273
|
+
expect(f.labelReserve).toBe(0);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('adds a label reserve via the extension in a small container', () => {
|
|
277
|
+
const plain = computeRadialFrame({
|
|
278
|
+
basePadding: 48,
|
|
279
|
+
zoomToFitArc: true,
|
|
280
|
+
areas: ZOOM_AREAS,
|
|
281
|
+
innerRadius: 112,
|
|
282
|
+
});
|
|
283
|
+
const labeled = computeRadialFrame({
|
|
284
|
+
basePadding: 48,
|
|
285
|
+
zoomToFitArc: true,
|
|
286
|
+
areas: ZOOM_AREAS,
|
|
287
|
+
innerRadius: 112,
|
|
288
|
+
labelWidthPx: 28,
|
|
289
|
+
containerPx: {width: 300, height: 300},
|
|
290
|
+
});
|
|
291
|
+
expect(labeled.labelsHidden).toBe(false);
|
|
292
|
+
expect(labeled.labelReserve).toBeGreaterThan(0);
|
|
293
|
+
expect(labeled.width).toBeGreaterThan(plain.width);
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
describe('estimateLabelWidthPx', () => {
|
|
298
|
+
it('is maxChars * 7', () => {
|
|
299
|
+
expect(estimateLabelWidthPx(['0', '3600', undefined])).toBe(28);
|
|
300
|
+
expect(estimateLabelWidthPx(['5'])).toBe(7);
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it('is 0 for no texts', () => {
|
|
304
|
+
expect(estimateLabelWidthPx([undefined])).toBe(0);
|
|
305
|
+
expect(estimateLabelWidthPx([])).toBe(0);
|
|
306
|
+
});
|
|
307
|
+
});
|