Add handler for edge case data points.
This commit is contained in:
parent
cc00d4a92d
commit
7c314212d3
1 changed files with 16 additions and 1 deletions
|
|
@ -21,7 +21,7 @@
|
||||||
>
|
>
|
||||||
<percent
|
<percent
|
||||||
:size="40"
|
:size="40"
|
||||||
:progress="Math.round(value * 100)"
|
:progress="get_percentage(name)"
|
||||||
:color="css_var('--percent-filled')"
|
:color="css_var('--percent-filled')"
|
||||||
:empty-color="css_var('--percent-empty')"
|
:empty-color="css_var('--percent-empty')"
|
||||||
:loading="!data_populated"
|
:loading="!data_populated"
|
||||||
|
|
@ -83,6 +83,21 @@ export default {
|
||||||
.catch(err => console.error(err))
|
.catch(err => console.error(err))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
get_percentage(key) {
|
||||||
|
let value = this.data_points[key];
|
||||||
|
|
||||||
|
// Calculate data value
|
||||||
|
switch (key) {
|
||||||
|
case `loudness`:
|
||||||
|
return Math.round((10 ** (value / 10) * 100));
|
||||||
|
case `popularity`:
|
||||||
|
return this.track.popularity;
|
||||||
|
default:
|
||||||
|
return Math.round(value * 100);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue