diff --git a/examples/graph-layers/graph-viewer/layout-options-panel.tsx b/examples/graph-layers/graph-viewer/layout-options-panel.tsx index 2c0d4e86..b77448b7 100644 --- a/examples/graph-layers/graph-viewer/layout-options-panel.tsx +++ b/examples/graph-layers/graph-viewer/layout-options-panel.tsx @@ -312,13 +312,22 @@ export function LayoutOptionsPanel({ appliedOptions, onApply }: LayoutOptionsPanelProps) { + const [isDagOptionsOpen, setIsDagOptionsOpen] = useState(true); + const handleDagToggle = useCallback((event: React.SyntheticEvent) => { + setIsDagOptionsOpen(event.currentTarget.open); + }, []); + if (!layout) { return null; } if (layout === 'd3-dag-layout') { return ( -
+
{ + const width = Number(value); + if (!Number.isFinite(width) || width <= 0) { + return TEXT_LAYER_MAX_SAFE_WIDTH; + } + return Math.min(width, TEXT_LAYER_MAX_SAFE_WIDTH); +}; + +const normalizeMaxWidth = (value: unknown) => { + if (typeof value === 'function') { + return (d: unknown) => clampMaxWidth((value as (arg0: unknown) => unknown)(d)); + } + return clampMaxWidth(value); +}; + export class ZoomableTextLayer extends CompositeLayer { static layerName = 'ZoomableTextLayer'; @@ -59,6 +78,8 @@ export class ZoomableTextLayer extends CompositeLayer { // getText only expects function not plain value (string) const newGetText = typeof getText === 'function' ? getText : () => getText; + const resolvedMaxWidth = normalizeMaxWidth(textMaxWidth); + return [ new TextLayer( this.getSubLayerProps({ @@ -73,7 +94,7 @@ export class ZoomableTextLayer extends CompositeLayer { getAlignmentBaseline, getAngle, getText: newGetText, - maxWidth: textMaxWidth ?? 12, + maxWidth: resolvedMaxWidth, wordBreak: textWordBreak ?? 'break-all', fontFamily: fontFamily ?? 'Red Hat Text', wordUnits: textWordUnits ?? 'pixels',