From 469f7af7a4696c32d6ff5735ac91630efb99637a Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Thu, 24 Jul 2025 09:06:23 +0200 Subject: [PATCH] remove loan from some charts --- .../static/js/roi-calculator/chart-manager.js | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/hub/services/static/js/roi-calculator/chart-manager.js b/hub/services/static/js/roi-calculator/chart-manager.js index d8e1657..4d1a2e1 100644 --- a/hub/services/static/js/roi-calculator/chart-manager.js +++ b/hub/services/static/js/roi-calculator/chart-manager.js @@ -32,7 +32,7 @@ class ChartManager { maintainAspectRatio: false, plugins: { legend: { position: 'top' }, - title: { display: true, text: 'ROI Progression Over Time' } + title: { display: true, text: 'ROI Progression Over Time - Direct Investment Only' } }, scales: { y: { @@ -65,7 +65,7 @@ class ChartManager { maintainAspectRatio: false, plugins: { legend: { position: 'top' }, - title: { display: true, text: 'Net Financial Position (Break-Even Analysis)' } + title: { display: true, text: 'Net Financial Position - Direct Investment Only' } }, scales: { y: { @@ -252,21 +252,20 @@ class ChartManager { const maxMonths = Math.max(...scenarios.map(s => this.calculator.monthlyData[s].length)); const monthLabels = Array.from({ length: maxMonths }, (_, i) => `M${i + 1}`); - // Update ROI Progression Chart with both models + // Update ROI Progression Chart - Direct Investment Only this.charts.roiProgression.data.labels = monthLabels; - this.charts.roiProgression.data.datasets = scenarios.filter(s => this.calculator.results[s]).map(scenario => { - const scenarioBase = scenario.replace('_direct', '').replace('_loan', ''); - const model = scenario.includes('_loan') ? 'loan' : 'direct'; - const isDirect = model === 'direct'; + this.charts.roiProgression.data.datasets = scenarios.filter(s => + this.calculator.results[s] && s.includes('_direct') + ).map(scenario => { + const scenarioBase = scenario.replace('_direct', ''); const scenarioName = this.calculator.scenarios[scenarioBase]?.name || scenarioBase; return { - label: `${scenarioName} (${model.charAt(0).toUpperCase() + model.slice(1)})`, + label: `${scenarioName}`, data: this.calculator.monthlyData[scenario].map(d => d.roiPercent), borderColor: colors[scenarioBase], - backgroundColor: colors[scenarioBase] + (isDirect ? '30' : '15'), - borderDash: isDirect ? [] : [5, 5], - borderWidth: isDirect ? 3 : 2, + backgroundColor: colors[scenarioBase] + '30', + borderWidth: 3, tension: 0.4, pointBackgroundColor: this.calculator.monthlyData[scenario].map(d => d.roiPercent >= 0 ? colors[scenarioBase] : '#dc3545' @@ -275,25 +274,24 @@ class ChartManager { }); this.charts.roiProgression.update(); - // Update Net Position Chart (Break-Even Analysis) with both models + // Update Net Position Chart (Break-Even Analysis) - Direct Investment Only this.charts.netPosition.data.labels = monthLabels; - this.charts.netPosition.data.datasets = scenarios.filter(s => this.calculator.results[s]).map(scenario => { - const scenarioBase = scenario.replace('_direct', '').replace('_loan', ''); - const model = scenario.includes('_loan') ? 'loan' : 'direct'; - const isDirect = model === 'direct'; + this.charts.netPosition.data.datasets = scenarios.filter(s => + this.calculator.results[s] && s.includes('_direct') + ).map(scenario => { + const scenarioBase = scenario.replace('_direct', ''); const scenarioName = this.calculator.scenarios[scenarioBase]?.name || scenarioBase; return { - label: `${scenarioName} (${model.charAt(0).toUpperCase() + model.slice(1)}) Net Position`, + label: `${scenarioName} Net Position`, data: this.calculator.monthlyData[scenario].map(d => d.netPosition), borderColor: colors[scenarioBase], - backgroundColor: colors[scenarioBase] + (isDirect ? '30' : '15'), - borderDash: isDirect ? [] : [5, 5], - borderWidth: isDirect ? 3 : 2, + backgroundColor: colors[scenarioBase] + '30', + borderWidth: 3, tension: 0.4, fill: { target: 'origin', - above: colors[scenarioBase] + (isDirect ? '20' : '10'), + above: colors[scenarioBase] + '20', below: '#dc354510' } };