Spaces:
Running
Running
Update ui.js
Browse files
ui.js
CHANGED
|
@@ -108,36 +108,33 @@ function renderProductionHistoryChart() {
|
|
| 108 |
.reduce((sum, entry) => sum + entry.quantity, 0);
|
| 109 |
data.push(totalProduced);
|
| 110 |
}
|
| 111 |
-
|
| 112 |
if (productionChart) {
|
| 113 |
-
productionChart.
|
| 114 |
-
productionChart.data.datasets[0].data = data;
|
| 115 |
-
productionChart.update();
|
| 116 |
-
} else {
|
| 117 |
-
productionChart = new Chart(ctx, {
|
| 118 |
-
type: 'bar',
|
| 119 |
-
data: {
|
| 120 |
-
labels: labels,
|
| 121 |
-
datasets: [{
|
| 122 |
-
label: 'Complete Units Produced',
|
| 123 |
-
data: data,
|
| 124 |
-
backgroundColor: 'rgba(66, 153, 225, 0.5)',
|
| 125 |
-
borderColor: 'rgba(66, 153, 225, 1)',
|
| 126 |
-
borderWidth: 1,
|
| 127 |
-
borderRadius: 4,
|
| 128 |
-
}]
|
| 129 |
-
},
|
| 130 |
-
options: {
|
| 131 |
-
responsive: true,
|
| 132 |
-
maintainAspectRatio: false,
|
| 133 |
-
plugins: { legend: { display: false } },
|
| 134 |
-
scales: {
|
| 135 |
-
y: { beginAtZero: true, grid: { color: 'hsl(220, 13%, 30%)' } },
|
| 136 |
-
x: { grid: { display: false } }
|
| 137 |
-
}
|
| 138 |
-
}
|
| 139 |
-
});
|
| 140 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
}
|
| 142 |
|
| 143 |
function renderInventoryStatusChart() {
|
|
@@ -156,25 +153,23 @@ function renderInventoryStatusChart() {
|
|
| 156 |
datasets: [{
|
| 157 |
data: [okCount, warningCount, criticalCount],
|
| 158 |
backgroundColor: [ 'hsla(145, 63%, 49%, 0.7)', 'hsla(50, 91%, 64%, 0.7)', 'hsla(0, 89%, 69%, 0.7)' ],
|
| 159 |
-
borderColor: 'hsl(220, 26%, 18%)',
|
| 160 |
borderWidth: 2
|
| 161 |
}]
|
| 162 |
};
|
| 163 |
|
| 164 |
if (inventoryChart) {
|
| 165 |
-
inventoryChart.
|
| 166 |
-
inventoryChart.update();
|
| 167 |
-
} else {
|
| 168 |
-
inventoryChart = new Chart(ctx, {
|
| 169 |
-
type: 'doughnut',
|
| 170 |
-
data: data,
|
| 171 |
-
options: {
|
| 172 |
-
responsive: true,
|
| 173 |
-
maintainAspectRatio: false,
|
| 174 |
-
plugins: { legend: { position: 'top', labels: { color: 'hsl(210, 14%, 66%)' } } }
|
| 175 |
-
}
|
| 176 |
-
});
|
| 177 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
}
|
| 179 |
|
| 180 |
function renderModals() {
|
|
|
|
| 108 |
.reduce((sum, entry) => sum + entry.quantity, 0);
|
| 109 |
data.push(totalProduced);
|
| 110 |
}
|
| 111 |
+
|
| 112 |
if (productionChart) {
|
| 113 |
+
productionChart.destroy(); // BUG FIX: Destroy old chart instance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
}
|
| 115 |
+
productionChart = new Chart(ctx, {
|
| 116 |
+
type: 'bar',
|
| 117 |
+
data: {
|
| 118 |
+
labels: labels,
|
| 119 |
+
datasets: [{
|
| 120 |
+
label: 'Complete Units Produced',
|
| 121 |
+
data: data,
|
| 122 |
+
backgroundColor: 'rgba(66, 153, 225, 0.5)',
|
| 123 |
+
borderColor: 'rgba(66, 153, 225, 1)',
|
| 124 |
+
borderWidth: 1,
|
| 125 |
+
borderRadius: 4,
|
| 126 |
+
}]
|
| 127 |
+
},
|
| 128 |
+
options: {
|
| 129 |
+
responsive: true,
|
| 130 |
+
maintainAspectRatio: false,
|
| 131 |
+
plugins: { legend: { display: false } },
|
| 132 |
+
scales: {
|
| 133 |
+
y: { beginAtZero: true, grid: { color: 'hsl(220, 13%, 30%)' } },
|
| 134 |
+
x: { grid: { display: false } }
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
});
|
| 138 |
}
|
| 139 |
|
| 140 |
function renderInventoryStatusChart() {
|
|
|
|
| 153 |
datasets: [{
|
| 154 |
data: [okCount, warningCount, criticalCount],
|
| 155 |
backgroundColor: [ 'hsla(145, 63%, 49%, 0.7)', 'hsla(50, 91%, 64%, 0.7)', 'hsla(0, 89%, 69%, 0.7)' ],
|
| 156 |
+
borderColor: 'hsl(220, 26%, 18%)',
|
| 157 |
borderWidth: 2
|
| 158 |
}]
|
| 159 |
};
|
| 160 |
|
| 161 |
if (inventoryChart) {
|
| 162 |
+
inventoryChart.destroy(); // BUG FIX: Destroy old chart instance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
}
|
| 164 |
+
inventoryChart = new Chart(ctx, {
|
| 165 |
+
type: 'doughnut',
|
| 166 |
+
data: data,
|
| 167 |
+
options: {
|
| 168 |
+
responsive: true,
|
| 169 |
+
maintainAspectRatio: false,
|
| 170 |
+
plugins: { legend: { position: 'top', labels: { color: 'hsl(210, 14%, 66%)' } } }
|
| 171 |
+
}
|
| 172 |
+
});
|
| 173 |
}
|
| 174 |
|
| 175 |
function renderModals() {
|