import * as React from 'react'; import { useMemo } from 'react'; import { Center, Text, Tooltip, rem } from '@mantine/core'; import { VIS_GRID_COLOR, VIS_LABEL_COLOR, VIS_TICK_LABEL_SIZE, VIS_TICK_LABEL_SIZE_SMALL } from '../general/constants'; // code taken from https://wattenberger.com/blog/react-and-d3 export function XAxis({ xScale, yRange, vertPosition, multiples = false }) { const ticks = useMemo(() => { return xScale.ticks(5).map((value) => ({ value, xOffset: xScale(value), })); }, [xScale]); const tickWidth = useMemo(() => { if (ticks.length > 1) { return Math.abs(ticks[1].xOffset - ticks[0].xOffset); } return xScale.range()[0] - xScale.range()[1]; }, [ticks, xScale]); return ( <> {ticks.map(({ value, xOffset }) => ( {yRange ? : null}
{value}
))} ); }