From fb491742eed8ab5b01c52010da0931ccc2c3924e Mon Sep 17 00:00:00 2001 From: MichalKalke Date: Fri, 30 Sep 2022 11:58:48 +0200 Subject: [PATCH 1/2] Add dynamic heatmap --- .../src/components/Heatmap/Colors.js | 12 ++++++------ .../src/components/Heatmap/Heatmap.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/smart-kickers-game/src/components/Heatmap/Colors.js b/frontend/smart-kickers-game/src/components/Heatmap/Colors.js index b1bfdf2..bd034ad 100644 --- a/frontend/smart-kickers-game/src/components/Heatmap/Colors.js +++ b/frontend/smart-kickers-game/src/components/Heatmap/Colors.js @@ -37,19 +37,19 @@ export const Colors = { }, }; -export function chooseColor(value) { +export function chooseColor(value, max) { switch (true) { case value <= 2: return returnCellColor(Colors.none); - case value <= 5: + case value <= max / 6: return returnCellColor(Colors.blue); - case value <= 10: + case value <= max / 3: return returnCellColor(Colors.purple); - case value <= 15: + case value <= max / 2: return returnCellColor(Colors.green); - case value <= 25: + case value <= (5 * max) / 6: return returnCellColor(Colors.yellow); - case value > 25: + case value > (5 * max) / 6: return returnCellColor(Colors.red); default: return returnCellColor(Colors.none); diff --git a/frontend/smart-kickers-game/src/components/Heatmap/Heatmap.js b/frontend/smart-kickers-game/src/components/Heatmap/Heatmap.js index 409dbba..c4172c0 100644 --- a/frontend/smart-kickers-game/src/components/Heatmap/Heatmap.js +++ b/frontend/smart-kickers-game/src/components/Heatmap/Heatmap.js @@ -17,7 +17,7 @@ function Heatmap() { yLabels={heatmap.array} data={heatmap.numbers} cellStyle={(background, value, min, max) => ({ - background: `${chooseColor(value)} `, + background: `${chooseColor(value, max)} `, fontSize: '0px', color: '#444', width: '6.56px', From 6604e5aab038a3989df11c0cc49513aeaee3f29c Mon Sep 17 00:00:00 2001 From: MichalKalke Date: Fri, 30 Sep 2022 12:04:03 +0200 Subject: [PATCH 2/2] Rename colors to match heatmap --- .../src/components/Heatmap/Colors.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/smart-kickers-game/src/components/Heatmap/Colors.js b/frontend/smart-kickers-game/src/components/Heatmap/Colors.js index bd034ad..9eba7f7 100644 --- a/frontend/smart-kickers-game/src/components/Heatmap/Colors.js +++ b/frontend/smart-kickers-game/src/components/Heatmap/Colors.js @@ -5,25 +5,25 @@ export const Colors = { blue: 0, opacity: 0.75, }, - yellow: { + orange: { red: 225, green: 101, blue: 25, opacity: 1, }, - green: { + yellow: { red: 202, green: 206, blue: 23, opacity: 0.75, }, - purple: { + lightGreen: { red: 56, green: 140, blue: 4, opacity: 0.5, }, - blue: { + darkGreen: { red: 4, green: 115, blue: 49, @@ -42,13 +42,13 @@ export function chooseColor(value, max) { case value <= 2: return returnCellColor(Colors.none); case value <= max / 6: - return returnCellColor(Colors.blue); + return returnCellColor(Colors.darkGreen); case value <= max / 3: - return returnCellColor(Colors.purple); + return returnCellColor(Colors.lightGreen); case value <= max / 2: - return returnCellColor(Colors.green); - case value <= (5 * max) / 6: return returnCellColor(Colors.yellow); + case value <= (5 * max) / 6: + return returnCellColor(Colors.orange); case value > (5 * max) / 6: return returnCellColor(Colors.red); default: