mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-05 02:52:50 -05:00
fix: column ordering (#4621)
This commit is contained in:
committed by
GitHub
parent
25f99da172
commit
f68f87645f
+4
-2
@@ -48,7 +48,9 @@ export const MatrixQuestionSummary = ({
|
||||
return "";
|
||||
};
|
||||
|
||||
const columns = questionSummary.data[0] ? Object.keys(questionSummary.data[0].columnPercentages) : [];
|
||||
const columns = questionSummary.data[0]
|
||||
? questionSummary.data[0].columnPercentages.map((c) => c.column)
|
||||
: [];
|
||||
|
||||
return (
|
||||
<div className="rounded-xl border border-slate-200 bg-white shadow-sm">
|
||||
@@ -81,7 +83,7 @@ export const MatrixQuestionSummary = ({
|
||||
<p className="max-w-40 overflow-hidden text-ellipsis whitespace-nowrap">{rowLabel}</p>
|
||||
</TooltipRenderer>
|
||||
</td>
|
||||
{Object.entries(columnPercentages).map(([column, percentage]) => (
|
||||
{columnPercentages.map(({ column, percentage }) => (
|
||||
<td
|
||||
key={column}
|
||||
className="text-center text-slate-500 dark:border-slate-700 dark:text-slate-400">
|
||||
|
||||
+6
-4
@@ -778,13 +778,15 @@ export const getQuestionSummary = async (
|
||||
totalResponsesForRow += countMap[row][col];
|
||||
});
|
||||
|
||||
const columnPercentages = columns.reduce((acc, col) => {
|
||||
const columnPercentages = columns.map((col) => {
|
||||
const count = countMap[row][col];
|
||||
const percentage =
|
||||
totalResponsesForRow > 0 ? ((count / totalResponsesForRow) * 100).toFixed(2) : "0.00";
|
||||
acc[col] = percentage;
|
||||
return acc;
|
||||
}, {});
|
||||
return {
|
||||
column: col,
|
||||
percentage: Number(percentage),
|
||||
};
|
||||
});
|
||||
|
||||
return { rowLabel: row, columnPercentages, totalResponsesForRow };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user