Weight Height Calorie Calculator

Weight Height Calorie Calculator: Estimate Your Daily Needs :root { –primary-color: #004a99; –success-color: #28a745; –background-color: #f8f9fa; –text-color: #333; –white-color: #fff; –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(–white-color); 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: 1.8em; margin-top: 30px; border-bottom: 2px solid var(–primary-color); padding-bottom: 5px; } h3 { font-size: 1.3em; margin-top: 25px; color: var(–primary-color); } .loan-calc-container, .results-container, .chart-container, .article-section { background-color: var(–white-color); padding: 25px; border-radius: 8px; margin-bottom: 25px; box-shadow: 0 2px 10px var(–shadow-color); } .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 { padding: 12px; border: 1px solid var(–border-color); border-radius: 5px; font-size: 1em; width: 100%; box-sizing: border-box; /* Ensure padding doesn't affect width */ 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.85em; margin-top: 5px; display: none; /* Hidden by default */ } .input-group .error-message.visible { display: block; } .button-group { display: flex; justify-content: space-between; margin-top: 20px; flex-wrap: wrap; /* Allow wrapping on smaller screens */ } 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; margin: 5px; /* Spacing for wrapped buttons */ } .btn-calculate, .btn-copy { background-color: var(–primary-color); color: var(–white-color); } .btn-calculate:hover, .btn-copy:hover { background-color: #003366; transform: translateY(-2px); } .btn-reset { background-color: #6c757d; color: var(–white-color); } .btn-reset:hover { background-color: #5a6268; transform: translateY(-2px); } .results-container h2 { margin-top: 0; border-bottom: none; text-align: left; color: var(–primary-color); } .primary-result { font-size: 2em; font-weight: bold; color: var(–white-color); background-color: var(–success-color); padding: 15px 20px; border-radius: 5px; text-align: center; margin-bottom: 20px; display: block; } .intermediate-results div, .formula-explanation { background-color: var(–background-color); padding: 15px; border-radius: 5px; margin-bottom: 15px; border-left: 5px solid var(–primary-color); } .intermediate-results span, .formula-explanation span { font-weight: bold; color: var(–primary-color); } .formula-explanation { border-left-color: var(–primary-color); font-style: italic; } table { width: 100%; border-collapse: collapse; margin-top: 20px; box-shadow: 0 2px 5px var(–shadow-color); } th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(–border-color); } thead { background-color: var(–primary-color); color: var(–white-color); } th { font-weight: bold; } td { background-color: var(–white-color); } caption { caption-side: top; font-weight: bold; font-size: 1.1em; color: var(–primary-color); margin-bottom: 10px; text-align: left; padding: 5px 0; } .chart-container { text-align: center; } canvas { max-width: 100%; height: auto; } /* Article Styling */ .article-section { background-color: var(–white-color); padding: 30px; margin-top: 30px; box-shadow: 0 2px 10px var(–shadow-color); text-align: left; } .article-section p, .article-section ul, .article-section ol { margin-bottom: 15px; font-size: 1.05em; } .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-list .question { font-weight: bold; color: var(–primary-color); margin-top: 15px; display: block; } .faq-list .answer { margin-left: 15px; margin-top: 5px; display: block; } .related-tools ul { list-style: none; padding: 0; } .related-tools li { margin-bottom: 15px; } .related-tools a { font-weight: bold; color: var(–primary-color); text-decoration: none; } .related-tools a:hover { text-decoration: underline; } .related-tools span { font-size: 0.9em; color: #6c757d; display: block; margin-top: 3px; } /* Responsive Adjustments */ @media (max-width: 768px) { .container { margin: 10px; padding: 15px; } h1 { font-size: 2em; } h2 { font-size: 1.5em; } button { width: 100%; margin: 5px 0; } .button-group { flex-direction: column; align-items: center; } .primary-result { font-size: 1.6em; } }

Weight Height Calorie Calculator

Calculate your estimated daily calorie needs (TDEE) and Basal Metabolic Rate (BMR) using our accurate Weight Height Calorie Calculator. Input your weight, height, age, gender, and activity level to understand your energy expenditure.

Calorie Needs Calculator

Male Female Select your gender for calculation.
Enter your age in years. Please enter a valid age between 1 and 120.
Enter your weight in kilograms (kg). Please enter a valid weight between 1 and 1000 kg.
Enter your height in centimeters (cm). Please enter a valid height between 1 and 300 cm.
Sedentary (little or no exercise) Lightly active (light exercise/sports 1-3 days/week) Moderately active (moderate exercise/sports 3-5 days/week) Very active (hard exercise/sports 6-7 days a week) Extra active (very hard exercise/physical job) Select your typical weekly physical activity.

Your Calorie Estimates

— kcal
Basal Metabolic Rate (BMR): — kcal
BMR is the energy your body needs at rest.
Total Daily Energy Expenditure (TDEE): — kcal
TDEE is your BMR plus calories burned through activity.
Estimated Maintenance Calories: — kcal
Formula Used: We use the Mifflin-St Jeor Equation for BMR, then multiply by an activity factor for TDEE.

Mifflin-St Jeor BMR (kcal/day):
For Men: (10 × weight in kg) + (6.25 × height in cm) – (5 × age in years) + 5
For Women: (10 × weight in kg) + (6.25 × height in cm) – (5 × age in years) – 161

TDEE = BMR × Activity Factor

Daily Calorie Needs Overview

What is a Weight Height Calorie Calculator?

A Weight Height Calorie Calculator is a valuable online tool designed to estimate the number of calories an individual needs to consume daily to maintain their current body weight. This estimate, often referred to as Total Daily Energy Expenditure (TDEE), takes into account several key personal metrics, including your weight, height, age, gender, and crucially, your activity level. The calculator typically works by first determining your Basal Metabolic Rate (BMR), which is the number of calories your body burns at rest to perform essential functions like breathing, circulation, and cell production. It then applies an activity factor to this BMR to account for the calories burned through daily activities and exercise, resulting in your TDEE.

Who should use it? This weight height calorie calculator is useful for anyone interested in understanding their energy balance. This includes individuals aiming for weight loss (by consuming fewer calories than their TDEE), weight gain (by consuming more calories than their TDEE), or simply maintaining their current weight. Athletes, fitness enthusiasts, and those managing specific health conditions may also find this tool beneficial for fine-tuning their nutritional intake. Understanding your calorie needs is a foundational step in achieving your health and fitness goals.

Common misconceptions: One common misconception is that these calculators provide an exact calorie count. In reality, they offer an estimate. Individual metabolisms can vary significantly due to genetics, body composition (muscle vs. fat), hormonal factors, and even environmental conditions. Another misconception is that focusing solely on calorie count is sufficient for health; the quality and nutritional density of those calories are equally, if not more, important. This weight height calorie calculator serves as a starting point, not a definitive prescription.

Weight Height Calorie Calculator Formula and Mathematical Explanation

The foundation of most weight height calorie calculators lies in estimating your Basal Metabolic Rate (BMR) and then adjusting it for your daily activity to determine your Total Daily Energy Expenditure (TDEE). A widely accepted and relatively accurate formula for BMR calculation is the Mifflin-St Jeor Equation. This equation was developed to be more accurate than older formulas like the Harris-Benedict equation.

The Mifflin-St Jeor Equation:

  • For Men: BMR = (10 × weight in kg) + (6.25 × height in cm) – (5 × age in years) + 5
  • For Women: BMR = (10 × weight in kg) + (6.25 × height in cm) – (5 × age in years) – 161

Once the BMR is calculated, it needs to be multiplied by an activity factor to estimate the Total Daily Energy Expenditure (TDEE). This factor accounts for the calories burned through physical activity, from light daily movements to intense workouts.

TDEE = BMR × Activity Factor

The activity factors typically used are:

  • Sedentary: 1.2 (little or no exercise, desk job)
  • Lightly Active: 1.375 (light exercise/sports 1-3 days/week)
  • Moderately Active: 1.55 (moderate exercise/sports 3-5 days/week)
  • Very Active: 1.725 (hard exercise/sports 6-7 days a week)
  • Extra Active: 1.9 (very hard exercise/sports & physical job or training twice a day)

The output of the calculator provides your estimated TDEE, which represents the calories you need to consume to maintain your current weight. To lose weight, you generally need to consume fewer calories than your TDEE, and to gain weight, you need to consume more.

Variables Table

Variables Used in Calorie Calculation
Variable Meaning Unit Typical Range
Gender Biological sex, affecting hormonal and metabolic differences. Male/Female Male, Female
Age Years since birth, affecting metabolic rate. Years 1 – 120
Weight Body mass. Kilograms (kg) 1 – 1000
Height Body stature. Centimeters (cm) 1 – 300
Activity Factor Multiplier representing daily physical activity level. Multiplier (e.g., 1.2 – 1.9) 1.2 – 1.9
BMR Basal Metabolic Rate – energy expenditure at rest. Kilocalories (kcal) per day Varies greatly by individual
TDEE Total Daily Energy Expenditure – total daily calorie needs. Kilocalories (kcal) per day Varies greatly by individual

Practical Examples (Real-World Use Cases)

Understanding how the Weight Height Calorie Calculator works is best illustrated with practical examples.

Example 1: Sarah, aiming for Weight Maintenance

Inputs:

  • Gender: Female
  • Age: 28 years
  • Weight: 65 kg
  • Height: 165 cm
  • Activity Level: Moderately active (exercises 3-5 times a week)

Calculation Steps:

  1. BMR Calculation (Female): (10 × 65) + (6.25 × 165) – (5 × 28) – 161
  2. BMR = 650 + 1031.25 – 140 – 161 = 1380.25 kcal/day
  3. TDEE Calculation: BMR × Activity Factor (1.55 for moderately active)
  4. TDEE = 1380.25 × 1.55 = 2139.39 kcal/day

Outputs:

  • BMR: Approximately 1380 kcal
  • TDEE: Approximately 2139 kcal
  • Estimated Maintenance Calories: Approximately 2139 kcal

Interpretation: Sarah needs to consume roughly 2139 calories per day to maintain her current weight of 65 kg, given her age, height, and moderate activity level. If she wishes to lose weight, she should aim for a daily intake below this number (e.g., 1800-1900 kcal), ensuring adequate nutrition.

Example 2: David, aiming for Weight Loss

Inputs:

  • Gender: Male
  • Age: 45 years
  • Weight: 90 kg
  • Height: 180 cm
  • Activity Level: Lightly active (exercises 1-3 times a week)

Calculation Steps:

  1. BMR Calculation (Male): (10 × 90) + (6.25 × 180) – (5 × 45) + 5
  2. BMR = 900 + 1125 – 225 + 5 = 1805 kcal/day
  3. TDEE Calculation: BMR × Activity Factor (1.375 for lightly active)
  4. TDEE = 1805 × 1.375 = 2481.88 kcal/day

Outputs:

  • BMR: Approximately 1805 kcal
  • TDEE: Approximately 2482 kcal
  • Estimated Maintenance Calories: Approximately 2482 kcal

Interpretation: David's estimated daily calorie needs to maintain his current weight of 90 kg are around 2482 calories. To lose weight effectively and sustainably, a common recommendation is to create a deficit of 500 calories per day, which could lead to about 1 pound of fat loss per week. Therefore, David might aim for a daily intake of approximately 1900-2000 calories.

How to Use This Weight Height Calorie Calculator

Using this Weight Height Calorie Calculator is straightforward. Follow these simple steps to get your personalized calorie estimates:

  1. Select Gender: Choose either 'Male' or 'Female' from the dropdown menu. This is important as the BMR formula differs slightly based on gender.
  2. Enter Age: Input your current age in years into the 'Age' field. Ensure it's a whole number.
  3. Input Weight: Enter your current body weight in kilograms (kg) into the 'Weight' field.
  4. Input Height: Enter your current height in centimeters (cm) into the 'Height' field.
  5. Choose Activity Level: Select the option that best describes your typical weekly physical activity from the 'Activity Level' dropdown. Be honest with your assessment for the most accurate results.
  6. Calculate: Click the 'Calculate Calories' button.

How to Read Results:

  • Primary Result (TDEE): The large, highlighted number represents your Total Daily Energy Expenditure (TDEE). This is the estimated number of calories you need to consume daily to maintain your current body weight.
  • Basal Metabolic Rate (BMR): This value indicates the calories your body burns at rest. It's the minimum energy required for basic life-sustaining functions.
  • Estimated Maintenance Calories: This is essentially your TDEE, indicating the calorie intake required to stay at your current weight.
  • Formula Explanation: Review the explanation to understand the Mifflin-St Jeor equation and how the activity factor is applied.

Decision-Making Guidance:

  • Weight Maintenance: Consume calories equal to your TDEE.
  • Weight Loss: Consume fewer calories than your TDEE. A common deficit is 500 calories per day for approximately 1 lb of fat loss per week.
  • Weight Gain: Consume more calories than your TDEE. A surplus of 250-500 calories per day can lead to gradual muscle gain.

Remember, these are estimates. Adjust your intake based on your progress and consult with a healthcare professional or registered dietitian for personalized advice.

Key Factors That Affect Calorie Needs

While the Weight Height Calorie Calculator provides a solid estimate, several factors can influence your actual daily calorie requirements beyond the inputs provided. Understanding these nuances can help you fine-tune your approach to nutrition and health goals.

  1. Body Composition (Muscle Mass): Muscle tissue is metabolically more active than fat tissue, meaning it burns more calories even at rest. Individuals with higher muscle mass will generally have a higher BMR and TDEE than someone of the same weight, height, and age but with less muscle.
  2. Genetics: Your genetic makeup plays a significant role in your metabolic rate. Some people naturally have a faster metabolism, burning more calories throughout the day, while others have a slower metabolism.
  3. Hormonal Factors: Hormones like thyroid hormones (T3 and T4) directly regulate metabolism. Conditions like hypothyroidism (underactive thyroid) can significantly lower BMR, while hyperthyroidism (overactive thyroid) can increase it.
  4. Thermic Effect of Food (TEF): Digesting, absorbing, and metabolizing food requires energy. Different macronutrients have different TEFs; protein requires the most energy to process. While included implicitly in activity factors, the specific composition of your diet can slightly alter total energy expenditure.
  5. Environmental Temperature: Your body expends energy to maintain its core temperature. In very cold or very hot environments, your body may need to work harder (burning more calories) to stay within its optimal temperature range.
  6. Health Status and Illness: During illness, injury, or recovery from surgery, your body's metabolic rate can increase significantly as it fights infection or repairs tissue. Conversely, certain chronic conditions might lower metabolic rate.
  7. Age-Related Metabolic Slowdown: As people age, especially after 30, there's a natural tendency for metabolic rate to decrease, often due to a loss of muscle mass and hormonal changes. This is why activity level becomes even more critical for weight management as we get older.
  8. Medications: Certain medications can affect metabolism and appetite, potentially influencing daily calorie needs or weight management outcomes.

This weight height calorie calculator serves as an excellent starting point, but individual variations mean that monitoring your body's response and adjusting your intake accordingly is crucial for success.

Frequently Asked Questions (FAQ)

Q1: Is the Mifflin-St Jeor equation the most accurate for all ages? A1: The Mifflin-St Jeor equation is considered one of the most accurate BMR formulas currently available for adults. However, metabolic rates can differ in children, adolescents, and the very elderly. For most adults, it provides a reliable estimate. Q2: How often should I recalculate my TDEE? A2: You should recalculate your TDEE whenever significant changes occur in your weight, activity level, or body composition. Even small adjustments in weight (e.g., 5-10 lbs) can warrant a recalculation for accuracy. Q3: Can this calculator predict calorie needs for muscle gain? A3: This calculator estimates maintenance calories. For muscle gain, you typically need to consume a surplus (more calories than TDEE). A common recommendation is to add 250-500 calories to your TDEE, but this weight height calorie calculator provides the baseline TDEE figure. Q4: What if my activity level changes frequently? A4: If your activity level varies significantly day-to-day or week-to-week, it's best to use an average or choose the activity level that represents the majority of your week. Alternatively, you might calculate TDEE for different activity levels to get a range. Q5: Does the calculator account for different body types (e.g., ectomorph, mesomorph, endomorph)? A5: No, this calculator does not directly account for somatotypes (body types). It relies on measurable data like weight, height, age, and activity. Body composition (muscle vs. fat percentage) is a more significant factor than theoretical body types. Q6: Is TDEE the same as my caloric deficit for weight loss? A6: No, TDEE is your maintenance calorie level. A caloric deficit is achieved by consuming fewer calories than your TDEE. This weight height calorie calculator helps you find your TDEE, which is the first step in determining your deficit. Q7: Why is my BMR lower than expected? A7: A lower-than-expected BMR could be due to a slower metabolism (potentially influenced by genetics or age), lower muscle mass, or certain health conditions. It's always advisable to consult a healthcare professional if you have concerns. Q8: Can I use pounds and feet/inches instead of kg and cm? A8: This specific calculator requires input in kilograms (kg) and centimeters (cm) as per the Mifflin-St Jeor formula's standard units for optimal accuracy. You would need to convert your measurements before inputting them.

Related Tools and Internal Resources

© 2023 Your Website Name. All rights reserved.

var primaryResultElement = document.getElementById('primaryResult'); var bmrResultElement = document.getElementById('bmrResult').querySelector('span'); var tdeeResultElement = document.getElementById('tdeeResult').querySelector('span'); var maintenanceResultElement = document.getElementById('calorieMaintenance').querySelector('span'); var resultsContainer = document.getElementById('resultsContainer'); var calorieChart; var chartData = { bmr: [], tdee: [] }; var chartLabels = []; function validateInput(inputElement, min, max) { var errorElementId = inputElement.id + 'Error'; var errorElement = document.getElementById(errorElementId); var value = parseFloat(inputElement.value); if (isNaN(value) || value max) { inputElement.style.borderColor = '#dc3545'; if (errorElement) { errorElement.classList.add('visible'); } return false; } else { inputElement.style.borderColor = '#004a99'; if (errorElement) { errorElement.classList.remove('visible'); } return true; } } function calculateCalories() { var gender = document.getElementById('gender').value; var age = parseFloat(document.getElementById('age').value); var weight = parseFloat(document.getElementById('weight').value); var height = parseFloat(document.getElementById('height').value); var activityFactor = parseFloat(document.getElementById('activityLevel').value); var ageError = document.getElementById('ageError'); var weightError = document.getElementById('weightError'); var heightError = document.getElementById('heightError'); var isAgeValid = validateInput(document.getElementById('age'), 1, 120); var isWeightValid = validateInput(document.getElementById('weight'), 1, 1000); var isHeightValid = validateInput(document.getElementById('height'), 1, 300); if (!isAgeValid || !isWeightValid || !isHeightValid) { resultsContainer.style.display = 'none'; return; } var bmr; if (gender === 'male') { bmr = (10 * weight) + (6.25 * height) – (5 * age) + 5; } else { // female bmr = (10 * weight) + (6.25 * height) – (5 * age) – 161; } var tdee = bmr * activityFactor; bmrResultElement.textContent = Math.round(bmr) + ' kcal'; tdeeResultElement.textContent = Math.round(tdee) + ' kcal'; maintenanceResultElement.textContent = Math.round(tdee) + ' kcal'; primaryResultElement.textContent = Math.round(tdee) + ' kcal'; resultsContainer.style.display = 'block'; // Update chart data chartLabels.push(new Date().toLocaleTimeString()); chartData.bmr.push(Math.round(bmr)); chartData.tdee.push(Math.round(tdee)); // Keep only the last 10 data points for clarity if (chartLabels.length > 10) { chartLabels.shift(); chartData.bmr.shift(); chartData.tdee.shift(); } updateChart(); } function updateChart() { var ctx = document.getElementById('calorieChart').getContext('2d'); if (calorieChart) { calorieChart.destroy(); } calorieChart = new Chart(ctx, { type: 'line', data: { labels: chartLabels, datasets: [{ label: 'BMR (kcal)', data: chartData.bmr, borderColor: 'rgba(0, 74, 153, 1)', backgroundColor: 'rgba(0, 74, 153, 0.2)', fill: true, tension: 0.1 }, { label: 'TDEE (kcal)', data: chartData.tdee, borderColor: 'rgba(40, 167, 69, 1)', backgroundColor: 'rgba(40, 167, 69, 0.2)', fill: true, tension: 0.1 }] }, options: { responsive: true, maintainAspectRatio: false, scales: { y: { beginAtZero: true, title: { display: true, text: 'Calories (kcal)' } }, x: { title: { display: true, text: 'Time of Update' } } }, plugins: { legend: { position: 'top', }, title: { display: true, text: 'Your Calorie Trends' } } } }); // Update chart legend manually if needed or rely on chart.js legend var legendHtml = 'Legend: '; legendHtml += 'BMR'; legendHtml += 'TDEE'; document.getElementById('chartLegend').innerHTML = legendHtml; } function resetForm() { document.getElementById('gender').value = 'male'; document.getElementById('age').value = "; document.getElementById('weight').value = "; document.getElementById('height').value = "; document.getElementById('activityLevel').value = '1.2'; document.getElementById('ageError').classList.remove('visible'); document.getElementById('weightError').classList.remove('visible'); document.getElementById('heightError').classList.remove('visible'); document.getElementById('age').style.borderColor = '#ddd'; document.getElementById('weight').style.borderColor = '#ddd'; document.getElementById('height').style.borderColor = '#ddd'; primaryResultElement.textContent = '– kcal'; bmrResultElement.textContent = '– kcal'; tdeeResultElement.textContent = '– kcal'; maintenanceResultElement.textContent = '– kcal'; resultsContainer.style.display = 'none'; // Clear chart data and redraw with empty state chartData.bmr = []; chartData.tdee = []; chartLabels = []; updateChart(); } function copyResults() { var bmrVal = bmrResultElement.textContent; var tdeeVal = tdeeResultElement.textContent; var maintenanceVal = maintenanceResultElement.textContent; var primaryVal = primaryResultElement.textContent; var gender = document.getElementById('gender').value; var age = document.getElementById('age').value; var weight = document.getElementById('weight').value; var height = document.getElementById('height').value; var activityLevelText = document.getElementById('activityLevel').options[document.getElementById('activityLevel').selectedIndex].text; var copyText = "— Calorie Estimates —\n"; copyText += "Basal Metabolic Rate (BMR): " + bmrVal + "\n"; copyText += "Total Daily Energy Expenditure (TDEE): " + tdeeVal + "\n"; copyText += "Estimated Maintenance Calories: " + maintenanceVal + "\n"; copyText += "\n— Input Parameters —\n"; copyText += "Gender: " + gender.charAt(0).toUpperCase() + gender.slice(1) + "\n"; copyText += "Age: " + age + " years\n"; copyText += "Weight: " + weight + " kg\n"; copyText += "Height: " + height + " cm\n"; copyText += "Activity Level: " + activityLevelText + "\n"; copyText += "\n(Calculated using Mifflin-St Jeor equation and activity factor)"; navigator.clipboard.writeText(copyText).then(function() { // Success feedback (optional) var copyButton = document.querySelector('.btn-copy'); var originalText = copyButton.textContent; copyButton.textContent = 'Copied!'; setTimeout(function() { copyButton.textContent = originalText; }, 1500); }, function() { // Failure feedback (optional) alert('Failed to copy results. Please copy manually.'); }); } // Initialize chart on load window.onload = function() { var canvas = document.getElementById('calorieChart'); var ctx = canvas.getContext('2d'); // Initialize with empty chart calorieChart = new Chart(ctx, { type: 'line', data: { labels: [], datasets: [{ label: 'BMR (kcal)', data: [], borderColor: 'rgba(0, 74, 153, 1)', backgroundColor: 'rgba(0, 74, 153, 0.2)', fill: true, tension: 0.1 }, { label: 'TDEE (kcal)', data: [], borderColor: 'rgba(40, 167, 69, 1)', backgroundColor: 'rgba(40, 167, 69, 0.2)', fill: true, tension: 0.1 }] }, options: { responsive: true, maintainAspectRatio: false, scales: { y: { beginAtZero: true, title: { display: true, text: 'Calories (kcal)' } }, x: { title: { display: true, text: 'Time of Update' } } }, plugins: { legend: { position: 'top', }, title: { display: true, text: 'Your Calorie Trends' } } } }); var legendHtml = 'Legend: '; legendHtml += 'BMR'; legendHtml += 'TDEE'; document.getElementById('chartLegend').innerHTML = legendHtml; };

Leave a Comment