fix: added custom breakdown of one day to handle billing graph issue. (#5994)

* fix: added custom breakdown to handle billing graph issue

* chore: remove console statement

* chore: added comment for current implementation of adding next day details in breakdown
This commit is contained in:
rahulkeswani101 2024-10-01 19:17:43 +05:30 committed by GitHub
parent e1ca71dcea
commit 5ba9c9d48c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -58,6 +58,21 @@ const calculateStartEndTime = (
export function BillingUsageGraph(props: BillingUsageGraphProps): JSX.Element {
const { data, billAmount } = props;
// Added this to fix the issue where breakdown with one day data are causing the bars to spread across multiple days
data?.details?.breakdown?.forEach((breakdown: any) => {
if (breakdown?.dayWiseBreakdown?.breakdown?.length === 1) {
const currentDay = breakdown.dayWiseBreakdown.breakdown[0];
const nextDay = {
...currentDay,
timestamp: currentDay.timestamp + 86400,
count: 0,
size: 0,
quantity: 0,
total: 0,
};
breakdown.dayWiseBreakdown.breakdown.push(nextDay);
}
});
const graphCompatibleData = useMemo(
() => convertDataToMetricRangePayload(data),
[data],