1800 Inflation Calculator

1800 Inflation Calculator: See How Much Money Was Worth Then vs. Now body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f8f9fa; color: #333; line-height: 1.6; margin: 0; padding: 0; } .container { max-width: 960px; margin: 20px auto; padding: 20px; background-color: #fff; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } h1, h2, h3 { color: #004a99; } h1 { text-align: center; margin-bottom: 20px; } .calculator-section { background-color: #eef5ff; padding: 25px; border-radius: 8px; margin-bottom: 30px; border: 1px solid #cce0ff; } .calculator-section h2 { margin-top: 0; text-align: center; color: #003366; } .input-group { margin-bottom: 15px; display: flex; flex-direction: column; } .input-group label { display: block; margin-bottom: 8px; font-weight: bold; color: #004a99; } .input-group input[type="number"], .input-group select { padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 1rem; width: calc(100% – 22px); /* Adjust for padding and border */ } .input-group input[type="number"]:focus, .input-group select:focus { border-color: #004a99; outline: none; box-shadow: 0 0 0 2px rgba(0, 74, 153, 0.2); } .input-group .helper-text { font-size: 0.85em; color: #666; margin-top: 5px; } .input-group .error-message { color: #dc3545; font-size: 0.85em; margin-top: 5px; display: none; /* Hidden by default */ } .button-group { display: flex; justify-content: space-between; margin-top: 20px; gap: 10px; } .button-group button { padding: 10px 15px; border: none; border-radius: 4px; cursor: pointer; font-size: 1rem; font-weight: bold; transition: background-color 0.3s ease; } .btn-calculate { background-color: #004a99; color: white; flex-grow: 1; } .btn-calculate:hover { background-color: #003366; } .btn-reset { background-color: #6c757d; color: white; } .btn-reset:hover { background-color: #5a6268; } .btn-copy { background-color: #28a745; color: white; } .btn-copy:hover { background-color: #218838; } #results-container { margin-top: 30px; padding: 20px; background-color: #f0f8ff; border-radius: 8px; border: 1px solid #b3d7ff; } #results-container h3 { margin-top: 0; color: #003366; text-align: center; } .result-item { margin-bottom: 15px; padding: 10px; border-radius: 4px; background-color: #fff; border: 1px solid #e0e0e0; } .result-item label { font-weight: bold; color: #004a99; display: block; margin-bottom: 5px; } .result-item .value { font-size: 1.2em; font-weight: bold; color: #004a99; } .primary-result { background-color: #28a745; color: white; padding: 15px; text-align: center; border-radius: 6px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(40, 167, 69, 0.3); } .primary-result label { color: white; font-size: 1.1em; margin-bottom: 8px; } .primary-result .value { font-size: 2em; font-weight: bold; color: white; } .formula-explanation { font-size: 0.9em; color: #555; margin-top: 15px; padding-top: 10px; border-top: 1px dashed #ccc; } table { width: 100%; border-collapse: collapse; margin-top: 20px; margin-bottom: 20px; } th, td { padding: 10px; text-align: left; border: 1px solid #ddd; } th { background-color: #004a99; color: white; font-weight: bold; } tr:nth-child(even) { background-color: #f2f2f2; } caption { font-size: 1.1em; font-weight: bold; color: #004a99; margin-bottom: 10px; caption-side: top; text-align: left; } #chartContainer { text-align: center; margin-top: 30px; background-color: #fff; padding: 20px; border-radius: 8px; border: 1px solid #e0e0e0; } #chartContainer canvas { max-width: 100%; height: auto; } .chart-legend { margin-top: 15px; font-size: 0.9em; color: #555; } .chart-legend span { display: inline-block; margin: 0 10px; } .chart-legend .color-box { display: inline-block; width: 12px; height: 12px; margin-right: 5px; vertical-align: middle; border: 1px solid #ccc; } .color-1800 { background-color: #004a99; } .color-today { background-color: #28a745; } /* Article Styling */ .article-content { margin-top: 40px; background-color: #fff; padding: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } .article-content h2, .article-content h3 { margin-top: 30px; margin-bottom: 15px; color: #004a99; } .article-content p { margin-bottom: 15px; } .article-content ul, .article-content ol { margin-bottom: 15px; padding-left: 25px; } .article-content li { margin-bottom: 8px; } .article-content strong { color: #004a99; } .faq-item { margin-bottom: 15px; padding: 10px; border-left: 3px solid #004a99; background-color: #fefefe; border-radius: 4px; } .faq-item strong { display: block; margin-bottom: 5px; color: #004a99; } .internal-links { margin-top: 30px; padding: 20px; background-color: #eef5ff; border-radius: 8px; border: 1px solid #cce0ff; } .internal-links h3 { margin-top: 0; text-align: center; color: #003366; } .internal-links ul { list-style: none; padding: 0; } .internal-links li { margin-bottom: 10px; } .internal-links a { color: #004a99; text-decoration: none; font-weight: bold; } .internal-links a:hover { text-decoration: underline; } .internal-links p { font-size: 0.9em; color: #555; margin-top: 5px; } .highlight { background-color: #fff3cd; padding: 2px 4px; border-radius: 3px; }

1800 Inflation Calculator

Understand the historical value of money. See how much a dollar in 1800 would be worth today.

Inflation Value Calculator

Enter the monetary value from the year 1800.
Enter the year you want to compare to (e.g., 2023).

Results

Formula Used: The value of money in a future year is calculated by multiplying the original amount by the ratio of the Consumer Price Index (CPI) of the future year to the CPI of the base year (1800).

Value in Year Y = Amount in Base Year * (CPI in Year Y / CPI in Base Year)

Inflation Rate (%) = ((CPI in Year Y / CPI in Base Year) – 1) * 100

Average Annual Inflation = ( (CPI in Year Y / CPI in Base Year)^(1 / Number of Years) – 1 ) * 100

Historical Inflation Trend

Value in 1800 Equivalent Value in Target Year Equivalent

CPI Data Used (Sample)

Year CPI (Approximate) Value of $1 in 1800
1800 1.00 $1.00
1850 3.70 $0.27
1900 4.70 $0.21
1950 24.10 $0.04
2000 172.20 $0.01
2023 304.70 $0.003

Note: CPI data is approximate and varies by source. This table uses representative figures for illustrative purposes.

What is an 1800 Inflation Calculator?

An 1800 inflation calculator is a specialized financial tool designed to help you understand the significant changes in the purchasing power of money between the year 1800 and the present day. It quantifies how much a specific amount of money in 1800 would be equivalent to in terms of purchasing power in a more recent year, typically the current year. This is achieved by using historical Consumer Price Index (CPI) data, which tracks the average change over time in the prices paid by urban consumers for a market basket of consumer goods and services.

Who Should Use an 1800 Inflation Calculator?

This calculator is invaluable for a diverse range of individuals and professionals:

  • Historians and Researchers: To accurately assess the economic conditions, wages, and costs of goods and services in the early 19th century relative to modern times.
  • Genealogists: To understand the financial circumstances of ancestors who lived in the early 1800s, providing context to their earnings, savings, and expenditures.
  • Economists and Students: To study long-term economic trends, the impact of monetary policy, and the effects of sustained inflation over centuries.
  • Anyone Curious About History: To grasp the dramatic economic evolution of society and how the value of money has eroded over more than two centuries.
  • Investors and Financial Planners: To gain a broader perspective on long-term investment returns and the persistent challenge of inflation eroding wealth.

Common Misconceptions About Historical Inflation

Several myths surround historical inflation:

  • "Money was worth more" is too simplistic: While true in terms of purchasing power for many goods, the availability and types of goods and services were vastly different. Comparing a dollar in 1800 to today isn't a perfect apples-to-apples comparison of lifestyle.
  • Inflation was always steady: Historical inflation has been highly volatile, with periods of deflation (falling prices) and rapid inflation, often tied to wars, economic booms, and busts.
  • The CPI perfectly reflects past costs: The CPI is an estimate based on available data. The "basket" of goods and services consumed in 1800 was fundamentally different from today's, making precise comparisons challenging.
  • A high inflation rate in the past means the economy was bad: Not necessarily. Moderate inflation can sometimes accompany economic growth, while deflation can signal economic stagnation or depression.

1800 Inflation Calculator Formula and Mathematical Explanation

The core of the 1800 inflation calculator relies on the Consumer Price Index (CPI) to adjust historical monetary values. The CPI is a measure that examines the weighted average of prices of a basket of consumer goods and services, such as transportation, food, and medical care. It is calculated by taking price changes for each item in the predetermined basket of goods and averaging them.

The Basic Formula

To find the equivalent value of an amount from 1800 in a target year (let's call it Year Y), we use the following formula:

Equivalent Value in Year Y = Amount in 1800 * (CPI in Year Y / CPI in 1800)

Derivation and Variables

Let's break down the components:

  • Amount in 1800: This is the specific sum of money you want to convert from the year 1800.
  • CPI in 1800: This is the baseline Consumer Price Index for the year 1800. For simplicity and as a starting point, the CPI in the base year is often set to 1.00.
  • CPI in Year Y: This is the Consumer Price Index for the target year (e.g., 2023).
  • Equivalent Value in Year Y: This is the calculated amount of money in Year Y that would have the same purchasing power as the "Amount in 1800".

Calculating Inflation Rate

The overall percentage increase in prices from 1800 to Year Y is calculated as:

Inflation Rate (%) = [ (CPI in Year Y / CPI in 1800) – 1 ] * 100

Calculating Average Annual Inflation

To understand the consistent yearly price increase, we calculate the average annual inflation rate:

Average Annual Inflation (%) = [ (CPI in Year Y / CPI in 1800)^(1 / Number of Years) – 1 ] * 100

Where 'Number of Years' is the difference between Year Y and 1800.

Variable Table

Variable Meaning Unit Typical Range (for 1800-2023)
Amount in 1800 The principal sum of money in the year 1800. Currency Unit (e.g., Dollars) Any positive value
CPI in 1800 Consumer Price Index for the year 1800. Often set as the base (1.00). Index Value ~1.00
CPI in Year Y Consumer Price Index for the target year. Index Value Varies significantly (e.g., ~300+ for 2023)
Equivalent Value in Year Y The calculated value in the target year with equivalent purchasing power. Currency Unit (e.g., Dollars) Typically much higher than Amount in 1800
Inflation Rate Total percentage increase in prices over the period. Percentage (%) Hundreds or thousands of percent
Average Annual Inflation The constant yearly rate of price increase. Percentage (%) Typically 1-3% historically, but varies
Number of Years The duration between the base year (1800) and the target year. Years 200+ years

Practical Examples (Real-World Use Cases)

Example 1: The Value of a Day's Wage in 1800

Let's say a skilled laborer in 1800 earned approximately $1.00 per day. How much would that daily wage be worth in 2023?

  • Input: Amount in 1800 = $1.00, Current Year = 2023
  • CPI Data (Approximate): CPI in 1800 = 1.00, CPI in 2023 = 304.70
  • Calculation:
    • Equivalent Value in 2023 = $1.00 * (304.70 / 1.00) = $304.70
    • Inflation Rate = ((304.70 / 1.00) – 1) * 100 = 30370%
    • Number of Years = 2023 – 1800 = 223 years
    • Average Annual Inflation = ((304.70)^(1/223) – 1) * 100 ≈ 1.63%
  • Output: A $1.00 wage in 1800 had the purchasing power equivalent to approximately $304.70 in 2023. The average annual inflation rate over this period was about 1.63%.
  • Interpretation: This highlights the immense erosion of purchasing power due to inflation over more than two centuries. A wage that was once considered decent for a day's work would require a significantly higher nominal amount today to achieve the same standard of living.

Example 2: The Cost of a Horse in 1800

Imagine a sturdy horse cost around $50 in 1800. What would that equate to in today's money?

  • Input: Amount in 1800 = $50.00, Current Year = 2023
  • CPI Data (Approximate): CPI in 1800 = 1.00, CPI in 2023 = 304.70
  • Calculation:
    • Equivalent Value in 2023 = $50.00 * (304.70 / 1.00) = $15,235.00
    • Inflation Rate = ((304.70 / 1.00) – 1) * 100 = 30370%
    • Number of Years = 223 years
    • Average Annual Inflation ≈ 1.63%
  • Output: A $50.00 horse in 1800 had the purchasing power equivalent to approximately $15,235.00 in 2023.
  • Interpretation: This demonstrates how the cost of goods, even those that seem basic, has dramatically increased in nominal terms. While horses are no longer a primary mode of transport, this comparison helps contextualize the scale of price changes over time. It also underscores why saving substantial sums in the early 19th century would yield significant purchasing power today, assuming the money was preserved and not spent.

How to Use This 1800 Inflation Calculator

Using the 1800 inflation calculator is straightforward:

  1. Enter the Amount from 1800: In the "Amount in 1800" field, type the specific monetary value you wish to convert (e.g., 100 for $100).
  2. Specify the Target Year: In the "Current Year" field, enter the year for which you want to know the equivalent value (e.g., 2023).
  3. Click Calculate: Press the "Calculate Value" button.

How to Read the Results

  • Primary Result (Value in Target Year): This is the main output, showing the equivalent purchasing power of your 1800 amount in the year you specified.
  • Inflation Rate: Displays the total percentage increase in prices between 1800 and the target year.
  • Average Annual Inflation: Shows the consistent yearly rate at which prices have increased on average over the period.
  • Purchasing Power Comparison: A simple ratio or statement indicating how much more (or less) expensive things have become.

Decision-Making Guidance

Understanding these figures can inform various decisions:

  • Historical Context: Provides a realistic perspective on historical wealth and poverty.
  • Long-Term Savings: Emphasizes the critical need for investments that outpace inflation to preserve and grow wealth over long periods.
  • Economic Analysis: Helps in analyzing historical economic data and trends.

Don't forget to use the "Reset" button to clear the fields and start a new calculation, and the "Copy Results" button to easily share your findings.

Key Factors That Affect 1800 Inflation Results

While the CPI-based calculation is standard, several underlying factors influence the results and their interpretation:

  1. CPI Data Accuracy and Source: Historical CPI data is an estimation. Different sources might use slightly different methodologies or data points, leading to minor variations in results. The further back in time, the less precise the data becomes.
  2. Changes in Goods and Services: The "basket" of goods and services considered by the CPI has evolved dramatically. Many items available today (smartphones, internet) didn't exist in 1800, and vice versa (e.g., horse-drawn carriages as a primary transport). This makes direct comparison imperfect.
  3. Quality Improvements: Modern goods are often of higher quality or offer more features than their historical counterparts, even if the nominal price is higher. A modern car is vastly different from a horse and buggy, making a simple price comparison insufficient for lifestyle analysis.
  4. Economic Shocks and Policy: Major events like wars (e.g., War of 1812, Civil War), industrial revolutions, technological advancements, and government monetary policies (or lack thereof) have caused significant fluctuations in inflation rates throughout history, far from a smooth, linear progression.
  5. Regional Differences: Inflation rates could vary significantly based on geographic location. Urban centers might experience different price pressures than rural areas. The CPI typically reflects national averages or specific urban indices.
  6. Deflationary Periods: The period between 1800 and today wasn't solely inflationary. There were periods of deflation (falling prices), particularly in the late 19th century, which complicate the long-term average.
  7. Technological Advancements: Innovations have drastically reduced the cost of producing many goods over time (e.g., textiles, manufacturing). While this lowers prices for consumers, it also changes the nature of the economy and the goods available.
  8. Global Economic Factors: International trade, commodity prices, and global events have always influenced domestic price levels, even in the early 19th century, albeit to a lesser extent than today.

Frequently Asked Questions (FAQ)

Q1: Is the CPI the only way to measure historical inflation?

A1: While the CPI is the most common and widely accepted measure for consumer goods, other indices like the Producer Price Index (PPI) or GDP deflators exist. However, for comparing the purchasing power of everyday money, the CPI is the standard.

Q2: Can I use this calculator for years other than 1800?

A2: This specific calculator is designed for 1800 as the base year. For other base years, you would need a calculator specifically configured for that period, using the appropriate historical CPI data.

Q3: Why is the CPI for 1800 usually set to 1.00?

A3: Setting the CPI of the base year to 1.00 (or 100 in some scales) is a convention. It simplifies calculations, making the ratio directly represent the change in prices relative to that base year.

Q4: Does the calculator account for changes in wages?

A4: No, the calculator only adjusts for changes in the price level (inflation). It doesn't track wage growth relative to inflation. To compare wages, you'd need separate historical wage data.

Q5: How accurate is the CPI data from the early 1800s?

A5: Data from the early 19th century is less comprehensive and standardized than modern data. The CPI figures used are often reconstructions based on available price information for key commodities, making them estimates rather than exact measurements.

Q6: What does a high inflation rate mean for the economy?

A6: High inflation erodes purchasing power, can lead to economic uncertainty, discourage saving and investment, and disproportionately affect those on fixed incomes. However, moderate inflation is often seen as a sign of a healthy, growing economy.

Q7: If I had $100 in 1800, could I buy the same amount of goods today with $30,470?

A7: Approximately, yes, in terms of the *average* cost of a basket of goods. However, the specific goods available and their relative importance have changed so much that a direct comparison of lifestyle is difficult.

Q8: Does this calculator consider deflation?

A8: The calculation method inherently handles both inflation (price increases) and deflation (price decreases) if the CPI data reflects it. However, the long-term trend from 1800 to today has been overwhelmingly inflationary.

Related Tools and Internal Resources

© 2023 Your Financial Website. All rights reserved.

var chart = null; var chartContext = null; function getCpiData() { // Simplified CPI data for demonstration. Real-world applications would use more extensive datasets. // Source: Historical statistics, approximations. return { 1800: 1.00, 1850: 3.70, 1900: 4.70, 1950: 24.10, 1970: 38.80, 1990: 130.70, 2000: 172.20, 2010: 218.06, 2020: 258.83, 2023: 304.70 // Approximate for mid-2023 }; } function getCpiValue(year) { var cpiData = getCpiData(); var years = Object.keys(cpiData).map(Number).sort(function(a, b) { return a – b; }); if (year years[years.length – 1]) { return cpiData[years[years.length – 1]]; // Return latest available CPI if year is after data } // Find the closest year or interpolate if needed (simplified: use closest) var closestYear = years.reduce(function(prev, curr) { return (Math.abs(curr – year) < Math.abs(prev – year) ? curr : prev); }); return cpiData[closestYear]; } function validateInput(id, errorId, minValue, maxValue) { var input = document.getElementById(id); var errorSpan = document.getElementById(errorId); var value = parseFloat(input.value); errorSpan.style.display = 'none'; // Hide error by default if (isNaN(value)) { errorSpan.textContent = "Please enter a valid number."; errorSpan.style.display = 'block'; return false; } if (value maxValue) { errorSpan.textContent = "Value cannot exceed " + maxValue + "."; errorSpan.style.display = 'block'; return false; } return true; } function calculateInflation() { var isValidAmount = validateInput('amountIn1800', 'amountIn1800Error', 0); var isValidYear = validateInput('currentYear', 'currentYearError', 1800, new Date().getFullYear() + 5); // Allow a few years in the future if (!isValidAmount || !isValidYear) { return; } var amountIn1800 = parseFloat(document.getElementById('amountIn1800').value); var targetYear = parseInt(document.getElementById('currentYear').value); var baseYear = 1800; var cpi1800 = getCpiValue(baseYear); var cpiTargetYear = getCpiValue(targetYear); var equivalentValue = amountIn1800 * (cpiTargetYear / cpi1800); var inflationRate = ((cpiTargetYear / cpi1800) – 1) * 100; var numberOfYears = targetYear – baseYear; var averageAnnualInflation = 0; if (numberOfYears > 0 && cpiTargetYear > 0 && cpi1800 > 0) { averageAnnualInflation = (Math.pow((cpiTargetYear / cpi1800), (1 / numberOfYears)) – 1) * 100; } var purchasingPower = (cpi1800 / cpiTargetYear); var purchasingPowerText = ""; if (purchasingPower > 1) { purchasingPowerText = (purchasingPower * 100).toFixed(2) + "% of what $1 bought in 1800"; } else { purchasingPowerText = "$1 today buys " + (1/purchasingPower).toFixed(2) + "x what $1 bought in 1800"; } document.getElementById('primaryResultValue').textContent = formatCurrency(equivalentValue); document.getElementById('inflationRate').textContent = inflationRate.toFixed(2) + "%"; document.getElementById('averageAnnualInflation').textContent = averageAnnualInflation.toFixed(2) + "%"; document.getElementById('purchasingPower').textContent = purchasingPowerText; updateChart(targetYear, cpi1800, cpiTargetYear, amountIn1800, equivalentValue); updateTable(targetYear, cpi1800, cpiTargetYear, amountIn1800, equivalentValue); } function formatCurrency(amount) { return "$" + amount.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'); } function resetCalculator() { document.getElementById('amountIn1800').value = "100"; document.getElementById('currentYear').value = "2023"; document.getElementById('amountIn1800Error').style.display = 'none'; document.getElementById('currentYearError').style.display = 'none'; document.getElementById('primaryResultValue').textContent = "–"; document.getElementById('inflationRate').textContent = "–"; document.getElementById('averageAnnualInflation').textContent = "–"; document.getElementById('purchasingPower').textContent = "–"; if (chart) { chart.destroy(); chart = null; } } function copyResults() { var mainResultLabel = document.getElementById('primaryResultLabel').textContent; var mainResultValue = document.getElementById('primaryResultValue').textContent; var inflationRate = document.getElementById('inflationRate').textContent; var avgInflation = document.getElementById('averageAnnualInflation').textContent; var purchasingPower = document.getElementById('purchasingPower').textContent; var assumptions = "Key Assumptions:\n"; assumptions += "- Base Year: 1800\n"; assumptions += "- Target Year: " + document.getElementById('currentYear').value + "\n"; assumptions += "- CPI Data Source: Historical Estimates\n"; var textToCopy = mainResultLabel + ": " + mainResultValue + "\n"; textToCopy += "Inflation Rate (1800-" + document.getElementById('currentYear').value + "): " + inflationRate + "\n"; textToCopy += "Average Annual Inflation: " + avgInflation + "\n"; textToCopy += "Purchasing Power: " + purchasingPower + "\n\n"; textToCopy += assumptions; navigator.clipboard.writeText(textToCopy).then(function() { // Optional: Show a confirmation message var btnCopy = document.querySelector('.btn-copy'); var originalText = btnCopy.textContent; btnCopy.textContent = 'Copied!'; setTimeout(function() { btnCopy.textContent = originalText; }, 1500); }).catch(function(err) { console.error('Failed to copy text: ', err); // Optional: Show an error message }); } function updateChart(targetYear, cpi1800, cpiTargetYear, amountIn1800, equivalentValue) { var ctx = document.getElementById('inflationChart').getContext('2d'); if (chart) { chart.destroy(); } var cpiData = getCpiData(); var years = Object.keys(cpiData).map(Number).sort(function(a, b) { return a – b; }); var labels = []; var values1800Equivalent = []; var valuesTargetYearEquivalent = []; // Generate data points for the chart var yearStep = Math.max(1, Math.floor((targetYear – 1800) / 10)); // Adjust step for smoother curve for (var year = 1800; year targetYear) year = targetYear; // Ensure target year is included labels.push(year); var currentCpi = getCpiValue(year); var valueIn1800 = (amountIn1800 / cpi1800) * currentCpi; values1800Equivalent.push(valueIn1800); var valueInTarget = (equivalentValue / cpiTargetYear) * currentCpi; valuesTargetYearEquivalent.push(valueInTarget); if (year === targetYear) break; // Exit loop if target year is reached } chartContext = ctx; chart = new Chart(chartContext, { type: 'line', data: { labels: labels, datasets: [{ label: 'Value of $' + amountIn1800.toFixed(2) + ' in 1800', data: values1800Equivalent, borderColor: '#004a99', backgroundColor: 'rgba(0, 74, 153, 0.1)', fill: false, tension: 0.1 }, { label: 'Value of $' + equivalentValue.toFixed(2) + ' in ' + targetYear, data: valuesTargetYearEquivalent, borderColor: '#28a745', backgroundColor: 'rgba(40, 167, 69, 0.1)', fill: false, tension: 0.1 }] }, options: { responsive: true, maintainAspectRatio: false, scales: { y: { beginAtZero: true, title: { display: true, text: 'Equivalent Value ($)' } }, x: { title: { display: true, text: 'Year' } } }, 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 updateTable(targetYear, cpi1800, cpiTargetYear, amountIn1800, equivalentValue) { var tableBody = document.getElementById('cpiTableBody'); tableBody.innerHTML = "; // Clear existing rows var cpiData = getCpiData(); var years = Object.keys(cpiData).map(Number).sort(function(a, b) { return a – b; }); var yearStep = Math.max(1, Math.floor((targetYear – 1800) / 5)); // Show fewer points in table for (var year = 1800; year targetYear) year = targetYear; var currentCpi = getCpiValue(year); var valueIn1800 = (amountIn1800 / cpi1800) * currentCpi; var row = tableBody.insertRow(); var cellYear = row.insertCell(); var cellCpi = row.insertCell(); var cellValue = row.insertCell(); cellYear.textContent = year; cellCpi.textContent = currentCpi.toFixed(2); cellValue.textContent = formatCurrency(valueIn1800); if (year === targetYear) break; } } // Initial calculation on load document.addEventListener('DOMContentLoaded', function() { calculateInflation(); });

Leave a Comment