From 9f16d3f957425487d827ec6a3a89266de65cfcaf Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Wed, 17 Apr 2024 01:12:45 +0200 Subject: [PATCH] add tooltip formatter --- src/frontend/src/components/charts/tooltipFormatter.tsx | 9 +++++++++ src/frontend/src/pages/part/pricing/BomPricingPanel.tsx | 9 +++++++-- src/frontend/src/pages/part/pricing/PriceBreakPanel.tsx | 7 ++++++- .../src/pages/part/pricing/PricingOverviewPanel.tsx | 7 ++++++- .../src/pages/part/pricing/PurchaseHistoryPanel.tsx | 5 ++++- src/frontend/src/pages/part/pricing/SaleHistoryPanel.tsx | 5 ++++- .../src/pages/part/pricing/SupplierPricingPanel.tsx | 5 ++++- .../src/pages/part/pricing/VariantPricingPanel.tsx | 7 ++++++- 8 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 src/frontend/src/components/charts/tooltipFormatter.tsx diff --git a/src/frontend/src/components/charts/tooltipFormatter.tsx b/src/frontend/src/components/charts/tooltipFormatter.tsx new file mode 100644 index 0000000000..73b3b97703 --- /dev/null +++ b/src/frontend/src/components/charts/tooltipFormatter.tsx @@ -0,0 +1,9 @@ +import { formatCurrency } from '../../defaults/formatters'; + +export function tooltipFormatter(label: any, currency: string) { + return ( + formatCurrency(label, { + currency: currency + })?.toString() ?? '' + ); +} diff --git a/src/frontend/src/pages/part/pricing/BomPricingPanel.tsx b/src/frontend/src/pages/part/pricing/BomPricingPanel.tsx index e6ea6ba6d4..b8228b0334 100644 --- a/src/frontend/src/pages/part/pricing/BomPricingPanel.tsx +++ b/src/frontend/src/pages/part/pricing/BomPricingPanel.tsx @@ -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 }) { /> ))} - + tooltipFormatter(label, currency)} + /> ); @@ -87,7 +90,9 @@ function BomBarChart({ data, currency }: { data: any[]; currency: string }) { })?.toString() ?? '' } /> - + tooltipFormatter(label, currency)} + /> - + + tooltipFormatter(label, currency) + } + /> - + + tooltipFormatter(label, pricing?.currency) + } + /> - + tooltipFormatter(label, currency)} + /> - + tooltipFormatter(label, currency)} + /> - + tooltipFormatter(label, currency)} + /> - + + tooltipFormatter(label, pricing?.currency) + } + />