feat: display ordered and produced product side by side

This commit is contained in:
Julien Calixte
2026-01-02 10:44:00 +01:00
parent e6e0cb8cb0
commit 5940bb92ab
2 changed files with 64 additions and 60 deletions

View File

@@ -9,7 +9,7 @@ const svgElement = ref<VNodeRef | null>(null)
const products: ProductType[] = ['shirt', 'jeans', 'shoes', 'hat']
const heijunkaStore = useHeijunkaStore()
const { orders } = storeToRefs(heijunkaStore)
const { orders, inventory } = storeToRefs(heijunkaStore)
const renderChart = () => {
if (orders.value.length === 0) {
@@ -25,13 +25,15 @@ const renderChart = () => {
xLabel: 'Products',
yLabel: '# of orders',
data: {
labels: products,
labels: products.map((p) => [`${p} ordered`, `${p} made |`]).flat(),
datasets: [
{
data: products.map(
(product) =>
orders.value.filter((o) => o.product === product).length
)
data: products
.map((product) => [
orders.value.filter((o) => o.product === product).length,
inventory.value[product]
])
.flat()
}
]
},
@@ -44,7 +46,7 @@ const renderChart = () => {
}
onMounted(renderChart)
watch(orders, renderChart, { deep: true })
watch([orders, inventory], renderChart, { deep: true })
</script>
<template>