diff --git a/.changeset/wise-ligers-scream.md b/.changeset/wise-ligers-scream.md new file mode 100644 index 0000000000..d71c69fd42 --- /dev/null +++ b/.changeset/wise-ligers-scream.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-cost-insights': patch +--- + +Fixed bug in `CostOverviewBreakdownChart` component where some datasets caused the cost overview breakdown chart to tear. diff --git a/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewBreakdownChart.tsx b/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewBreakdownChart.tsx index d0731326f2..5b912c09a6 100644 --- a/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewBreakdownChart.tsx +++ b/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewBreakdownChart.tsx @@ -113,8 +113,8 @@ export const CostOverviewBreakdownChart = ({ {} as Record>, ); - const chartData: Record[] = Object.keys(breakdownsByDate).map( - date => { + const chartData: Record[] = Object.keys(breakdownsByDate) + .map(date => { const costsForDate = Object.keys(breakdownsByDate[date]).reduce( (dateCosts, breakdown) => { // Group costs for items that belong to 'Other' in the chart. @@ -131,8 +131,8 @@ export const CostOverviewBreakdownChart = ({ ...costsForDate, date: Date.parse(date), }; - }, - ); + }) + .sort((a, b) => a.date - b.date); const sortedBreakdowns = costBreakdown.sort( (a, b) => aggregationSum(a.aggregation) - aggregationSum(b.aggregation),