Skip to content

Commit

Permalink
[#148] Fix line chart error when yAxis not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
wayangalihpratama committed Dec 11, 2023
1 parent dc83303 commit c053924
Showing 1 changed file with 58 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,61 +41,64 @@ const getOptions = ({
: answers.find((a) => a.name === yAxis.name)?.qid;
const yAxisDefaultValue = { default_value: yAxisCalculation[`#${yAxisId}`] };

const series = binCharts.map((b) => {
const bId = b.binName.includes("Diversified")
? 9002
: answers.find((a) => a.name === b.binName)?.qid;
const dt = xAxisData
.map((h) => {
let newValues = answers
.filter((m) => m.name !== b.binName)
.map((m) => {
if (m.name === xAxis.name) {
return { ...m, value: h };
}
return m;
const series = yAxisDefaultValue.default_value
? binCharts.map((b) => {
const bId = b.binName.includes("Diversified")
? 9002
: answers.find((a) => a.name === b.binName)?.qid;
const dt = xAxisData
.map((h) => {
let newValues = answers
.filter((m) => m.name !== b.binName)
.map((m) => {
if (m.name === xAxis.name) {
return { ...m, value: h };
}
return m;
})
.map((x) => ({
id: `c-${x.qid}`,
value: x.value,
}));
newValues = [
...newValues,
{
id: "c-9001",
value: total_current_income,
},
{
id: "c-9002",
value: diversified,
},
{
id: `c-${bId}`,
value: b.binValue,
},
];
const newYAxisValue = getFunctionDefaultValue(
yAxisDefaultValue,
"c",
newValues
);
return newYAxisValue.toFixed(2);
})
.map((x) => ({
id: `c-${x.qid}`,
value: x.value,
}));
newValues = [
...newValues,
{
id: "c-9001",
value: total_current_income,
},
{
id: "c-9002",
value: diversified,
.flatMap((x) => x);
return {
type: "line",
smooth: true,
stack: yAxis.name,
name: `${b.binName}: ${b.binValue}`,
data: dt,
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowColor: "rgba(0, 0, 0, 0.5)",
},
},
{
id: `c-${bId}`,
value: b.binValue,
},
];
const newYAxisValue = getFunctionDefaultValue(
yAxisDefaultValue,
"c",
newValues
);
return newYAxisValue.toFixed(2);
};
})
.flatMap((x) => x);
return {
type: "line",
smooth: true,
stack: yAxis.name,
name: `${b.binName}: ${b.binValue}`,
data: dt,
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowColor: "rgba(0, 0, 0, 0.5)",
},
},
};
});
: [];

const legends = binCharts.map((b) => `${b.binName}: ${b.binValue}`);

const options = {
Expand Down Expand Up @@ -222,7 +225,7 @@ const ChartSensitivityAnalysisLine = ({ data, segment, origin }) => {
};
}, [data, segment, origin]);

return (
return binningData.binCharts?.length ? (
<Col span={24}>
<Row gutter={[24, 24]} ref={elLineChart}>
<Col span={8}>
Expand Down Expand Up @@ -255,6 +258,8 @@ const ChartSensitivityAnalysisLine = ({ data, segment, origin }) => {
</Col>
</Row>
</Col>
) : (
""
);
};

Expand Down

0 comments on commit c053924

Please # to comment.