Weighted Average Cost of Capital Wacc Calculator

Weighted Average Cost of Capital (WACC) Calculator & Guide :root { –primary-color: #004a99; –success-color: #28a745; –background-color: #f8f9fa; –text-color: #333; –border-color: #ddd; –card-bg: #fff; –shadow: 0 2px 5px rgba(0,0,0,0.1); } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: var(–background-color); color: var(–text-color); line-height: 1.6; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: center; padding-top: 20px; padding-bottom: 40px; } .container { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 15px; background-color: var(–card-bg); border-radius: 8px; box-shadow: var(–shadow); overflow: hidden; } header { background-color: var(–primary-color); color: white; padding: 20px; text-align: center; margin-bottom: 20px; } header h1 { margin: 0; font-size: 2.2em; } main { padding: 20px; } .loan-calc-container { background-color: var(–card-bg); padding: 30px; border-radius: 8px; box-shadow: var(–shadow); margin-bottom: 30px; border: 1px solid var(–border-color); } .input-group { margin-bottom: 20px; width: 100%; } .input-group label { display: block; margin-bottom: 8px; font-weight: bold; color: var(–primary-color); } .input-group input[type="number"], .input-group select { width: calc(100% – 20px); /* Adjust for padding */ padding: 10px; border: 1px solid var(–border-color); border-radius: 4px; font-size: 1em; margin-top: 5px; } .input-group select { cursor: pointer; } .input-group small { display: block; margin-top: 5px; font-size: 0.85em; color: #6c757d; } .error-message { color: red; font-size: 0.8em; margin-top: 5px; display: none; /* Hidden by default */ } .calculator-buttons { display: flex; justify-content: space-between; margin-top: 25px; gap: 10px; } button { padding: 12px 20px; border: none; border-radius: 5px; cursor: pointer; font-size: 1em; font-weight: bold; transition: background-color 0.3s ease; } button.primary { background-color: var(–primary-color); color: white; } button.primary:hover { background-color: #003366; } button.reset { background-color: #6c757d; color: white; } button.reset:hover { background-color: #5a6268; } button.copy { background-color: var(–success-color); color: white; } button.copy:hover { background-color: #218838; } #results { margin-top: 30px; padding: 25px; border: 1px solid var(–border-color); border-radius: 8px; background-color: #e9ecef; text-align: center; } #results h2 { color: var(–primary-color); margin-top: 0; } .result-item { margin-bottom: 15px; } .result-item label { font-weight: bold; display: block; margin-bottom: 5px; color: var(–text-color); } .result-item .value { font-size: 1.8em; font-weight: bold; color: var(–success-color); } .result-item .unit { font-size: 1em; color: #6c757d; } .formula-explanation { margin-top: 20px; font-size: 0.9em; color: #555; border-left: 3px solid var(–primary-color); padding-left: 15px; } table { width: 100%; border-collapse: collapse; margin-top: 20px; margin-bottom: 20px; } th, td { border: 1px solid var(–border-color); padding: 10px; text-align: left; } th { background-color: var(–primary-color); color: white; font-weight: bold; } td { background-color: var(–card-bg); } caption { caption-side: top; font-weight: bold; margin-bottom: 10px; font-size: 1.1em; color: var(–primary-color); text-align: left; } canvas { display: block; margin: 20px auto; max-width: 100%; background-color: var(–card-bg); border-radius: 4px; box-shadow: var(–shadow); } .article-section { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(–border-color); } .article-section:first-of-type { border-top: none; padding-top: 0; } .article-section h2, .article-section h3 { color: var(–primary-color); margin-bottom: 15px; } .article-section h2 { font-size: 1.8em; } .article-section h3 { font-size: 1.4em; } .article-section p, .article-section ul, .article-section ol { margin-bottom: 15px; } .article-section li { margin-bottom: 8px; } .faq-item { margin-bottom: 15px; padding: 10px; background-color: var(–card-bg); border-radius: 4px; border-left: 3px solid var(–primary-color); } .faq-item strong { color: var(–primary-color); display: block; margin-bottom: 5px; } .highlighted-result { background-color: var(–success-color); color: white; padding: 20px; border-radius: 5px; font-size: 1.5em; font-weight: bold; margin-top: 15px; margin-bottom: 15px; text-align: center; box-shadow: inset 0 0 10px rgba(0,0,0,0.2); } .internal-links-list { list-style: none; padding: 0; } .internal-links-list li { margin-bottom: 10px; padding: 10px; background-color: var(–card-bg); border: 1px solid var(–border-color); border-radius: 4px; } .internal-links-list a { text-decoration: none; color: var(–primary-color); font-weight: bold; } .internal-links-list a:hover { text-decoration: underline; } .internal-links-list p { font-size: 0.9em; color: #555; margin-top: 5px; } /* Responsive adjustments */ @media (max-width: 768px) { header h1 { font-size: 1.8em; } .loan-calc-container, main { padding: 20px; } .calculator-buttons { flex-direction: column; gap: 10px; } button { width: 100%; } #results .value { font-size: 1.5em; } }

Weighted Average Cost of Capital (WACC) Calculator

Calculate WACC

Enter the cost and market value of each capital component to determine your company's WACC.

Proportion of company's market value financed by equity. Must be between 0 and 1.
Required rate of return for equity investors (%). Enter as a decimal (e.g., 12% is 0.12).
Proportion of company's market value financed by debt. Must be between 0 and 1.
Interest rate on company's debt (%). Enter as a decimal (e.g., 5% is 0.05).
Company's effective corporate tax rate. Enter as a decimal (e.g., 21% is 0.21).

Results

–.–%
–.–%
–.–
–.–

Formula: WACC = (We * Re) + (Wd * Rd * (1 – Tc))
Where: We = Weight of Equity, Re = Cost of Equity, Wd = Weight of Debt, Rd = Cost of Debt, Tc = Corporate Tax Rate.

What is Weighted Average Cost of Capital (WACC)?

The Weighted Average Cost of Capital (WACC) is a crucial financial metric that represents a company's blended cost of capital across all sources, including common stock, preferred stock, bonds, and other forms of debt. Essentially, it's the average rate a company expects to pay to finance its assets. WACC is calculated by taking the weighted average of the cost of each component of the company's capital structure, with the weights reflecting the proportion of each component in the total capital. This weighted average is vital because it signifies the minimum rate of return a company must earn on its existing asset base to satisfy its creditors, owners, and other capital providers. If a company's projects yield returns lower than its WACC, it is not creating value for its shareholders. The WACC is predominantly used by corporate finance professionals, investors, and analysts to evaluate potential investments, assess project feasibility, and make strategic financial decisions. It serves as a discount rate in discounted cash flow (DCF) analysis to determine the present value of future cash flows.

Who Should Use It?

The primary users of WACC calculations include:

  • Corporate Financial Managers: To evaluate investment proposals and capital budgeting decisions. Projects with expected returns exceeding the WACC are generally considered value-creating.
  • Investment Analysts: To value companies and their securities. WACC is a key input for discounted cash flow (DCF) models.
  • Investors: To assess the risk profile of a company and its potential return on investment. A higher WACC might indicate higher risk.
  • Economists and Policymakers: To understand the cost of capital in different industries or economies, which can influence investment trends and economic policy.

Common Misconceptions

  • WACC is a fixed number: WACC fluctuates based on market conditions, company performance, and changes in capital structure.
  • WACC is the cost of new debt: WACC reflects the average cost of all capital components, not just the most recent borrowing.
  • WACC applies to all projects equally: While WACC is a company-wide average, specific projects may have different risk profiles requiring a risk-adjusted discount rate, which could be higher or lower than the company's overall WACC.

WACC Formula and Mathematical Explanation

The Weighted Average Cost of Capital (WACC) formula is designed to capture the blended cost of all the different types of financing a company uses. It acknowledges that different sources of capital (like debt and equity) have different costs and risks, and they are used in varying proportions within a company's financial structure.

The WACC Formula

The most common form of the WACC formula is:

WACC = (We * Re) + (Wd * Rd * (1 – Tc))

Step-by-Step Derivation and Variable Explanations

  1. Identify Capital Components: The first step is to identify all the sources of capital a company uses. The most common are common equity and debt. Preferred stock can also be included if it represents a significant portion of the capital structure.
  2. Determine the Market Value of Each Component: This involves finding the current market value of the company's outstanding equity (market capitalization = share price * number of shares) and the market value of its outstanding debt.
  3. Calculate the Total Market Value of Capital: Sum the market values of all capital components to get the total capital structure value.
  4. Calculate the Weights (Proportions): Determine the weight (proportion) of each capital component by dividing its market value by the total market value of capital. For example, Weight of Equity (We) = Market Value of Equity / Total Market Value of Capital. The sum of all weights must equal 1 (or 100%).
  5. Determine the Cost of Each Component:
    • Cost of Equity (Re): This is the return required by equity investors. It's often estimated using the Capital Asset Pricing Model (CAPM) or other valuation methods.
    • Cost of Debt (Rd): This is the effective interest rate a company pays on its debt. It can be approximated by the yield to maturity on the company's outstanding bonds.
  6. Adjust Cost of Debt for Taxes: Since interest payments on debt are typically tax-deductible, the effective cost of debt is lower after accounting for taxes. This is calculated as Cost of Debt * (1 – Corporate Tax Rate), or Rd * (1 – Tc).
  7. Calculate the Weighted Average: Multiply the weight of each capital component by its respective cost (after-tax for debt) and sum these products to arrive at the WACC.

Variables Table

WACC Formula Variables
Variable Meaning Unit Typical Range / Notes
WACC Weighted Average Cost of Capital Percentage (%) Represents the company's overall cost of financing.
We Weight of Equity Decimal (0-1) or Percentage (%) Proportion of market value from equity. Sum of weights = 1.
Re Cost of Equity Decimal (0-1) or Percentage (%) Required return by equity holders. Often estimated via CAPM.
Wd Weight of Debt Decimal (0-1) or Percentage (%) Proportion of market value from debt. Sum of weights = 1.
Rd Cost of Debt Decimal (0-1) or Percentage (%) Effective interest rate on company debt before tax.
Tc Corporate Tax Rate Decimal (0-1) or Percentage (%) Company's effective tax rate. Used to calculate after-tax cost of debt.

Practical Examples of WACC

Understanding WACC is best achieved through practical application. Here are a couple of scenarios:

Example 1: Established Tech Company

TechCorp is a publicly traded company with a stable market position. Its capital structure and costs are as follows:

  • Market Value of Equity: $500 million
  • Market Value of Debt: $200 million
  • Total Capital Value: $700 million
  • Cost of Equity (Re): 15% (0.15)
  • Cost of Debt (Rd): 6% (0.06)
  • Corporate Tax Rate (Tc): 25% (0.25)

Calculations:

  • Weight of Equity (We) = $500M / $700M = 0.714 (71.4%)
  • Weight of Debt (Wd) = $200M / $700M = 0.286 (28.6%)
  • After-Tax Cost of Debt = 0.06 * (1 – 0.25) = 0.045 (4.5%)
  • WACC = (0.714 * 0.15) + (0.286 * 0.045)
  • WACC = 0.1071 + 0.0129
  • WACC = 0.1200 or 12.00%

Interpretation: TechCorp needs to earn at least 12.00% on its investments to satisfy its capital providers. This WACC of 12.00% will be used as the discount rate for evaluating new projects.

Example 2: Manufacturing Startup

ManuStart is a growing manufacturing firm that relies heavily on debt financing. Its current situation:

  • Market Value of Equity: $30 million
  • Market Value of Debt: $70 million
  • Total Capital Value: $100 million
  • Cost of Equity (Re): 20% (0.20) – Higher due to startup risk
  • Cost of Debt (Rd): 8% (0.08)
  • Corporate Tax Rate (Tc): 30% (0.30)

Calculations:

  • Weight of Equity (We) = $30M / $100M = 0.30 (30%)
  • Weight of Debt (Wd) = $70M / $100M = 0.70 (70%)
  • After-Tax Cost of Debt = 0.08 * (1 – 0.30) = 0.056 (5.6%)
  • WACC = (0.30 * 0.20) + (0.70 * 0.056)
  • WACC = 0.06 + 0.0392
  • WACC = 0.0992 or 9.92%

Interpretation: ManuStart's WACC is 9.92%. Despite a higher cost of equity due to risk, its significant use of debt (which is tax-advantaged) results in a lower overall WACC than might be expected. They must target returns above 9.92% for projects.

How to Use This WACC Calculator

This tool is designed to provide a quick and accurate WACC calculation. Follow these simple steps:

  1. Input Capital Weights: Enter the proportion of your company's total market value that is financed by equity (Weight of Equity – We) and debt (Weight of Debt – Wd). These should sum to 1 (or 100%). For example, if equity is 60% and debt is 40%, enter 0.60 for We and 0.40 for Wd.
  2. Enter Cost of Equity (Re): Input the required rate of return for your equity investors. This is often derived using models like CAPM. Enter it as a decimal (e.g., 12% is 0.12).
  3. Enter Cost of Debt (Rd): Input the current interest rate your company pays on its debt. Enter it as a decimal (e.g., 5% is 0.05).
  4. Enter Tax Rate (Tc): Input your company's effective corporate tax rate as a decimal (e.g., 21% is 0.21).
  5. Calculate: Click the "Calculate WACC" button. The calculator will compute the after-tax cost of debt, the total debt and equity weights (if they don't sum to 1, it will use the entered values directly in the formula), and the final WACC.

How to Read Results

  • Highlighted WACC: This is your company's Weighted Average Cost of Capital, displayed prominently. It represents the minimum acceptable rate of return for new investments.
  • After-Tax Cost of Debt: Shows the effective cost of debt after accounting for tax deductibility of interest expenses.
  • Total Debt Weight & Equity Weight: These display the proportions of debt and equity in your capital structure used for the calculation.
  • Formula Explanation: A reminder of the WACC formula used.

Decision-Making Guidance

Use your calculated WACC as a hurdle rate. If a potential project or investment is expected to generate returns *higher* than your WACC, it's likely to create value for shareholders. If the expected returns are *lower*, the investment should be rejected or reconsidered. It's essential to ensure your inputs accurately reflect current market values and costs.

Key Factors That Affect WACC Results

Several dynamic factors influence a company's Weighted Average Cost of Capital. Understanding these helps in interpreting WACC fluctuations and strategic financial planning:

  1. Market Risk Premium: The excess return investors expect for investing in the stock market over a risk-free rate. A higher market risk premium generally increases the cost of equity (Re), thus increasing WACC.
  2. Interest Rates: General economic interest rate levels directly impact the cost of debt (Rd). Rising rates increase Rd and often Re, leading to a higher WACC.
  3. Company-Specific Risk: Factors like operational volatility, management quality, competitive landscape, and industry stability affect the perceived risk of the company. Higher risk typically leads to a higher cost of equity and potentially a higher WACC.
  4. Capital Structure (Weights): The proportion of debt versus equity significantly affects WACC. Debt is usually cheaper than equity (especially after tax benefits), so increasing the debt-to-equity ratio can lower WACC, up to a point where financial distress risk becomes too high.
  5. Corporate Tax Rate: A higher tax rate makes the tax shield on debt more valuable, reducing the after-tax cost of debt and thus lowering WACC. Conversely, lower tax rates increase WACC.
  6. Inflation Expectations: High inflation often leads central banks to raise interest rates, increasing both the cost of debt and the required return on equity, thereby pushing WACC higher.
  7. Company Size and Liquidity: Larger, more liquid companies often have lower costs of capital as they are perceived as less risky and have better access to funding.

Frequently Asked Questions (FAQ)

Q1: What is the difference between WACC and the cost of capital?

WACC is a specific calculation that represents the *weighted average* cost of *all* capital components (debt, equity, etc.) a company uses. 'Cost of capital' can sometimes refer to the cost of a single source, but WACC is the most comprehensive measure of a company's overall cost of financing.

Q2: How do I find the correct market value of debt?

For publicly traded debt, use the current market price. For non-traded debt (like bank loans), the book value is often used as a proxy if it closely approximates the market value, or the present value of future cash flows discounted at the current market interest rate for similar debt can be calculated.

Q3: Can WACC be negative?

In extremely rare theoretical scenarios, possibly if a company has highly subsidized debt or unusual financial instruments. However, for practical purposes, WACC is almost always positive as both cost of equity and cost of debt are positive.

Q4: Does WACC apply to private companies?

Yes, but calculating it can be more challenging. Market values for debt might be easier to estimate, but estimating the cost and market value of equity is more complex, often relying on comparable public companies or valuation multiples.

Q5: What is the role of CAPM in WACC?

The Capital Asset Pricing Model (CAPM) is a primary method used to estimate the Cost of Equity (Re), a key component of the WACC formula. CAPM calculates Re based on the risk-free rate, the stock's beta (its volatility relative to the market), and the market risk premium.

Q6: When should I use a project-specific discount rate instead of WACC?

If a project's risk profile differs significantly from the company's average risk, a project-specific discount rate should be used. For riskier projects, use a rate higher than WACC; for less risky projects, use a rate lower than WACC.

Q7: How often should WACC be recalculated?

WACC should be recalculated whenever there are significant changes in the company's capital structure, market interest rates, market risk premium, tax rates, or the company's specific risk profile. Annually is a common practice for stable companies.

Q8: What are the limitations of WACC?

Limitations include the difficulty in accurately estimating inputs (especially cost of equity), the assumption of constant capital structure, and its potential inadequacy for projects with significantly different risk profiles than the company average. It also assumes the company's risk is constant over the project's life.

function validateInput(id, min, max, errorId) { var input = document.getElementById(id); var value = parseFloat(input.value); var errorElement = document.getElementById(errorId); errorElement.style.display = 'none'; if (isNaN(value)) { errorElement.innerText = "Please enter a valid number."; errorElement.style.display = 'block'; return false; } if (value max) { errorElement.innerText = "Value must be between " + min + " and " + max + "."; errorElement.style.display = 'block'; return false; } return true; } function calculateWACC() { // Clear previous errors document.getElementById('equityWeightError').style.display = 'none'; document.getElementById('costOfEquityError').style.display = 'none'; document.getElementById('debtWeightError').style.display = 'none'; document.getElementById('costOfDebtError').style.display = 'none'; document.getElementById('taxRateError').style.display = 'none'; var equityWeight = document.getElementById('equityWeight').value; var costOfEquity = document.getElementById('costOfEquity').value; var debtWeight = document.getElementById('debtWeight').value; var costOfDebt = document.getElementById('costOfDebt').value; var taxRate = document.getElementById('taxRate').value; var we = parseFloat(equityWeight); var re = parseFloat(costOfEquity); var wd = parseFloat(debtWeight); var rd = parseFloat(costOfDebt); var tc = parseFloat(taxRate); var valid = true; if (isNaN(we) || we 1) { document.getElementById('equityWeightError').innerText = "Weight must be between 0 and 1."; document.getElementById('equityWeightError').style.display = 'block'; valid = false; } if (isNaN(re) || re < 0) { document.getElementById('costOfEquityError').innerText = "Cost of Equity cannot be negative."; document.getElementById('costOfEquityError').style.display = 'block'; valid = false; } if (isNaN(wd) || wd 1) { document.getElementById('debtWeightError').innerText = "Weight must be between 0 and 1."; document.getElementById('debtWeightError').style.display = 'block'; valid = false; } if (isNaN(rd) || rd < 0) { document.getElementById('costOfDebtError').innerText = "Cost of Debt cannot be negative."; document.getElementById('costOfDebtError').style.display = 'block'; valid = false; } if (isNaN(tc) || tc 1) { document.getElementById('taxRateError').innerText = "Tax Rate must be between 0 and 1."; document.getElementById('taxRateError').style.display = 'block'; valid = false; } if (!valid) { document.getElementById('mainResult').innerText = "–.–%"; document.getElementById('afterTaxCostOfDebt').innerText = "–.–%"; document.getElementById('totalDebtWeight').innerText = "–.–"; document.getElementById('totalEquityWeight').innerText = "–.–"; return; } var afterTaxCostOfDebt = rd * (1 – tc); var wacc = (we * re) + (wd * afterTaxCostOfDebt); document.getElementById('mainResult').innerText = (wacc * 100).toFixed(2) + "%"; document.getElementById('afterTaxCostOfDebt').innerText = (afterTaxCostOfDebt * 100).toFixed(2) + "%"; document.getElementById('totalDebtWeight').innerText = wd.toFixed(3); document.getElementById('totalEquityWeight').innerText = we.toFixed(3); // Dynamic Chart Update updateChart(we, wd, re, afterTaxCostOfDebt, wacc); } function resetCalculator() { document.getElementById('equityWeight').value = '0.60'; document.getElementById('costOfEquity').value = '0.12'; document.getElementById('debtWeight').value = '0.40'; document.getElementById('costOfDebt').value = '0.05'; document.getElementById('taxRate').value = '0.21'; // Clear errors document.getElementById('equityWeightError').style.display = 'none'; document.getElementById('costOfEquityError').style.display = 'none'; document.getElementById('debtWeightError').style.display = 'none'; document.getElementById('costOfDebtError').style.display = 'none'; document.getElementById('taxRateError').style.display = 'none'; calculateWACC(); // Recalculate with default values } function copyResults() { var mainResult = document.getElementById('mainResult').innerText; var atCostOfDebt = document.getElementById('afterTaxCostOfDebt').innerText; var debtWeight = document.getElementById('totalDebtWeight').innerText; var equityWeight = document.getElementById('totalEquityWeight').innerText; var equityWeightInput = document.getElementById('equityWeight').value; var costOfEquityInput = document.getElementById('costOfEquity').value; var debtWeightInput = document.getElementById('debtWeight').value; var costOfDebtInput = document.getElementById('costOfDebt').value; var taxRateInput = document.getElementById('taxRate').value; var textToCopy = "— WACC Calculation Results —\n\n"; textToCopy += "Primary Result:\n"; textToCopy += "WACC: " + mainResult + "\n\n"; textToCopy += "Key Intermediate Values:\n"; textToCopy += "After-Tax Cost of Debt: " + atCostOfDebt + "\n"; textToCopy += "Total Debt Weight: " + debtWeight + "\n"; textToCopy += "Total Equity Weight: " + equityWeight + "\n\n"; textToCopy += "Assumptions/Inputs:\n"; textToCopy += "Weight of Equity (We): " + equityWeightInput + "\n"; textToCopy += "Cost of Equity (Re): " + (parseFloat(costOfEquityInput) * 100).toFixed(2) + "%\n"; textToCopy += "Weight of Debt (Wd): " + debtWeightInput + "\n"; textToCopy += "Cost of Debt (Rd): " + (parseFloat(costOfDebtInput) * 100).toFixed(2) + "%\n"; textToCopy += "Corporate Tax Rate (Tc): " + (parseFloat(taxRateInput) * 100).toFixed(2) + "%\n"; navigator.clipboard.writeText(textToCopy).then(function() { // Optionally provide user feedback, e.g., change button text briefly var originalText = button.innerText; button.innerText = 'Copied!'; setTimeout(function() { button.innerText = originalText; }, 1500); }, function(err) { console.error('Failed to copy text: ', err); alert('Failed to copy results. Please copy manually.'); }); } // Charting Logic var myChart; var ctx = document.getElementById('waccChartCanvas')?.getContext('2d'); // Ensure canvas element exists before initializing chart if (ctx) { myChart = new Chart(ctx, { type: 'bar', // Changed to bar chart for better comparison data: { labels: ['Equity Cost', 'Debt Cost (After-Tax)'], datasets: [{ label: 'Cost Components', data: [0, 0], // Placeholder data backgroundColor: [ 'rgba(0, 74, 153, 0.7)', // Primary color for Equity 'rgba(40, 167, 69, 0.7)' // Success color for Debt ], borderColor: [ 'rgba(0, 74, 153, 1)', 'rgba(40, 167, 69, 1)' ], borderWidth: 1 }, { label: 'Weighted Contribution', data: [0, 0], // Placeholder for weighted contributions backgroundColor: [ 'rgba(0, 74, 153, 0.4)', 'rgba(40, 167, 69, 0.4)' ], borderColor: [ 'rgba(0, 74, 153, 0.8)', 'rgba(40, 167, 69, 0.8)' ], borderWidth: 1, type: 'line', // Display as line on top fill: false, tension: 0.1 }] }, options: { responsive: true, maintainAspectRatio: false, scales: { y: { beginAtZero: true, ticks: { callback: function(value) { return (value * 100).toFixed(1) + '%'; } } } }, plugins: { legend: { position: 'top', }, title: { display: true, text: 'WACC Calculation Components', font: { size: 16 } } } } }); } else { console.error("Canvas element with ID 'waccChartCanvas' not found."); } function updateChart(we, wd, re, afterTaxCostOfDebt, wacc) { if (myChart) { myChart.data.datasets[0].data = [re, afterTaxCostOfDebt]; myChart.data.datasets[1].data = [we * re, wd * afterTaxCostOfDebt]; myChart.options.plugins.title.text = 'WACC Calculation Components (WACC: ' + (wacc * 100).toFixed(2) + '%)'; myChart.update(); } } // Initial calculation and chart setup on load document.addEventListener('DOMContentLoaded', function() { // Add a canvas element for the chart var canvasContainer = document.createElement('div'); canvasContainer.style.height = '300px'; // Fixed height for the chart area canvasContainer.style.marginBottom = '30px'; var canvas = document.createElement('canvas'); canvas.id = 'waccChartCanvas'; canvasContainer.appendChild(canvas); document.getElementById('results').parentNode.insertBefore(canvasContainer, document.getElementById('results')); resetCalculator(); // Set default values and perform initial calculation });

Leave a Comment