Skip to content

Commit bc5926a

Browse files
committed
color bivariate chart category x category changed to steelblue and orange
1 parent 2ce99c9 commit bc5926a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/components/DistributionReport.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ export const DistributionReport = (
332332
className="flex flex-col"
333333
>
334334
<GroupBarChart
335+
colorRange={[
336+
'steelblue',
337+
'orange',
338+
]}
335339
yAxisLabel={t(
336340
'distribution.percentage'
337341
)}

src/components/graphs/GroupBarChart.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@ interface GroupBarChartProps {
1010
yAxisLabel: string;
1111
title: string;
1212
data: Data[];
13+
colorRange?: string[];
1314
}
1415

1516
const margin = { top: 30, right: 50, bottom: 40, left: 80 };
1617
const height = 300 - margin.top - margin.bottom;
1718
const barWidth = 0.05 * window.innerWidth < 40 ? 40 : 0.05 * window.innerWidth;
1819
const barGap = 5;
1920

20-
const GroupBarChart = ({ title, data, yAxisLabel }: GroupBarChartProps) => {
21+
const GroupBarChart = ({
22+
title,
23+
data,
24+
yAxisLabel,
25+
colorRange,
26+
}: GroupBarChartProps) => {
2127
const svgRef = useRef<SVGSVGElement>(null);
2228
const containerRef = useRef<HTMLDivElement>(null);
2329
const [containerWidth, setContainerWidth] = useState(800); // Default width
@@ -57,7 +63,10 @@ const GroupBarChart = ({ title, data, yAxisLabel }: GroupBarChartProps) => {
5763
const color = d3
5864
.scaleOrdinal()
5965
.domain(groupbarNames)
60-
.range(d3.schemeSpectral[Math.max(Math.min(groupbarNames.size, 11), 3)])
66+
.range(
67+
colorRange ??
68+
d3.schemeSpectral[Math.max(Math.min(groupbarNames.size, 11), 3)]
69+
)
6170
.unknown('#ccc');
6271

6372
const y = useMemo(

0 commit comments

Comments
 (0)