fix(champions): background color 0 opacity if kda was Infinity

This commit is contained in:
Valentin Kaelin 2020-08-22 15:12:01 +02:00
parent 7f631d2662
commit 20b7bc08e0

View file

@ -233,8 +233,13 @@ export default {
methods: { methods: {
bgColor(champion, rgb, stats) { bgColor(champion, rgb, stats) {
const value = parseFloat(champion[stats]) const biggestValue = Math.max(
const biggestValue = Math.max(...this.championsToDisplay.map(c => parseFloat(c[stats])), 0) ...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) const opacity = (value / biggestValue).toFixed(2)
return { return {