feat(network-map): introduce compact edge label display for improved readability in dense mode
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m37s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m37s
This commit is contained in:
@@ -278,6 +278,7 @@ export default function NetworkMapUnifi({
|
|||||||
speed && (speed.tcpDownloadBps != null || speed.tcpUploadBps != null)
|
speed && (speed.tcpDownloadBps != null || speed.tcpUploadBps != null)
|
||||||
? formatSpeedShort(speed.tcpDownloadBps, speed.tcpUploadBps)
|
? formatSpeedShort(speed.tcpDownloadBps, speed.tcpUploadBps)
|
||||||
: null;
|
: null;
|
||||||
|
const compactEdgeLabel = pingLabel || speedLabel || null;
|
||||||
const edgeLabel =
|
const edgeLabel =
|
||||||
pingLabel && speedLabel ? `${pingLabel} • ${speedLabel}` : (pingLabel || speedLabel);
|
pingLabel && speedLabel ? `${pingLabel} • ${speedLabel}` : (pingLabel || speedLabel);
|
||||||
return {
|
return {
|
||||||
@@ -288,6 +289,7 @@ export default function NetworkMapUnifi({
|
|||||||
p2,
|
p2,
|
||||||
pingLabel,
|
pingLabel,
|
||||||
speedLabel,
|
speedLabel,
|
||||||
|
compactEdgeLabel,
|
||||||
edgeLabel,
|
edgeLabel,
|
||||||
pingStale,
|
pingStale,
|
||||||
speedStale,
|
speedStale,
|
||||||
@@ -552,9 +554,12 @@ export default function NetworkMapUnifi({
|
|||||||
filter="url(#edgeGlow)"
|
filter="url(#edgeGlow)"
|
||||||
/>
|
/>
|
||||||
{(() => {
|
{(() => {
|
||||||
const showLabel = e.edgeLabel && (!denseMode || isFocused || e.stale);
|
const compactOnly = denseMode && !isFocused && !e.stale;
|
||||||
if (!showLabel) return null;
|
const labelText = compactOnly
|
||||||
const minDist = denseMode ? 56 : 70;
|
? (e.compactEdgeLabel || e.edgeLabel)
|
||||||
|
: e.edgeLabel;
|
||||||
|
if (!labelText) return null;
|
||||||
|
const minDist = denseMode ? 52 : 70;
|
||||||
let level = 0;
|
let level = 0;
|
||||||
let x; let y;
|
let x; let y;
|
||||||
while (level < 10) {
|
while (level < 10) {
|
||||||
@@ -572,9 +577,11 @@ export default function NetworkMapUnifi({
|
|||||||
const pad = 10;
|
const pad = 10;
|
||||||
const isStale = e.stale === true;
|
const isStale = e.stale === true;
|
||||||
const staleColor = UNIFI_WARNING;
|
const staleColor = UNIFI_WARNING;
|
||||||
const textWidth = e.edgeLabel.length * 6.2;
|
const textWidth = labelText.length * (compactOnly ? 5.9 : 6.2);
|
||||||
const iconWidth = isStale ? 14 : 0;
|
const iconWidth = isStale ? 14 : 0;
|
||||||
const w = Math.max(LABEL_W, Math.min(textWidth + pad * 2 + iconWidth, 210));
|
const minW = compactOnly ? 76 : LABEL_W;
|
||||||
|
const maxW = compactOnly ? 160 : 210;
|
||||||
|
const w = Math.max(minW, Math.min(textWidth + pad * 2 + iconWidth, maxW));
|
||||||
const h = LABEL_H;
|
const h = LABEL_H;
|
||||||
const textX = x - (iconWidth / 2);
|
const textX = x - (iconWidth / 2);
|
||||||
return (
|
return (
|
||||||
@@ -605,10 +612,10 @@ export default function NetworkMapUnifi({
|
|||||||
textAnchor="middle"
|
textAnchor="middle"
|
||||||
dominantBaseline="middle"
|
dominantBaseline="middle"
|
||||||
fill={isStale ? staleColor : edgeColor}
|
fill={isStale ? staleColor : edgeColor}
|
||||||
fontSize={11}
|
fontSize={compactOnly ? 10.2 : 11}
|
||||||
fontWeight={600}
|
fontWeight={600}
|
||||||
>
|
>
|
||||||
{e.edgeLabel}
|
{labelText}
|
||||||
</text>
|
</text>
|
||||||
</g>
|
</g>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user