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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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