Skip to content

Commit 3a952b1

Browse files
committed
color fix heatmap
1 parent 26caa89 commit 3a952b1

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/components/graphs/HeatMap.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,26 @@ const HeatMapChart = ({
5050
"@import url('https://fonts.googleapis.com/css2?family=Avenir:wght@600');"
5151
);
5252

53-
const colorScale = d3
54-
.scaleSequential()
55-
.domain([rangeMin, rangeMax])
56-
.interpolator(
57-
colors === 'RdYlBu' ? d3.interpolateRdYlBu : d3.interpolatePuRd
58-
);
53+
const customColors = ['#ddebd5', '#f4b183', '#c15811', '#f50101'];
54+
55+
// Create a linear color scale
56+
const customColorScale = d3
57+
.scaleLinear<string>()
58+
.domain([
59+
0,
60+
1 / (customColors.length - 1),
61+
2 / (colors.length - 1),
62+
1,
63+
])
64+
.range(customColors);
65+
66+
const colorScale =
67+
colors === 'RdYlBu'
68+
? d3
69+
.scaleSequential()
70+
.domain([rangeMin, rangeMax])
71+
.interpolator(d3.interpolateRdYlBu)
72+
: customColorScale;
5973

6074
const domain = colorScale.domain();
6175

0 commit comments

Comments
 (0)