diff --git a/frontend/src/TransitionGraph.vue b/frontend/src/TransitionGraph.vue index 59325d8..1f45fd1 100644 --- a/frontend/src/TransitionGraph.vue +++ b/frontend/src/TransitionGraph.vue @@ -10,7 +10,8 @@ import { computed, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vu import { rangeWindow, WEEK } from './analytics/time.js' import { formatCount } from './analytics/format.js' import { - TNODE_R, + TNODE_W, + TNODE_H, BEAD_R, BEAD_SPEED, buildTransitionGraph, @@ -146,16 +147,17 @@ watch(svgEl, (el) => { }) watch(() => graph.value?.bounds, updateScale) onBeforeUnmount(() => resizeObs?.disconnect()) + +// Font size (px) that fits a label inside the pill width at the current +// zoom: ~0.52 em average glyph width, 12 px padding per side, capped. +const fitPx = (label) => + Math.min(15, (TNODE_W * pxPerUnit.value - 24) / (0.52 * Math.max(label.length, 1)))