mirror of
https://github.com/inventree/InvenTree.git
synced 2025-11-13 19:36:46 +00:00
(cherry picked from commit 77f80385c9)
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
committed by
GitHub
parent
68e3216b7b
commit
4bb1354b68
@@ -1,9 +1,8 @@
|
|||||||
import { t } from '@lingui/core/macro';
|
import { t } from '@lingui/core/macro';
|
||||||
import { BarChart, type ChartTooltipProps, DonutChart } from '@mantine/charts';
|
import { BarChart, DonutChart } from '@mantine/charts';
|
||||||
import {
|
import {
|
||||||
Center,
|
Center,
|
||||||
Group,
|
Group,
|
||||||
Paper,
|
|
||||||
SegmentedControl,
|
SegmentedControl,
|
||||||
SimpleGrid,
|
SimpleGrid,
|
||||||
Stack,
|
Stack,
|
||||||
@@ -17,40 +16,12 @@ import { apiUrl } from '@lib/functions/Api';
|
|||||||
import type { TableColumn } from '@lib/types/Tables';
|
import type { TableColumn } from '@lib/types/Tables';
|
||||||
import { CHART_COLORS } from '../../../components/charts/colors';
|
import { CHART_COLORS } from '../../../components/charts/colors';
|
||||||
import { tooltipFormatter } from '../../../components/charts/tooltipFormatter';
|
import { tooltipFormatter } from '../../../components/charts/tooltipFormatter';
|
||||||
import {
|
import { formatDecimal, formatPriceRange } from '../../../defaults/formatters';
|
||||||
formatCurrency,
|
|
||||||
formatDecimal,
|
|
||||||
formatPriceRange
|
|
||||||
} from '../../../defaults/formatters';
|
|
||||||
import { useTable } from '../../../hooks/UseTable';
|
import { useTable } from '../../../hooks/UseTable';
|
||||||
import { DateColumn, PartColumn } from '../../../tables/ColumnRenderers';
|
import { DateColumn, PartColumn } from '../../../tables/ColumnRenderers';
|
||||||
import { InvenTreeTable } from '../../../tables/InvenTreeTable';
|
import { InvenTreeTable } from '../../../tables/InvenTreeTable';
|
||||||
import { LoadingPricingData, NoPricingData } from './PricingPanel';
|
import { LoadingPricingData, NoPricingData } from './PricingPanel';
|
||||||
|
|
||||||
/*
|
|
||||||
* Render a tooltip for the chart, with correct date information
|
|
||||||
*/
|
|
||||||
function ChartTooltip({ label, payload }: ChartTooltipProps) {
|
|
||||||
if (!payload) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = payload[0] ?? {};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Paper px='md' py='sm' withBorder shadow='md' radius='md'>
|
|
||||||
<Group justify='space-between' wrap='nowrap'>
|
|
||||||
<Text key='title' c={data.payload?.color}>
|
|
||||||
{data.name}
|
|
||||||
</Text>
|
|
||||||
<Text key='price' fz='sm'>
|
|
||||||
{formatCurrency(data.payload?.value)}
|
|
||||||
</Text>
|
|
||||||
</Group>
|
|
||||||
</Paper>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display BOM data as a pie chart
|
// Display BOM data as a pie chart
|
||||||
function BomPieChart({
|
function BomPieChart({
|
||||||
data,
|
data,
|
||||||
@@ -86,11 +57,6 @@ function BomPieChart({
|
|||||||
tooltipDataSource='segment'
|
tooltipDataSource='segment'
|
||||||
chartLabel={t`Total Price`}
|
chartLabel={t`Total Price`}
|
||||||
valueFormatter={(value) => tooltipFormatter(value, currency)}
|
valueFormatter={(value) => tooltipFormatter(value, currency)}
|
||||||
tooltipProps={{
|
|
||||||
content: ({ label, payload }) => (
|
|
||||||
<ChartTooltip label={label} payload={payload} />
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</Center>
|
</Center>
|
||||||
);
|
);
|
||||||
@@ -116,11 +82,6 @@ function BomBarChart({
|
|||||||
{ name: 'total_price_max', label: t`Maximum Price`, color: 'teal.6' }
|
{ name: 'total_price_max', label: t`Maximum Price`, color: 'teal.6' }
|
||||||
]}
|
]}
|
||||||
valueFormatter={(value) => tooltipFormatter(value, currency)}
|
valueFormatter={(value) => tooltipFormatter(value, currency)}
|
||||||
tooltipProps={{
|
|
||||||
content: ({ label, payload }) => (
|
|
||||||
<ChartTooltip label={label} payload={payload} />
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user