2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +00:00

Fix for chart rendering (#8981) (#8982)

- Graphs like numbers, not strings, I guess...

(cherry picked from commit 0c56a3132ba7a739f2d8401fa472376ae622c7ea)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
github-actions[bot] 2025-01-29 17:43:33 +11:00 committed by GitHub
parent b6ca9ec6a4
commit 453c726d1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -107,18 +107,19 @@ export default function PartStocktakeDetail({
return [ return [
{ {
accessor: 'quantity', accessor: 'quantity',
sortable: true, sortable: false,
switchable: false switchable: false
}, },
{ {
accessor: 'item_count', accessor: 'item_count',
title: t`Stock Items`, title: t`Stock Items`,
switchable: true, switchable: true,
sortable: true sortable: false
}, },
{ {
accessor: 'cost', accessor: 'cost',
title: t`Stock Value`, title: t`Stock Value`,
sortable: false,
render: (record: any) => { render: (record: any) => {
return formatPriceRange(record.cost_min, record.cost_max, { return formatPriceRange(record.cost_min, record.cost_max, {
currency: record.cost_min_currency currency: record.cost_min_currency
@ -127,10 +128,11 @@ export default function PartStocktakeDetail({
}, },
{ {
accessor: 'date', accessor: 'date',
sortable: true sortable: false
}, },
{ {
accessor: 'note' accessor: 'note',
sortable: false
} }
]; ];
}, []); }, []);
@ -174,17 +176,15 @@ export default function PartStocktakeDetail({
return { return {
date: new Date(record.date).valueOf(), date: new Date(record.date).valueOf(),
quantity: record.quantity, quantity: record.quantity,
value_min: record.cost_min, value_min: Number.parseFloat(record.cost_min),
value_max: record.cost_max value_max: Number.parseFloat(record.cost_max)
}; };
}) ?? []; }) ?? [];
// Sort records to ensure correct date order // Sort records to ensure correct date order
records.sort((a, b) => { return records.sort((a, b) => {
return a < b ? -1 : 1; return a < b ? -1 : 1;
}); });
return records;
}, [table.records]); }, [table.records]);
// Calculate the date limits of the chart // Calculate the date limits of the chart
@ -216,7 +216,8 @@ export default function PartStocktakeDetail({
columns={tableColumns} columns={tableColumns}
props={{ props={{
params: { params: {
part: partId part: partId,
ordering: 'date'
}, },
rowActions: rowActions, rowActions: rowActions,
tableActions: tableActions tableActions: tableActions
@ -241,6 +242,12 @@ export default function PartStocktakeDetail({
<ChartTooltip label={label} payload={payload} /> <ChartTooltip label={label} payload={payload} />
) )
}} }}
yAxisProps={{
allowDataOverflow: false
}}
rightYAxisProps={{
allowDataOverflow: false
}}
xAxisProps={{ xAxisProps={{
scale: 'time', scale: 'time',
type: 'number', type: 'number',