Skip to content

Commit 013c7c2

Browse files
committed
fix: precipitation and rain color scale
1 parent 4468acb commit 013c7c2

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

src/lib/utils/color-scales.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function interpolateColorScaleHSL(colors: Array<string>, steps: number) {
55
const stepsPerSegment = Math.floor(steps / segments);
66
const remainder = steps % segments;
77

8-
const rgbArray = [];
8+
const rgbArray: number[][] = [];
99

1010
for (let i = 0; i < segments; i++) {
1111
const startColor = colors[i];
@@ -27,7 +27,29 @@ function interpolateColorScaleHSL(colors: Array<string>, steps: number) {
2727
return rgbArray;
2828
}
2929

30-
export const colorScales = {
30+
type ColorScale = {
31+
min: number;
32+
max: number;
33+
scalefactor: number;
34+
colors: number[][];
35+
};
36+
37+
type ColorScales = {
38+
[key: string]: ColorScale;
39+
};
40+
41+
const precipScale: ColorScale = {
42+
min: 0,
43+
max: 20,
44+
scalefactor: 1,
45+
colors: [
46+
...interpolateColorScaleHSL(['blue', 'green'], 5), // 0 to 5mm
47+
...interpolateColorScaleHSL(['green', 'orange'], 5), // 5 to 10mm
48+
...interpolateColorScaleHSL(['orange', 'red'], 10) // 10 to 20mm
49+
]
50+
};
51+
52+
export const colorScales: ColorScales = {
3153
cape: {
3254
min: 0,
3355
max: 4000,
@@ -47,15 +69,7 @@ export const colorScales = {
4769
...interpolateColorScaleHSL(['#FFF', '#c3c2c2'], 100) // 0 to 100%
4870
]
4971
},
50-
precipitation: {
51-
min: 0,
52-
max: 20,
53-
colors: [
54-
...interpolateColorScaleHSL(['blue', 'green'], 5), // 0 to 5mm
55-
...interpolateColorScaleHSL(['green', 'orange'], 5), // 5 to 10mm
56-
...interpolateColorScaleHSL(['orange', 'red'], 10) // 10 to 20mm
57-
]
58-
},
72+
precipitation: precipScale,
5973
pressure: {
6074
min: 950,
6175
max: 1050,
@@ -65,6 +79,7 @@ export const colorScales = {
6579
...interpolateColorScaleHSL(['#FFFFFF', '#FF4444'], 25) // 1000hPa to 1050hPa
6680
]
6781
},
82+
rain: precipScale,
6883
relative: {
6984
min: 0,
7085
max: 100,

src/lib/utils/variables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ for (const height of heights) {
8484
variables.push({ value: `wind_${height}m`, label: `Wind ${height}m` });
8585
}
8686

87-
export const hideZero = ['precipitation', 'cloud_cover'];
87+
export const hideZero = ['precipitation', 'cloud_cover', 'rain'];
8888
export const requestMultiple = [
8989
'wind_10m',
9090
'wind_40m',

0 commit comments

Comments
 (0)