Tyre Fitment Calculator – Ensure Perfect Tyre Size
:root {
–primary-color: #004a99;
–secondary-color: #e9ecef;
–background-color: #f8f9fa;
–card-background: #ffffff;
–text-color: #333;
–border-color: #dee2e6;
–error-color: #dc3545;
}
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;
}
.container {
max-width: 960px;
margin: 20px auto;
padding: 20px;
background-color: var(–card-background);
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
h1, h2, h3 {
color: var(–primary-color);
text-align: center;
margin-bottom: 1.5em;
}
h1 {
font-size: 2.2em;
}
h2 {
font-size: 1.8em;
margin-top: 1.5em;
}
h3 {
font-size: 1.4em;
margin-top: 1.2em;
}
.calculator-section {
margin-bottom: 30px;
padding: 25px;
border: 1px solid var(–border-color);
border-radius: 8px;
background-color: var(–card-background);
}
.input-group {
margin-bottom: 20px;
text-align: left;
}
.input-group label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: var(–primary-color);
}
.input-group input[type="number"],
.input-group select {
width: calc(100% – 22px);
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: #6c757d;
margin-top: 5px;
display: block;
}
.error-message {
color: var(–error-color);
font-size: 0.8em;
margin-top: 5px;
min-height: 1.2em;
}
.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;
transition: background-color 0.3s ease;
margin: 5px;
}
button:hover {
background-color: #003366;
}
button.reset-button {
background-color: var(–secondary-color);
color: var(–text-color);
}
button.reset-button:hover {
background-color: #d3d9e0;
}
#results {
margin-top: 30px;
padding: 25px;
border: 1px solid var(–border-color);
border-radius: 8px;
background-color: var(–card-background);
text-align: center;
}
#results h3 {
margin-top: 0;
margin-bottom: 1.5em;
}
.result-item {
margin-bottom: 15px;
font-size: 1.1em;
}
.result-item strong {
color: var(–primary-color);
font-size: 1.3em;
}
.result-item.primary-result {
background-color: var(–secondary-color);
padding: 15px;
border-radius: 5px;
margin-bottom: 20px;
}
.result-item.primary-result strong {
font-size: 1.8em;
}
.formula-explanation {
font-size: 0.9em;
color: #6c757d;
margin-top: 15px;
text-align: left;
}
.table-container {
overflow-x: auto;
margin-top: 20px;
margin-bottom: 30px;
border: 1px solid var(–border-color);
border-radius: 8px;
}
table {
width: 100%;
border-collapse: collapse;
min-width: 600px;
}
caption {
font-size: 1.1em;
font-weight: 600;
color: var(–primary-color);
margin-bottom: 10px;
text-align: left;
}
th, td {
padding: 12px 15px;
text-align: center;
border: 1px solid var(–border-color);
}
thead th {
background-color: var(–secondary-color);
color: var(–primary-color);
font-weight: 600;
}
tbody tr:nth-child(even) {
background-color: var(–secondary-color);
}
.chart-container {
width: 100%;
max-width: 700px;
margin: 30px auto;
background-color: var(–card-background);
padding: 20px;
border-radius: 8px;
border: 1px solid var(–border-color);
}
canvas {
display: block;
width: 100% !important;
height: auto !important;
}
.article-content {
margin-top: 40px;
padding: 25px;
border: 1px solid var(–border-color);
border-radius: 8px;
background-color: var(–card-background);
text-align: left;
}
.article-content p {
margin-bottom: 1.2em;
}
.article-content ul {
margin-left: 20px;
margin-bottom: 1.2em;
}
.article-content li {
margin-bottom: 0.5em;
}
.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 strong {
display: block;
margin-bottom: 5px;
}
.internal-links-list span {
font-size: 0.9em;
color: #6c757d;
}
@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 {
width: 100%;
margin: 5px 0;
padding: 10px 15px;
}
.button-group {
display: flex;
flex-direction: column;
align-items: center;
}
.button-group button {
width: auto;
}
.result-item.primary-result strong {
font-size: 1.5em;
}
}
Calculation Results
Tyre Diameter Difference: —%
Original Tyre Diameter: — mm
New Tyre Diameter: — mm
Speedometer Error: —%
Overall Diameter Change: — mm
Formula Explanation:
Tyre Diameter = (Width * Aspect Ratio * 2 / 100) + (Rim Diameter * 25.4)
Percentage Difference = ((New Diameter – Original Diameter) / Original Diameter) * 100
Speedometer Error = Percentage Difference (positive means speedo reads lower than actual speed)
Tyre Dimension Comparison
| Metric |
Original Tyre |
New Tyre |
| Width (mm) |
— |
— |
| Aspect Ratio (%) |
— |
— |
| Rim Diameter (inches) |
— |
— |
| Sidewall Height (mm) |
— |
— |
| Overall Diameter (mm) |
— |
— |
| Circumference (mm) |
— |
— |
| Revolutions per km |
— |
— |
Comparison of Tyre Diameters and Circumferences
What is a Tyre Fitment Calculator?
A tyre fitment calculator is an essential online tool designed to help vehicle owners and enthusiasts determine the correct and compatible tyre sizes for their cars, trucks, or SUVs. It allows users to input their current tyre specifications and compare them against potential new tyre sizes. The primary goal is to ensure that any new tyre chosen will fit the vehicle's wheel arches, suspension, and braking systems without causing issues. Beyond just fitment, these calculators also provide critical insights into how a change in tyre size can affect crucial metrics like speedometer accuracy, odometer readings, fuel efficiency, and handling characteristics. Understanding these implications is vital for safe and optimal vehicle performance.
Tyre Fitment Calculator Formula and Mathematical Explanation
The core of a tyre fitment calculator relies on a series of geometric and trigonometric calculations to determine the physical dimensions of a tyre. A tyre size, typically represented as "Width/Aspect Ratio R Diameter" (e.g., 205/55 R16), breaks down as follows:
- Width (W): The first number (e.g., 205) is the tyre's width in millimeters (mm).
- Aspect Ratio (AR): The second number (e.g., 55) is the tyre's sidewall height as a percentage of its width. So, a 205/55 tyre has a sidewall height of 55% of 205mm.
- Rim Diameter (RD): The last number (e.g., 16) is the diameter of the wheel rim in inches.
The calculator uses these values to compute the overall tyre diameter and circumference. The formulas are:
Sidewall Height (SH) in mm: SH = (Width * Aspect Ratio) / 100
Overall Tyre Diameter (OD) in mm: OD = (SH * 2) + (Rim Diameter * 25.4)
(We multiply Rim Diameter by 25.4 because it's given in inches and needs conversion to mm).
Tyre Circumference (C) in mm: C = π * OD
Revolutions per Kilometer: Revs/km = (1,000,000 mm/km) / C
When comparing two tyre sizes, the calculator determines the percentage difference in overall diameter:
Percentage Diameter Difference: %Diff = ((OD_New – OD_Original) / OD_Original) * 100
This percentage difference directly impacts the speedometer and odometer. If the new tyre's diameter is larger, the speedometer will read lower than the actual speed (e.g., showing 60 mph when you're actually going 63 mph). Conversely, a smaller diameter tyre will cause the speedometer to read higher than the actual speed. A common guideline is to keep the overall diameter change within ±2% to maintain reasonable accuracy.
Practical Examples (Real-World Use Cases)
Consider a vehicle with original tyre size 205/55 R16. Using our tyre fitment calculator:
- Original Tyre Dimensions:
- Width: 205 mm
- Aspect Ratio: 55%
- Rim Diameter: 16 inches
- Sidewall Height: (205 * 55) / 100 = 112.75 mm
- Overall Diameter: (112.75 * 2) + (16 * 25.4) = 225.5 + 406.4 = 631.9 mm
- Scenario 1: Upgrading to larger wheels and lower profile tyres
A common upgrade is to 225/45 R17 tyres.
- New Tyre Dimensions:
- Width: 225 mm
- Aspect Ratio: 45%
- Rim Diameter: 17 inches
- Sidewall Height: (225 * 45) / 100 = 101.25 mm
- Overall Diameter: (101.25 * 2) + (17 * 25.4) = 202.5 + 431.8 = 634.3 mm
- Calculator Output:
- Overall Diameter Change: 634.3 – 631.9 = 2.4 mm
- Tyre Diameter Difference: ((634.3 – 631.9) / 631.9) * 100 ≈ +0.38%
- Speedometer Error: +0.38% (At 60 mph, speedo reads ~59.77 mph)
This change is well within the acceptable ±2% range, indicating good compatibility.
- Scenario 2: Fitting taller off-road tyres
Imagine fitting 235/75 R15 tyres on a vehicle originally designed for 205/55 R16.
- New Tyre Dimensions:
- Width: 235 mm
- Aspect Ratio: 75%
- Rim Diameter: 15 inches
- Sidewall Height: (235 * 75) / 100 = 176.25 mm
- Overall Diameter: (176.25 * 2) + (15 * 25.4) = 352.5 + 381 = 733.5 mm
- Calculator Output:
- Overall Diameter Change: 733.5 – 631.9 = 101.6 mm
- Tyre Diameter Difference: ((733.5 – 631.9) / 631.9) * 100 ≈ +16.08%
- Speedometer Error: +16.08% (At 60 mph, speedo reads ~50.6 mph)
This significant increase in diameter would drastically affect speedometer accuracy and may cause clearance issues with the wheel arches and suspension components. This tyre fitment is likely unsuitable without modifications.
How to Use This Tyre Fitment Calculator
Using our tyre fitment calculator is straightforward:
- Locate Original Tyre Size: Find the tyre size information on the sidewall of your current tyres. It will look something like "205/55 R16".
- Input Original Dimensions: Enter the 'Width' (205), 'Aspect Ratio' (55), and 'Rim Diameter' (16) into the corresponding fields under "Original Tyre".
- Input New Tyre Dimensions: Enter the 'Width', 'Aspect Ratio', and 'Rim Diameter' for the new tyres you are considering into the fields under "New Tyre".
- Calculate: Click the "Calculate Fitment" button.
- Review Results: The calculator will display the percentage difference in overall diameter, the actual diameters of both tyres, the resulting speedometer error, and the overall diameter change in millimeters.
- Check Table: Examine the detailed comparison table for metrics like sidewall height and circumference.
- Analyze Chart: Visualize the diameter and circumference differences on the provided chart.
- Reset: If you want to start over or try different sizes, click the "Reset" button.
- Copy: Use the "Copy Results" button to easily share or save the calculated data.
Always ensure that the new tyre size does not exceed the manufacturer's recommended limits for your vehicle, especially concerning clearance and load rating. Consulting your vehicle's owner's manual or a professional tyre fitter is also recommended.
Key Factors That Affect Tyre Fitment Results
While the tyre fitment calculator provides essential data, several other factors are crucial for proper tyre selection:
- Load Index: This number indicates the maximum weight each tyre can support. The new tyres must have a load index equal to or greater than the original specification.
- Speed Rating: This letter code indicates the maximum speed capability of the tyre. Ensure the new tyre's speed rating meets or exceeds your vehicle's top speed capabilities.
- Tread Pattern and Type: Different tread patterns are designed for various conditions (all-season, summer, winter, off-road). The chosen pattern should suit your driving environment.
- Vehicle Clearance: Even if the diameter is within limits, the width and sidewall height of the new tyre must clear the vehicle's fenders, suspension components, and chassis, especially during full suspension travel and steering lock.
- Rolling Resistance and Fuel Economy: Wider tyres or those with aggressive tread patterns can sometimes increase rolling resistance, potentially impacting fuel efficiency.
- Handling and Ride Comfort: Changes in tyre aspect ratio and construction can affect steering response, grip levels, and the overall smoothness of the ride. Lower profile tyres generally offer sharper handling but a firmer ride.
- Legal Requirements: In some regions, there are regulations regarding the permissible variance in tyre diameter and width compared to the original equipment.
Our tyre fitment calculator is a powerful tool for the dimensional aspect of tyre selection, but these other factors are equally important for a safe and suitable upgrade.
Frequently Asked Questions (FAQ)
Q1: What is the acceptable percentage difference in tyre diameter?
Generally, a difference of ±2% in overall tyre diameter is considered acceptable. Exceeding this can lead to significant speedometer/odometer inaccuracies and potential mechanical issues or clearance problems.
Q2: Can I fit larger wheels (e.g., 18-inch rims instead of 16-inch)?
Yes, you can often fit larger wheels, but it requires a corresponding decrease in the tyre's aspect ratio (sidewall height) to maintain a similar overall tyre diameter. Our calculator helps you find compatible aspect ratios. Always check for physical clearance.
Q3: What happens if my speedometer is inaccurate due to new tyres?
If your speedometer reads lower than your actual speed (due to larger tyres), you might be driving faster than you think, potentially leading to speeding tickets or unsafe driving. If it reads higher (due to smaller tyres), your odometer will also record fewer miles than you've actually driven, affecting resale value and maintenance schedules.
Q4: Does changing tyre size affect my car's warranty?
Modifying tyre sizes outside the manufacturer's specifications can potentially void your vehicle's warranty, especially if the modification causes damage to drivetrain components (like differentials or transmission) or suspension parts.
Q5: How do I find my car's original tyre size?
Your original tyre size is usually listed on a sticker located on the driver's side doorjamb, glove box door, or fuel filler flap. It's also often found in your vehicle's owner's manual.
Related Tools and Internal Resources
var originalWidthInput = document.getElementById('originalWidth');
var originalAspectInput = document.getElementById('originalAspect');
var originalDiameterInput = document.getElementById('originalDiameter');
var newWidthInput = document.getElementById('newWidth');
var newAspectInput = document.getElementById('newAspect');
var newDiameterInput = document.getElementById('newDiameter');
var originalWidthError = document.getElementById('originalWidthError');
var originalAspectError = document.getElementById('originalAspectError');
var originalDiameterError = document.getElementById('originalDiameterError');
var newWidthError = document.getElementById('newWidthError');
var newAspectError = document.getElementById('newAspectError');
var newDiameterError = document.getElementById('newDiameterError');
var diameterDifferenceSpan = document.getElementById('diameterDifference');
var originalDiameterValueSpan = document.getElementById('originalDiameterValue');
var newDiameterValueSpan = document.getElementById('newDiameterValue');
var speedometerErrorSpan = document.getElementById('speedometerError');
var overallDiameterChangeSpan = document.getElementById('overallDiameterChange');
var tableOriginalWidth = document.getElementById('tableOriginalWidth');
var tableNewWidth = document.getElementById('tableNewWidth');
var tableOriginalAspect = document.getElementById('tableOriginalAspect');
var tableNewAspect = document.getElementById('tableNewAspect');
var tableOriginalRim = document.getElementById('tableOriginalRim');
var tableNewRim = document.getElementById('tableNewRim');
var tableOriginalSidewall = document.getElementById('tableOriginalSidewall');
var tableNewSidewall = document.getElementById('tableNewSidewall');
var tableOriginalOverallDiameter = document.getElementById('tableOriginalOverallDiameter');
var tableNewOverallDiameter = document.getElementById('tableNewOverallDiameter');
var tableOriginalCircumference = document.getElementById('tableOriginalCircumference');
var tableNewCircumference = document.getElementById('tableNewCircumference');
var tableOriginalRevsPerKm = document.getElementById('tableOriginalRevsPerKm');
var tableNewRevsPerKm = document.getElementById('tableNewRevsPerKm');
var chart = null;
var chartContext = null;
var tyreComparisonChart = null;
function validateInput(value, min, max, errorElement, inputName) {
if (value === ") {
errorElement.textContent = inputName + ' cannot be empty.';
return false;
}
var numValue = parseFloat(value);
if (isNaN(numValue)) {
errorElement.textContent = inputName + ' must be a number.';
return false;
}
if (numValue max) {
errorElement.textContent = inputName + ' must be between ' + min + ' and ' + max + '.';
return false;
}
errorElement.textContent = ";
return true;
}
function calculateTyreDimensions(width, aspect, rimDiameterInches) {
var sidewallHeightMm = (width * aspect) / 100;
var rimDiameterMm = rimDiameterInches * 25.4;
var overallDiameterMm = (sidewallHeightMm * 2) + rimDiameterMm;
var circumferenceMm = Math.PI * overallDiameterMm;
var revsPerKm = (1000000) / circumferenceMm; // 1,000,000 mm in 1 km
return {
sidewallHeightMm: sidewallHeightMm.toFixed(2),
overallDiameterMm: overallDiameterMm.toFixed(2),
circumferenceMm: circumferenceMm.toFixed(2),
revsPerKm: revsPerKm.toFixed(2)
};
}
function calculateTyreFitment() {
var valid = true;
valid &= validateInput(originalWidthInput.value, 100, 300, originalWidthError, 'Original Width');
valid &= validateInput(originalAspectInput.value, 10, 90, originalAspectError, 'Original Aspect Ratio');
valid &= validateInput(originalDiameterInput.value, 10, 26, originalDiameterError, 'Original Rim Diameter');
valid &= validateInput(newWidthInput.value, 100, 300, newWidthError, 'New Width');
valid &= validateInput(newAspectInput.value, 10, 90, newAspectError, 'New Aspect Ratio');
valid &= validateInput(newDiameterInput.value, 10, 26, newDiameterError, 'New Rim Diameter');
if (!valid) {
resetResults();
return;
}
var ow = parseFloat(originalWidthInput.value);
var oa = parseFloat(originalAspectInput.value);
var odi = parseFloat(originalDiameterInput.value);
var nw = parseFloat(newWidthInput.value);
var na = parseFloat(newAspectInput.value);
var ndi = parseFloat(newDiameterInput.value);
var originalDims = calculateTyreDimensions(ow, oa, odi);
var newDims = calculateTyreDimensions(nw, na, ndi);
var originalOverallDiameter = parseFloat(originalDims.overallDiameterMm);
var newOverallDiameter = parseFloat(newDims.overallDiameterMm);
var diameterDifferencePercent = ((newOverallDiameter – originalOverallDiameter) / originalOverallDiameter) * 100;
var overallDiameterChangeMm = newOverallDiameter – originalOverallDiameter;
var speedometerErrorPercent = diameterDifferencePercent; // Positive means speedo reads lower
diameterDifferenceSpan.textContent = diameterDifferencePercent.toFixed(2) + '%';
originalDiameterValueSpan.textContent = originalOverallDiameter.toFixed(2) + ' mm';
newDiameterValueSpan.textContent = newOverallDiameter.toFixed(2) + ' mm';
speedometerErrorSpan.textContent = speedometerErrorPercent.toFixed(2) + '%';
overallDiameterChangeSpan.textContent = overallDiameterChangeMm.toFixed(2) + ' mm';
tableOriginalWidth.textContent = ow;
tableNewWidth.textContent = nw;
tableOriginalAspect.textContent = oa;
tableNewAspect.textContent = na;
tableOriginalRim.textContent = odi;
tableNewRim.textContent = ndi;
tableOriginalSidewall.textContent = originalDims.sidewallHeightMm;
tableNewSidewall.textContent = newDims.sidewallHeightMm;
tableOriginalOverallDiameter.textContent = originalOverallDiameter.toFixed(2);
tableNewOverallDiameter.textContent = newOverallDiameter.toFixed(2);
tableOriginalCircumference.textContent = originalDims.circumferenceMm;
tableNewCircumference.textContent = newDims.circumferenceMm;
tableOriginalRevsPerKm.textContent = originalDims.revsPerKm;
tableNewRevsPerKm.textContent = newDims.revsPerKm;
updateChart(originalOverallDiameter, newOverallDiameter, parseFloat(originalDims.circumferenceMm), parseFloat(newDims.circumferenceMm));
}
function resetResults() {
diameterDifferenceSpan.textContent = '–';
originalDiameterValueSpan.textContent = '–';
newDiameterValueSpan.textContent = '–';
speedometerErrorSpan.textContent = '–';
overallDiameterChangeSpan.textContent = '–';
tableOriginalWidth.textContent = '–';
tableNewWidth.textContent = '–';
tableOriginalAspect.textContent = '–';
tableNewAspect.textContent = '–';
tableOriginalRim.textContent = '–';
tableNewRim.textContent = '–';
tableOriginalSidewall.textContent = '–';
tableNewSidewall.textContent = '–';
tableOriginalOverallDiameter.textContent = '–';
tableNewOverallDiameter.textContent = '–';
tableOriginalCircumference.textContent = '–';
tableNewCircumference.textContent = '–';
tableOriginalRevsPerKm.textContent = '–';
tableNewRevsPerKm.textContent = '–';
if (tyreComparisonChart) {
tyreComparisonChart.destroy();
}
}
function resetForm() {
originalWidthInput.value = '205';
originalAspectInput.value = '55';
originalDiameterInput.value = '16';
newWidthInput.value = '225';
newAspectInput.value = '45';
newDiameterInput.value = '17';
originalWidthError.textContent = ";
originalAspectError.textContent = ";
originalDiameterError.textContent = ";
newWidthError.textContent = ";
newAspectError.textContent = ";
newDiameterError.textContent = ";
resetResults();
calculateTyreFitment(); // Recalculate with defaults
}
function copyResults() {
var resultsText = "Tyre Fitment Calculation Results:\n\n";
resultsText += "Original Tyre: " + originalWidthInput.value + "/" + originalAspectInput.value + " R" + originalDiameterInput.value + "\n";
resultsText += "New Tyre: " + newWidthInput.value + "/" + newAspectInput.value + " R" + newDiameterInput.value + "\n\n";
resultsText += "Primary Result:\n";
resultsText += "- Tyre Diameter Difference: " + diameterDifferenceSpan.textContent + "\n";
resultsText += "- Speedometer Error: " + speedometerErrorSpan.textContent + "\n";
resultsText += "- Overall Diameter Change: " + overallDiameterChangeSpan.textContent + "\n\n";
resultsText += "Key Values:\n";
resultsText += "- Original Tyre Diameter: " + originalDiameterValueSpan.textContent + "\n";
resultsText += "- New Tyre Diameter: " + newDiameterValueSpan.textContent + "\n\n";
resultsText += "Detailed Comparison:\n";
resultsText += "- Width: Original " + tableOriginalWidth.textContent + "mm / New " + tableNewWidth.textContent + "mm\n";
resultsText += "- Aspect Ratio: Original " + tableOriginalAspect.textContent + "% / New " + tableNewAspect.textContent + "%\n";
resultsText += "- Rim Diameter: Original " + tableOriginalRim.textContent + " inches / New " + tableNewRim.textContent + " inches\n";
resultsText += "- Sidewall Height: Original " + tableOriginalSidewall.textContent + "mm / New " + tableNewSidewall.textContent + "mm\n";
resultsText += "- Overall Diameter: Original " + tableOriginalOverallDiameter.textContent + "mm / New " + tableNewOverallDiameter.textContent + "mm\n";
resultsText += "- Circumference: Original " + tableOriginalCircumference.textContent + "mm / New " + tableNewCircumference.textContent + "mm\n";
resultsText += "- Revolutions per Km: Original " + tableOriginalRevsPerKm.textContent + " / New " + tableNewRevsPerKm.textContent + "\n";
var textArea = document.createElement("textarea");
textArea.value = resultsText;
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
alert('Results copied to clipboard!');
} catch (e) {
alert('Failed to copy results. Please copy manually.');
}
textArea.remove();
}
function updateChart(originalDiameter, newDiameter, originalCircumference, newCircumference) {
if (!chartContext) {
chartContext = document.getElementById('tyreComparisonChart').getContext('2d');
}
if (tyreComparisonChart) {
tyreComparisonChart.destroy();
}
tyreComparisonChart = new Chart(chartContext, {
type: 'bar',
data: {
labels: ['Overall Diameter (mm)', 'Circumference (mm)'],
datasets: [{
label: 'Original Tyre',
data: [originalDiameter, originalCircumference],
backgroundColor: 'rgba(0, 74, 153, 0.6)',
borderColor: 'rgba(0, 74, 153, 1)',
borderWidth: 1
}, {
label: 'New Tyre',
data: [newDiameter, newCircumference],
backgroundColor: 'rgba(220, 53, 69, 0.6)',
borderColor: 'rgba(220, 53, 69, 1)',
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: true,
scales: {
y: {
beginAtZero: true,
title: {
display: true,
text: 'Measurement (mm)'
}
}
},
plugins: {
legend: {
position: 'top',
},
title: {
display: true,
text: 'Tyre Dimension Comparison'
}
}
}
});
}
// Initial calculation on page load
document.addEventListener('DOMContentLoaded', function() {
calculateTyreFitment();
// Add event listeners for real-time updates
var inputs = document.querySelectorAll('.calculator-section input[type="number"], .calculator-section select');
for (var i = 0; i < inputs.length; i++) {
inputs[i].addEventListener('input', calculateTyreFitment);
}
});