Tyre Fit Calculator

Tyre Fit Calculator: Ensure Perfect Tyre Compatibility :root { –primary-color: #004a99; –background-color: #f8f9fa; –card-background: #ffffff; –text-color: #333; –border-color: #ddd; –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); text-align: center; margin-bottom: 20px; } h1 { font-size: 2.2em; } h2 { font-size: 1.8em; margin-top: 30px; border-bottom: 2px solid var(–primary-color); padding-bottom: 5px; } h3 { font-size: 1.4em; margin-top: 25px; } .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); } .input-group { margin-bottom: 20px; text-align: left; } .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); padding: 10px; border: 1px solid var(–border-color); border-radius: 4px; font-size: 1em; box-sizing: border-box; } .input-group input[type="number"]: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: #666; margin-top: 5px; display: block; } .error-message { color: #d9534f; font-size: 0.85em; margin-top: 5px; display: block; min-height: 1.2em; /* Prevent layout shifts */ } .button-group { text-align: center; margin-top: 25px; } button { background-color: var(–primary-color); color: white; border: none; padding: 12px 25px; border-radius: 5px; font-size: 1.1em; cursor: pointer; margin: 0 10px; transition: background-color 0.3s ease; } button:hover { background-color: #003366; } button.reset-button { background-color: #6c757d; } button.reset-button:hover { background-color: #5a6268; } .results-container { margin-top: 30px; padding: 20px; border: 1px solid var(–border-color); border-radius: 8px; background-color: #e7f3ff; /* Light accent background for results */ box-shadow: 0 1px 5px var(–shadow-color); text-align: center; } .results-container h3 { margin-top: 0; color: var(–primary-color); } .primary-result { font-size: 2.5em; font-weight: bold; color: var(–primary-color); margin: 15px 0; } .intermediate-results div, .key-assumptions div { margin-bottom: 10px; font-size: 1.1em; } .intermediate-results span, .key-assumptions span { font-weight: bold; color: var(–primary-color); } .formula-explanation { font-size: 0.9em; color: #555; margin-top: 15px; padding-top: 15px; border-top: 1px dashed var(–border-color); } .table-responsive { overflow-x: auto; margin-top: 20px; margin-bottom: 30px; border: 1px solid var(–border-color); border-radius: 4px; } table { width: 100%; border-collapse: collapse; min-width: 600px; /* Ensure horizontal scroll on mobile */ } th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(–border-color); } thead th { background-color: var(–primary-color); color: white; font-weight: bold; } tbody tr:nth-child(even) { background-color: #f2f2f2; } caption { caption-side: bottom; padding: 10px; font-size: 0.9em; color: #666; text-align: center; margin-top: 10px; } canvas { max-width: 100%; height: auto; display: block; margin: 20px auto; border: 1px solid var(–border-color); border-radius: 4px; } .article-content { 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); text-align: left; } .article-content p { margin-bottom: 15px; } .article-content a { color: var(–primary-color); text-decoration: none; } .article-content a:hover { text-decoration: underline; } .internal-links-list { list-style: none; padding: 0; } .internal-links-list li { margin-bottom: 15px; } .internal-links-list a { font-weight: bold; } .internal-links-list span { font-size: 0.9em; color: #555; display: block; margin-top: 3px; } @media (max-width: 768px) { .container { margin: 10px; padding: 15px; } h1 { font-size: 1.8em; } h2 { font-size: 1.5em; } h3 { font-size: 1.2em; } button { margin: 5px 5px; padding: 10px 20px; font-size: 1em; } .primary-result { font-size: 2em; } }

Tyre Fit Calculator: Ensure Perfect Tyre Compatibility

Tyre Fit Calculator

The width of your current tyre in millimeters.
The sidewall height as a percentage of the width (e.g., 55 for 55%).
The diameter of your wheel rim in inches.
The width of the new tyre you are considering.
The sidewall height of the new tyre as a percentage of its width.
The diameter of the new wheel rim in inches.
The offset of the wheel (distance from hub to wheel centerline). Positive values push the wheel out.

Tyre Fit Comparison

Key Assumptions:

Wheel Offset: mm
Tyre Clearance: mm (Estimated)
Calculations are based on tyre dimensions and wheel offset to estimate overall diameter, speedometer error, and potential clearance issues.

Tyre Dimension Comparison Table

Parameter Current Tyre New Tyre Difference
Width (mm)
Sidewall Height (mm)
Overall Diameter (mm)
Circumference (mm)
Revolutions per km
Detailed comparison of current and proposed tyre specifications.

Tyre Diameter Comparison Chart

Visual representation of the overall diameter difference between current and new tyres.

Understanding the Tyre Fit Calculator

What is a Tyre Fit Calculator?

A tyre fit calculator is an essential tool for any vehicle owner looking to change their tyres or wheels. It helps determine if a new tyre and wheel combination will physically fit on your vehicle without causing issues like rubbing against the bodywork, suspension components, or brakes. Beyond just physical fit, it also calculates how the new tyre dimensions will affect your speedometer accuracy and overall driving dynamics. Using a tyre fit calculator ensures you make informed decisions, preventing costly mistakes and potential safety hazards.

When considering new tyres, it's not just about finding the right size that matches the manufacturer's recommendation. Factors like wheel offset, tyre profile, and even the specific tread pattern can influence how well a tyre fits. This tyre fit calculator simplifies this complex process by comparing your current tyre specifications against a potential new set, providing clear insights into compatibility and performance changes. It's a crucial step before purchasing new tyre fit options.

Tyre Fit Calculator Formula and Mathematical Explanation

The core of the tyre fit calculator relies on calculating the overall diameter of a tyre and comparing it to the existing one. The formula for tyre dimensions is as follows:

Tyre Overall Diameter (in mm) = (Tyre Width (mm) * Aspect Ratio (%) / 100) * 2 + (Wheel Diameter (inches) * 25.4 mm/inch)

Let's break this down:

  • Tyre Width (mm): The first number in a tyre size (e.g., 205 in 205/55 R16).
  • Aspect Ratio (%): The second number, representing the sidewall height as a percentage of the width (e.g., 55 in 205/55 R16). So, the sidewall height in mm is (Tyre Width * Aspect Ratio) / 100.
  • Overall Diameter: Since there are two sidewalls (top and bottom), we multiply the sidewall height by 2.
  • Wheel Diameter: The diameter of the rim, usually in inches. We convert this to millimeters by multiplying by 25.4.

The calculator then compares the overall diameter of the current tyre to the new tyre. A significant difference can lead to:

  • Speedometer Error: If the new tyre's overall diameter is larger, your speedometer will read lower than your actual speed. If it's smaller, your speedometer will read higher. The error percentage is calculated as: ((New Overall Diameter - Current Overall Diameter) / Current Overall Diameter) * 100%.
  • Clearance Issues: The calculator also considers wheel offset. A change in offset combined with a change in tyre width can affect how close the tyre comes to the vehicle's fenders and suspension. While this calculator provides an estimate, precise clearance checks often require physical inspection or more advanced tools. A positive offset pushes the wheel further into the car, while a negative offset pushes it out.

The tyre fit calculator uses these principles to provide a comprehensive comparison.

Practical Examples (Real-World Use Cases)

Consider a vehicle currently fitted with 205/55 R16 tyres on wheels with an ET45 offset. The owner wants to upgrade to 225/45 R17 tyres on new wheels with an ET35 offset.

Using the tyre fit calculator:

  • Current Tyre: 205mm width, 55% aspect ratio, 16-inch wheel.
  • New Tyre: 225mm width, 45% aspect ratio, 17-inch wheel.
  • Offset Change: From ET45 to ET35 (a 10mm outward push).

The calculator would show:

  • The new tyre is wider (225mm vs 205mm).
  • The new tyre has a lower profile (45% vs 55%), resulting in a similar or slightly different overall diameter.
  • The new wheel has a lower offset (ET35 vs ET45), meaning the wheel sits 10mm further out from the hub.

The primary result might indicate a slight increase in overall diameter (e.g., +0.5%) and a potential speedometer reading that is 0.5% lower than actual speed. It would also highlight that the combination of wider tyre and lower offset means the new wheel/tyre assembly will sit approximately 20mm further out than the original (10mm from offset change + ~10mm from tyre width increase). This information is crucial for determining if the new setup will clear the fenders and suspension, making the tyre fit calculator invaluable.

Another common scenario involves checking if a spare tyre will fit in an emergency. If you have a flat on a 225/45 R17 tyre, and your spare is a temporary "donut" tyre, say 125/80 R15, the tyre fit calculator can quickly show the significant difference in diameter and the resulting speedometer error, advising caution when driving on the spare.

How to Use This Tyre Fit Calculator

Using this tyre fit calculator is straightforward. Follow these steps:

  1. Identify Current Tyre Specifications: Find the tyre size on the sidewall of your current tyres (e.g., 205/55 R16). Note the width (205mm), aspect ratio (55%), and wheel diameter (16 inches).
  2. Identify New Tyre Specifications: Note the width, aspect ratio, and wheel diameter of the new tyres you are considering.
  3. Find Wheel Offset: Locate the offset (often marked as ET followed by a number, e.g., ET45) for both your current and proposed wheels. If you only know the new wheel offset, enter it into the calculator.
  4. Enter Data: Input all the collected values into the corresponding fields in the calculator: 'Current Tyre Width (mm)', 'Current Tyre Aspect Ratio (%)', 'Current Wheel Diameter (inches)', 'New Tyre Width (mm)', 'New Tyre Aspect Ratio (%)', 'New Wheel Diameter (inches)', and 'Wheel Offset (mm)'.
  5. Calculate: Click the 'Calculate Fit' button.
  6. Review Results: The calculator will display the primary result (e.g., "Good Fit" or "Potential Issues"), the difference in overall diameter, estimated speedometer error, and key assumptions like wheel offset and estimated clearance. It will also populate a detailed comparison table and a chart.
  7. Reset: If you need to perform a new calculation, click the 'Reset' button to clear all fields and start over.
  8. Copy Results: Use the 'Copy Results' button to save or share the calculated information.

This process ensures you have all the necessary information to assess tyre fit compatibility.

Key Factors That Affect Tyre Fit Results

Several factors influence the accuracy and interpretation of the results from a tyre fit calculator:

  • Tyre Width: A wider tyre increases the overall diameter slightly if the aspect ratio remains constant, and significantly affects how close the tyre is to the fender and suspension components.
  • Aspect Ratio: A lower aspect ratio means a shorter, stiffer sidewall, leading to a smaller overall tyre diameter. This is a primary driver of speedometer error.
  • Wheel Diameter: Larger wheels generally require lower aspect ratio tyres to maintain a similar overall diameter, but the change in wheel size itself impacts the overall diameter.
  • Wheel Offset (ET): This is critical for clearance. A lower offset (e.g., ET35 vs ET45) pushes the wheel further outwards, increasing the risk of rubbing against the fender. A higher offset pushes the wheel inwards, potentially causing it to rub against suspension components like the brake caliper or control arms. The calculator estimates clearance based on width and offset changes.
  • Tyre Brand and Model: Different tyre manufacturers may have slightly different actual dimensions for tyres listed with the same size code. Tread patterns can also vary, affecting clearance.
  • Vehicle Suspension: Ride height and suspension design play a significant role. A lowered vehicle will have less clearance than a stock one.
  • Tyre Pressure: Underinflated tyres can bulge outwards, reducing clearance.

While this tyre fit calculator provides excellent guidance, always consider these factors and, if possible, consult a professional tyre fitter for a definitive assessment of tyre fit.

Frequently Asked Questions (FAQ)

Q1: Can I put larger wheels on my car?

A1: Yes, you often can, but you must ensure the new wheel and tyre combination's overall diameter is very close to the original. Use a tyre fit calculator to compare dimensions. You also need to consider the new tyre's width and the wheel's offset to avoid clearance issues.

Q2: What happens if my speedometer is inaccurate due to new tyres?

A2: If your new tyres have a different overall diameter than the originals, your speedometer will be inaccurate. A larger diameter tyre makes the speedometer read slower than your actual speed, while a smaller diameter tyre makes it read faster. This can lead to speeding tickets or incorrect fuel consumption readings. The tyre fit calculator helps estimate this error.

Q3: How much difference in tyre size is acceptable?

A3: Generally, a difference of up to 3% in overall diameter is considered acceptable for most vehicles. Exceeding this can significantly impact speedometer accuracy, ABS, and traction control systems. Always aim for the smallest possible deviation when using a tyre fit calculator.

Q4: What does wheel offset mean?

A4: Wheel offset is the distance between the wheel's mounting surface (where it bolts to the hub) and the wheel's centerline. A positive offset (common on front-wheel-drive cars) means the mounting surface is towards the outside of the wheel. A negative offset (common on rear-wheel-drive cars) means it's towards the inside. Changes in offset directly affect how the wheel sits in the wheel well and are crucial for tyre fit.

Q5: Can I mix tyre sizes on my car?

A5: It is strongly advised NOT to mix tyre sizes (width, aspect ratio, or diameter) between the front and rear axles, especially on vehicles with all-wheel-drive or electronic stability control systems. This can cause damage to the drivetrain and compromise safety. Always use matching tyre specifications on all four wheels unless your vehicle manufacturer specifically allows for different sizes front/rear.

Related Tools and Internal Resources

© 2023 Your Company Name. All rights reserved.

var currentTyreWidthInput = document.getElementById('currentTyreWidth'); var currentTyreAspectInput = document.getElementById('currentTyreAspect'); var currentTyreDiameterInput = document.getElementById('currentTyreDiameter'); var newTyreWidthInput = document.getElementById('newTyreWidth'); var newTyreAspectInput = document.getElementById('newTyreAspect'); var newTyreDiameterInput = document.getElementById('newTyreDiameter'); var wheelOffsetInput = document.getElementById('wheelOffset'); var currentTyreWidthError = document.getElementById('currentTyreWidthError'); var currentTyreAspectError = document.getElementById('currentTyreAspectError'); var currentTyreDiameterError = document.getElementById('currentTyreDiameterError'); var newTyreWidthError = document.getElementById('newTyreWidthError'); var newTyreAspectError = document.getElementById('newTyreAspectError'); var newTyreDiameterError = document.getElementById('newTyreDiameterError'); var wheelOffsetError = document.getElementById('wheelOffsetError'); var resultsContainer = document.getElementById('resultsContainer'); var primaryResult = document.getElementById('primaryResult'); var diameterDifference = document.getElementById('diameterDifference'); var overallDiameterDifference = document.getElementById('overallDiameterDifference'); var speedometerError = document.getElementById('speedometerError'); var assumptionOffset = document.getElementById('assumptionOffset'); var assumptionClearance = document.getElementById('assumptionClearance'); var tableCurrentWidth = document.getElementById('tableCurrentWidth'); var tableNewWidth = document.getElementById('tableNewWidth'); var tableWidthDiff = document.getElementById('tableWidthDiff'); var tableCurrentSidewall = document.getElementById('tableCurrentSidewall'); var tableNewSidewall = document.getElementById('tableNewSidewall'); var tableSidewallDiff = document.getElementById('tableSidewallDiff'); var tableCurrentDiameter = document.getElementById('tableCurrentDiameter'); var tableNewDiameter = document.getElementById('tableNewDiameter'); var tableDiameterDiff = document.getElementById('tableDiameterDiff'); var tableCurrentCircumference = document.getElementById('tableCurrentCircumference'); var tableNewCircumference = document.getElementById('tableNewCircumference'); var tableCircumferenceDiff = document.getElementById('tableCircumferenceDiff'); var tableCurrentRevPerKm = document.getElementById('tableCurrentRevPerKm'); var tableNewRevPerKm = document.getElementById('tableNewRevPerKm'); var tableRevPerKmDiff = document.getElementById('tableRevPerKmDiff'); var chart; var chartContext; function validateInput(inputElement, errorElement, min, max, fieldName) { var value = parseFloat(inputElement.value); var errorMessage = ""; if (isNaN(value)) { errorMessage = fieldName + " is required."; } else if (value max) { errorMessage = fieldName + " cannot be greater than " + max + "."; } errorElement.textContent = errorMessage; return errorMessage === ""; } function calculateTyreFit() { // Clear previous errors currentTyreWidthError.textContent = ""; currentTyreAspectError.textContent = ""; currentTyreDiameterError.textContent = ""; newTyreWidthError.textContent = ""; newTyreAspectError.textContent = ""; newTyreDiameterError.textContent = ""; wheelOffsetError.textContent = ""; // Validate inputs var valid = true; valid &= validateInput(currentTyreWidthInput, currentTyreWidthError, 100, 300, "Tyre Width"); valid &= validateInput(currentTyreAspectInput, currentTyreAspectError, 10, 90, "Aspect Ratio"); valid &= validateInput(currentTyreDiameterInput, currentTyreDiameterError, 10, 24, "Wheel Diameter"); valid &= validateInput(newTyreWidthInput, newTyreWidthError, 100, 300, "New Tyre Width"); valid &= validateInput(newTyreAspectInput, newTyreAspectError, 10, 90, "New Aspect Ratio"); valid &= validateInput(newTyreDiameterInput, newTyreDiameterError, 10, 24, "New Wheel Diameter"); valid &= validateInput(wheelOffsetInput, wheelOffsetError, -50, 70, "Wheel Offset"); if (!valid) { resultsContainer.style.display = 'none'; return; } var currentWidth = parseFloat(currentTyreWidthInput.value); var currentAspect = parseFloat(currentTyreAspectInput.value); var currentWheelDiameter = parseFloat(currentTyreDiameterInput.value); var newWidth = parseFloat(newTyreWidthInput.value); var newAspect = parseFloat(newTyreAspectInput.value); var newWheelDiameter = parseFloat(newTyreDiameterInput.value); var wheelOffset = parseFloat(wheelOffsetInput.value); // Calculations var currentSidewallHeight = (currentWidth * currentAspect) / 100; var newSidewallHeight = (newWidth * newAspect) / 100; var currentOverallDiameterMM = (currentSidewallHeight * 2) + (currentWheelDiameter * 25.4); var newOverallDiameterMM = (newSidewallHeight * 2) + (newWheelDiameter * 25.4); var diameterDifferenceMM = newOverallDiameterMM – currentOverallDiameterMM; var diameterDifferencePercent = (diameterDifferenceMM / currentOverallDiameterMM) * 100; var currentCircumferenceMM = Math.PI * currentOverallDiameterMM; var newCircumferenceMM = Math.PI * newOverallDiameterMM; var circumferenceDifferenceMM = newCircumferenceMM – currentCircumferenceMM; var circumferenceDifferencePercent = (circumferenceDifferenceMM / currentCircumferenceMM) * 100; var currentRevPerKm = (1000000 / currentCircumferenceMM) * 2; // Revolutions per km var newRevPerKm = (1000000 / newCircumferenceMM) * 2; var revPerKmDifference = newRevPerKm – currentRevPerKm; var speedometerErrorPercent = diameterDifferencePercent; // Speedometer error is directly related to diameter difference // Wheel position calculation (simplified) // Current wheel position relative to fender (assuming 0 offset is flush with hub face) // New wheel position relative to hub face var currentWheelCenterToFender = (currentWidth / 2) + (currentWheelDiameter * 25.4 / 2) + currentWheelOffsetInput.value; // Simplified, assumes hub face is reference var newWheelCenterToFender = (newWidth / 2) + (newWheelDiameter * 25.4 / 2) + wheelOffset; // Difference in how far the wheel sits out relative to the hub face var offsetDifference = wheelOffset – parseFloat(document.getElementById('currentTyreDiameter').getAttribute('data-original-offset') || 45); // Default to a common offset if not set var widthDifference = newWidth – currentWidth; var totalOutwardMovement = (offsetDifference) + (widthDifference / 2); // Simplified outward movement var estimatedClearanceChangeMM = totalOutwardMovement; // This is a simplification. Real clearance depends on fender shape and suspension. var primaryResultMessage = ""; var resultClass = ""; if (Math.abs(diameterDifferencePercent) < 1.5) { primaryResultMessage = "Good Fit"; resultClass = "good-fit"; } else if (Math.abs(diameterDifferencePercent) 15) { // Arbitrary threshold for potential rubbing primaryResultMessage += " (Check Clearance)"; } primaryResult.textContent = primaryResultMessage; primaryResult.className = "primary-result " + resultClass; diameterDifference.innerHTML = "Overall Diameter Difference: " + diameterDifferenceMM.toFixed(1) + " mm (" + diameterDifferencePercent.toFixed(2) + "%)"; overallDiameterDifference.innerHTML = "New Tyre Diameter: " + newOverallDiameterMM.toFixed(1) + " mm"; speedometerError.innerHTML = "Estimated Speedometer Error: " + speedometerErrorPercent.toFixed(2) + "%"; assumptionOffset.textContent = wheelOffset.toFixed(1); // Provide a more informative clearance estimate var clearanceNote = "The new tyre/wheel assembly will sit approximately " + totalOutwardMovement.toFixed(1) + " mm further out "; if (Math.abs(totalOutwardMovement) > 15) { clearanceNote += "than your current setup. Check for fender and suspension clearance."; } else { clearanceNote += "than your current setup. Clearance should be adequate."; } assumptionClearance.textContent = clearanceNote; // Update Table tableCurrentWidth.textContent = currentWidth.toFixed(0); tableNewWidth.textContent = newWidth.toFixed(0); tableWidthDiff.textContent = (newWidth – currentWidth).toFixed(0); tableCurrentSidewall.textContent = currentSidewallHeight.toFixed(1); tableNewSidewall.textContent = newSidewallHeight.toFixed(1); tableSidewallDiff.textContent = (newSidewallHeight – currentSidewallHeight).toFixed(1); tableCurrentDiameter.textContent = currentOverallDiameterMM.toFixed(1); tableNewDiameter.textContent = newOverallDiameterMM.toFixed(1); tableDiameterDiff.textContent = diameterDifferenceMM.toFixed(1); tableCurrentCircumference.textContent = currentCircumferenceMM.toFixed(1); tableNewCircumference.textContent = newCircumferenceMM.toFixed(1); tableCircumferenceDiff.textContent = circumferenceDifferenceMM.toFixed(1); tableCurrentRevPerKm.textContent = currentRevPerKm.toFixed(2); tableNewRevPerKm.textContent = newRevPerKm.toFixed(2); tableRevPerKmDiff.textContent = revPerKmDifference.toFixed(2); // Update Chart updateChart(currentOverallDiameterMM, newOverallDiameterMM); resultsContainer.style.display = 'block'; } function updateChart(currentDiameter, newDiameter) { var ctx = document.getElementById('tyreDiameterChart'); if (!ctx) return; // Canvas not found if (chart) { chart.destroy(); // Destroy previous chart instance if it exists } chartContext = ctx.getContext('2d'); chart = new Chart(chartContext, { type: 'bar', data: { labels: ['Current Tyre', 'New Tyre'], datasets: [{ label: 'Overall Diameter (mm)', data: [currentDiameter, newDiameter], backgroundColor: [ 'rgba(0, 74, 153, 0.6)', // Primary color 'rgba(108, 117, 125, 0.6)' // Secondary color ], borderColor: [ 'rgba(0, 74, 153, 1)', 'rgba(108, 117, 125, 1)' ], borderWidth: 1 }] }, options: { responsive: true, maintainAspectRatio: false, scales: { y: { beginAtZero: true, title: { display: true, text: 'Overall Diameter (mm)' } } }, plugins: { legend: { display: true, position: 'top', }, title: { display: true, text: 'Comparison of Tyre Overall Diameters' } } } }); } function copyResults() { var textToCopy = "Tyre Fit Comparison Results:\n\n"; textToCopy += "Primary Result: " + primaryResult.textContent + "\n"; textToCopy += "Overall Diameter Difference: " + diameterDifference.textContent.split(': ')[1] + "\n"; textToCopy += "New Tyre Diameter: " + overallDiameterDifference.textContent.split(': ')[1] + "\n"; textToCopy += "Estimated Speedometer Error: " + speedometerError.textContent.split(': ')[1] + "\n\n"; textToCopy += "Key Assumptions:\n"; textToCopy += "Wheel Offset: " + assumptionOffset.textContent + " mm\n"; textToCopy += "Clearance Note: " + assumptionClearance.textContent + "\n\n"; textToCopy += "Tyre Dimension Comparison:\n"; textToCopy += "Width: Current " + tableCurrentWidth.textContent + "mm, New " + tableNewWidth.textContent + "mm, Diff " + tableWidthDiff.textContent + "mm\n"; textToCopy += "Sidewall Height: Current " + tableCurrentSidewall.textContent + "mm, New " + tableNewSidewall.textContent + "mm, Diff " + tableSidewallDiff.textContent + "mm\n"; textToCopy += "Overall Diameter: Current " + tableCurrentDiameter.textContent + "mm, New " + tableNewDiameter.textContent + "mm, Diff " + tableDiameterDiff.textContent + "mm\n"; textToCopy += "Circumference: Current " + tableCurrentCircumference.textContent + "mm, New " + tableNewCircumference.textContent + "mm, Diff " + tableCircumferenceDiff.textContent + "mm\n"; textToCopy += "Revolutions per km: Current " + tableCurrentRevPerKm.textContent + ", New " + tableNewRevPerKm.textContent + ", Diff " + tableRevPerKmDiff.textContent + "\n"; var textArea = document.createElement("textarea"); textArea.value = textToCopy; document.body.appendChild(textArea); textArea.select(); document.execCommand("copy"); document.body.removeChild(textArea); alert("Results copied to clipboard!"); } function resetForm() { currentTyreWidthInput.value = ""; currentTyreAspectInput.value = ""; currentTyreDiameterInput.value = ""; newTyreWidthInput.value = ""; newTyreAspectInput.value = ""; newTyreDiameterInput.value = ""; wheelOffsetInput.value = ""; currentTyreWidthError.textContent = ""; currentTyreAspectError.textContent = ""; currentTyreDiameterError.textContent = ""; newTyreWidthError.textContent = ""; newTyreAspectError.textContent = ""; newTyreDiameterError.textContent = ""; wheelOffsetError.textContent = ""; resultsContainer.style.display = 'none'; // Clear table tableCurrentWidth.textContent = ""; tableNewWidth.textContent = ""; tableWidthDiff.textContent = ""; tableCurrentSidewall.textContent = ""; tableNewSidewall.textContent = ""; tableSidewallDiff.textContent = ""; tableCurrentDiameter.textContent = ""; tableNewDiameter.textContent = ""; tableDiameterDiff.textContent = ""; tableCurrentCircumference.textContent = ""; tableNewCircumference.textContent = ""; tableCircumferenceDiff.textContent = ""; tableCurrentRevPerKm.textContent = ""; tableNewRevPerKm.textContent = ""; tableRevPerKmDiff.textContent = ""; // Clear chart if (chart) { chart.destroy(); chart = null; } var canvas = document.getElementById('tyreDiameterChart'); if (canvas) { var ctx = canvas.getContext('2d'); ctx.clearRect(0, 0, canvas.width, canvas.height); } } // Initial setup for chart document.addEventListener('DOMContentLoaded', function() { var canvas = document.getElementById('tyreDiameterChart'); if (canvas) { chartContext = canvas.getContext('2d'); // Initialize with empty data or placeholder if needed, or wait for first calculation // For now, we'll var updateChart handle the creation after calculation } }); // Add event listeners for real-time updates (optional, but good UX) var inputElements = [ currentTyreWidthInput, currentTyreAspectInput, currentTyreDiameterInput, newTyreWidthInput, newTyreAspectInput, newTyreDiameterInput, wheelOffsetInput ]; inputElements.forEach(function(input) { input.addEventListener('input', function() { // Only calculate if all fields have some value, or trigger validation on each change var allFilled = inputElements.every(function(el) { return el.value !== ""; }); if (allFilled) { calculateTyreFit(); } else { // Optionally clear results if fields are emptied if (resultsContainer.style.display === 'block') { // Check if the specific input that was changed is now empty if (parseFloat(this.value) === 0 || this.value === "") { resultsContainer.style.display = 'none'; } } } }); }); // Add placeholder data-original-offset for wheel offset calculation if needed // This is a placeholder and might need adjustment based on actual user input context document.getElementById('currentTyreDiameter').setAttribute('data-original-offset', '45'); // Example default

Leave a Comment