Skip to content

Commit b20c041

Browse files
wfryc-apptensionwfryc
andauthored
Adjust quadrants badges
* Adjust quadrants badges * Fix label for zoom-out smallerRadar * Fix badge for zoom-in smallerRadar Co-authored-by: wfryc <waldemar.fryc@schemadesign.com>
1 parent ba06ef4 commit b20c041

File tree

2 files changed

+24
-30
lines changed

2 files changed

+24
-30
lines changed

src/lib/zalando-tech-radar.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -234,32 +234,33 @@ export default function radar_visualization(config) {
234234

235235
// draw quadrant labels
236236
for (let i = 0; i < config.quadrants.length; i++) {
237-
const smallerLabels = config.zoomed_quadrant || !fullSize;
237+
const smallerRadar = !fullSize;
238238
const isZoomed = i === config.zoomed_quadrant;
239239
const factorX = quadrants[i].factor_x;
240240
const factorY = quadrants[i].factor_y;
241241
// magic numbers (found by experimentation)
242-
const factorsForSmallerLabels = [
243-
{ x: factorX * 200, y: factorY * 220 },
244-
{ x: factorX * 300, y: factorY * 200 },
245-
{ x: factorX * 320, y: factorY * 220 },
246-
{ x: factorX * 200, y: factorY * 200 },
242+
const factorsForSmallerRadar = [
243+
{ x: factorX * 210, y: factorY * 220 },
244+
{ x: factorX * 350, y: factorY * 200 },
245+
{ x: factorX * (isZoomed ? 300 : 410), y: factorY * 220 },
246+
{ x: factorX * 220, y: factorY * 200 },
247247
];
248-
const factorsForBiggerLabels = [
249-
{ x: factorX * 340, y: factorY * 280 },
250-
{ x: factorX * 510, y: factorY * 250 },
251-
{ x: factorX * 550, y: factorY * 300 },
252-
{ x: factorX * 330, y: factorY * 260 },
248+
const factorsForBiggerRadar = [
249+
{ x: factorX * 290, y: factorY * 280 },
250+
{ x: factorX * 450, y: factorY * 250 },
251+
{ x: factorX * (isZoomed ? 400 : 480), y: factorY * (isZoomed ? 270 : 300) },
252+
{ x: factorX * 300, y: factorY * 260 },
253253
];
254254

255-
const currentFactors = smallerLabels ? factorsForSmallerLabels : factorsForBiggerLabels;
256-
const { subtractX, subtractY } = getPxToSubtractQuadrantLabelText(smallerLabels);
255+
const currentFactors = smallerRadar ? factorsForSmallerRadar : factorsForBiggerRadar;
256+
const { subtractX, subtractY } = getPxToSubtractQuadrantLabelText(smallerRadar);
257257

258258
const quadrantLabel = grid.append('g').attr('id', `quadrant-label-${i}`).style('opacity', 1);
259+
259260
quadrantLabel
260261
.append('rect')
261-
.attr('rx', smallerLabels ? 12 : 20)
262-
.attr('ry', smallerLabels ? 12 : 20)
262+
.attr('rx', isZoomed ? 7 : 15)
263+
.attr('ry', isZoomed ? 7 : 15)
263264
.attr('x', currentFactors[i].x)
264265
.attr('y', currentFactors[i].y)
265266
.style('fill', color.mineShaft)
@@ -272,7 +273,7 @@ export default function radar_visualization(config) {
272273
.attr('text-anchor', 'left')
273274
.style('fill', config.active_quadrant === i || config.zoomed_quadrant === i ? color.mineShaft : color.scorpion)
274275
.style('font-family', 'Hellix')
275-
.style('font-size', `${smallerLabels ? 8 : 14}px`)
276+
.style('font-size', `${isZoomed ? (smallerRadar ? 5.5 : 6.5) : 13}px`)
276277
.style('font-weight', 600)
277278
.style('letter-spacing', '0.2em');
278279

@@ -294,8 +295,8 @@ export default function radar_visualization(config) {
294295
'y',
295296
config.zoomed_quadrant ? currentFactors[i].y - bbox.height + addY : currentFactors[i].y - bbox.height - 5
296297
)
297-
.attr('width', smallerLabels ? bbox.width + 30 : bbox.width + 40)
298-
.attr('height', smallerLabels ? bbox.height + 12 : bbox.height + 18);
298+
.attr('width', bbox.width + 30)
299+
.attr('height', isZoomed ? (smallerRadar ? 14 : 16) : 32);
299300
}
300301
}
301302

src/shared/utils/radarUtils.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
RotateDataProps,
1919
UpdateTechnologiesProps,
2020
} from '../components/radar/radar.types';
21-
import { FilterType } from '../../modules/filters/filters.types';
2221
import { sizes } from '../../theme/media';
2322

2423
// custom random number generator, to make random sequence reproducible
@@ -192,7 +191,7 @@ export const getRotationForQuadrant = (quadrant: number | null) => {
192191
};
193192

194193
export const getPxToSubtractQuadrantLabelText = (smallerLabels: boolean): { subtractX: number; subtractY: number } => {
195-
return { subtractX: smallerLabels ? 6 : 0, subtractY: smallerLabels ? 1 : -1 };
194+
return { subtractX: smallerLabels ? 6 : 0, subtractY: smallerLabels ? 0 : -1 };
196195
};
197196

198197
export const getPxToAddQuadrantLabelTextZoomed = (
@@ -201,12 +200,9 @@ export const getPxToAddQuadrantLabelTextZoomed = (
201200
): { addX: number; addY: number } => {
202201
const isSmallScreen = window.innerWidth < sizes.desktopWide || window.innerHeight < MIN_WINDOW_HEIGHT;
203202
if (isSmallScreen) {
204-
return { addX: isZoomed ? 56 : -50, addY: isZoomed ? -26 : -130 };
203+
return { addX: isZoomed ? 56 : -1000, addY: isZoomed ? 22.5 : -1000 };
205204
}
206-
if (fullSize) {
207-
return { addX: isZoomed ? -50 : 240, addY: isZoomed ? -130 : -26 };
208-
}
209-
return { addX: isZoomed ? 24 : -50, addY: isZoomed ? -26 : -130 };
205+
return { addX: isZoomed ? 56 : -1000, addY: isZoomed ? -27.7 : -1000 };
210206
};
211207

212208
export const getPxToAddQuadrantLabelRectZoomed = (
@@ -215,12 +211,9 @@ export const getPxToAddQuadrantLabelRectZoomed = (
215211
): { addX: number; addY: number } => {
216212
const isSmallScreen = window.innerWidth < sizes.desktopWide || window.innerHeight < MIN_WINDOW_HEIGHT;
217213
if (isSmallScreen) {
218-
return { addX: isZoomed ? 42 : -64, addY: isZoomed ? -30 : -134 };
219-
}
220-
if (fullSize) {
221-
return { addX: isZoomed ? -64 : -1000, addY: isZoomed ? -134 : -30 };
214+
return { addX: isZoomed ? 42 : -1000, addY: isZoomed ? 20 : -1000 };
222215
}
223-
return { addX: isZoomed ? 10 : -64, addY: isZoomed ? -30 : -134 };
216+
return { addX: isZoomed ? 42 : -1000, addY: isZoomed ? -30 : -1000 };
224217
};
225218

226219
export const destroyRadar = () => {

0 commit comments

Comments
 (0)