fikumiku
        body {
            font-family: Arial, sans-serif;
        }
        .calculator {
            width: 300px;
            margin: auto;
            padding: 20px;
            border: 1px solid #ddd;
            border-radius: 5px;
            box-shadow: 2px 2px 10px #ccc;
            text-align: center;
        }
        input[type=”number”], select {
            width: 90%;
            padding: 8px;
            margin: 10px 0;
            border: 1px solid #ddd;
            border-radius: 4px;
        }
        button {
            padding: 10px 15px;
            color: white;
            background-color: #007bff;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        button:hover {
            background-color: #0056b3;
        }
        #results {
            margin-top: 20px;
        }
        #chartContainer {
            width: 600px;
            height: 400px;
            margin: 20px auto;
        }
        canvas {
            width: 100% !important;
            height: 100% !important;
        }
Kalkulator Inwestycji
            3 lata
            5 lat
            10 lat
            Depozytowa
            Konserwatywna
            Optymalna
            Wzrostowa
Suma wpłat:
Wartość inwestycji:
Zysk:
var investmentChart;
function calculateInvestment() {
    var initialInvestment = parseFloat(document.getElementById(’initialInvestment’).value);
    var monthlyContribution = parseFloat(document.getElementById(’monthlyContribution’).value);
    var years = parseFloat(document.getElementById(’years’).value);
    var strategy = document.getElementById(’investmentStrategy’).value;
    var fundReturns = {
        'Agio Kapitał Plus’: 0.09,
        'Agio Dochodowy Plus’: 0.07,
        'Agio Stabilny Plus’: 0.18,
        'Agio Akcji Plus’: 0.39
    };
    var strategyAllocation = {
        'depozytowa’: {’Agio Kapitał Plus’: 0.80, 'Agio Dochodowy Plus’: 0.20},
        'konserwatywna’: {’Agio Kapitał Plus’: 0.50, 'Agio Dochodowy Plus’: 0.10, 'Agio Stabilny Plus’: 0.25, 'Agio Akcji Plus’: 0.15},
        'optymalna’: {’Agio Kapitał Plus’: 0.30, 'Agio Dochodowy Plus’: 0.15, 'Agio Stabilny Plus’: 0.30, 'Agio Akcji Plus’: 0.25},
        'wzrostowa’: {’Agio Kapitał Plus’: 0.10, 'Agio Dochodowy Plus’: 0.10, 'Agio Stabilny Plus’: 0.20, 'Agio Akcji Plus’: 0.60}
    };
    var months = years * 12;
    var totalContributions = initialInvestment;
    var fundValues = JSON.parse(JSON.stringify(strategyAllocation[strategy]));
    for (var fund in fundValues) {
        fundValues[fund] *= initialInvestment;
    }
    var contributionsData = [initialInvestment];
    var valuesData = [initialInvestment];
    var labels = [’Start’];
    for (var i = 1; i  a + b, 0);
            for (var fund in fundValues) {
                fundValues[fund] = totalValue * strategyAllocation[strategy][fund];
            }
        }
        for (var fund in fundValues) {
            fundValues[fund] *= (1 + fundReturns[fund] / 12);
        }
        for (var fund in fundValues) {
            fundValues[fund] += monthlyContribution * strategyAllocation[strategy][fund];
        }
        var finalValue = Object.values(fundValues).reduce((a, b) => a + b, 0);
        contributionsData.push(totalContributions);
        valuesData.push(finalValue);
        labels.push(’Miesiąc ’ + i);
    }
    var profit = valuesData[valuesData.length – 1] – totalContributions;
    var profitPercentage = (profit / totalContributions) * 100;
    document.getElementById(’totalContributions’).textContent = formatNumber(totalContributions) + ’ PLN’;
    document.getElementById(’finalValue’).textContent = formatNumber(finalValue) + ’ PLN’;
    document.getElementById(’profit’).textContent = formatNumber(profit) + ’ PLN (’ + formatNumber(profitPercentage, false) + '%)’;
    drawChart(labels, contributionsData, valuesData);
}
function drawChart(labels, contributionsData, valuesData) {
    var ctx = document.getElementById(’investmentChart’).getContext(’2d’);
    if (investmentChart) {
        investmentChart.destroy();
    }
    investmentChart = new Chart(ctx, {
        type: 'line’,
        data: {
            labels: labels,
            datasets: [{
                label: 'Suma wpłat’,
                data: contributionsData,
                borderColor: 'rgba(0, 123, 255, 1)’,
                fill: false
            }, {
                label: 'Wartość inwestycji’,
                data: valuesData,
                borderColor: 'rgba(40, 167, 69, 1)’,
                fill: false
            }]
        },
        options: {
            scales: {
                y: {
                    beginAtZero: true
                }
            },
            responsive: true,
            maintainAspectRatio: false
        }
    });
}
function formatNumber(num, fixed = true) {
    var options = fixed ? { minimumFractionDigits: 2, maximumFractionDigits: 2 } : {};
    return parseFloat(num).toLocaleString(undefined, options);
}