mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Fixed change labels display.
This commit is contained in:
parent
6c79175077
commit
9abb201d86
2 changed files with 7 additions and 6 deletions
|
|
@ -62,7 +62,7 @@ export function WebsiteMetricsBar({
|
||||||
change:
|
change:
|
||||||
(Math.min(visitors.value, bounces.value) / visitors.value) * 100 -
|
(Math.min(visitors.value, bounces.value) / visitors.value) * 100 -
|
||||||
(Math.min(visitors.prev, bounces.prev) / visitors.prev) * 100,
|
(Math.min(visitors.prev, bounces.prev) / visitors.prev) * 100,
|
||||||
formatValue: n => Number(n).toFixed(0) + '%',
|
formatValue: n => Math.round(+n) + '%',
|
||||||
reverseColors: true,
|
reverseColors: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -19,21 +19,22 @@ export function ChangeLabel({
|
||||||
className?: string;
|
className?: string;
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
const positive = value * (reverseColors ? -1 : 1) >= 0;
|
const positive = value >= 0;
|
||||||
const negative = value * (reverseColors ? -1 : 1) < 0;
|
const negative = value < 0;
|
||||||
const neutral = value === 0 || isNaN(value);
|
const neutral = value === 0 || isNaN(value);
|
||||||
|
const good = reverseColors ? negative : positive;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(styles.label, className, {
|
className={classNames(styles.label, className, {
|
||||||
[styles.positive]: positive,
|
[styles.positive]: good,
|
||||||
[styles.negative]: negative,
|
[styles.negative]: !good,
|
||||||
[styles.neutral]: neutral,
|
[styles.neutral]: neutral,
|
||||||
})}
|
})}
|
||||||
title={title}
|
title={title}
|
||||||
>
|
>
|
||||||
{!neutral && (
|
{!neutral && (
|
||||||
<Icon rotate={value === 0 ? 0 : positive || reverseColors ? -90 : 90} size={size}>
|
<Icon rotate={positive ? -90 : 90} size={size}>
|
||||||
<Icons.ArrowRight />
|
<Icons.ArrowRight />
|
||||||
</Icon>
|
</Icon>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue