import { useMemo, useRef } from 'react'; import { useLinearPrimaryTicks } from 'react-d3-utils'; import { useChartData } from '../context/ChartContext.js'; import { useScaleChecked } from '../context/ScaleContext.js'; import { D3Axis } from '../elements/D3Axis.js'; import { useCheckExportStatus } from '../hooks/useViewportSize.js'; import { useIsInset } from './inset/InsetProvider.js'; interface XAxisProps { label?: string; } export function XAxis1D(props: XAxisProps) { const { label: labelProp } = props; const { height, width, margin, mode } = useChartData(); const { scaleX } = useScaleChecked(); const isInset = useIsInset(); const isExportingProcessStart = useCheckExportStatus(); const label = labelProp || (mode === 'RTL' ? 'δ [ppm]' : 'time [s]'); const refAxis = useRef(null); const scale = useMemo(() => scaleX(null), [scaleX]); const { ticks, scale: ticksScale } = useLinearPrimaryTicks( scale, 'horizontal', refAxis, ); if (!width || !height) { return null; } return ( {!isInset && ( {label} )} ); }