Skip to content

Commit

Permalink
Merge pull request #1327 from openedx/maham/ENT-9538-index-fix
Browse files Browse the repository at this point in the history
[ENT-9538] Fixed index mapping for scatter chart
  • Loading branch information
mahamakifdar19 authored Oct 3, 2024
2 parents b06faa9 + 50d46f4 commit e3b1452
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/AdvanceAnalyticsV2/charts/ScatterChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const ScatterChart = ({

const traces = useMemo(() => categories.map(category => {
const filteredData = data.filter(item => item[colorKey] === category);
// Create a Map to get the index of each item for bubble marker size calculation.
const dataIndexMap = new Map(data.map((item, index) => [item, index]));
return {
x: filteredData.map(item => item[xKey]),
y: filteredData.map(item => item[yKey]),
Expand All @@ -36,7 +38,10 @@ const ScatterChart = ({
name: messages[category] ? intl.formatMessage(messages[category]) : category,
marker: {
color: colorMap[category],
size: filteredData.map((item, index) => markerSizes[index]), // Use the pre-calculated sizes from props
size: filteredData.map(item => {
const index = dataIndexMap.get(item);
return markerSizes[index]; // Use the pre-calculated sizes from props
}),
sizeref: 0.2,
sizemode: 'area',
},
Expand Down

0 comments on commit e3b1452

Please sign in to comment.