From 453c726d1e0378ee71c2caa9e4f0195af78a3f1f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 17:43:33 +1100 Subject: [PATCH] Fix for chart rendering (#8981) (#8982) - Graphs like numbers, not strings, I guess... (cherry picked from commit 0c56a3132ba7a739f2d8401fa472376ae622c7ea) Co-authored-by: Oliver --- .../src/pages/part/PartStocktakeDetail.tsx | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/frontend/src/pages/part/PartStocktakeDetail.tsx b/src/frontend/src/pages/part/PartStocktakeDetail.tsx index b51c3f32d0..f55480d8a0 100644 --- a/src/frontend/src/pages/part/PartStocktakeDetail.tsx +++ b/src/frontend/src/pages/part/PartStocktakeDetail.tsx @@ -107,18 +107,19 @@ export default function PartStocktakeDetail({ return [ { accessor: 'quantity', - sortable: true, + sortable: false, switchable: false }, { accessor: 'item_count', title: t`Stock Items`, switchable: true, - sortable: true + sortable: false }, { accessor: 'cost', title: t`Stock Value`, + sortable: false, render: (record: any) => { return formatPriceRange(record.cost_min, record.cost_max, { currency: record.cost_min_currency @@ -127,10 +128,11 @@ export default function PartStocktakeDetail({ }, { accessor: 'date', - sortable: true + sortable: false }, { - accessor: 'note' + accessor: 'note', + sortable: false } ]; }, []); @@ -174,17 +176,15 @@ export default function PartStocktakeDetail({ return { date: new Date(record.date).valueOf(), quantity: record.quantity, - value_min: record.cost_min, - value_max: record.cost_max + value_min: Number.parseFloat(record.cost_min), + value_max: Number.parseFloat(record.cost_max) }; }) ?? []; // Sort records to ensure correct date order - records.sort((a, b) => { + return records.sort((a, b) => { return a < b ? -1 : 1; }); - - return records; }, [table.records]); // Calculate the date limits of the chart @@ -216,7 +216,8 @@ export default function PartStocktakeDetail({ columns={tableColumns} props={{ params: { - part: partId + part: partId, + ordering: 'date' }, rowActions: rowActions, tableActions: tableActions @@ -241,6 +242,12 @@ export default function PartStocktakeDetail({ ) }} + yAxisProps={{ + allowDataOverflow: false + }} + rightYAxisProps={{ + allowDataOverflow: false + }} xAxisProps={{ scale: 'time', type: 'number',