Skip to content

Commit

Permalink
Fix for BOM pricing donut chart (#7917) (#7922)
Browse files Browse the repository at this point in the history
- Mantine charts tooltip can't handle '.' character.

(cherry picked from commit d7d908b)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
  • Loading branch information
github-actions[bot] and SchrodingersGat authored Aug 19, 2024
1 parent 5b1e15e commit 24d5730
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/frontend/src/pages/part/pricing/BomPricingPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@ function BomPieChart({
}) {
// Construct donut data
const maxPricing = useMemo(() => {
return data.map((entry, index) => {
return {
name: entry.name,
value: entry.total_price_max,
color: CHART_COLORS[index % CHART_COLORS.length] + '.5'
};
});
return (
data
?.filter((el: any) => !!el.total_price_max)
.map((entry, index) => {
return {
// Note: Replace '.' in name to avoid issues with tooltip
name: entry?.name?.replace('.', '') ?? '',
value: entry?.total_price_max,
color: CHART_COLORS[index % CHART_COLORS.length] + '.5'
};
}) ?? []
);
}, [data]);

return (
Expand Down Expand Up @@ -170,8 +175,8 @@ export default function BomPricingPanel({
const [chartType, setChartType] = useState<string>('pie');

const hasData: boolean = useMemo(() => {
return !table.isLoading && bomPricingData.length > 0;
}, [table.isLoading, bomPricingData.length]);
return !table.isLoading && bomPricingData && bomPricingData.length > 0;
}, [table.isLoading, bomPricingData]);

return (
<Stack gap="xs">
Expand Down

0 comments on commit 24d5730

Please sign in to comment.