1/8 Mile Calculator: HP to Weight Ratio for Drag Racing
:root {
–primary-color: #004a99;
–success-color: #28a745;
–background-color: #f8f9fa;
–text-color: #333;
–border-color: #ddd;
–card-background: #fff;
–shadow: 0 4px 8px rgba(0,0,0,0.1);
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: var(–background-color);
color: var(–text-color);
line-height: 1.6;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
padding-top: 20px;
padding-bottom: 40px;
}
.container {
width: 100%;
max-width: 960px;
margin: 0 auto;
padding: 20px;
background-color: var(–card-background);
border-radius: 8px;
box-shadow: var(–shadow);
display: flex;
flex-direction: column;
align-items: center;
}
h1, h2, h3 {
color: var(–primary-color);
text-align: center;
margin-bottom: 1.5em;
}
h1 {
font-size: 2.5em;
}
h2 {
font-size: 1.8em;
margin-top: 1.5em;
}
h3 {
font-size: 1.4em;
margin-top: 1.2em;
}
.calculator-section {
width: 100%;
margin-bottom: 30px;
padding: 25px;
border: 1px solid var(–border-color);
border-radius: 8px;
background-color: var(–card-background);
box-shadow: var(–shadow);
}
.input-group {
margin-bottom: 20px;
width: 100%;
}
.input-group label {
display: block;
margin-bottom: 8px;
font-weight: bold;
color: var(–primary-color);
}
.input-group input[type="number"],
.input-group select {
width: calc(100% – 24px);
padding: 12px;
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: #dc3545;
font-size: 0.85em;
margin-top: 5px;
display: none; /* Hidden by default */
height: 1.2em; /* Reserve space */
}
.button-group {
display: flex;
justify-content: space-between;
margin-top: 25px;
flex-wrap: wrap;
gap: 10px;
}
button {
padding: 12px 25px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 1em;
font-weight: bold;
transition: background-color 0.3s ease, transform 0.2s ease;
flex: 1;
min-width: 150px;
}
button.primary {
background-color: var(–primary-color);
color: white;
}
button.primary:hover {
background-color: #003366;
transform: translateY(-2px);
}
button.secondary {
background-color: #6c757d;
color: white;
}
button.secondary:hover {
background-color: #5a6268;
transform: translateY(-2px);
}
button.reset {
background-color: #ffc107;
color: #212529;
}
button.reset:hover {
background-color: #e0a800;
transform: translateY(-2px);
}
.results-container {
width: 100%;
margin-top: 30px;
padding: 25px;
border: 1px solid var(–border-color);
border-radius: 8px;
background-color: var(–card-background);
box-shadow: var(–shadow);
text-align: center;
}
#result-primary {
font-size: 2.5em;
font-weight: bold;
color: var(–success-color);
margin-bottom: 15px;
padding: 15px;
background-color: #e9ecef;
border-radius: 5px;
display: inline-block;
}
.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: 20px;
padding-top: 15px;
border-top: 1px dashed var(–border-color);
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 25px;
box-shadow: var(–shadow);
}
caption {
font-size: 1.2em;
font-weight: bold;
color: var(–primary-color);
margin-bottom: 15px;
text-align: left;
}
th, td {
padding: 12px 15px;
border: 1px solid var(–border-color);
text-align: left;
}
thead th {
background-color: var(–primary-color);
color: white;
font-weight: bold;
}
tbody tr:nth-child(even) {
background-color: #f2f2f2;
}
canvas {
margin-top: 25px;
border: 1px solid var(–border-color);
border-radius: 5px;
background-color: var(–card-background);
}
.chart-legend {
margin-top: 15px;
font-size: 0.9em;
color: #555;
text-align: center;
}
.chart-legend span {
display: inline-block;
margin: 0 10px;
}
.chart-legend .color-box {
display: inline-block;
width: 15px;
height: 15px;
margin-right: 5px;
vertical-align: middle;
}
.article-content {
width: 100%;
margin-top: 40px;
padding: 30px;
background-color: var(–card-background);
border-radius: 8px;
box-shadow: var(–shadow);
text-align: left;
}
.article-content p, .article-content ul, .article-content ol {
margin-bottom: 1.5em;
font-size: 1.05em;
}
.article-content ul, .article-content ol {
padding-left: 25px;
}
.article-content li {
margin-bottom: 0.8em;
}
.article-content a {
color: var(–primary-color);
text-decoration: none;
font-weight: bold;
}
.article-content a:hover {
text-decoration: underline;
}
.faq-item {
margin-bottom: 20px;
padding: 15px;
border: 1px solid var(–border-color);
border-radius: 5px;
background-color: #fdfdfd;
}
.faq-item h3 {
margin-bottom: 10px;
font-size: 1.2em;
color: var(–primary-color);
text-align: left;
}
.faq-item p {
margin-bottom: 0;
font-size: 1em;
}
.related-links ul {
list-style: none;
padding: 0;
}
.related-links li {
margin-bottom: 15px;
}
.related-links a {
font-size: 1.1em;
}
.related-links span {
display: block;
font-size: 0.9em;
color: #555;
margin-top: 5px;
}
.highlight {
background-color: var(–success-color);
color: white;
padding: 2px 5px;
border-radius: 3px;
}
.formula-variable-table {
margin-top: 20px;
}
.formula-variable-table th, .formula-variable-table td {
text-align: center;
}
.formula-variable-table th:first-child, .formula-variable-table td:first-child {
text-align: left;
}
.formula-variable-table td:nth-child(3) { /* Unit column */
font-style: italic;
color: #555;
}
.formula-variable-table td:nth-child(4) { /* Typical Range column */
font-style: italic;
color: #555;
}
@media (max-width: 768px) {
h1 {
font-size: 2em;
}
h2 {
font-size: 1.5em;
}
button {
min-width: 100%;
}
.button-group {
flex-direction: column;
align-items: center;
}
.container {
padding: 15px;
}
.calculator-section, .results-container, .article-content {
padding: 20px 15px;
}
}
Vehicle Performance Calculator
Performance Estimates
—
Key Assumptions
Drivetrain: —
Traction Factor: —
Formula Explanation: The estimated 1/8 mile time is derived from the vehicle's power-to-weight ratio, adjusted by a traction factor based on drivetrain type. Higher HP/weight generally leads to quicker times. The MPH is estimated based on the calculated ET and typical acceleration curves.
Estimated 1/8 Mile ET vs. Power-to-Weight Ratio
Estimated ET
Power-to-Weight Ratio
Understanding Your 1/8 Mile Performance
What is 1/8 Mile Performance Calculation?
The 1/8 mile calculator hp weight is a tool designed to estimate a vehicle's potential performance on a drag strip over an eighth-mile distance. It primarily focuses on the critical relationship between a car's horsepower and its weight, often expressed as the power-to-weight ratio. This ratio is a fundamental indicator of acceleration capability. Drag racers, tuners, and automotive enthusiasts use this type of calculator to predict how modifications, weight changes, or different vehicles might perform. It helps set realistic expectations and provides a baseline for understanding vehicle dynamics. Common misconceptions include believing that horsepower alone dictates speed, ignoring the crucial role of weight and traction. A high-horsepower vehicle that is excessively heavy might not outperform a lighter vehicle with less horsepower. This 1/8 mile calculator hp weight tool aims to provide a more holistic estimate.
1/8 Mile Performance Formula and Mathematical Explanation
The core of the 1/8 mile calculator hp weight lies in estimating the time it takes for a vehicle to cover 1/8th of a mile (660 feet). While precise calculations involve complex physics, including aerodynamics, tire grip, gearing, and driver reaction, a simplified model can be derived from the power-to-weight ratio. A common approach involves using empirical data and established formulas that approximate acceleration. The formula used here is a simplified estimation based on established drag racing principles:
Estimated 1/8 Mile ET (Seconds) = C * sqrt(Weight (lbs) / Horsepower (HP))
Where 'C' is a constant that incorporates factors like drivetrain efficiency, tire grip, and aerodynamic drag. This constant is often adjusted based on the drivetrain type and general track conditions.
For this calculator, we use a base 'C' value and adjust it:
- Base C: ~35 (empirical value)
- Drivetrain Adjustment Factor:
- AWD: Multiplier of 0.95 (better traction)
- 2WD: Multiplier of 1.00 (standard)
- FWD: Multiplier of 1.05 (can experience wheel hop/less efficient launch)
Therefore, the adjusted formula becomes:
Adjusted C = Base C * Drivetrain Adjustment Factor
Estimated 1/8 Mile ET = Adjusted C * sqrt(Weight (lbs) / Horsepower (HP))
The Power-to-Weight Ratio is calculated directly:
Power-to-Weight Ratio = Horsepower (HP) / Weight (lbs)
The Estimated 1/8 Mile MPH is derived from the ET, assuming a constant acceleration curve, which is another simplification. A more accurate calculation would involve integrating acceleration over time.
Estimated 1/8 Mile MPH = (1/8 Mile Distance in Feet / (Estimated ET * 5280 / 3600)) * 0.6818 (This is a rough approximation, often derived from empirical data correlating ET and MPH)
Variables Table
Practical Examples (Real-World Use Cases)
Let's explore how the 1/8 mile calculator hp weight works with realistic scenarios:
Example 1: A Modified Muscle Car
Consider a popular rear-wheel-drive muscle car that has been tuned for performance.
- Inputs:
- Horsepower: 600 HP
- Vehicle Weight: 3600 lbs (including driver)
- Drivetrain Type: 2WD
- Calculation:
- Power-to-Weight Ratio = 600 HP / 3600 lbs = 0.167 HP/lb
- Adjusted C = 35 * 1.00 = 35
- Estimated 1/8 Mile ET = 35 * sqrt(3600 / 600) = 35 * sqrt(6) ≈ 35 * 2.45 ≈ 8.57 seconds
- Estimated 1/8 Mile MPH ≈ 105 MPH
- Interpretation: With 600 HP and weighing 3600 lbs, this car is expected to run around 8.57 seconds in the 1/8 mile, reaching approximately 105 MPH. This is a respectable time for a street-legal modified car.
Example 2: A Lightweight Sport Compact
Now, let's look at a lighter, front-wheel-drive sport compact car with moderate modifications.
- Inputs:
- Horsepower: 300 HP
- Vehicle Weight: 2800 lbs (including driver)
- Drivetrain Type: FWD
- Calculation:
- Power-to-Weight Ratio = 300 HP / 2800 lbs ≈ 0.107 HP/lb
- Adjusted C = 35 * 1.05 = 36.75
- Estimated 1/8 Mile ET = 36.75 * sqrt(2800 / 300) = 36.75 * sqrt(9.33) ≈ 36.75 * 3.05 ≈ 11.21 seconds
- Estimated 1/8 Mile MPH ≈ 90 MPH
- Interpretation: Despite having less absolute horsepower, the significantly lower weight and the FWD adjustment result in an estimated 11.21-second 1/8 mile time. This highlights how weight plays a critical role in acceleration.
How to Use This 1/8 Mile Calculator
Using the 1/8 mile calculator hp weight is straightforward:
- Enter Horsepower: Input the peak horsepower your vehicle produces. This is often found in the vehicle's specifications or dyno results.
- Enter Vehicle Weight: Provide the total weight of the vehicle, including the driver, any passengers, and a full tank of fuel. This is crucial for accurate calculations.
- Select Drivetrain Type: Choose between 2WD, AWD, or FWD. This selection impacts the traction factor used in the estimation.
- Click Calculate: Press the "Calculate" button to see the estimated results.
Reading the Results:
- Primary Result (Estimated 1/8 Mile ET): This is your main estimated time in seconds. Lower numbers indicate faster acceleration.
- Power-to-Weight Ratio: A key metric showing how much horsepower is available for each pound of vehicle weight. Higher is generally better for acceleration.
- Estimated 1/8 Mile MPH: The projected speed at the 1/8 mile finish line.
- Key Assumptions: Shows the drivetrain type and the traction factor used, which are important context for the estimates.
Decision-Making Guidance: Use these results to understand the impact of potential modifications. For instance, if you're considering adding more horsepower, you can estimate the ET improvement. Conversely, if you're looking to reduce weight, you can see how that might affect your times. Remember these are estimates; actual performance depends on many variables.
Key Factors That Affect 1/8 Mile Results
While the 1/8 mile calculator hp weight provides a good estimate, several real-world factors can significantly influence actual drag strip performance:
- Traction: This is arguably the most critical factor. The ability of the tires to grip the track surface determines how effectively the engine's power can be translated into forward motion. Poor traction leads to wheelspin, slower times, and lower trap speeds. Tire compound, width, pressure, and track preparation all play a role.
- Gearing: The transmission's gear ratios and the final drive ratio determine how engine RPMs are delivered to the wheels. Optimal gearing allows the engine to stay within its power band during the acceleration phase, maximizing performance. Incorrect gearing can lead to bogging down or hitting the rev limiter too early.
- Aerodynamics: While less critical over 1/8 mile than a full 1/4 mile, aerodynamic drag still plays a part, especially at higher speeds. A car with a lower drag coefficient (Cd) will generally be faster. Body kits, spoilers, and even open windows can affect airflow.
- Driver Skill: The driver's ability to launch the car effectively, shift gears smoothly and at the right time, and react quickly significantly impacts ET. A skilled driver can often shave tenths of a second off a run.
- Engine Efficiency and Power Delivery: The calculated horsepower is often a peak number. How the engine delivers power throughout the RPM range (torque curve) is crucial. A broader, flatter torque curve often results in better acceleration than a peaky one. Engine tuning, fuel quality, and air intake temperature can affect actual power output.
- Weight Distribution: How the vehicle's weight is distributed between the front and rear axles can affect traction, particularly for rear-wheel-drive vehicles during launch. A slight rearward bias is often beneficial for drag racing.
- Tire Temperature and Pressure: Properly heated and pressurized drag slicks or performance tires are essential for optimal grip. Cold or improperly inflated tires will significantly hinder performance.
- Environmental Conditions: Air density (affected by altitude, temperature, and humidity) impacts engine performance. Denser air allows for more efficient combustion. Track surface temperature also affects traction.
Frequently Asked Questions (FAQ)
Q1: Is the 1/8 mile calculator hp weight accurate?
A1: This calculator provides an *estimate* based on simplified physics and empirical data. Actual performance can vary significantly due to factors like traction, driver skill, gearing, and specific track conditions. It's a useful tool for comparison and prediction, not a definitive measurement.
Q2: What is a good power-to-weight ratio for drag racing?
A2: For 1/8 mile racing, a power-to-weight ratio below 0.10 HP/lb is generally considered very good and indicative of a fast car. Ratios between 0.10 and 0.15 HP/lb are common for performance vehicles, while ratios above 0.20 HP/lb might indicate a slower vehicle unless other factors like extreme traction compensate.
Q3: How does drivetrain type affect 1/8 mile times?
A3: AWD vehicles typically have an advantage due to superior traction off the line, allowing them to launch harder and achieve quicker times. 2WD vehicles can be very fast but are more susceptible to traction issues. FWD vehicles can also be quick but may struggle with wheel hop or lack of weight transfer to the drive wheels during acceleration.
Q4: Should I include the driver's weight?
A4: Yes, absolutely. The driver's weight is a significant part of the total vehicle weight. For accurate estimations, always include the driver's weight, plus a full tank of fuel.
Q5: How do I find my vehicle's actual horsepower?
A5: Horsepower figures can be found in your vehicle's owner's manual or manufacturer specifications. For modified vehicles, a dynamometer (dyno) test provides the most accurate measurement of current horsepower output.
Q6: Can I use this calculator for a 1/4 mile?
A6: While the power-to-weight ratio is relevant for both distances, the specific ET and MPH estimations are tailored for 1/8 mile. A separate 1/4 mile calculator would be needed for more accurate predictions over that longer distance, as aerodynamics and sustained acceleration become more dominant factors.
Q7: What does it mean if my estimated MPH is much higher than expected for my ET?
A7: This could indicate excellent acceleration but potentially poor traction off the line, leading to a slower ET but high trap speed. Conversely, it might suggest the car has a lot of power but isn't efficiently putting it down. It could also point to limitations in the simplified MPH estimation formula.
Q8: How can I improve my 1/8 mile time?
A8: Focus on increasing your power-to-weight ratio (more HP or less weight), improving traction (better tires, suspension tuning), optimizing gearing, and honing your driving skills. Even small improvements in these areas can lead to significant time drops.
Related Tools and Internal Resources
var horsepowerInput = document.getElementById('horsepower');
var weightInput = document.getElementById('weight');
var driveTypeSelect = document.getElementById('driveType');
var resultPrimaryDiv = document.getElementById('result-primary');
var powerToWeightRatioDiv = document.getElementById('powerToWeightRatio').getElementsByTagName('span')[0];
var estimatedETDiv = document.getElementById('estimatedET').getElementsByTagName('span')[0];
var estimatedMPHDiv = document.getElementById('estimatedMPH').getElementsByTagName('span')[0];
var assumptionDrivetrainDiv = document.getElementById('assumptionDrivetrain').getElementsByTagName('span')[0];
var assumptionTractionDiv = document.getElementById('assumptionTraction').getElementsByTagName('span')[0];
var tableHP = document.getElementById('tableHP');
var tableWeight = document.getElementById('tableWeight');
var tablePWR = document.getElementById('tablePWR');
var tableDrivetrain = document.getElementById('tableDrivetrain');
var tableET = document.getElementById('tableET');
var tableMPH = document.getElementById('tableMPH');
var hpError = document.getElementById('hpError');
var weightError = document.getElementById('weightError');
var chart = null;
var chartContext = null;
function validateInput(value, min, max, errorElement, inputElement, fieldName) {
var numValue = parseFloat(value);
if (isNaN(numValue) || value === ") {
errorElement.textContent = fieldName + ' is required.';
errorElement.style.display = 'block';
inputElement.style.borderColor = '#dc3545';
return false;
}
if (numValue max) {
errorElement.textContent = fieldName + ' cannot be greater than ' + max + '.';
errorElement.style.display = 'block';
inputElement.style.borderColor = '#dc3545';
return false;
}
errorElement.textContent = ";
errorElement.style.display = 'none';
inputElement.style.borderColor = '#ddd';
return true;
}
function calculatePerformance() {
var hp = parseFloat(horsepowerInput.value);
var weight = parseFloat(weightInput.value);
var driveType = driveTypeSelect.value;
var hpValid = validateInput(horsepowerInput.value, 1, 5000, hpError, horsepowerInput, 'Horsepower');
var weightValid = validateInput(weightInput.value, 500, 10000, weightError, weightInput, 'Vehicle Weight');
if (!hpValid || !weightValid) {
resetResults();
return;
}
var powerToWeight = hp / weight;
var baseC = 35;
var drivetrainFactor = 1.0;
var drivetrainText = '2WD';
if (driveType === 'awd') {
drivetrainFactor = 0.95;
drivetrainText = 'AWD';
} else if (driveType === 'fwd') {
drivetrainFactor = 1.05;
drivetrainText = 'FWD';
}
var adjustedC = baseC * drivetrainFactor;
var estimatedET = adjustedC * Math.sqrt(weight / hp);
var estimatedMPH = (660 / (estimatedET * 5280 / 3600)) * 0.6818; // Simplified MPH estimation
// Ensure results are not NaN and have reasonable bounds
if (isNaN(estimatedET) || estimatedET < 4.0) estimatedET = 4.0; // Minimum realistic ET
if (isNaN(estimatedMPH) || estimatedMPH 20.0) estimatedET = 20.0; // Maximum realistic ET
if (estimatedMPH > 200) estimatedMPH = 200; // Maximum realistic MPH
resultPrimaryDiv.textContent = estimatedET.toFixed(2);
powerToWeightRatioDiv.textContent = powerToWeight.toFixed(3);
estimatedETDiv.textContent = estimatedET.toFixed(2) + ' s';
estimatedMPHDiv.textContent = estimatedMPH.toFixed(0) + ' MPH';
assumptionDrivetrainDiv.textContent = drivetrainText;
assumptionTractionDiv.textContent = (drivetrainFactor 1.0 ? 'Moderate/Low' : 'Standard')) + ' (based on drivetrain)';
// Update table
tableHP.textContent = hp.toFixed(0);
tableWeight.textContent = weight.toFixed(0);
tablePWR.textContent = powerToWeight.toFixed(3);
tableDrivetrain.textContent = drivetrainText;
tableET.textContent = estimatedET.toFixed(2);
tableMPH.textContent = estimatedMPH.toFixed(0);
updateChart(powerToWeight, estimatedET, estimatedMPH);
}
function resetResults() {
resultPrimaryDiv.textContent = '–';
powerToWeightRatioDiv.textContent = '–';
estimatedETDiv.textContent = '–';
estimatedMPHDiv.textContent = '–';
assumptionDrivetrainDiv.textContent = '–';
assumptionTractionDiv.textContent = '–';
tableHP.textContent = '–';
tableWeight.textContent = '–';
tablePWR.textContent = '–';
tableDrivetrain.textContent = '–';
tableET.textContent = '–';
tableMPH.textContent = '–';
if (chart) {
chart.destroy();
chart = null;
}
}
function resetCalculator() {
horsepowerInput.value = '450';
weightInput.value = '3200';
driveTypeSelect.value = '2wd';
hpError.textContent = ";
hpError.style.display = 'none';
horsepowerInput.style.borderColor = '#ddd';
weightError.textContent = ";
weightError.style.display = 'none';
weightInput.style.borderColor = '#ddd';
calculatePerformance();
}
function copyResults() {
var primaryResult = resultPrimaryDiv.textContent;
var pwr = powerToWeightRatioDiv.textContent;
var et = estimatedETDiv.textContent;
var mph = estimatedMPHDiv.textContent;
var drivetrain = assumptionDrivetrainDiv.textContent;
var traction = assumptionTractionDiv.textContent;
var textToCopy = "1/8 Mile Performance Estimates:\n\n";
textToCopy += "Estimated 1/8 Mile ET: " + et + "\n";
textToCopy += "Power-to-Weight Ratio: " + pwr + " HP/lb\n";
textToCopy += "Estimated 1/8 Mile MPH: " + mph + "\n\n";
textToCopy += "Key Assumptions:\n";
textToCopy += "- Drivetrain: " + drivetrain + "\n";
textToCopy += "- Traction Factor: " + traction + "\n\n";
textToCopy += "Primary Result (ET): " + primaryResult + "\n";
navigator.clipboard.writeText(textToCopy).then(function() {
// Optional: Show a confirmation message
var copyButton = document.querySelector('button.secondary');
var originalText = copyButton.textContent;
copyButton.textContent = 'Copied!';
setTimeout(function() {
copyButton.textContent = originalText;
}, 1500);
}).catch(function(err) {
console.error('Failed to copy text: ', err);
// Optional: Show an error message
});
}
function updateChart(powerToWeight, estimatedET, estimatedMPH) {
var canvas = document.getElementById('performanceChart');
if (!canvas) return;
if (chart) {
chart.destroy();
}
chartContext = canvas.getContext('2d');
chart = new Chart(chartContext, {
type: 'bar', // Changed to bar for better visualization of discrete points
data: {
labels: ['Performance Metrics'], // Single label for simplicity
datasets: [{
label: 'Estimated 1/8 Mile ET (s)',
data: [estimatedET],
backgroundColor: 'rgba(0, 74, 153, 0.6)', // Primary color
borderColor: 'rgba(0, 74, 153, 1)',
borderWidth: 1,
type: 'line', // Display ET as a line
fill: false,
yAxisID: 'y-axis-et'
}, {
label: 'Power-to-Weight Ratio (HP/lb)',
data: [powerToWeight],
backgroundColor: 'rgba(40, 167, 69, 0.6)', // Success color
borderColor: 'rgba(40, 167, 69, 1)',
borderWidth: 1,
yAxisID: 'y-axis-pwr'
}]
},
options: {
responsive: true,
maintainAspectRatio: true,
scales: {
x: {
grid: {
display: false
}
},
'y-axis-et': {
type: 'linear',
position: 'left',
title: {
display: true,
text: 'Time (Seconds)'
},
ticks: {
beginAtZero: false, // ET doesn't start at zero
callback: function(value) {
return value.toFixed(2) + 's';
}
},
grid: {
display: true,
color: 'rgba(200, 200, 200, 0.2)'
}
},
'y-axis-pwr': {
type: 'linear',
position: 'right',
title: {
display: true,
text: 'HP per lb'
},
ticks: {
beginAtZero: true,
callback: function(value) {
return value.toFixed(3);
}
},
grid: {
display: false // Hide grid lines for the right axis
}
}
},
plugins: {
legend: {
display: true,
position: 'top',
},
title: {
display: true,
text: 'Key Performance Indicators'
}
}
}
});
}
// Initial calculation on page load
document.addEventListener('DOMContentLoaded', function() {
// Set default values and trigger calculation
horsepowerInput.value = '450';
weightInput.value = '3200';
driveTypeSelect.value = '2wd';
calculatePerformance();
});
// Add event listeners for real-time updates
horsepowerInput.addEventListener('input', calculatePerformance);
weightInput.addEventListener('input', calculatePerformance);
driveTypeSelect.addEventListener('change', calculatePerformance);