Skip to content

Commit

Permalink
Fix for chart rendering (#8981)
Browse files Browse the repository at this point in the history
- Graphs like numbers, not strings, I guess...
  • Loading branch information
SchrodingersGat authored Jan 29, 2025
1 parent 01b74da commit 0c56a31
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/frontend/src/pages/part/PartStocktakeDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -127,10 +128,11 @@ export default function PartStocktakeDetail({
},
{
accessor: 'date',
sortable: true
sortable: false
},
{
accessor: 'note'
accessor: 'note',
sortable: false
}
];
}, []);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -216,7 +216,8 @@ export default function PartStocktakeDetail({
columns={tableColumns}
props={{
params: {
part: partId
part: partId,
ordering: 'date'
},
rowActions: rowActions,
tableActions: tableActions
Expand All @@ -241,6 +242,12 @@ export default function PartStocktakeDetail({
<ChartTooltip label={label} payload={payload} />
)
}}
yAxisProps={{
allowDataOverflow: false
}}
rightYAxisProps={{
allowDataOverflow: false
}}
xAxisProps={{
scale: 'time',
type: 'number',
Expand Down

0 comments on commit 0c56a31

Please sign in to comment.