import { Fragment } from 'react'; import { XAxis, YAxis } from 'recharts'; import { TOKEN_COLOR_TEXT_SUBTLE, TOKEN_FONT_FAMILY_DEFAULT_LATIN, TOKEN_FONT_SIZE_100, TOKEN_FONT_WEIGHT_NORMAL, } from 'gestalt-design-tokens'; export default function renderAxis({ isHorizontalLayout, isHorizontalBiaxialLayout, isVerticalLayout, isTimeSeries, isVerticalBiaxialLayout, range, tickFormatter, labelMap, tickCount, }: { isHorizontalLayout: boolean; isHorizontalBiaxialLayout: boolean; isVerticalLayout: boolean; isVerticalBiaxialLayout: boolean; isTimeSeries: boolean; range: | [ number | 'auto' | 'dataMin' | 'dataMax' | ((arg1: number) => number), number | 'auto' | 'dataMin' | 'dataMax' | ((arg1: number) => number), ] | { xAxisBottom?: [ number | 'auto' | 'dataMin' | 'dataMax' | ((arg1: number) => number), number | 'auto' | 'dataMin' | 'dataMax' | ((arg1: number) => number), ]; xAxisTop?: [ number | 'auto' | 'dataMin' | 'dataMax' | ((arg1: number) => number), number | 'auto' | 'dataMin' | 'dataMax' | ((arg1: number) => number), ]; yAxisLeft?: [ number | 'auto' | 'dataMin' | 'dataMax' | ((arg1: number) => number), number | 'auto' | 'dataMin' | 'dataMax' | ((arg1: number) => number), ]; yAxisRight?: [ number | 'auto' | 'dataMin' | 'dataMax' | ((arg1: number) => number), number | 'auto' | 'dataMin' | 'dataMax' | ((arg1: number) => number), ]; }; tickFormatter?: { timeseries?: (arg1: number) => string | number; xAxisTop?: (arg1: number, arg2: number) => string | number; xAxisBottom?: (arg1: number, arg2: number) => string | number; yAxisRight?: (arg1: number, arg2: number) => string | number; yAxisLeft?: (arg1: number, arg2: number) => string | number; }; labelMap?: { [key: string]: string; }; tickCount: 5 | 3; }) { const FONT_STYLE_CATEGORIES = { fontSize: TOKEN_FONT_SIZE_100, fontFamily: TOKEN_FONT_FAMILY_DEFAULT_LATIN, fontWeight: TOKEN_FONT_WEIGHT_NORMAL, } as const; const FONT_STYLE_VALUES = { color: TOKEN_COLOR_TEXT_SUBTLE, fontSize: TOKEN_FONT_SIZE_100, fontFamily: TOKEN_FONT_FAMILY_DEFAULT_LATIN, fontWeight: TOKEN_FONT_WEIGHT_NORMAL, } as const; const isRtl = typeof document === 'undefined' ? false : document?.dir === 'rtl'; return ( {isHorizontalLayout && ( {/* @ts-expect-error - TS2769 - No overload matches this call. */} labelMap?.[value] || value } tickLine={false} type={isTimeSeries ? 'number' : 'category'} // DO NOT SET xAxisId here (it breaks the component, opaque behavior from Recharts) /> {/* @ts-expect-error - TS2769 - No overload matches this call. */} )} {isHorizontalBiaxialLayout && ( // @ts-expect-error - TS2769 - No overload matches this call. )} {isVerticalLayout && ( {/* @ts-expect-error - TS2769 - No overload matches this call. */} labelMap?.[value] || value} tickLine={false} type="category" // DO NOT SET yAxisId here /> )} {isVerticalBiaxialLayout && ( // @ts-expect-error - TS2769 - No overload matches this call. )} ); }