import * as React from 'react'; import { useMemo } from 'react'; import { Center, Stack, Text, Tooltip } from '@mantine/core'; import * as d3 from 'd3v7'; import { AnimatedLine } from './AnimatedLine'; import { AnimatedText } from './AnimatedText'; import { NAN_REPLACEMENT, VIS_LABEL_COLOR, VIS_TICK_LABEL_SIZE } from '../general/constants'; const textMargin = 2; export function HeatmapText({ margin, yScale, xScale, width, rectHeight, height, rectWidth, isImmediate, }: { margin: { top: number; right: number; bottom: number; left: number }; yScale: d3.ScaleBand; xScale: d3.ScaleBand; width: number; height: number; rectHeight: number; rectWidth: number; isImmediate: boolean; }) { const labelSpacing = useMemo(() => { const maxLabelLength = d3.max(yScale.domain().map((m) => m?.length)); return maxLabelLength > 5 ? 35 : maxLabelLength * 7; }, [yScale]); return ( {xScale.domain().map((xVal, i) => (
{xVal || NAN_REPLACEMENT}
))} {yScale.domain().map((yVal, i) => ( {yVal || NAN_REPLACEMENT} ))}
); }