Ohlins Spring Weight Calculator

Ohlins Spring Weight Calculator: Find Your Perfect Setting :root { –primary-color: #004a99; –success-color: #28a745; –background-color: #f8f9fa; –text-color: #333; –border-color: #ccc; –shadow-color: rgba(0, 0, 0, 0.1); –white: #fff; } 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: 20px; } .container { max-width: 960px; margin: 0 auto; background-color: var(–white); padding: 30px; border-radius: 8px; box-shadow: 0 4px 15px var(–shadow-color); } h1, h2, h3 { color: var(–primary-color); text-align: center; margin-bottom: 20px; } h1 { font-size: 2.5em; } h2 { font-size: 2em; margin-top: 30px; } h3 { font-size: 1.5em; margin-top: 25px; } .loan-calc-container { margin-top: 25px; padding: 25px; border: 1px solid var(–border-color); border-radius: 8px; background-color: var(–white); } .input-group { margin-bottom: 20px; display: flex; flex-direction: column; } .input-group label { font-weight: bold; margin-bottom: 8px; display: block; color: var(–primary-color); } .input-group input[type="number"], .input-group select { width: 100%; padding: 10px 12px; border: 1px solid var(–border-color); border-radius: 5px; box-sizing: border-box; font-size: 1em; transition: border-color 0.3s ease; } .input-group input[type="number"]:focus, .input-group select:focus { border-color: var(–primary-color); outline: none; } .input-group .helper-text { font-size: 0.85em; color: #6c757d; margin-top: 5px; } .input-group .error-message { color: #dc3545; font-size: 0.8em; margin-top: 5px; height: 16px; } button { background-color: var(–primary-color); color: var(–white); border: none; padding: 12px 20px; border-radius: 5px; cursor: pointer; font-size: 1.1em; transition: background-color 0.3s ease, transform 0.2s ease; margin: 5px; } button:hover { background-color: #003366; transform: translateY(-1px); } button.secondary { background-color: #6c757d; } button.secondary:hover { background-color: #5a6268; } #results { margin-top: 25px; padding: 25px; border: 1px solid var(–border-color); border-radius: 8px; background-color: #e9ecef; text-align: center; box-shadow: inset 0 2px 5px rgba(0,0,0,0.05); } #results h3 { margin-top: 0; color: var(–text-color); } .result-item { margin-bottom: 15px; } .result-item strong { color: var(–primary-color); font-size: 1.3em; } .result-item span { display: block; font-size: 0.9em; color: #6c757d; } .primary-result { background-color: var(–primary-color); color: var(–white); padding: 20px; border-radius: 5px; margin-bottom: 20px; box-shadow: 0 2px 10px rgba(0, 74, 153, 0.4); } .primary-result strong { font-size: 2em; display: block; } .primary-result span { font-size: 1.2em; color: rgba(255, 255, 255, 0.8); } .formula-explanation { font-size: 0.9em; color: #555; margin-top: 15px; text-align: left; border-top: 1px dashed #ccc; padding-top: 15px; } table { width: 100%; border-collapse: collapse; margin-top: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); } th, td { padding: 12px 15px; text-align: left; border: 1px solid #ddd; } th { background-color: var(–primary-color); color: var(–white); font-weight: bold; } tr:nth-child(even) { background-color: #f2f2f2; } caption { font-size: 1.1em; margin-bottom: 10px; font-weight: bold; color: var(–primary-color); text-align: left; } #chartContainer { margin-top: 25px; padding: 20px; background-color: var(–white); border: 1px solid var(–border-color); border-radius: 8px; text-align: center; } #chartContainer h3 { margin-top: 0; } #springChart { max-width: 100%; height: 350px; } .article-section { margin-top: 40px; padding: 30px; background-color: var(–white); border: 1px solid var(–border-color); border-radius: 8px; box-shadow: 0 4px 15px var(–shadow-color); } .article-section h2 { text-align: left; margin-bottom: 20px; } .article-section h3 { text-align: left; margin-top: 25px; margin-bottom: 15px; color: #0056b3; } .article-section p, .article-section ul, .article-section ol { margin-bottom: 15px; font-size: 1.05em; color: #444; } .article-section ul, .article-section ol { padding-left: 25px; } .article-section li { margin-bottom: 10px; } .article-section a { color: var(–primary-color); text-decoration: none; font-weight: bold; } .article-section a:hover { text-decoration: underline; } .faq-item { margin-bottom: 15px; border-bottom: 1px dashed #eee; padding-bottom: 10px; } .faq-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; } .faq-item strong { color: var(–primary-color); display: block; margin-bottom: 5px; font-size: 1.1em; } .faq-item p { margin-bottom: 0; } .related-tools { margin-top: 30px; padding: 25px; background-color: #f0f0f0; border-radius: 8px; } .related-tools ul { list-style: none; padding: 0; } .related-tools li { margin-bottom: 10px; } .related-tools a { font-weight: bold; color: var(–primary-color); } .related-tools span { font-size: 0.9em; color: #666; display: block; } .button-group { text-align: center; margin-top: 20px; display: flex; justify-content: center; flex-wrap: wrap; } @media (min-width: 600px) { .container { padding: 40px; } .input-group input[type="number"], .input-group select { width: calc(100% – 24px); /* Account for padding */ } }

Ohlins Spring Weight Calculator

Determine the ideal Ohlins spring rate for your motorcycle's suspension based on rider and bike weight.

Suspension Setup

Your weight including gear.
Weight of a passenger, if applicable.
Weight of touring luggage or bags.
Dry weight of the motorcycle.
Measure from axle to fork bottom/swingarm pivot.
25% (Sport Riding) 30% (All-around) 35% (Touring/Comfort)
How much the suspension should compress under load.

Your Suspension Recommendations

N/mm Recommended Ohlins Spring Rate
kg Total Static Load Weight
mm Calculated Static Sag
mm Target Compression for Sag
Formula Used:
The recommended spring rate (K) is primarily determined by the total static load (Ws) and the desired sag percentage (Sag%) applied to the suspension travel (T). The basic principle is that the spring must support the total weight while allowing a specific amount of compression. A simplified approach calculates the necessary force to achieve the desired sag: K = Ws / (Sag%). For motorcycle suspension, we use a common recommendation of 30% sag for general use.

Spring Rate vs. Sag Comparison

Different spring rates and their corresponding sag measurements for your bike's suspension travel.

Spring Rate Data Table

Spring Rate (N/mm) Rider Sag (mm) Rider Sag (%)
Typical sag measurements for various spring rates under your total load.

What is an Ohlins Spring Weight Calculator?

An Ohlins spring weight calculator is a specialized tool designed to help motorcycle riders and mechanics determine the most appropriate spring rate for their Ohlins suspension components. Ohlins is a highly respected brand known for its premium performance suspension systems. Selecting the correct spring rate is crucial for optimizing a motorcycle's handling, comfort, and safety. This calculator takes into account various factors, primarily the total weight the suspension will carry, to recommend a specific spring stiffness (measured in Newtons per millimeter, N/mm) from Ohlins' range. Using the right spring ensures the suspension performs as intended, providing plushness over bumps while maintaining stability and control during aggressive riding or cornering.

Who Should Use It?

This calculator is invaluable for:

  • Motorcycle Enthusiasts: Riders looking to fine-tune their bike's suspension for a better riding experience, whether for street, track, or off-road use.
  • Performance Riders: Those who demand the utmost from their suspension during spirited riding or competitive events.
  • Touring Riders: Riders who frequently carry a passenger and/or luggage and need their suspension to handle the added load effectively.
  • Motorcycle Mechanics and Technicians: Professionals who service and set up suspension for various types of motorcycles.
  • New Ohlins Owners: Individuals purchasing Ohlins suspension for the first time who want to ensure they select the correct initial spring.

Common Misconceptions

  • "Stiffer is always better": This is false. An overly stiff spring will lead to a harsh ride, reduced traction, and poor handling as the suspension cannot absorb bumps effectively.
  • "My friend uses X spring, so I should too": Every rider and bike combination is unique. Factors like weight, riding style, and bike geometry significantly impact the ideal spring rate.
  • "Weight is the only factor": While weight is primary, suspension travel and desired sag percentage also play critical roles in the calculation. Riding style can also influence the optimal sag.
  • "OEM springs are good enough": While OEM springs are designed for a broad range of riders, aftermarket springs like Ohlins allow for precise tuning to a specific rider's needs, leading to superior performance and feel.

Ohlins Spring Weight Calculator Formula and Mathematical Explanation

The core principle behind selecting a spring rate is to ensure the suspension compresses appropriately under a given load. This compression is known as "sag." Sag is the amount the suspension compresses when the bike's static weight (rider, passenger, luggage) is applied. A common and effective target for rider sag on most street and sport motorcycles is 30% of the total available suspension travel.

The Basic Formula

The fundamental calculation is derived from Hooke's Law (F = kx), where F is the force, k is the spring constant (spring rate), and x is the displacement (sag).

Rearranged for our purpose: k = F / x

In the context of our calculator:

  • F (Force): This is the total static load weight (Ws) applied to the suspension.
  • x (Displacement): This is the desired amount of sag, calculated as a percentage of the total suspension travel.

Step-by-Step Calculation

  1. Calculate Total Static Load Weight (Ws): Sum of rider weight, passenger weight, luggage weight, and the bike's weight.
    Ws = RiderWeight + PassengerWeight + LuggageWeight + BikeWeight
  2. Calculate Target Compression (Sag Amount in mm): Multiply the total suspension travel by the desired sag percentage.
    TargetSag_mm = SuspensionTravel_mm * (DesiredSagPercentage / 100)
  3. Calculate Recommended Spring Rate (K): Divide the total static load weight by the target compression. Since we need to use consistent units (e.g., kgf for force and mm for distance), and the result is often desired in N/mm, we apply a conversion factor (approximately 9.81 N/kgf). However, a common simplification in suspension tuning is to work directly with kg, considering the force needed per mm of compression. For many practical calculators, including this one, the calculation is often presented as:
    Recommended_K (N/mm) = (Ws_kg * 9.81 N/kgf) / TargetSag_mm
    A slightly more direct simplification often used in calculators derived from race engineering practices uses the static load and desired sag directly, assuming the units will resolve appropriately or using a simplified ratio. For this calculator, we will use the load in kg and the travel in mm, and the result will be in N/mm.
    Recommended_K (N/mm) = (Ws_kg) / (TargetSag_mm / 100) * Simplified for illustrative purposes, common in some tuning contexts. The true physics involves converting kg to Newtons. The calculator will use: Ws_kg * 9.81 / TargetSag_mm

Variable Explanations

Here's a breakdown of the variables used in the Ohlins spring weight calculator:

Variable Meaning Unit Typical Range
Rider Weight The weight of the primary rider, including riding gear. kg 40 – 150+
Passenger Weight The weight of a typical passenger, including gear. kg 0 – 100+
Luggage Weight The approximate weight of any additional luggage or equipment carried. kg 0 – 50+
Bike Weight The operational or "wet" weight of the motorcycle (including fluids). Some calculators use dry weight, but wet is often more representative of the load. For simplicity here, we'll use the provided input. kg 100 – 300+
Suspension Travel The maximum range of motion for the front forks or rear shock absorber. mm 100 – 300+
Desired Sag Percentage The target percentage of suspension travel that should compress under static load. Affects ride height and handling characteristics. % 20 – 40
Total Static Load Weight The combined weight of the rider, passenger, luggage, and the motorcycle itself. kg 150 – 600+
Target Compression The absolute amount of suspension travel (in mm) that should be used by the static load. mm 30 – 100+
Recommended Spring Rate The stiffness of the spring required to achieve the desired sag under the total static load. N/mm 3 – 20+ (varies greatly by bike type)

Practical Examples (Real-World Use Cases)

Example 1: Sportbike Rider

A rider is setting up their sportbike for track days. They want a firm, responsive feel with less sag.

  • Rider Weight: 80 kg (with gear)
  • Passenger Weight: 0 kg
  • Luggage Weight: 0 kg
  • Bike Weight: 190 kg (wet weight)
  • Suspension Travel: 130 mm (front forks)
  • Desired Sag Percentage: 25% (for a firmer, sportier feel)

Calculation:

  • Total Static Load Weight = 80 + 0 + 0 + 190 = 270 kg
  • Target Compression = 130 mm * (25 / 100) = 32.5 mm
  • Recommended Spring Rate = (270 kg * 9.81 N/kgf) / 32.5 mm ≈ 81.4 N/mm

Calculator Result: Approximately 81.4 N/mm. The rider would look for an Ohlins spring closest to this value, perhaps an 80 N/mm or 85 N/mm, depending on availability and finer tuning preferences.

Interpretation: This spring rate is relatively stiff, suitable for aggressive riding where rider feedback and minimal suspension dive are prioritized. It offers less comfort but better control during hard braking and cornering.

Example 2: Adventure Touring Rider

An adventure rider is preparing for a long-distance tour, often carrying luggage and occasionally a passenger.

  • Rider Weight: 95 kg (with gear)
  • Passenger Weight: 70 kg (occasionally)
  • Luggage Weight: 25 kg (fully loaded)
  • Bike Weight: 250 kg (wet weight)
  • Suspension Travel: 200 mm (front forks)
  • Desired Sag Percentage: 30% (balanced performance and comfort)

Calculation (for fully loaded, solo riding):

  • Total Static Load Weight = 95 + 0 + 25 + 250 = 370 kg
  • Target Compression = 200 mm * (30 / 100) = 60 mm
  • Recommended Spring Rate = (370 kg * 9.81 N/kgf) / 60 mm ≈ 60.6 N/mm

Calculation (for fully loaded, with passenger):

  • Total Static Load Weight = 95 + 70 + 25 + 250 = 440 kg
  • Target Compression = 200 mm * (30 / 100) = 60 mm
  • Recommended Spring Rate = (440 kg * 9.81 N/kgf) / 60 mm ≈ 71.9 N/mm

Calculator Result: For solo touring, approximately 60.6 N/mm. With a passenger, it's closer to 71.9 N/mm. The rider needs to choose a spring that best balances these conditions, often opting for a slightly stiffer spring (e.g., 65 N/mm or 70 N/mm) to avoid bottoming out when carrying heavier loads or a passenger.

Interpretation: This rider requires a softer spring than the sportbike rider. The chosen spring needs to provide comfort over long distances while still managing the significant load variations. A spring around 65-70 N/mm would be a good starting point.

How to Use This Ohlins Spring Weight Calculator

Using this calculator is straightforward. Follow these steps to get your recommended spring rate:

  1. Gather Your Weights: Accurately determine your rider weight (including gear), any passenger weight, and the typical weight of your luggage.
  2. Find Your Bike's Weight: Locate your motorcycle's wet weight (with all fluids).
  3. Measure Suspension Travel: Measure the maximum travel of your front forks or rear shock in millimeters. You can usually find this specification in your owner's manual or service manual.
  4. Enter Data into Calculator: Input each of these values into the corresponding fields on the calculator.
  5. Select Desired Sag: Choose the sag percentage that best matches your riding style. 30% is a good all-around choice, while lower percentages (25%) are for sporty riding and higher percentages (35%) for comfort or heavy loads.
  6. Review Results: The calculator will instantly display:
    • Recommended Ohlins Spring Rate (N/mm): This is the primary output, indicating the stiffness you should aim for.
    • Total Static Load Weight (kg): The sum of all weights calculated.
    • Calculated Static Sag (mm): How much the suspension will compress with the recommended spring.
    • Target Compression (mm): The calculated sag amount based on your inputs.
  7. Interpret the Data: The results provide a strong starting point. You may need to consult Ohlins technical documentation or a suspension specialist for exact part numbers or fine-tuning.
  8. Use the Table and Chart: Explore the generated table and chart to see how different spring rates would affect sag on your bike. This helps visualize the impact of spring stiffness.
  9. Copy Results: If you need to share this information or save it, use the "Copy Results" button.

Decision-Making Guidance: Use the recommended spring rate as your primary guide. If you frequently ride with a passenger or heavy luggage, consider a spring rate slightly stiffer than the solo rider recommendation. If you prioritize plush comfort over sharp handling, a slightly softer spring might be considered, but always stay within a reasonable range of the calculated value to avoid compromising safety and performance.

Key Factors That Affect Ohlins Spring Weight Results

While the calculator uses core data, several other factors influence the ideal spring choice and overall suspension performance:

  1. Riding Style: Aggressive track riding requires less sag (stiffer spring) for better feedback and control, whereas comfortable touring might benefit from more sag (softer spring) for plushness. This is why the "Desired Sag Percentage" is a key input.
  2. Suspension Type and Design: Different suspension systems (e.g., conventional forks, upside-down forks, linkage-based rear shocks) have different characteristics. Ohlins components are engineered for optimal performance, but the underlying design influences how a spring rate affects the ride.
  3. Spring Material and Quality: Ohlins uses high-quality materials, ensuring consistent spring rates and durability. Variations in material properties across different manufacturers or lower-quality springs can lead to unpredictable performance.
  4. Damping Settings: Spring rate and damping (rebound and compression) work together. The correct spring rate sets the suspension's initial response and ride height, while damping controls the *rate* at which the suspension moves. Improper damping can make even the correct spring feel wrong.
  5. Tire Pressure and Type: Tire pressure significantly affects how the bike interacts with the road surface. Incorrect tire pressure can mimic the symptoms of poorly chosen suspension. The type of tire (e.g., sport, touring, off-road) also influences grip and feedback.
  6. Chassis Geometry and Weight Distribution: The bike's frame design, wheelbase, head angle, and overall weight distribution impact how the suspension loads and unloads. Adjustments like rider position or changes to the bike (e.g., aftermarket exhaust) can subtly alter this balance.
  7. Inflation Pressure (Air Suspension): Some modern suspensions (especially on adventure bikes) use air pressure in addition to or instead of traditional springs. Adjusting air pressure acts like changing spring rate, but it also affects damping characteristics differently. This calculator is primarily for coil springs.
  8. Road Conditions/Track Surface: The surface you ride on dictates how much the suspension needs to work. A smooth track might allow for a very firm setup, while rough roads demand more compliance.

Frequently Asked Questions (FAQ)

Q1: How accurate is this calculator?

This calculator provides a highly accurate starting point based on established suspension principles. However, rider preference and specific riding conditions mean fine-tuning may still be necessary. It's a recommendation, not an absolute rule.

Q2: What if my calculated spring rate isn't available?

Ohlins offers a range of spring rates. Choose the closest available rate. If you're between two rates, consider your riding style: slightly stiffer for sportier riding, slightly softer for more comfort or heavier loads.

Q3: Should I use front or rear suspension travel for the calculation?

Typically, you'd perform this calculation for both front and rear if you are replacing both sets of springs. The calculator uses the input "Suspension Travel" for a general recommendation. For precise setup, you would ideally calculate for each end separately using their respective travel figures and spring types.

Q4: Does "wet weight" or "dry weight" matter more for the bike?

Wet weight (including all fluids like oil, coolant, and fuel) is generally more representative of the actual load the suspension carries during riding. If you only know the dry weight, add an estimated amount for fluids (typically 10-20 kg).

Q5: How do I measure suspension travel?

Measure the distance from the axle to the point where the fork bottoms out (or the swingarm pivot for the rear) when the suspension is fully extended. You can use a zip tie around the fork leg or swingarm to indicate full compression after a ride.

Q6: What is the difference between static sag and rider sag?

Static sag refers to the sag when the vehicle is at rest, supported only by its own weight (bike, rider, etc.). Rider sag specifically refers to the sag *caused by the rider's weight alone*. Our calculator aims to achieve a specific *total* static sag percentage.

Q7: Can I adjust damping instead of changing the spring?

Springs determine how much the suspension compresses under load (ride height and sag). Damping controls the speed of compression and rebound. While damping is critical for handling, it cannot compensate for a spring that is fundamentally too soft or too stiff for the bike's load.

Q8: Is it worth investing in Ohlins springs?

For riders seeking the highest level of performance, precision, and feel from their motorcycle suspension, Ohlins components are often considered a worthwhile investment. They offer superior materials, manufacturing tolerances, and performance characteristics compared to many stock or budget aftermarket options.

© 2023 Your Website Name. All rights reserved.

var chartInstance = null; function validateInput(value, id, min, max, message, isOptional = false) { var errorElement = document.getElementById(id + 'Error'); if (value === " && isOptional) { errorElement.textContent = "; return true; } if (value === " && !isOptional) { errorElement.textContent = 'This field is required.'; return false; } var numValue = parseFloat(value); if (isNaN(numValue)) { errorElement.textContent = 'Please enter a valid number.'; return false; } if (numValue max) { errorElement.textContent = message || 'Value cannot be greater than ' + max + '.'; return false; } errorElement.textContent = "; return true; } function calculateSpringWeight() { var riderWeight = document.getElementById('riderWeight').value; var passengerWeight = document.getElementById('passengerWeight').value; var luggageWeight = document.getElementById('luggageWeight').value; var bikeWeight = document.getElementById('bikeWeight').value; var suspensionTravel = document.getElementById('suspensionTravel').value; var desiredSagPercentage = document.getElementById('desiredSagPercentage').value; var isValid = true; isValid = validateInput(riderWeight, 'riderWeight', 1, 500, 'Weight must be between 1 and 500 kg.') && isValid; isValid = validateInput(passengerWeight, 'passengerWeight', 0, 500, 'Weight must be between 0 and 500 kg.', true) && isValid; isValid = validateInput(luggageWeight, 'luggageWeight', 0, 500, 'Weight must be between 0 and 500 kg.', true) && isValid; isValid = validateInput(bikeWeight, 'bikeWeight', 50, 1000, 'Weight must be between 50 and 1000 kg.') && isValid; isValid = validateInput(suspensionTravel, 'suspensionTravel', 10, 1000, 'Suspension travel must be between 10 and 1000 mm.') && isValid; isValid = validateInput(desiredSagPercentage, 'desiredSagPercentage', 1, 100, ", false) && isValid; // Selects are validated differently if (!isValid) { resetResults(); return; } var numRiderWeight = parseFloat(riderWeight); var numPassengerWeight = parseFloat(passengerWeight || 0); // Default to 0 if empty var numLuggageWeight = parseFloat(luggageWeight || 0); // Default to 0 if empty var numBikeWeight = parseFloat(bikeWeight); var numSuspensionTravel = parseFloat(suspensionTravel); var numDesiredSagPercentage = parseFloat(desiredSagPercentage); var totalLoadWeight = numRiderWeight + numPassengerWeight + numLuggageWeight + numBikeWeight; var targetSagMm = numSuspensionTravel * (numDesiredSagPercentage / 100); var calculatedSpringRate = (totalLoadWeight * 9.81) / targetSagMm; // Convert kg to Newtons, then divide by mm var staticSagMm = targetSagMm; // The target sag is what we calculate the spring for var targetCompressionMm = targetSagMm; document.getElementById('totalLoadWeight').textContent = totalLoadWeight.toFixed(1); document.getElementById('staticSag').textContent = staticSagMm.toFixed(1); document.getElementById('targetCompression').textContent = targetCompressionMm.toFixed(1); if (!isNaN(calculatedSpringRate) && calculatedSpringRate > 0) { document.getElementById('recommendedSpringRate').textContent = calculatedSpringRate.toFixed(1); } else { document.getElementById('recommendedSpringRate').textContent = '–'; } updateChartAndTable(totalLoadWeight, numSuspensionTravel, numDesiredSagPercentage); } function updateChartAndTable(totalLoadWeight, suspensionTravel, currentSagPercent) { var springRates = [ Math.max(2, Math.round(totalLoadWeight * 0.5)), // Start with a lower bound based on load Math.max(3, Math.round(totalLoadWeight * 0.7)), Math.max(4, Math.round(totalLoadWeight * 0.9)), Math.max(5, Math.round(totalLoadWeight * 1.1)), Math.max(6, Math.round(totalLoadWeight * 1.3)), Math.max(7, Math.round(totalLoadWeight * 1.5)) ]; var chartData = { labels: [], riderSagData: [], currentRateSagData: [] }; var tableHtml = "; var currentRecommendedRate = parseFloat(document.getElementById('recommendedSpringRate').textContent); springRates.forEach(function(rate) { var sagMm = (totalLoadWeight * 9.81) / (rate * 1000); // Convert rate to N/mm, then calculate sag var sagPercent = (sagMm / suspensionTravel) * 100; chartData.labels.push(rate.toFixed(1) + " N/mm"); chartData.riderSagData.push(sagPercent); // Highlight the sag for the currently recommended rate if (Math.abs(rate – currentRecommendedRate) < 1) { // Check if this rate is close to the recommended one chartData.currentRateSagData.push(sagPercent); } else { chartData.currentRateSagData.push(null); // Use null for non-highlighted points } tableHtml += ''; tableHtml += '' + rate.toFixed(1) + ''; tableHtml += '' + sagMm.toFixed(1) + ''; tableHtml += '' + sagPercent.toFixed(1) + '%'; tableHtml += ''; }); document.getElementById('springTableBody').innerHTML = tableHtml; var ctx = document.getElementById('springChart').getContext('2d'); if (chartInstance) { chartInstance.destroy(); } chartInstance = new Chart(ctx, { type: 'bar', data: { labels: chartData.labels, datasets: [{ label: 'Sag Percentage (%)', data: chartData.riderSagData, backgroundColor: 'rgba(0, 74, 153, 0.6)', borderColor: 'rgba(0, 74, 153, 1)', borderWidth: 1, yAxisID: 'y-axis-sag' }, { label: 'Recommended Sag (' + currentRecommendedRate.toFixed(1) + ' N/mm)', data: chartData.currentRateSagData, type: 'line', borderColor: 'rgba(40, 167, 69, 1)', borderWidth: 3, pointRadius: 6, fill: false, yAxisID: 'y-axis-sag' }] }, options: { responsive: true, maintainAspectRatio: false, scales: { x: { title: { display: true, text: 'Spring Rate (N/mm)' } }, 'y-axis-sag': { type: 'linear', position: 'left', min: 0, max: 50, // Max sag percentage usually doesn't exceed 50% title: { display: true, text: 'Sag Percentage (%)' }, ticks: { callback: function(value) { return value + '%'; } } } }, plugins: { tooltip: { callbacks: { label: function(context) { var label = context.dataset.label || "; if (label) { label += ': '; } if (context.parsed.y !== null) { label += context.parsed.y.toFixed(1) + '%'; } return label; } } }, legend: { position: 'top' } } } }); } function resetResults() { document.getElementById('recommendedSpringRate').textContent = '–'; document.getElementById('totalLoadWeight').textContent = '–'; document.getElementById('staticSag').textContent = '–'; document.getElementById('targetCompression').textContent = '–'; var ctx = document.getElementById('springChart').getContext('2d'); if (chartInstance) { chartInstance.destroy(); chartInstance = null; } ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); document.getElementById('springTableBody').innerHTML = "; // Reset input fields to sensible defaults document.getElementById('riderWeight').value = '75'; document.getElementById('passengerWeight').value = '0'; document.getElementById('luggageWeight').value = '5'; document.getElementById('bikeWeight').value = '200'; document.getElementById('suspensionTravel').value = '150'; document.getElementById('desiredSagPercentage').value = '30'; // Set to default option // Clear error messages var errorElements = document.querySelectorAll('.error-message'); for (var i = 0; i < errorElements.length; i++) { errorElements[i].textContent = ''; } } function resetCalculator() { resetResults(); calculateSpringWeight(); // Recalculate with default values } function copyResults() { var recommendedRate = document.getElementById('recommendedSpringRate').textContent; var totalLoad = document.getElementById('totalLoadWeight').textContent; var staticSag = document.getElementById('staticSag').textContent; var targetCompression = document.getElementById('targetCompression').textContent; var assumptions = "Key Assumptions:\n"; assumptions += "- Rider Weight: " + document.getElementById('riderWeight').value + " kg\n"; assumptions += "- Passenger Weight: " + (document.getElementById('passengerWeight').value || '0') + " kg\n"; assumptions += "- Luggage Weight: " + (document.getElementById('luggageWeight').value || '0') + " kg\n"; assumptions += "- Bike Weight: " + document.getElementById('bikeWeight').value + " kg\n"; assumptions += "- Suspension Travel: " + document.getElementById('suspensionTravel').value + " mm\n"; assumptions += "- Desired Sag Percentage: " + document.getElementById('desiredSagPercentage').options[document.getElementById('desiredSagPercentage').selectedIndex].text + "\n"; var textToCopy = "— Ohlins Spring Weight Calculator Results —\n\n"; textToCopy += "Recommended Ohlins Spring Rate: " + recommendedRate + " N/mm\n"; textToCopy += "Total Static Load Weight: " + totalLoad + " kg\n"; textToCopy += "Calculated Static Sag: " + staticSag + " mm\n"; textToCopy += "Target Compression: " + targetCompression + " mm\n\n"; textToCopy += assumptions; if (navigator.clipboard && window.isSecureContext) { navigator.clipboard.writeText(textToCopy).then(function() { alert('Results copied to clipboard!'); }).catch(function(err) { console.error('Failed to copy text: ', err); fallbackCopyTextToClipboard(textToCopy); }); } else { fallbackCopyTextToClipboard(textToCopy); } } function fallbackCopyTextToClipboard(text) { var textArea = document.createElement("textarea"); textArea.value = text; textArea.style.position = "fixed"; textArea.style.left = "-9999px"; textArea.style.top = "-9999px"; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { var successful = document.execCommand('copy'); var msg = successful ? 'successful' : 'unsuccessful'; alert('Results copied to clipboard! (' + msg + ')'); } catch (err) { console.error('Fallback: Oops, unable to copy', err); alert('Could not copy text. Please copy manually.'); } document.body.removeChild(textArea); } // Initial calculation on page load with default values document.addEventListener('DOMContentLoaded', function() { resetCalculator(); // Ensures default values are set and calculation runs }); // Chart.js library included via CDN in a real scenario, or could be embedded. // For this self-contained HTML, we assume Chart.js is available globally. // If running locally, you'd need to include the Chart.js library. // Example CDN: <!– Add this script tag before the closing tag if running this as a standalone file: –> <!– –>

Leave a Comment