import { ZOOM_LAYOUT } from '../actions/zoom-toggle' /** * If the option includes a `dataZoom` array (from ZoomToggle's transform), * lift any slider entries above the legend row so they don't overlap. * Returns `null` when there is no `dataZoom` — caller skips the layout * adjustment entirely. * * Shared between bar, histogram, and timeseries — every widget with a * horizontal x-axis dataZoom slider needs the same offset when a legend * is rendered below the plot. */ export function positionDataZoomForLegend( dataZoom: unknown, hasLegend: boolean, ): unknown[] | null { if (!Array.isArray(dataZoom) || dataZoom.length === 0) return null return dataZoom.map((entry: unknown) => { if (entry == null || typeof entry !== 'object') return entry const dz = entry as { type?: string; bottom?: number } if (dz.type === 'slider' && hasLegend) { return { ...dz, bottom: ZOOM_LAYOUT.sliderBottomWithLegend } } return dz }) }