fix(dashboard,api): show correct percentage on retention
This commit is contained in:
@@ -36,11 +36,12 @@ export function Chart({ data }: Props) {
|
|||||||
tickFormatter: (value) => `${value}%`,
|
tickFormatter: (value) => `${value}%`,
|
||||||
});
|
});
|
||||||
const averageRow = data[0];
|
const averageRow = data[0];
|
||||||
const averageRetentionRate = average(averageRow?.percentages || [], true);
|
const averageRetentionRate =
|
||||||
const rechartData = averageRow?.percentages.map((item, index, list) => ({
|
average(averageRow?.percentages || [], true) * 100;
|
||||||
|
const rechartData = averageRow?.percentages.map((item, index) => ({
|
||||||
days: index,
|
days: index,
|
||||||
percentage: item,
|
percentage: item * 100,
|
||||||
value: averageRow.values[index],
|
value: averageRow.values?.[index],
|
||||||
sum: averageRow.sum,
|
sum: averageRow.sum,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export function RetentionTooltip({ active, payload }: Props) {
|
|||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<span className="text-muted-foreground">Retention Rate:</span>
|
<span className="text-muted-foreground">Retention Rate:</span>
|
||||||
<span className="font-medium">
|
<span className="font-medium">
|
||||||
{number.formatWithUnit(percentage, '%')}
|
{number.formatWithUnit(percentage / 100, '%')}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
|
|||||||
@@ -402,9 +402,7 @@ function processCohortData(
|
|||||||
cohort_interval: row.cohort_interval,
|
cohort_interval: row.cohort_interval,
|
||||||
sum,
|
sum,
|
||||||
values: values,
|
values: values,
|
||||||
percentages: values.map((value) =>
|
percentages: values.map((value) => (sum > 0 ? round(value / sum, 2) : 0)),
|
||||||
sum > 0 ? round((value / sum) * 100, 2) : 0,
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user