This commit is contained in:
Andras Schmelczer 2026-05-11 21:38:26 +01:00
parent 9248e26af2
commit f2a2651b8a
95 changed files with 3993 additions and 1471 deletions

View file

@ -1,3 +1,5 @@
import { useTranslation } from 'react-i18next';
function downsampleBars(counts: number[], targetBars: number): number[] {
const step = Math.max(1, Math.floor(counts.length / targetBars));
const bars: number[] = [];
@ -34,7 +36,7 @@ export function DualHistogram({
p1,
p99,
globalMean,
meanLabel = 'National avg',
meanLabel,
formatLabel,
}: {
localCounts: number[];
@ -45,6 +47,7 @@ export function DualHistogram({
meanLabel?: string;
formatLabel?: (value: number) => string;
}) {
const { t } = useTranslation();
const targetBars = 25;
const localBars = downsampleBars(localCounts, targetBars);
const globalBars = downsampleBars(globalCounts, targetBars);
@ -124,7 +127,7 @@ export function DualHistogram({
className="absolute top-0 max-w-[7rem] truncate rounded-sm border border-warm-300 bg-white px-1 py-0.5 text-[9px] font-medium leading-none text-warm-600 shadow-sm dark:border-warm-600 dark:bg-navy-900 dark:text-warm-300"
style={meanLabelStyle}
>
{meanLabel}
{meanLabel ?? t('areaPane.nationalAvg')}
</div>
<div className="absolute bottom-0 top-5 w-px border-l border-dashed border-warm-400 dark:border-warm-500" />
</div>