Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(GroupFunnel): Add __rate for GroupFunnel data #378

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/funnel/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,26 @@ const getCovertData = (data: LooseObject[], forwardKey: string, yAxis: string) =
const covertData = [] as LooseObject[];
const fieldY = getFixedFieldY(yAxis);
if (forwardKey) {
const prevs = {} as LooseObject;
const prefixItems = {} as LooseObject;
data.forEach((item: LooseObject) => {
if (!item) {
return;
}
item[fieldY] = item[yAxis];
const prevItem = prevs[item?.[forwardKey]];
const prevItem = prefixItems[item?.[forwardKey]];
if (prevItem) {
if (!item.isPlaceholder) {
prevs[item[forwardKey]] = item;
prefixItems[item[forwardKey]] = item;
const covertYAxisVal = item?.[fieldY] < 0.01 ? prevItem?.[fieldY] - item?.[fieldY] : prevItem?.[fieldY] || 0;
const rate = (item?.[yAxis] / prevItem?.[yAxis]) || 0
const [src, dst] = fixedYAxisValue(item[fieldY], covertYAxisVal);
covertData.push({
...item,
[fieldY]: dst,
prev: { ...prevItem },
column: { ...item },
});
item.__rate = rate
if (item) {
item[fieldY] = src;
}
Expand All @@ -105,9 +107,10 @@ const getCovertData = (data: LooseObject[], forwardKey: string, yAxis: string) =
}
} else {
if (!item?.isPlaceholder) {
prevs[item?.[forwardKey]] = item;
prefixItems[item?.[forwardKey]] = item;
}
covertData.push({ ...item });
item.__rate = 1;
covertData.push({ ...item, __rate: 1 });
}
});
}
Expand Down
Loading