mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
add tooltip formatter
This commit is contained in:
parent
f1bc66e353
commit
9f16d3f957
9
src/frontend/src/components/charts/tooltipFormatter.tsx
Normal file
9
src/frontend/src/components/charts/tooltipFormatter.tsx
Normal file
@ -0,0 +1,9 @@
|
||||
import { formatCurrency } from '../../defaults/formatters';
|
||||
|
||||
export function tooltipFormatter(label: any, currency: string) {
|
||||
return (
|
||||
formatCurrency(label, {
|
||||
currency: currency
|
||||
})?.toString() ?? ''
|
||||
);
|
||||
}
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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]}
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user