Skip to content

Commit

Permalink
Fix the issue that chart(scatter, line, bubble...) having same x-valu…
Browse files Browse the repository at this point in the history
…e have wrong y-value (getredash#7330)
  • Loading branch information
yoshiokatsuneo authored Feb 18, 2025
1 parent e95de2e commit 8387fe6
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions viz-lib/src/visualizations/chart/plotly/prepareDefaultData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,36 +99,29 @@ 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 => {
const x = normalizeValue(row.x, options.xAxis.type); // number/datetime/category
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,
Expand Down

0 comments on commit 8387fe6

Please sign in to comment.