feat: sort chart options by current probability
This commit is contained in:
parent
3b85c32c9d
commit
3ec3c873ff
|
@ -56,12 +56,11 @@ const getVictoryGroup = ({ data, i }: { data: DataSet; i: number }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const HistoryChart: React.FC<Props> = ({ question }) => {
|
export const HistoryChart: React.FC<Props> = ({ question }) => {
|
||||||
let dataSetsNames: string[] = [];
|
let dataSetsNames = question.options
|
||||||
question.history.forEach((item) => {
|
.sort((a, b) => (a.probability < b.probability ? -1 : 1))
|
||||||
let optionNames = item.options.map((option) => option.name);
|
.map((o) => o.name);
|
||||||
dataSetsNames.push(...optionNames);
|
|
||||||
});
|
|
||||||
dataSetsNames = [...new Set(dataSetsNames)].slice(0, 5); // take the first 5
|
dataSetsNames = [...new Set(dataSetsNames)].slice(0, 5); // take the first 5
|
||||||
|
|
||||||
const isBinary =
|
const isBinary =
|
||||||
(dataSetsNames[0] === "Yes" && dataSetsNames[1] === "No") ||
|
(dataSetsNames[0] === "Yes" && dataSetsNames[1] === "No") ||
|
||||||
(dataSetsNames[0] === "No" && dataSetsNames[1] === "Yes");
|
(dataSetsNames[0] === "No" && dataSetsNames[1] === "Yes");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user