add tooltip formatter

This commit is contained in:
Matthias Mair 2024-04-17 01:12:45 +02:00
parent f1bc66e353
commit 9f16d3f957
No known key found for this signature in database
GPG Key ID: A593429DDA23B66A
8 changed files with 46 additions and 8 deletions

View File

@ -0,0 +1,9 @@
import { formatCurrency } from '../../defaults/formatters';
export function tooltipFormatter(label: any, currency: string) {
return (
formatCurrency(label, {
currency: currency
})?.toString() ?? ''
);
}

View File

@ -21,6 +21,7 @@ import {
} from 'recharts';
import { CHART_COLORS } from '../../../components/charts/colors';
import { tooltipFormatter } from '../../../components/charts/tooltipFormatter';
import {
formatCurrency,
formatDecimal,
@ -68,7 +69,9 @@ function BomPieChart({ data, currency }: { data: any[]; currency: string }) {
/>
))}
</Pie>
<Tooltip />
<Tooltip
formatter={(label, payload) => tooltipFormatter(label, currency)}
/>
</PieChart>
</ResponsiveContainer>
);
@ -87,7 +90,9 @@ function BomBarChart({ data, currency }: { data: any[]; currency: string }) {
})?.toString() ?? ''
}
/>
<Tooltip />
<Tooltip
formatter={(label, payload) => tooltipFormatter(label, currency)}
/>
<Legend />
<Bar
dataKey="total_price_min"

View File

@ -13,6 +13,7 @@ import {
import { AddItemButton } from '../../../components/buttons/AddItemButton';
import { CHART_COLORS } from '../../../components/charts/colors';
import { tooltipFormatter } from '../../../components/charts/tooltipFormatter';
import { ApiFormFieldSet } from '../../../components/forms/fields/ApiFormField';
import { formatCurrency } from '../../../defaults/formatters';
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
@ -180,7 +181,11 @@ export default function PriceBreakPanel({
})?.toString() ?? ''
}
/>
<Tooltip />
<Tooltip
formatter={(label, payload) =>
tooltipFormatter(label, currency)
}
/>
<Legend />
<Bar
dataKey="price"

View File

@ -30,6 +30,7 @@ import {
} from 'recharts';
import { CHART_COLORS } from '../../../components/charts/colors';
import { tooltipFormatter } from '../../../components/charts/tooltipFormatter';
import { formatCurrency, renderDate } from '../../../defaults/formatters';
import { panelOptions } from '../PartPricingPanel';
@ -197,7 +198,11 @@ export default function PricingOverviewPanel({
})?.toString() ?? ''
}
/>
<Tooltip />
<Tooltip
formatter={(label, payload) =>
tooltipFormatter(label, pricing?.currency)
}
/>
<Legend />
<Bar
dataKey="min_value"

View File

@ -12,6 +12,7 @@ import {
} from 'recharts';
import { CHART_COLORS } from '../../../components/charts/colors';
import { tooltipFormatter } from '../../../components/charts/tooltipFormatter';
import { formatCurrency, renderDate } from '../../../defaults/formatters';
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
import { useTable } from '../../../hooks/UseTable';
@ -140,7 +141,9 @@ export default function PurchaseHistoryPanel({
})?.toString() ?? ''
}
/>
<Tooltip />
<Tooltip
formatter={(label, payload) => tooltipFormatter(label, currency)}
/>
<Legend />
<Bar
dataKey="unit_price"

View File

@ -12,6 +12,7 @@ import {
} from 'recharts';
import { CHART_COLORS } from '../../../components/charts/colors';
import { tooltipFormatter } from '../../../components/charts/tooltipFormatter';
import { formatCurrency, renderDate } from '../../../defaults/formatters';
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
import { useTable } from '../../../hooks/UseTable';
@ -104,7 +105,9 @@ export default function SaleHistoryPanel({ part }: { part: any }): ReactNode {
})?.toString() ?? ''
}
/>
<Tooltip />
<Tooltip
formatter={(label, payload) => tooltipFormatter(label, currency)}
/>
<Legend />
<Bar
dataKey="sale_price"

View File

@ -11,6 +11,7 @@ import {
} from 'recharts';
import { CHART_COLORS } from '../../../components/charts/colors';
import { tooltipFormatter } from '../../../components/charts/tooltipFormatter';
import { formatCurrency } from '../../../defaults/formatters';
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
import { useTable } from '../../../hooks/UseTable';
@ -73,7 +74,9 @@ export default function SupplierPricingPanel({ part }: { part: any }) {
})?.toString() ?? ''
}
/>
<Tooltip />
<Tooltip
formatter={(label, payload) => tooltipFormatter(label, currency)}
/>
<Bar
dataKey="unit_price"
fill={CHART_COLORS[0]}

View File

@ -12,6 +12,7 @@ import {
} from 'recharts';
import { CHART_COLORS } from '../../../components/charts/colors';
import { tooltipFormatter } from '../../../components/charts/tooltipFormatter';
import { formatCurrency } from '../../../defaults/formatters';
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
import { ModelType } from '../../../enums/ModelType';
@ -106,7 +107,11 @@ export default function VariantPricingPanel({
})?.toString() ?? ''
}
/>
<Tooltip />
<Tooltip
formatter={(label, payload) =>
tooltipFormatter(label, pricing?.currency)
}
/>
<Legend />
<Bar
dataKey="pmin"