From 50d46f41c73574be1b07ee0fb05f49d855a1df48 Mon Sep 17 00:00:00 2001 From: Maham Akif Date: Thu, 3 Oct 2024 12:49:58 +0500 Subject: [PATCH] fix: fixed index mapping for scatter chart --- src/components/AdvanceAnalyticsV2/charts/ScatterChart.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/AdvanceAnalyticsV2/charts/ScatterChart.jsx b/src/components/AdvanceAnalyticsV2/charts/ScatterChart.jsx index 2b2426c3d..bbb1165e9 100644 --- a/src/components/AdvanceAnalyticsV2/charts/ScatterChart.jsx +++ b/src/components/AdvanceAnalyticsV2/charts/ScatterChart.jsx @@ -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]), @@ -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', },