Skip to content

Commit 8387fe6

Browse files
Fix the issue that chart(scatter, line, bubble...) having same x-value have wrong y-value (#7330)
1 parent e95de2e commit 8387fe6

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

viz-lib/src/visualizations/chart/plotly/prepareDefaultData.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,36 +99,29 @@ function prepareSeries(series: any, options: any, numSeries: any, additionalOpti
9999
};
100100

101101
const sourceData = new Map();
102-
103-
const labelsValuesMap = new Map();
102+
const xValues: any[] = [];
103+
const yValues: any[] = [];
104104

105105
const yErrorValues: any = [];
106106
each(data, row => {
107107
const x = normalizeValue(row.x, options.xAxis.type); // number/datetime/category
108108
const y = cleanYValue(row.y, seriesYAxis === "y2" ? options.yAxis[1].type : options.yAxis[0].type); // depends on series type!
109109
const yError = cleanNumber(row.yError); // always number
110110
const size = cleanNumber(row.size); // always number
111-
if (labelsValuesMap.has(x)) {
112-
labelsValuesMap.set(x, labelsValuesMap.get(x) + y);
113-
} else {
114-
labelsValuesMap.set(x, y);
115-
}
116-
const aggregatedY = labelsValuesMap.get(x);
117111

118112
sourceData.set(x, {
119113
x,
120-
y: aggregatedY,
114+
y,
121115
yError,
122116
size,
123117
yPercent: null, // will be updated later
124118
row,
125119
});
120+
xValues.push(x);
121+
yValues.push(y);
126122
yErrorValues.push(yError);
127123
});
128124

129-
const xValues = Array.from(labelsValuesMap.keys());
130-
const yValues = Array.from(labelsValuesMap.values());
131-
132125
const plotlySeries = {
133126
visible: true,
134127
hoverinfo: hoverInfoPattern,

0 commit comments

Comments
 (0)