Fix chart y axis and other small styling tweaks#470
Conversation
PR Review: Fix chart y axis and other small styling tweaks🟡 Code Quality / Performance
In const yAxisWidth = useMemo(() => {
const maxValue = Math.max(...transformer(data), 0)
return maxValue.toLocaleString().length * pxPerChar
}, [data, transformer])Every caller passes an inline arrow function, which creates a new reference each render: // BarChartCard.tsx — new function reference every render
const { yAxisProps } = useYAxis({
data,
transformer: (d) => {
return d.flatMap((item) => bars.map((bar) => ...))
}
})Since const transformerRef = useRef(transformer)
transformerRef.current = transformer
const yAxisWidth = useMemo(() => {
const maxValue = Math.max(...transformerRef.current(data), 0)
return maxValue.toLocaleString().length * pxPerChar
}, [data])🔵 Minor
// StatGlobalValueChart.tsx — hasData not passed
<ChartCard
title='Global value'
loading={loading}
error={error}
// hasData={dataPoints.length > 0} <-- missing
> |
No description provided.