0
0
Fork 0

Add handler for edge case data points.

This commit is contained in:
Oliver-Akins 2020-08-11 00:48:04 -06:00
parent cc00d4a92d
commit 7c314212d3

View file

@ -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>