Skip to content

Commit 0f1ffde

Browse files
committed
Use Equinor colors for plots
1 parent 60c1690 commit 0f1ffde

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

frontend/src/functions/Colors.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
import chroma from "chroma-js";
22

3-
export const getDistributedColor = (current: number, total: number) => {
4-
return chroma.hsl((360 / total) * current, 0.6, 0.5).hex();
3+
export const EQUINOR_CHART_PALETTE: readonly string[] = [
4+
"#007079", // Moss Green 100
5+
"#FF1243", // Energy Red 100
6+
"#243746", // Slate Blue 100
7+
"#FFC67A", // Spruce Wood 100
8+
"#7193AE", // Mist Blue 100
9+
"#A8CED1", // Lichen Green 55
10+
"#EB0037", // Equinor Red
11+
"#3AADA8", // Moss Green 55
12+
"#FF92A8", // Energy Red 55
13+
] as const;
14+
15+
export const getDistributedColor = (current: number, total: number): string => {
16+
if (total <= 0) return EQUINOR_CHART_PALETTE[0];
17+
18+
if (total <= EQUINOR_CHART_PALETTE.length) {
19+
return EQUINOR_CHART_PALETTE[current % EQUINOR_CHART_PALETTE.length];
20+
}
21+
22+
const scale = chroma.scale([...EQUINOR_CHART_PALETTE]).mode("lab");
23+
return scale(current / Math.max(total - 1, 1)).hex();
524
};

0 commit comments

Comments
 (0)