Calculate Cash Flow from Operating Activities

Calculate Cash Flow from Operating Activities – Free Tool :root { –primary-color: #004a99; –background-color: #f8f9fa; –card-background: #ffffff; –text-color: #333; –border-color: #dee2e6; –shadow-color: 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); margin: 0; padding: 0; line-height: 1.6; } .container { max-width: 960px; margin: 20px auto; padding: 20px; background-color: var(–card-background); border-radius: 8px; box-shadow: 0 2px 10px var(–shadow-color); } h1, h2, h3 { color: var(–primary-color); margin-bottom: 15px; } h1 { text-align: center; font-size: 2.2em; margin-bottom: 30px; } .calculator-section { margin-bottom: 40px; padding: 25px; border: 1px solid var(–border-color); border-radius: 8px; background-color: var(–card-background); box-shadow: 0 1px 5px var(–shadow-color); } .calculator-section h2 { margin-top: 0; text-align: center; font-size: 1.8em; } .input-group { margin-bottom: 20px; display: flex; flex-direction: column; } .input-group label { display: block; margin-bottom: 8px; font-weight: bold; color: var(–primary-color); } .input-group input[type="number"], .input-group input[type="text"], .input-group select { width: 100%; padding: 10px; border: 1px solid var(–border-color); border-radius: 4px; box-sizing: border-box; font-size: 1em; } .input-group input[type="number"]:focus, .input-group input[type="text"]:focus, .input-group select:focus { outline: none; border-color: var(–primary-color); box-shadow: 0 0 0 2px rgba(0, 74, 153, 0.2); } .input-group .helper-text { font-size: 0.85em; color: #6c757d; margin-top: 5px; } .error-message { color: #dc3545; font-size: 0.85em; margin-top: 5px; min-height: 1.2em; /* Reserve space to prevent layout shifts */ } .button-group { display: flex; justify-content: center; gap: 15px; margin-top: 25px; flex-wrap: wrap; } button { padding: 12px 25px; border: none; border-radius: 4px; cursor: pointer; font-size: 1em; font-weight: bold; transition: background-color 0.3s ease, transform 0.2s ease; background-color: var(–primary-color); color: white; } button:hover { background-color: #003366; transform: translateY(-1px); } button:active { transform: translateY(0); } #resetButton { background-color: #6c757d; } #resetButton:hover { background-color: #5a6268; } #copyButton { background-color: #28a745; } #copyButton:hover { background-color: #218838; } .results-container { margin-top: 30px; padding: 25px; border: 1px solid var(–border-color); border-radius: 8px; background-color: var(–card-background); box-shadow: 0 1px 5px var(–shadow-color); text-align: center; } .results-container h3 { margin-top: 0; font-size: 1.6em; color: var(–primary-color); } .primary-result { font-size: 2.5em; font-weight: bold; color: var(–primary-color); margin: 15px 0; padding: 15px; background-color: #e7f3ff; /* Light blue background for emphasis */ border-radius: 6px; display: inline-block; min-width: 200px; } .intermediate-results div, .formula-explanation { margin-bottom: 15px; font-size: 1.1em; } .intermediate-results span { font-weight: bold; color: var(–primary-color); } .formula-explanation { font-style: italic; color: #555; border-top: 1px dashed var(–border-color); padding-top: 15px; margin-top: 20px; } .table-responsive { overflow-x: auto; margin-top: 25px; border: 1px solid var(–border-color); border-radius: 4px; } table { width: 100%; border-collapse: collapse; margin-bottom: 0; /* Remove margin if it's inside the responsive wrapper */ } caption { caption-side: bottom; padding: 10px; font-size: 0.9em; color: #6c757d; text-align: center; margin-top: 10px; } th, td { padding: 12px 15px; text-align: left; border: 1px solid var(–border-color); } thead th { background-color: #e9ecef; color: var(–text-color); font-weight: bold; } tbody tr:nth-child(even) { background-color: #f8f9fa; } .chart-container { margin-top: 30px; padding: 25px; border: 1px solid var(–border-color); border-radius: 8px; background-color: var(–card-background); box-shadow: 0 1px 5px var(–shadow-color); text-align: center; } canvas { max-width: 100%; height: auto; } .article-section { margin-top: 40px; padding: 25px; border: 1px solid var(–border-color); border-radius: 8px; background-color: var(–card-background); box-shadow: 0 1px 5px var(–shadow-color); } .article-section h2, .article-section h3 { margin-top: 0; font-size: 1.8em; } .article-section h3 { font-size: 1.4em; margin-top: 20px; } .article-section p { margin-bottom: 15px; } .article-section ul { list-style-type: disc; margin-left: 20px; margin-bottom: 15px; } .article-section li { margin-bottom: 8px; } .internal-links-list { list-style: none; padding: 0; } .internal-links-list li { margin-bottom: 10px; } .internal-links-list a { color: var(–primary-color); text-decoration: none; font-weight: bold; } .internal-links-list a:hover { text-decoration: underline; } footer { text-align: center; margin-top: 40px; padding: 20px; font-size: 0.9em; color: #6c757d; } @media (max-width: 768px) { .container { margin: 10px; padding: 15px; } h1 { font-size: 1.8em; } .calculator-section, .results-container, .chart-container, .article-section { padding: 15px; } button { width: 100%; margin-bottom: 10px; } .button-group { flex-direction: column; align-items: center; } .primary-result { font-size: 2em; min-width: unset; } }

Calculate Cash Flow from Operating Activities

Operating Cash Flow Calculator

Reported net income from your income statement.
Non-cash expenses added back.
Net change in current assets and liabilities (e.g., increase in inventory is negative).
Gains/losses on asset sales, stock-based compensation, etc.

Your Operating Cash Flow

Depreciation & Amortization:
Changes in Working Capital:
Other Non-Cash Items:
Formula: Net Income + Depreciation & Amortization + Changes in Working Capital + Other Non-Cash Items = Cash Flow from Operating Activities

Calculation Breakdown

Item Amount Impact on Cash Flow
Net Income Starting Point
Depreciation & Amortization Add Back (Non-cash expense)
Changes in Working Capital Adjustments
Other Non-Cash Items Adjustments
Cash Flow from Operating Activities Final Result
Summary of components used in the operating cash flow calculation.

Operating Cash Flow Components

Visual representation of the main components contributing to operating cash flow.

What is Cash Flow from Operating Activities?

Cash Flow from Operating Activities (CFO), often referred to as operating cash flow, is a crucial financial metric that represents the amount of cash a company generates from its core business operations over a specific period. It's a key component of the Statement of Cash Flows and provides insights into a company's ability to generate cash internally, which is essential for sustaining operations, paying debts, funding investments, and returning value to shareholders. Unlike net income, which can be influenced by accrual accounting principles, CFO focuses purely on the actual cash inflows and outflows directly related to the primary revenue-generating activities of the business. Understanding your company's cash flow from operating activities is vital for assessing its financial health and operational efficiency. This metric helps stakeholders determine if the business is generating enough cash to cover its day-to-day expenses and reinvest in its future. A consistently positive operating cash flow is generally a sign of a healthy and sustainable business, while negative CFO might indicate underlying operational issues or significant investments in working capital.

Cash Flow from Operating Activities Formula and Mathematical Explanation

The most common method to calculate Cash Flow from Operating Activities is the indirect method, which starts with net income and adjusts for non-cash items and changes in working capital. The formula is as follows:

Cash Flow from Operating Activities = Net Income + Depreciation & Amortization + Changes in Working Capital + Other Non-Cash Items

Let's break down each component:

  • Net Income: This is the starting point, found at the bottom of the income statement. It represents the company's profit after all expenses, taxes, and interest have been deducted. However, net income is calculated using accrual accounting, meaning revenues and expenses are recognized when earned or incurred, not necessarily when cash is exchanged.
  • Depreciation and Amortization: These are non-cash expenses that reduce net income but do not involve an outflow of cash. Depreciation applies to tangible assets, while amortization applies to intangible assets. Since no cash was spent in the current period for these items, they are added back to net income.
  • Changes in Working Capital: This accounts for the cash impact of changes in a company's current assets (like accounts receivable and inventory) and current liabilities (like accounts payable).
    • An increase in current assets (e.g., more inventory or accounts receivable) typically means cash has been used, so it's subtracted.
    • A decrease in current assets means cash has been generated, so it's added.
    • An increase in current liabilities (e.g., more accounts payable) means the company has deferred payment, effectively generating cash, so it's added.
    • A decrease in current liabilities means cash has been paid out, so it's subtracted.
    The net effect of these changes is added or subtracted from net income.
  • Other Non-Cash Items: This category includes various other items that affect net income but don't involve cash. Common examples include gains or losses on the sale of long-term assets (where the gain is subtracted and the loss is added back), stock-based compensation expenses (added back), and deferred taxes.

By adjusting net income for these items, the indirect method reconciles the accrual-based net income to the actual cash generated from operations. This calculation is fundamental for understanding the true cash-generating power of a business, independent of its financing and investing activities. Analyzing the trends in cash flow from operating activities over time can reveal significant insights into a company's operational performance and its ability to manage its working capital effectively.

Practical Examples (Real-World Use Cases)

Understanding cash flow from operating activities is crucial for various stakeholders. Here are a few practical examples:

  • Startup Business: A tech startup might show a net loss due to high R&D expenses but still generate positive operating cash flow if it effectively manages its accounts payable and collects receivables quickly. This indicates the core business model is generating cash, even if profitability is temporarily impacted.
  • Retail Company: A retail chain might have strong sales (high revenue) but experience negative operating cash flow if its inventory levels are excessively high or if it's slow to collect payments from customers. This highlights potential issues in inventory management or credit policies.
  • Manufacturing Firm: A manufacturer might have significant depreciation expenses due to heavy machinery. Adding back this non-cash expense is critical to understanding the cash generated from producing and selling goods. If the company is also increasing its accounts payable to suppliers, this further boosts its operating cash flow.
  • Service-Based Business: A consulting firm might have minimal depreciation but significant accounts receivable. If clients pay promptly, operating cash flow will closely track net income. However, if receivables grow substantially, operating cash flow could lag behind net income, signaling potential collection issues.

These examples illustrate how cash flow from operating activities provides a more realistic picture of a company's financial health than net income alone. It helps in making informed decisions about liquidity, solvency, and operational efficiency.

How to Use This Cash Flow from Operating Activities Calculator

Using our free online calculator to determine your company's cash flow from operating activities is straightforward. Follow these simple steps:

  1. Gather Financial Data: You will need your company's latest Income Statement and Balance Sheet.
  2. Input Net Income: Enter the 'Net Income' figure from your income statement into the corresponding field.
  3. Enter Depreciation and Amortization: Find the total 'Depreciation and Amortization' expense from your income statement (or notes) and enter it.
  4. Input Changes in Working Capital: This requires comparing current assets and liabilities between two balance sheet periods.
    • Calculate the net change in current assets (e.g., Accounts Receivable, Inventory, Prepaid Expenses).
    • Calculate the net change in current liabilities (e.g., Accounts Payable, Accrued Expenses).
    • The 'Changes in Working Capital' is typically (Change in Current Liabilities – Change in Current Assets). Remember that an increase in current assets decreases cash, and an increase in current liabilities increases cash. Enter the net result (positive or negative).
  5. Add Other Non-Cash Items: Include any other significant non-cash expenses or revenues not already accounted for, such as gains or losses on asset sales, or stock-based compensation. Enter these as positive or negative values as appropriate.
  6. Calculate: Click the 'Calculate' button.
  7. Review Results: The calculator will display your estimated Cash Flow from Operating Activities, along with the intermediate values used in the calculation.
  8. Reset: If you need to start over or input new figures, click the 'Reset' button.
  9. Copy Results: Use the 'Copy Results' button to easily transfer the calculated figures and assumptions to another document or report.

This tool simplifies the process, allowing you to quickly assess a key aspect of your business's financial performance. For a more detailed analysis, consider consulting with a financial professional or exploring our related financial tools.

Key Factors That Affect Cash Flow from Operating Activities Results

Several factors can significantly influence the calculated Cash Flow from Operating Activities (CFO). Understanding these can help in interpreting the results and identifying areas for improvement:

  • Profitability: While CFO isn't solely dependent on net income, higher profitability generally leads to higher operating cash flow, assuming other factors remain constant. Declining profits can signal future cash flow challenges.
  • Inventory Management: Holding excessive inventory ties up cash. If inventory levels increase significantly without a corresponding rise in sales, it will reduce CFO. Efficient inventory turnover is key.
  • Accounts Receivable Collection: The speed at which customers pay their invoices directly impacts CFO. Long collection periods (high Days Sales Outstanding) mean cash is tied up in receivables, reducing operating cash flow. Effective credit policies and diligent collection efforts are vital.
  • Accounts Payable Management: Extending payment terms to suppliers (increasing accounts payable) can temporarily boost CFO by holding onto cash longer. However, overly aggressive stretching can damage supplier relationships.
  • Non-Cash Expenses: The level of depreciation and amortization can significantly affect the reconciliation from net income to CFO. Companies with large investments in fixed assets will typically have higher depreciation charges.
  • Economic Conditions: Broader economic trends can impact sales, customer payment behavior, and supplier terms, indirectly affecting CFO. Recessions might lead to slower sales and increased difficulty in collecting receivables.
  • Seasonality: Businesses with seasonal sales patterns may see fluctuations in CFO throughout the year. It's often more insightful to analyze CFO trends over longer periods (e.g., annually) or on a trailing twelve-month basis.
  • One-Time Events: Significant gains or losses from asset sales, or large restructuring charges, can distort CFO in a single period. It's important to look beyond these one-off items to assess the underlying operational cash generation.

By monitoring these factors, businesses can gain a deeper understanding of their operating cash flow dynamics and implement strategies to improve cash generation from their core activities. Analyzing the interplay between these elements is crucial for robust financial planning.

Frequently Asked Questions (FAQ)

Q1: What is the difference between Net Income and Cash Flow from Operating Activities?

A1: Net Income is calculated using accrual accounting, recognizing revenues when earned and expenses when incurred, regardless of cash movement. Cash Flow from Operating Activities (CFO) focuses solely on the actual cash generated or used by the company's core business operations. CFO adjusts net income for non-cash items (like depreciation) and changes in working capital accounts.

Q2: Why is positive Cash Flow from Operating Activities important?

A2: Positive CFO indicates that a company's core business operations are generating enough cash to sustain itself, cover expenses, pay debts, and potentially fund growth without relying heavily on external financing. It's a strong sign of financial health and operational efficiency.

Q3: Can a company have positive Net Income but negative Cash Flow from Operating Activities?

A3: Yes. This can happen if a company has significant increases in inventory or accounts receivable, or if it has substantial non-cash revenues or gains that inflate net income but don't bring in cash. It can also occur if non-cash expenses like depreciation are low relative to changes in working capital.

Q4: How do I calculate 'Changes in Working Capital'?

A4: You compare the current balance sheet figures for current assets and current liabilities from one period to the next. Generally, an increase in current assets (like inventory or receivables) decreases cash flow, while an increase in current liabilities (like payables) increases cash flow. The net effect is calculated and adjusted in the CFO formula.

Q5: Is Cash Flow from Operating Activities the same as Free Cash Flow?

A5: No. Cash Flow from Operating Activities (CFO) measures cash from core operations. Free Cash Flow (FCF) is typically calculated as CFO minus capital expenditures (investments in long-term assets like property, plant, and equipment). FCF represents the cash available to the company after reinvesting in its operations.

Related Tools and Internal Resources

© 2023 Your Financial Tools. All rights reserved.

var netIncomeInput = document.getElementById('netIncome'); var depreciationInput = document.getElementById('depreciation'); var changesInWorkingCapitalInput = document.getElementById('changesInWorkingCapital'); var otherNonCashItemsInput = document.getElementById('otherNonCashItems'); var primaryResultDiv = document.getElementById('primaryResult'); var intermediateDepreciationDiv = document.getElementById('intermediateDepreciation').querySelector('span'); var intermediateWorkingCapitalDiv = document.getElementById('intermediateWorkingCapital').querySelector('span'); var intermediateOtherDiv = document.getElementById('intermediateOther').querySelector('span'); var tableNetIncomeCell = document.getElementById('tableNetIncome'); var tableDepreciationCell = document.getElementById('tableDepreciation'); var tableWorkingCapitalCell = document.getElementById('tableWorkingCapital'); var tableOtherNonCashCell = document.getElementById('tableOtherNonCash'); var tableOperatingCashFlowCell = document.getElementById('tableOperatingCashFlow'); var netIncomeError = document.getElementById('netIncomeError'); var depreciationError = document.getElementById('depreciationError'); var changesInWorkingCapitalError = document.getElementById('changesInWorkingCapitalError'); var otherNonCashItemsError = document.getElementById('otherNonCashItemsError'); var chartCanvas = document.getElementById('operatingCashFlowChart'); var chartInstance = null; function formatCurrency(value) { if (isNaN(value) || value === null) return '–'; return value.toLocaleString('en-US', { style: 'currency', currency: 'USD', minimumFractionDigits: 0, maximumFractionDigits: 0 }); } function formatNumber(value) { if (isNaN(value) || value === null) return '–'; return value.toLocaleString('en-US', { minimumFractionDigits: 0, maximumFractionDigits: 0 }); } function validateInput(inputElement, errorElement, label, minValue = null, maxValue = null) { var value = parseFloat(inputElement.value); var isValid = true; if (isNaN(value)) { errorElement.textContent = label + ' is required.'; isValid = false; } else if (value 0 && label === "Changes in Working Capital") { errorElement.textContent = "Increase in working capital usually reduces cash flow. Enter as negative if applicable."; isValid = false; } else if (value 0.01) { // Threshold to include data points filteredLabels.push(labels[index]); filteredDataValues.push(value); filteredBackgroundColors.push(backgroundColors[index]); filteredBorderColors.push(borderColors[index]); } }); if (filteredDataValues.length === 0) { ctx.clearRect(0, 0, chartCanvas.width, chartCanvas.height); // Clear canvas if no data return; } chartInstance = new Chart(ctx, { type: 'bar', data: { labels: filteredLabels, datasets: [{ label: 'Component Value (USD)', data: filteredDataValues, backgroundColor: filteredBackgroundColors, borderColor: filteredBorderColors, borderWidth: 1 }] }, options: { responsive: true, maintainAspectRatio: false, scales: { y: { beginAtZero: true, ticks: { callback: function(value) { return formatCurrency(value); } } } }, plugins: { legend: { position: 'top', }, title: { display: true, text: 'Breakdown of Operating Cash Flow Components' } } } }); } function calculateCashFlow() { var netIncome = parseFloat(netIncomeInput.value); var depreciation = parseFloat(depreciationInput.value); var changesInWC = parseFloat(changesInWorkingCapitalInput.value); var otherNonCash = parseFloat(otherNonCashItemsInput.value); var isValidNetIncome = validateInput(netIncomeInput, netIncomeError, 'Net Income'); var isValidDepreciation = validateInput(depreciationInput, depreciationError, 'Depreciation and Amortization'); var isValidChangesInWC = validateInput(changesInWorkingCapitalInput, changesInWorkingCapitalError, 'Changes in Working Capital'); var isValidOtherNonCash = validateInput(otherNonCashItemsInput, otherNonCashItemsError, 'Other Non-Cash Items'); if (!isValidNetIncome || !isValidDepreciation || !isValidChangesInWC || !isValidOtherNonCash) { primaryResultDiv.textContent = '–'; intermediateDepreciationDiv.textContent = '–'; intermediateWorkingCapitalDiv.textContent = '–'; intermediateOtherDiv.textContent = '–'; updateTable('–', '–', '–', '–', '–'); updateChart(0, 0, 0, 0); // Clear chart if inputs are invalid return; } var operatingCashFlow = netIncome + depreciation + changesInWC + otherNonCash; primaryResultDiv.textContent = formatCurrency(operatingCashFlow); intermediateDepreciationDiv.textContent = formatCurrency(depreciation); intermediateWorkingCapitalDiv.textContent = formatCurrency(changesInWC); intermediateOtherDiv.textContent = formatCurrency(otherNonCash); updateTable(netIncome, depreciation, changesInWC, otherNonCash, operatingCashFlow); updateChart(netIncome, depreciation, changesInWC, otherNonCash); } function updateTable(netIncome, depreciation, changesInWC, otherNonCash, operatingCashFlow) { tableNetIncomeCell.textContent = formatCurrency(netIncome); tableDepreciationCell.textContent = formatCurrency(depreciation); tableWorkingCapitalCell.textContent = formatCurrency(changesInWC); tableOtherNonCashCell.textContent = formatCurrency(otherNonCash); tableOperatingCashFlowCell.textContent = formatCurrency(operatingCashFlow); } function resetCalculator() { netIncomeInput.value = "; depreciationInput.value = "; changesInWorkingCapitalInput.value = "; otherNonCashItemsInput.value = "; netIncomeError.textContent = "; depreciationError.textContent = "; changesInWorkingCapitalError.textContent = "; otherNonCashItemsError.textContent = "; primaryResultDiv.textContent = '–'; intermediateDepreciationDiv.textContent = '–'; intermediateWorkingCapitalDiv.textContent = '–'; intermediateOtherDiv.textContent = '–'; updateTable('–', '–', '–', '–', '–'); if (chartInstance) { chartInstance.destroy(); chartInstance = null; } var ctx = chartCanvas.getContext('2d'); ctx.clearRect(0, 0, chartCanvas.width, chartCanvas.height); } function copyResults() { var netIncomeVal = parseFloat(netIncomeInput.value); var depreciationVal = parseFloat(depreciationInput.value); var changesInWCVal = parseFloat(changesInWorkingCapitalInput.value); var otherNonCashVal = parseFloat(otherNonCashItemsInput.value); var operatingCashFlowVal = netIncomeVal + depreciationVal + changesInWCVal + otherNonCashVal; var netIncomeFormatted = formatCurrency(netIncomeVal); var depreciationFormatted = formatCurrency(depreciationVal); var changesInWCFormatted = formatCurrency(changesInWCVal); var otherNonCashFormatted = formatCurrency(otherNonCashVal); var operatingCashFlowFormatted = formatCurrency(operatingCashFlowVal); var isValidNetIncome = !isNaN(netIncomeVal); var isValidDepreciation = !isNaN(depreciationVal); var isValidChangesInWC = !isNaN(changesInWCVal); var isValidOtherNonCash = !isNaN(otherNonCashVal); if (!isValidNetIncome || !isValidDepreciation || !isValidChangesInWC || !isValidOtherNonCash) { alert("Please enter valid numbers for all fields before copying."); return; } var resultText = "— Operating Cash Flow Calculation —\n\n"; resultText += "Key Assumptions:\n"; resultText += "- Net Income: " + netIncomeFormatted + "\n"; resultText += "- Depreciation & Amortization: " + depreciationFormatted + "\n"; resultText += "- Changes in Working Capital: " + changesInWCFormatted + "\n"; resultText += "- Other Non-Cash Items: " + otherNonCashFormatted + "\n\n"; resultText += "Formula: Net Income + Depreciation & Amortization + Changes in Working Capital + Other Non-Cash Items\n\n"; resultText += "Primary Result:\n"; resultText += "Cash Flow from Operating Activities: " + operatingCashFlowFormatted + "\n"; try { navigator.clipboard.writeText(resultText).then(function() { alert("Results copied to clipboard!"); }).catch(function(err) { console.error('Failed to copy text: ', err); alert("Failed to copy results. Please copy manually."); }); } catch (e) { console.error('Clipboard API not available: ', e); alert("Clipboard API not available. Please copy manually."); } } // Initial calculation on load if values are present (e.g., from URL params or saved state) // For this example, we'll just ensure the chart is set up correctly. // A full implementation might load saved values. document.addEventListener('DOMContentLoaded', function() { // Set initial sensible defaults for demonstration if fields are empty // netIncomeInput.value = 500000; // depreciationInput.value = 50000; // changesInWorkingCapitalInput.value = -15000; // otherNonCashItemsInput.value = 5000; // calculateCashFlow(); // Calculate with defaults if set // Ensure chart canvas is ready var ctx = chartCanvas.getContext('2d'); ctx.clearRect(0, 0, chartCanvas.width, chartCanvas.height); // Clear canvas initially // Add event listeners for real-time updates var inputs = [netIncomeInput, depreciationInput, changesInWorkingCapitalInput, otherNonCashItemsInput]; inputs.forEach(function(input) { input.addEventListener('input', calculateCashFlow); input.addEventListener('change', calculateCashFlow); // Also trigger on change }); }); // Add Chart.js library dynamically if not present // In a real WordPress setup, you'd enqueue this script properly. // For a single HTML file, we can embed it or link it. // For this example, assuming Chart.js is available globally or embedded. // If not, you'd need to include: // // somewhere in the or before the script tag. // For this specific output, I will assume Chart.js is available. // If it's not, the chart will fail to render. // To make this self-contained, I'll add the CDN link. var chartJsScript = document.createElement('script'); chartJsScript.src = 'https://cdn.jsdelivr.net/npm/chart.js'; document.head.appendChild(chartJsScript);

Leave a Comment