diff --git a/packages/desktop-client/src/components/reports/reports/CashFlowCard.jsx b/packages/desktop-client/src/components/reports/reports/CashFlowCard.jsx index 07759a4ece3..ed8daeb6af1 100644 --- a/packages/desktop-client/src/components/reports/reports/CashFlowCard.jsx +++ b/packages/desktop-client/src/components/reports/reports/CashFlowCard.jsx @@ -1,6 +1,6 @@ import React, { useState, useMemo, useCallback } from 'react'; -import { Bar, BarChart, ResponsiveContainer } from 'recharts'; +import { Bar, BarChart, LabelList, ResponsiveContainer } from 'recharts'; import * as monthUtils from 'loot-core/src/shared/months'; import { integerToCurrency } from 'loot-core/src/shared/util'; @@ -17,23 +17,48 @@ import { ReportCard } from '../ReportCard'; import { simpleCashFlow } from '../spreadsheets/cash-flow-spreadsheet'; import { useReport } from '../useReport'; -function CustomLabel({ value, name, position, ...props }) { +function CustomLabel({ + value, + name, + position, + x, + y, + width: barWidth, + height: barHeight, +}) { + const valueLengthOffset = value.toString().length < 5 ? -40 : 20; + + const yOffset = barHeight < 25 ? 105 : y; + + const labelXOffsets = { + right: 6, + left: -valueLengthOffset + 1, + }; + + const valueXOffsets = { + right: 6, + left: -valueLengthOffset + 2, + }; + + const anchorValue = { + right: 'start', + left: 'end', + }; + return ( <> {name} {integerToCurrency(value)} @@ -100,18 +125,20 @@ export function CashFlowCard() { bottom: 0, }} > - } - /> - } - /> + + } + /> + + + } + /> + ) : ( diff --git a/upcoming-release-notes/2597.md b/upcoming-release-notes/2597.md new file mode 100644 index 00000000000..3e370b40f1d --- /dev/null +++ b/upcoming-release-notes/2597.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [ttlgeek] +--- + +Stop cash flow card labels from getting cutting off if bar height is too low