From 20b7bc08e08ef1409edeb9973eba20a2d6e88d8f Mon Sep 17 00:00:00 2001 From: Valentin Kaelin Date: Sat, 22 Aug 2020 15:12:01 +0200 Subject: [PATCH] fix(champions): background color 0 opacity if kda was Infinity --- .../src/components/Summoner/Champions/ChampionsTable.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/src/components/Summoner/Champions/ChampionsTable.vue b/client/src/components/Summoner/Champions/ChampionsTable.vue index 27c70e0..91e30b0 100644 --- a/client/src/components/Summoner/Champions/ChampionsTable.vue +++ b/client/src/components/Summoner/Champions/ChampionsTable.vue @@ -233,8 +233,13 @@ export default { methods: { bgColor(champion, rgb, stats) { - const value = parseFloat(champion[stats]) - const biggestValue = Math.max(...this.championsToDisplay.map(c => parseFloat(c[stats])), 0) + const biggestValue = Math.max( + ...this.championsToDisplay + .filter(c => c[stats] !== Infinity) + .map(c => parseFloat(c[stats])) + , 0) + // Take the second biggest Value if it's an Infinity KDA + const value = champion[stats] === Infinity ? biggestValue : parseFloat(champion[stats]) const opacity = (value / biggestValue).toFixed(2) return {