Fix the issue that chart(scatter, line, bubble...) having same x-value have wrong y-value (#7330)

This commit is contained in:
Tsuneo Yoshioka
2025-02-19 05:04:12 +09:00
committed by GitHub
parent e95de2ee4c
commit 8387fe6fcb

View File

@@ -99,8 +99,8 @@ function prepareSeries(series: any, options: any, numSeries: any, additionalOpti
};
const sourceData = new Map();
const labelsValuesMap = new Map();
const xValues: any[] = [];
const yValues: any[] = [];
const yErrorValues: any = [];
each(data, row => {
@@ -108,27 +108,20 @@ function prepareSeries(series: any, options: any, numSeries: any, additionalOpti
const y = cleanYValue(row.y, seriesYAxis === "y2" ? options.yAxis[1].type : options.yAxis[0].type); // depends on series type!
const yError = cleanNumber(row.yError); // always number
const size = cleanNumber(row.size); // always number
if (labelsValuesMap.has(x)) {
labelsValuesMap.set(x, labelsValuesMap.get(x) + y);
} else {
labelsValuesMap.set(x, y);
}
const aggregatedY = labelsValuesMap.get(x);
sourceData.set(x, {
x,
y: aggregatedY,
y,
yError,
size,
yPercent: null, // will be updated later
row,
});
xValues.push(x);
yValues.push(y);
yErrorValues.push(yError);
});
const xValues = Array.from(labelsValuesMap.keys());
const yValues = Array.from(labelsValuesMap.values());
const plotlySeries = {
visible: true,
hoverinfo: hoverInfoPattern,