Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Bar Chart Widget on hover element to display accurate value #10716

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions web/client/components/charts/WidgetChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,25 @@ const chartDataTypes = {
}).filter(chart => chart !== null);
}
const sortedData = [...data].sort((a, b) => a[xDataKey] > b[xDataKey] ? 1 : -1);
const x = sortedData.map(d => d[xDataKey]);
const y = sortedData.map(d => d[yDataKey]);

//changes that we made **********************************************************************
const aggregatedData = sortedData.reduce((acc, item) => {
const xValue = item[xDataKey];
const yValue = item[yDataKey];

if (!acc[xValue])
acc[xValue] = 0;
acc[xValue] += yValue; // Summing up y-values for each unique x-value
return acc;
}, {});

const x = Object.keys(aggregatedData);
const y = Object.values(aggregatedData);
// const x = sortedData.map(d => d[xDataKey]);
// const y = sortedData.map(d => d[yDataKey]);

const name = traceName || yDataKey;

return {
...style,
type: 'bar',
Expand Down