Calculate the Internal Rate of Return for your investment projects with ease.
IRR Calculator
Enter the initial cost (as a negative number).
Typically years or months.
IRR Calculation Results
–
NPV at 10%: –
NPV at 20%: –
NPV at 30%: –
The Internal Rate of Return (IRR) is the discount rate at which the Net Present Value (NPV) of all cash flows from a particular project equals zero. It's an estimate of the profitability of an investment.
Net Present Value (NPV) vs. Discount Rate
Projected Cash Flows
Period
Cash Flow
Initial Investment
–
What is IRR on Financial Calculator?
The IRR on financial calculator is a specialized tool designed to compute the Internal Rate of Return (IRR) for a series of cash flows. The IRR is a fundamental metric in capital budgeting and investment analysis, representing the discount rate at which the Net Present Value (NPV) of an investment equals zero. Essentially, it tells you the effective annual rate of return that an investment is expected to yield.
Understanding the IRR on financial calculator is crucial for any investor, financial analyst, or business owner looking to evaluate the potential profitability of a project or investment. It helps in comparing different investment opportunities on a level playing field, regardless of their initial size or timing of cash flows.
Who should use it:
Investors evaluating potential projects.
Financial analysts performing capital budgeting.
Business owners assessing the viability of new ventures.
Real estate developers analyzing property investments.
Anyone needing to compare the profitability of multiple investment options.
Common misconceptions about IRR:
IRR assumes reinvestment at the IRR rate: A significant assumption is that all positive cash flows generated by the project are reinvested at the IRR itself. This may not always be realistic, especially for high IRR projects.
Multiple IRRs for non-conventional cash flows: Projects with fluctuating positive and negative cash flows beyond the initial investment can sometimes yield multiple IRRs or no IRR at all, making interpretation difficult.
IRR doesn't consider project scale: A project with a high IRR might generate less absolute profit than a project with a lower IRR but a larger initial investment and total cash flow.
IRR on Financial Calculator Formula and Mathematical Explanation
The core principle behind calculating IRR is finding the discount rate (often denoted as 'r' or 'IRR') that makes the Net Present Value (NPV) of a project's cash flows equal to zero. The formula for NPV is:
NPV = ∑nt=0 [CFt / (1 + r)t] = 0
Where:
CFt: The net cash flow during period t.
r: The discount rate (this is what we solve for, the IRR).
t: The time period (from 0 to n).
n: The total number of periods.
CF0: Typically the initial investment, which is usually a negative value.
The IRR on financial calculator doesn't solve this equation algebraically, as it's often impossible for more than a few periods. Instead, it uses iterative numerical methods (like the Newton-Raphson method) or trial-and-error to find the rate 'r' that makes the NPV equation hold true.
Step-by-step derivation (conceptual):
Set up the cash flows: Identify the initial investment (CF0) and all subsequent net cash flows (CF1, CF2, …, CFn).
Formulate the NPV equation: Write out the NPV formula with an unknown discount rate 'r'.
Iterate and adjust:
Start with an estimated discount rate.
Calculate the NPV at that rate.
If NPV is positive, the estimated rate is too low; increase it.
If NPV is negative, the estimated rate is too high; decrease it.
Repeat until the NPV is very close to zero. The rate that achieves this is the IRR.
Variables Explained
Variable
Meaning
Unit
Typical Range
Initial Investment (CF0)
The upfront cost of the project or investment.
Currency (e.g., USD, EUR)
Negative value (e.g., -10,000 to -1,000,000+)
Cash Flow (CFt)
The net amount of cash generated or consumed in a specific period (t).
Currency (e.g., USD, EUR)
Positive (inflow) or Negative (outflow)
Period (t)
A discrete time interval (e.g., year, month).
Count (e.g., 1, 2, 3…)
1 to n
Number of Periods (n)
The total duration over which cash flows are expected.
Count
Typically 1 to 30+
Discount Rate (r)
The rate used to discount future cash flows back to their present value. (This is solved for in IRR calculation).
Percentage (%)
N/A (solved for)
Internal Rate of Return (IRR)
The calculated discount rate where NPV = 0.
Percentage (%)
Varies greatly based on project risk and industry.
Net Present Value (NPV)
The present value of future cash flows minus the initial investment.
Currency (e.g., USD, EUR)
Can be positive, negative, or zero.
Practical Examples (Real-World Use Cases)
The IRR on financial calculator is a versatile tool. Here are a couple of examples:
Example 1: New Software Development Project
A company is considering investing $50,000 in developing a new software application. They project the following net cash flows over the next 5 years:
Year 0 (Initial Investment): -$50,000
Year 1: $10,000
Year 2: $15,000
Year 3: $20,000
Year 4: $25,000
Year 5: $30,000
Using the IRR calculator:
Inputs:
Initial Investment: -50000
Cash Flow Periods: 5
Period 1 Cash Flow: 10000
Period 2 Cash Flow: 15000
Period 3 Cash Flow: 20000
Period 4 Cash Flow: 25000
Period 5 Cash Flow: 30000
Calculator Output (approximate):
IRR Result: 27.65%
NPV at 10%: $37,446.50
NPV at 20%: $16,847.60
NPV at 30%: -$1,380.65
Financial Interpretation: The IRR of 27.65% suggests that this software project is expected to generate an annual return of approximately 27.65%. If the company's required rate of return (or cost of capital) is lower than 27.65% (e.g., 10%), this project would be considered financially attractive, as indicated by the positive NPV at 10%.
Example 2: Real Estate Investment
An investor is looking at a rental property requiring an initial outlay of $200,000. They anticipate owning it for 10 years and estimate the net annual rental income (after expenses) and eventual sale proceeds as follows:
Year 0 (Initial Investment): -$200,000
Year 1-9 Net Income: $25,000 per year
Year 10 Net Income + Sale: $25,000 + $220,000 (estimated sale price) = $245,000
Using the IRR calculator:
Inputs:
Initial Investment: -200000
Cash Flow Periods: 10
Period 1-9 Cash Flow: 25000
Period 10 Cash Flow: 245000
Calculator Output (approximate):
IRR Result: 11.76%
NPV at 8%: $57,545.30
NPV at 12%: $4,580.15
NPV at 15%: -$23,970.75
Financial Interpretation: The calculated IRR of 11.76% represents the effective annual return on this real estate investment. If the investor's target return or hurdle rate is, say, 10%, this project meets their criteria. The positive NPV at 8% and 12% further supports its viability, while the negative NPV at 15% indicates that 15% would be too high a discount rate for this investment to be profitable.
How to Use This IRR on Financial Calculator
Our IRR on financial calculator is designed for simplicity and accuracy. Follow these steps to get your IRR calculation:
Enter Initial Investment: Input the total upfront cost of your project. Remember to enter this as a negative number (e.g., -100000).
Specify Number of Periods: Enter how many periods (usually years) you expect the project to generate cash flows.
Input Cash Flows: For each subsequent period, enter the expected net cash flow. You can add or remove periods using the respective buttons. If cash flows are constant for multiple periods, you'll need to add each period individually and input the same value.
Calculate IRR: Click the "Calculate IRR" button.
Review Results: The calculator will display the primary IRR result, along with intermediate Net Present Values (NPVs) calculated at standard discount rates (10%, 20%, 30%). These NPVs help contextualize the IRR.
Analyze the Chart & Table: The generated chart visually represents the relationship between the discount rate and NPV, highlighting where the NPV crosses zero (the IRR). The table summarizes the cash flows you entered.
Use the Copy Button: Click "Copy Results" to copy the main IRR, intermediate NPVs, and key assumptions to your clipboard for use in reports or other documents.
Reset: If you need to start over or clear the inputs, click the "Reset" button.
Decision-Making Guidance: Compare the calculated IRR to your company's hurdle rate or cost of capital. If IRR > Hurdle Rate, the project is generally considered financially acceptable. If IRR < Hurdle Rate, it may not be worth pursuing. For investments with non-conventional cash flows, always consider the NPV at your required rate of return alongside the IRR.
Key Factors That Affect IRR Results
Several elements significantly influence the calculated IRR. Understanding these is key to interpreting the results accurately:
Accuracy of Cash Flow Projections: This is paramount. Overly optimistic revenue forecasts or underestimated costs will inflate the IRR, leading to potentially poor investment decisions. Conversely, conservative estimates might lead to rejecting profitable projects. Use realistic forecasting models.
Timing of Cash Flows: The IRR gives more weight to cash flows that occur earlier. A project that generates substantial cash flows sooner will have a higher IRR than a project with the same total cash flows spread over a longer period. This is a core concept in the time value of money.
Initial Investment Amount: A larger initial investment requires higher subsequent cash flows to achieve the same IRR. The absolute amount of the initial outlay directly impacts the required return rate.
Project Risk: Higher risk investments typically demand higher expected returns. If a project is perceived as very risky, its IRR must clear a higher hurdle rate. The discount rates used for NPV calculations at different risk levels can help inform IRR interpretation.
Inflation: If inflation is expected, it can erode the purchasing power of future cash flows. Nominal cash flows should be used consistently, and the IRR should be compared against a nominal hurdle rate that includes an inflation premium. Failing to account for inflation can lead to misleadingly high real IRRs.
Financing Costs (Cost of Capital): While IRR itself doesn't directly include financing costs, it's compared against the cost of capital (often WACC – Weighted Average Cost of Capital). If the IRR is below the cost of capital, the project isn't generating enough return to cover the cost of funds, even if the IRR is positive. Consider using our WACC Calculator.
Taxes: Corporate taxes reduce the net cash flows available to the company. Cash flow projections should ideally be after-tax figures. The IRR calculated on after-tax cash flows is the relevant metric for decision-making.
Salvage Value and Terminal Cash Flows: The final cash flow, often including the proceeds from selling the asset (salvage value), can significantly impact the IRR, especially for long-term projects. Accurate estimation of these terminal values is crucial.
Frequently Asked Questions (FAQ)
What is the ideal IRR percentage?
There isn't a universal "ideal" IRR percentage. It depends entirely on the investor's risk tolerance, the required rate of return (hurdle rate), and the available alternative investment opportunities. Generally, an IRR significantly higher than the hurdle rate is desirable.
Can IRR be negative?
Yes, IRR can be negative if the project's cash outflows consistently exceed its cash inflows over its lifetime, meaning the net present value is negative even at a 0% discount rate. A negative IRR generally indicates a project that is expected to lose money.
What's the difference between IRR and NPV?
IRR is a rate of return (%), while NPV is a value in currency ($). IRR tells you the project's effective yield, assuming reinvestment at the IRR. NPV tells you the absolute increase in wealth (or loss) in today's dollars, given a specific discount rate (your required return). For project acceptance, NPV is often considered superior, especially when comparing mutually exclusive projects of different scales.
Why does my IRR calculation have multiple results or no result?
This typically occurs with "non-conventional" cash flows, where the sign of the cash flow changes more than once (e.g., outflow, inflow, outflow, inflow). This mathematical anomaly can lead to multiple discount rates where NPV equals zero, or no real discount rate at all. In such cases, focus on NPV analysis.
Does the IRR calculator consider taxes?
This specific calculator assumes you input *net* cash flows, which should ideally be *after-tax* figures. If you input pre-tax cash flows, the resulting IRR will be higher than the actual after-tax return. Always aim to use after-tax projections for accurate results.
How important is the reinvestment assumption?
The IRR calculation inherently assumes that all intermediate positive cash flows are reinvested at the calculated IRR rate until the end of the project. This is often an unrealistic assumption. If the actual reinvestment rate is lower than the IRR, the project's true economic return will be less than the calculated IRR.
Can I use IRR for short-term versus long-term projects?
While IRR can be calculated for projects of any duration, comparing projects with vastly different lifespans using IRR alone can be misleading due to the reinvestment assumption and the difference in total value generated. NPV is often a better metric for comparing projects of unequal lives. Consider using our Project Payback Period Calculator as well.
What discount rates are commonly used for NPV checks alongside IRR?
Commonly used rates include the company's Weighted Average Cost of Capital (WACC), a target rate of return specific to the project's risk profile, or industry benchmarks. Checking NPV at rates around the estimated IRR helps confirm its validity and understand the sensitivity of the project's value to discount rate changes.
Find the current value of a future sum of money, given a specified rate of return.
var initialInvestmentInput = document.getElementById('initialInvestment');
var cashFlowPeriodsInput = document.getElementById('cashFlowPeriods');
var cashFlowInputsContainer = document.getElementById('cashFlowInputs');
var resultsContainer = document.getElementById('results-container');
var irrResultDisplay = document.getElementById('irrResult');
var npvAt10Display = document.getElementById('npvAt10').querySelector('span');
var npvAt20Display = document.getElementById('npvAt20').querySelector('span');
var npvAt30Display = document.getElementById('npvAt30').querySelector('span');
var cashFlowTableBody = document.getElementById('cashFlowTableBody');
var irrChartCanvas = document.getElementById('irrChart').getContext('2d');
var chartInstance = null;
var cashFlows = [];
var periods = 0;
// Function to validate numeric input
function isValidNumber(value) {
return !isNaN(parseFloat(value)) && isFinite(value);
}
// Function to display error messages
function showError(elementId, message) {
var errorElement = document.getElementById(elementId);
if (errorElement) {
errorElement.textContent = message;
errorElement.style.display = message ? 'block' : 'none';
}
}
// Function to create cash flow input fields
function updateCashFlowInputs() {
var numPeriods = parseInt(cashFlowPeriodsInput.value);
if (isNaN(numPeriods) || numPeriods = 0) {
showError('initialInvestmentError', 'Initial investment must be a negative number.');
numPeriods = 0; // Reset periods if initial investment is invalid
cashFlowPeriodsInput.value = 0;
} else {
showError('initialInvestmentError', ");
}
// Ensure cashFlows array matches the number of periods, preserving existing values
while (cashFlows.length > numPeriods) {
cashFlows.pop();
}
while (cashFlows.length < numPeriods) {
cashFlows.push(0); // Default to 0 if new period added
}
cashFlowInputsContainer.innerHTML = ''; // Clear previous inputs
for (var i = 0; i = 0 && index < cashFlows.length) {
cashFlows[index] = parseFloat(e.target.value);
if (isNaN(cashFlows[index])) cashFlows[index] = 0;
validateAllInputs();
calculateIRR(); // Recalculate on input change
}
});
var helper = document.createElement('div');
helper.className = 'helper-text';
helper.textContent = 'Net cash flow for year ' + periodIndex;
var errorDiv = document.createElement('div');
errorDiv.id = 'cashFlow' + periodIndex + 'Error';
errorDiv.className = 'error-message';
div.appendChild(label);
div.appendChild(input);
div.appendChild(helper);
div.appendChild(errorDiv);
cashFlowInputsContainer.appendChild(div);
}
validateAllInputs(); // Validate after updating inputs
updateCashFlowTable();
}
// Function to add a cash flow period
function addCashFlowPeriod() {
var currentPeriods = parseInt(cashFlowPeriodsInput.value);
if (isNaN(currentPeriods)) currentPeriods = 0;
cashFlowPeriodsInput.value = currentPeriods + 1;
updateCashFlowInputs();
calculateIRR(); // Recalculate after adding period
}
// Function to remove a cash flow period
function removeCashFlowPeriod() {
var currentPeriods = parseInt(cashFlowPeriodsInput.value);
if (isNaN(currentPeriods) || currentPeriods <= 0) return;
cashFlowPeriodsInput.value = currentPeriods – 1;
updateCashFlowInputs();
calculateIRR(); // Recalculate after removing period
}
// Function to reset the calculator
function resetCalculator() {
initialInvestmentInput.value = -100000;
cashFlowPeriodsInput.value = 5;
cashFlows = []; // Clear cash flows
updateCashFlowInputs(); // Rebuild inputs based on reset periods
document.getElementById('irrResult').textContent = '-';
npvAt10Display.textContent = '-';
npvAt20Display.textContent = '-';
npvAt30Display.textContent = '-';
resultsContainer.style.display = 'none';
if (chartInstance) {
chartInstance.destroy();
chartInstance = null;
}
showError('initialInvestmentError', '');
var errorElements = cashFlowInputsContainer.querySelectorAll('.error-message');
for (var i = 0; i = 0) {
showError('initialInvestmentError', 'Initial investment must be a negative number.');
isValid = false;
} else {
showError('initialInvestmentError', ");
}
if (isNaN(cashFlowPeriodsValue) || cashFlowPeriodsValue < 0) {
showError('cashFlowPeriodsError', 'Number of periods cannot be negative.');
isValid = false;
} else {
showError('cashFlowPeriodsError', '');
}
var periodInputs = cashFlowInputsContainer.querySelectorAll('input[type="number"]');
for (var i = 0; i < periodInputs.length; i++) {
var value = parseFloat(periodInputs[i].value);
var errorElementId = periodInputs[i].id + 'Error';
if (isNaN(value)) {
showError(errorElementId, 'Invalid number.');
isValid = false;
} else {
showError(errorElementId, '');
}
}
return isValid;
}
// Function to calculate NPV
function calculateNPV(rate, cashFlowsArray, initialInvestmentValue) {
var npv = initialInvestmentValue; // Start with initial investment (negative)
for (var i = 0; i < cashFlowsArray.length; i++) {
npv += cashFlowsArray[i] / Math.pow(1 + rate, i + 1);
}
return npv;
}
// Function to calculate IRR using the Newton-Raphson method
function calculateIRR() {
if (!validateAllInputs()) {
resultsContainer.style.display = 'none';
return;
}
var initialInvestment = parseFloat(initialInvestmentInput.value);
var numPeriods = parseInt(cashFlowPeriodsInput.value);
var currentCashFlows = [];
for (var i = 0; i < numPeriods; i++) {
var inputElement = document.getElementById('cashFlow' + (i + 1));
var cf = inputElement ? parseFloat(inputElement.value) : 0;
if (isNaN(cf)) cf = 0; // Handle cases where input might be cleared or invalid
currentCashFlows.push(cf);
}
// Combine initial investment with projected cash flows
var allCashFlows = [initialInvestment].concat(currentCashFlows);
// Calculate NPV at standard rates for display and chart data
var npv10 = calculateNPV(0.10, currentCashFlows, initialInvestment);
var npv20 = calculateNPV(0.20, currentCashFlows, initialInvestment);
var npv30 = calculateNPV(0.30, currentCashFlows, initialInvestment);
npvAt10Display.textContent = formatCurrency(npv10);
npvAt20Display.textContent = formatCurrency(npv20);
npvAt30Display.textContent = formatCurrency(npv30);
// — IRR Calculation using Newton-Raphson —
var irr = 0.1; // Initial guess for IRR
var maxIterations = 1000;
var tolerance = 0.00001;
var derivative = 0;
for (var i = 0; i < maxIterations; i++) {
var npvValue = calculateNPV(irr, currentCashFlows, initialInvestment);
derivative = 0;
for (var j = 0; j < currentCashFlows.length; j++) {
derivative -= (j + 1) * currentCashFlows[j] / Math.pow(1 + irr, j + 2);
}
derivative += initialInvestment * (-1) / Math.pow(1 + irr, 1); // Derivative for initial investment
// Correct derivative calculation for all cash flows including initial investment
derivative = 0;
for (var t = 0; t 0) { // Skip initial investment for derivative calculation here, handled separately if needed, but simplified approach is common.
derivative -= t * allCashFlows[t] / Math.pow(1 + irr, t + 1);
}
}
// Simplified derivative calculation is often sufficient for typical scenarios.
// A more robust implementation might involve symbolic differentiation or libraries.
if (Math.abs(derivative) < tolerance) { // Avoid division by zero or near-zero
break;
}
var newIrr = irr – npvValue / derivative;
if (Math.abs(newIrr – irr) 10 || irr < -1) { // If guess goes wildly off track
break;
}
}
var finalIRR = (Math.abs(calculateNPV(irr, currentCashFlows, initialInvestment)) < tolerance) ? irr : NaN;
if (!isNaN(finalIRR)) {
irrResultDisplay.textContent = (finalIRR * 100).toFixed(2) + '%';
resultsContainer.style.display = 'block';
} else {
irrResultDisplay.textContent = 'N/A';
resultsContainer.style.display = 'block'; // Still show container but indicate N/A
}
updateChart(npv10, npv20, npv30, finalIRR);
updateCashFlowTable();
}
// Function to format currency
function formatCurrency(amount) {
if (isNaN(amount)) return '-';
var formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 2,
maximumFractionDigits: 2
});
return formatter.format(amount);
}
// Function to update the cash flow table
function updateCashFlowTable() {
var initialInvestmentValue = parseFloat(initialInvestmentInput.value);
var numPeriods = parseInt(cashFlowPeriodsInput.value);
cashFlowTableBody.innerHTML = '
Initial Investment
' + formatCurrency(initialInvestmentValue) + '
';
for (var i = 0; i < numPeriods; i++) {
var row = cashFlowTableBody.insertRow();
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
cell1.textContent = 'Period ' + (i + 1);
var inputElement = document.getElementById('cashFlow' + (i + 1));
var cfValue = inputElement ? parseFloat(inputElement.value) : 0;
if (isNaN(cfValue)) cfValue = 0;
cell2.textContent = formatCurrency(cfValue);
}
}
// Function to update the chart
function updateChart(npv10, npv20, npv30, irrValue) {
var ctx = document.getElementById('irrChart');
// Data points for the chart
// We'll plot NPV vs Discount Rate. Need points around the IRR for better visualization.
var rates = [0.00, 0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40]; // Sample discount rates
var npvValues = [];
var initialInvestment = parseFloat(initialInvestmentInput.value);
var numPeriods = parseInt(cashFlowPeriodsInput.value);
var currentCashFlows = [];
for (var i = 0; i 0 && irrValue < 1) { // Check if IRR is valid and reasonable
npvValues.push({ x: irrValue * 100, y: 0 });
}
// Sort points by rate for correct line drawing
npvValues.sort(function(a, b) { return a.x – b.x; });
if (chartInstance) {
chartInstance.destroy();
}
chartInstance = new Chart(ctx, {
type: 'line',
data: {
datasets: [{
label: 'NPV vs. Discount Rate',
data: npvValues,
borderColor: 'var(–primary-color)',
backgroundColor: 'rgba(0, 74, 153, 0.1)',
fill: false,
tension: 0.1,
pointRadius: 5,
pointHoverRadius: 7
}]
},
options: {
responsive: true,
maintainAspectRatio: false, // Allow canvas to control aspect ratio based on container
scales: {
x: {
type: 'linear',
position: 'bottom',
title: {
display: true,
text: 'Discount Rate (%)'
},
ticks: {
callback: function(value, index, values) {
return value.toFixed(0) + '%';
}
}
},
y: {
title: {
display: true,
text: 'Net Present Value (NPV)'
},
beginAtZero: false // Adjust based on data range
}
},
plugins: {
tooltip: {
callbacks: {
label: function(context) {
var label = context.dataset.label || '';
if (label) {
label += ': ';
}
if (context.parsed.y !== null) {
label += formatCurrency(context.parsed.y);
}
return label;
}
}
}
}
}
});
}
// Function to copy results
function copyResults() {
var irr = document.getElementById('irrResult').textContent;
var npv10 = document.getElementById('npvAt10').textContent;
var npv20 = document.getElementById('npvAt20').textContent;
var npv30 = document.getElementById('npvAt30').textContent;
var initialInvestment = document.getElementById('initialInvestment').value;
var periods = document.getElementById('cashFlowPeriods').value;
var cashFlowEntries = [];
for (var i = 1; i 0) {
resultText += `Cash Flows:\n${cashFlowEntries.join('\n')}\n`;
}
navigator.clipboard.writeText(resultText).then(function() {
// Optional: Provide user feedback
var copyButton = document.querySelector('.btn-copy');
var originalText = copyButton.textContent;
copyButton.textContent = 'Copied!';
setTimeout(function() {
copyButton.textContent = originalText;
}, 2000);
}).catch(function(err) {
console.error('Failed to copy: ', err);
alert('Failed to copy results. Please copy manually.');
});
}
// Initial setup on page load
document.addEventListener('DOMContentLoaded', function() {
// Set sensible defaults on load
initialInvestmentInput.value = -100000;
cashFlowPeriodsInput.value = 5;
updateCashFlowInputs(); // Create the initial set of cash flow inputs
calculateIRR(); // Perform initial calculation
});
// Add event listeners for dynamic updates
initialInvestmentInput.addEventListener('input', function() {
updateCashFlowInputs(); // Rebuild inputs if initial investment invalidates periods
calculateIRR();
});
cashFlowPeriodsInput.addEventListener('input', function() {
updateCashFlowInputs();
calculateIRR();
});
// Initial chart setup with placeholder data if needed, or wait for calculation
updateChart(0, 0, 0, NaN); // Initialize chart structure