Fixed bug with rankings display.

This commit is contained in:
Mike Cao 2020-08-19 23:30:31 -07:00
parent b905824d50
commit d95e149cf6
3 changed files with 8 additions and 5 deletions

View File

@ -58,7 +58,7 @@ export default function RankingsChart({
const { x, y, z } = rankings[index]; const { x, y, z } = rankings[index];
return ( return (
<div style={style}> <div style={style}>
<AnimatedRow key={x} label={x} value={y} percent={z} animate={limit} /> <AnimatedRow key={x} label={x} value={y} percent={z} animate={limit} format={formatFunc} />
</div> </div>
); );
}; };
@ -108,7 +108,7 @@ export default function RankingsChart({
); );
} }
const AnimatedRow = ({ label, value, percent, animate, format }) => { const AnimatedRow = ({ label, value = 0, percent, animate, format }) => {
const props = useSpring({ const props = useSpring({
width: percent, width: percent,
y: value, y: value,
@ -119,7 +119,7 @@ const AnimatedRow = ({ label, value, percent, animate, format }) => {
return ( return (
<div className={styles.row}> <div className={styles.row}>
<div className={styles.label}>{label}</div> <div className={styles.label}>{label}</div>
<animated.div className={styles.value}>{props.y.interpolate(format)}</animated.div> <animated.div className={styles.value}>{props.y?.interpolate(format)}</animated.div>
<div className={styles.percent}> <div className={styles.percent}>
<animated.div <animated.div
className={styles.bar} className={styles.bar}

View File

@ -44,7 +44,9 @@ export function formatNumber(n) {
return Number(n).toFixed(0); return Number(n).toFixed(0);
} }
export function formatLongNumber(n) { export function formatLongNumber(value) {
const n = Number(value);
if (n >= 1000000) { if (n >= 1000000) {
return `${(n / 1000000).toFixed(1)}m`; return `${(n / 1000000).toFixed(1)}m`;
} }
@ -57,5 +59,6 @@ export function formatLongNumber(n) {
if (n >= 1000) { if (n >= 1000) {
return `${(n / 1000).toFixed(2)}k`; return `${(n / 1000).toFixed(2)}k`;
} }
return formatNumber(n); return formatNumber(n);
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "umami", "name": "umami",
"version": "0.10.2", "version": "0.10.3",
"description": "A simple, fast, website analytics alternative to Google Analytics. ", "description": "A simple, fast, website analytics alternative to Google Analytics. ",
"author": "Mike Cao <mike@mikecao.com>", "author": "Mike Cao <mike@mikecao.com>",
"license": "MIT", "license": "MIT",