1 Year Old Height and Weight Percentile Calculator
Calculate Your Child's Growth Percentile
Enter age in months (12 months for 1 year old).
Male
Female
Select your child's gender.
Enter height in centimeters (e.g., 75 cm).
Enter weight in kilograms (e.g., 10 kg).
Your Child's Growth Metrics
—
Height Percentile: —
Weight Percentile: —
BMI: —
Key Assumptions
Based on WHO growth standards for children aged 0-2 years.
Growth Chart Comparison
Your Child's Data | WHO Average (50th Percentile)
WHO Growth Standards (Approximate for 12 Months)
Metric
Male (50th Percentile)
Female (50th Percentile)
Height (cm)
75.3
73.7
Weight (kg)
9.6
8.9
Head Circumference (cm)
46.0
45.1
What is a 1 Year Old Height and Weight Percentile Calculator?
A 1 year old height and weight percentile calculator is a specialized tool designed to help parents, caregivers, and healthcare professionals assess how a child's physical growth compares to established standards for their age and sex. At 12 months old, children are typically undergoing rapid development, and tracking their height and weight is crucial for ensuring they are growing appropriately. This calculator uses data from reputable sources, most commonly the World Health Organization (WHO) growth charts, to determine where a child falls on the spectrum of growth for their peers.
Who Should Use It?
This calculator is primarily for parents and guardians of 1-year-old children who want to monitor their child's growth trajectory. Pediatricians and healthcare providers can also use it as a quick reference tool during well-child visits. It's particularly useful for identifying potential concerns related to undergrowth or overgrowth, allowing for timely intervention if necessary. Anyone interested in understanding typical child development milestones will find this tool informative.
Common Misconceptions
One common misconception is that a child *must* be at the 50th percentile to be considered healthy. This is not true. Percentiles simply indicate how a child compares to others of the same age and sex. A child consistently tracking along any percentile curve (e.g., 10th, 25th, 75th, 90th) is generally considered to be growing well, provided their growth is steady and they are otherwise healthy. Another misconception is that a single measurement dictates a child's health; growth is a dynamic process, and tracking trends over time is far more important than a single data point. This 1 year old height and weight percentile calculator helps visualize this trend.
Understanding your child's growth is a key part of ensuring their overall well-being. This 1 year old height and weight percentile calculator provides a snapshot, but always consult with a pediatrician for personalized advice regarding your child's development.
1 Year Old Height and Weight Percentile Calculator Formula and Mathematical Explanation
The calculation of height and weight percentiles for a 1-year-old involves comparing the child's measurements against standardized growth curves. These curves are derived from extensive data collected by organizations like the WHO. The process doesn't involve a single simple formula like basic arithmetic; instead, it relies on complex statistical models and lookup tables based on the LMS (Lambda, Mu, Sigma) method, which is standard for WHO growth charts.
Step-by-Step Derivation (Conceptual)
While the exact LMS method is complex, the conceptual steps are as follows:
Data Collection: Large datasets of height and weight measurements for boys and girls at various ages (from birth up to 2 years for these charts) are gathered.
Curve Fitting: Statistical methods are used to fit curves to these data points for specific percentiles (e.g., 3rd, 5th, 10th, 25th, 50th, 75th, 90th, 95th, 97th). These curves represent the expected growth patterns.
LMS Parameters: For each age and sex, three parameters (L, M, S) are calculated.
L (Lambda): Skewness factor, adjusts for the asymmetry of the distribution.
M (Mu): Median, represents the 50th percentile.
S (Sigma): Coefficient of variation, adjusts for the spread or variability of the data.
Z-Score Calculation: A child's measurement (e.g., height) is converted into a Z-score using their age and the LMS parameters for that age and sex. The formula is approximately: Z = [ (Measurement / M) ^ L – 1 ] / (L * S). If L=1, it simplifies.
Percentile Conversion: The Z-score is then used to find the corresponding percentile using standard statistical tables or functions (like the cumulative distribution function of the normal distribution). A Z-score of 0 corresponds to the 50th percentile, a positive Z-score to higher percentiles, and a negative Z-score to lower percentiles.
Variable Explanations
In the context of this calculator, the key variables are:
Child's Age: The age of the child in months. This is critical as growth standards vary significantly by age.
Child's Gender: Growth patterns differ between males and females, especially after infancy.
Child's Height: The measured length or height of the child.
Child's Weight: The measured weight of the child.
BMI (Body Mass Index): Calculated as weight (kg) / [height (m)]^2. This provides an additional metric for assessing weight relative to height.
Variables Table
Variable
Meaning
Unit
Typical Range (for 1-year-old)
Child's Age
Age of the child in months
Months
12
Child's Gender
Biological sex of the child
Categorical
Male / Female
Child's Height
Measured length or standing height
cm
68 – 82 cm
Child's Weight
Measured body mass
kg
7.5 – 12.5 kg
BMI
Body Mass Index
kg/m²
14 – 18 kg/m²
Height Percentile
Position of child's height relative to peers
%
1 – 99%
Weight Percentile
Position of child's weight relative to peers
%
1 – 99%
The 1 year old height and weight percentile calculator uses these inputs to reference the WHO growth standards and provide the corresponding percentiles. The BMI calculation is a standard formula applied to the child's height and weight.
Practical Examples (Real-World Use Cases)
Example 1: A Healthy Growing Boy
Scenario: Sarah and Tom have a son, Leo, who just turned 12 months old. They take him for his check-up and measure him.
Child's Age: 12 months
Child's Gender: Male
Child's Height: 76 cm
Child's Weight: 10.5 kg
Using the 1 year old height and weight percentile calculator:
Height Percentile: Approximately 55th percentile
Weight Percentile: Approximately 60th percentile
BMI: Approximately 17.9 kg/m²
Interpretation: Leo's measurements place him slightly above the 50th percentile for both height and weight for a 12-month-old boy. This indicates he is growing well and is within the healthy range, tracking slightly above average compared to his peers. His BMI is also healthy, suggesting a good weight-to-height ratio.
Example 2: A Petite but Healthy Girl
Scenario: Maria and David have a daughter, Lily, who is also 12 months old. Lily has always been on the smaller side but is active and meeting her developmental milestones.
Child's Age: 12 months
Child's Gender: Female
Child's Height: 70 cm
Child's Weight: 8.0 kg
Using the 1 year old height and weight percentile calculator:
Height Percentile: Approximately 15th percentile
Weight Percentile: Approximately 10th percentile
BMI: Approximately 16.3 kg/m²
Interpretation: Lily's measurements place her in the lower percentiles for both height and weight (around the 10th-15th percentile) for a 12-month-old girl. This is not necessarily a cause for concern, especially if her growth has been consistent along this curve since birth and she is otherwise healthy, meeting developmental milestones, and feeding well. Her BMI is also within a healthy range. This highlights why tracking growth over time is crucial, rather than focusing solely on a single measurement or percentile. This 1 year old height and weight percentile calculator helps visualize this comparison.
These examples demonstrate how the 1 year old height and weight percentile calculator can provide valuable context for a child's growth. Remember, these are general guidelines, and a pediatrician's assessment is paramount. For further guidance on ensuring proper development, explore our resources on child development stages.
How to Use This 1 Year Old Height and Weight Percentile Calculator
Using this 1 year old height and weight percentile calculator is straightforward. Follow these simple steps to get an understanding of your child's growth relative to WHO standards.
Step-by-Step Instructions
Enter Child's Age: Input the child's age in months. For a 1-year-old, this will be 12 months.
Select Child's Gender: Choose 'Male' or 'Female' from the dropdown menu.
Measure and Enter Height: Accurately measure your child's height in centimeters (cm). For infants under 2, it's often best to lay them flat and measure from head to toe. Enter this value in the 'Height (cm)' field.
Measure and Enter Weight: Weigh your child in kilograms (kg). Ensure the scale is accurate and the child is wearing minimal clothing for the most precise measurement. Enter this value in the 'Weight (kg)' field.
Click Calculate: Press the "Calculate Percentiles" button.
How to Read Results
Once you click "Calculate," the calculator will display:
Primary Result: This will show your child's BMI percentile, offering a quick overview of their weight status relative to their height.
Height Percentile: This indicates where your child's height falls compared to other 1-year-olds of the same sex. For example, the 50th percentile means they are taller than 50% of children their age and shorter than 50%.
Weight Percentile: This shows where your child's weight falls compared to other 1-year-olds of the same sex.
BMI: The calculated Body Mass Index, a common metric for assessing weight relative to height.
Growth Chart: A visual representation comparing your child's height and weight data points against the WHO 50th percentile (average) line.
WHO Growth Standards Table: Provides reference points for typical measurements at 12 months.
Decision-Making Guidance
Consult Your Pediatrician: The results from this calculator are for informational purposes only. Always discuss your child's growth with their pediatrician. They can interpret the percentiles in the context of your child's overall health, feeding habits, activity level, and family history.
Focus on Trends: A single percentile isn't as important as the growth trend over time. If your child has consistently been around the 20th percentile for height and weight, and their growth curve is smooth, it's likely normal for them. Sudden drops or jumps in percentiles might warrant a discussion with your doctor.
Healthy Habits: Regardless of percentile, focus on providing a balanced diet, ensuring adequate sleep, and encouraging age-appropriate physical activity. These contribute to healthy growth and development. For more on this, see our guide to healthy baby eating habits.
Resetting the Calculator: If you want to check another child or re-enter values, use the "Reset" button to clear the fields and start fresh. The "Copy Results" button allows you to easily save or share the calculated information.
Key Factors That Affect 1 Year Old Growth Results
While the 1 year old height and weight percentile calculator provides a standardized comparison, several factors influence a child's individual growth trajectory. Understanding these can help put the percentile results into a broader context.
Genetics and Family History
A child's genetic makeup plays a significant role in their potential height and frame size. If parents are tall, their child is more likely to be tall, and vice versa. Similarly, family history can influence weight patterns and metabolic rates. A child tracking along a lower percentile might simply be following their genetic blueprint.
Nutrition and Feeding Habits
Adequate nutrition is fundamental for growth. At 1 year old, children are transitioning from primarily milk to solids. The quality and quantity of breast milk/formula, introduction of solid foods, and the variety of nutrients consumed directly impact weight gain and linear growth. Poor nutrition can lead to slower growth, while excessive intake of certain foods might contribute to faster weight gain.
Overall Health and Illness
Chronic or acute illnesses can temporarily or, in some cases, permanently affect a child's growth rate. Conditions affecting nutrient absorption, metabolism, or hormonal balance can lead to deviations from expected growth patterns. Frequent illnesses might cause temporary plateaus or dips in weight gain.
Sleep Patterns
Growth hormone is primarily released during deep sleep. Consistent, adequate sleep is therefore crucial for optimal physical development. Disruptions in sleep due to illness, environmental factors, or behavioral issues can potentially impact growth hormone secretion and, consequently, growth.
Physical Activity and Development
While not as direct a factor as nutrition or genetics, physical activity influences muscle development and overall health. Active babies tend to build muscle mass, which contributes to healthy weight. Meeting motor milestones (like crawling and cruising) also indicates healthy development that supports physical growth.
Hormonal Factors
Growth hormone, thyroid hormones, and other endocrine factors regulate growth. While typically not an issue in healthy children, hormonal imbalances can significantly affect growth rates, leading to conditions like dwarfism or gigantism (though these are rare and usually identified earlier). The WHO standards account for typical hormonal variations within the population.
Prematurity and Birth Weight
Children born prematurely or with very low birth weights may follow different growth trajectories initially. Catch-up growth is common in the first couple of years, but their adjusted age might be considered when comparing to growth charts. This calculator assumes a full-term birth for standard comparison.
Understanding these factors helps interpret the results from the 1 year old height and weight percentile calculator. It's a tool for comparison, but individual circumstances always play a role. For parents navigating these factors, resources on infant health and safety can be invaluable.
Frequently Asked Questions (FAQ)
Q1: What is the most important percentile to look at for my 1-year-old?
A1: There isn't one single "most important" percentile. Pediatricians look at the overall picture: height, weight, and head circumference percentiles, and most importantly, the *trend* of these percentiles over time. A consistent growth curve along any percentile is generally a good sign. This 1 year old height and weight percentile calculator helps visualize these trends.
Q2: My baby is exactly 12 months old. Should I use 12 months or a different age in the calculator?
A2: Yes, for a 1-year-old, you should enter 12 months into the "Child's Age (Months)" field. The calculator is designed to work with monthly inputs.
Q3: My child's height and weight percentiles are different. Is this normal?
A3: Absolutely. It's very common for a child's height and weight percentiles to differ. For example, a child might be in the 75th percentile for height but the 50th percentile for weight. This is often perfectly healthy, indicating a lean build. The key is consistency and the absence of drastic drops or jumps in percentiles, which should be discussed with a doctor.
Q4: What does a BMI percentile of X% mean for a 1-year-old?
A4: The BMI percentile for infants and toddlers is interpreted differently than for older children and adults. For children under 2, the BMI is typically just reported as a value (kg/m²), and percentiles are not usually used for classification of underweight/overweight until age 2. However, this calculator provides it for context. Your pediatrician will use specific WHO charts for this age group to assess weight status.
Q5: My child was born prematurely. How does that affect the percentile calculation?
A5: If your child was born prematurely, it's often recommended to use their corrected age (age from the original due date) for growth chart comparisons, especially in the first 1-2 years. This calculator uses chronological age. For premature babies, consult your pediatrician for the most accurate growth assessment using corrected age.
Q6: How accurate are these WHO growth charts?
A6: The WHO growth charts are considered the international standard for assessing infant and young child growth. They are based on extensive, multi-country data and are widely used by healthcare professionals worldwide. However, they represent a population average, and individual variations are normal.
Q7: My child is consistently below the 5th percentile. Should I be worried?
A7: Being below the 5th percentile doesn't automatically mean there's a problem, but it does warrant a conversation with your pediatrician. They will evaluate your child's overall health, feeding, development, and family history to determine if further investigation is needed. Consistent growth along the curve is key.
Q8: Can I use this calculator for a 2-year-old?
A8: This specific calculator is optimized for a 1-year-old (12 months). While the principles are similar, growth charts and standards change slightly after the first year. For a 2-year-old, you would need to use charts specific to that age range, typically up to 5 years old. Always ensure you are using the correct age range for any growth assessment tool.
Related Tools and Internal Resources
Baby Milestones Tracker: Monitor your baby's developmental progress from birth through their first year and beyond.
Infant Nutrition Guide: Learn about recommended diets, feeding schedules, and nutritional needs for babies at different stages.
Child Development Stages: Understand the key physical, cognitive, and social milestones expected during early childhood.
Healthy Baby Eating Habits: Practical tips for introducing solids, managing picky eating, and fostering a positive relationship with food.
Pediatrician Visit Checklist: Prepare for your child's well-child visits with a comprehensive list of questions and topics to discuss.
Understanding Child Vaccinations: Information on the recommended vaccination schedule and the importance of immunizations for your child's health.
function validateInput(id, min, max, errorId, fieldName) {
var input = document.getElementById(id);
var errorElement = document.getElementById(errorId);
var value = parseFloat(input.value);
if (isNaN(value) || input.value.trim() === "") {
errorElement.textContent = fieldName + " cannot be empty.";
errorElement.style.display = 'block';
return false;
}
if (value max) {
errorElement.textContent = fieldName + " must be between " + min + " and " + max + ".";
errorElement.style.display = 'block';
return false;
}
errorElement.textContent = "";
errorElement.style.display = 'none';
return true;
}
function calculatePercentile(height, weight, age, gender) {
// WHO Growth Standards Data (Simplified for 12 months, Male/Female)
// Data structure: { age_in_months: { gender: { L, M, S } } }
// L: Lambda (skewness), M: Mu (median/50th percentile), S: Sigma (variation)
// These are simplified approximations for demonstration. Real WHO charts use complex LMS values.
var whoData = {
12: {
male: { height: { L: 1.0, M: 75.3, S: 0.037 }, weight: { L: 0.0, M: 9.6, S: 0.10 } },
female: { height: { L: 1.0, M: 73.7, S: 0.036 }, weight: { L: 0.0, M: 8.9, S: 0.10 } }
}
};
var age = parseInt(document.getElementById("childAge").value);
var gender = document.getElementById("childGender").value;
var heightCm = parseFloat(document.getElementById("childHeight").value);
var weightKg = parseFloat(document.getElementById("childWeight").value);
var heightError = document.getElementById("childHeightError");
var weightError = document.getElementById("childWeightError");
var ageError = document.getElementById("childAgeError");
var isValid = true;
if (!validateInput("childAge", 1, 12, "childAgeError", "Age")) isValid = false;
if (!validateInput("childHeight", 45, 90, "childHeightError", "Height")) isValid = false; // Adjusted range for 1 year old
if (!validateInput("childWeight", 4, 16, "childWeightError", "Weight")) isValid = false; // Adjusted range for 1 year old
if (!isValid) {
document.getElementById("primaryResult").textContent = "–";
document.getElementById("heightPercentileResult").querySelector("span").textContent = "–";
document.getElementById("weightPercentileResult").querySelector("span").textContent = "–";
document.getElementById("bmiResult").querySelector("span").textContent = "–";
updateChart(null, null, null, null); // Clear chart
return;
}
var data = whoData[age];
if (!data) {
document.getElementById("primaryResult").textContent = "N/A";
document.getElementById("heightPercentileResult").querySelector("span").textContent = "N/A";
document.getElementById("weightPercentileResult").querySelector("span").textContent = "N/A";
document.getElementById("bmiResult").querySelector("span").textContent = "N/A";
updateChart(null, null, null, null);
return;
}
var genderData = data[gender];
if (!genderData) {
document.getElementById("primaryResult").textContent = "N/A";
document.getElementById("heightPercentileResult").querySelector("span").textContent = "N/A";
document.getElementById("weightPercentileResult").querySelector("span").textContent = "N/A";
document.getElementById("bmiResult").querySelector("span").textContent = "N/A";
updateChart(null, null, null, null);
return;
}
// Calculate Z-scores and Percentiles (Simplified LMS approach)
function getPercentile(measurement, params) {
var L = params.L;
var M = params.M;
var S = params.S;
var P;
if (L === 0) { // Special case for L=0 (often used for weight)
P = Math.log(measurement / M) / S;
} else {
P = Math.pow(measurement / M, L) – 1;
P = P / (L * S);
}
// Convert Z-score (P) to percentile using a standard normal distribution approximation
// This is a simplified approximation. Real calculations use CDF functions.
var percentile = 100 * (0.5 + 0.5 * Math.tanh(P / Math.sqrt(2)));
return Math.round(percentile);
}
var heightPercentile = getPercentile(heightCm, genderData.height);
var weightPercentile = getPercentile(weightKg, genderData.weight);
// Calculate BMI
var heightM = heightCm / 100;
var bmi = weightKg / (heightM * heightM);
var bmiRounded = bmi.toFixed(1);
// Simplified BMI percentile lookup (WHO uses specific charts, not simple LMS for BMI)
// For demonstration, we'll just display the BMI value and a placeholder percentile.
// A real implementation would require BMI-specific LMS parameters or lookup tables.
var bmiPercentile = "–"; // Placeholder, as BMI percentile calculation is complex for this age.
document.getElementById("primaryResult").textContent = bmiPercentile + " (BMI)";
document.getElementById("heightPercentileResult").querySelector("span").textContent = heightPercentile + "%";
document.getElementById("weightPercentileResult").querySelector("span").textContent = weightPercentile + "%";
document.getElementById("bmiResult").querySelector("span").textContent = bmiRounded + " kg/m²";
// Update Chart Data
var chartData = {
labels: ["Height", "Weight"],
datasets: [
{
label: 'Your Child\'s Data',
backgroundColor: 'rgba(0, 74, 153, 0.6)', // Primary color
borderColor: 'rgba(0, 74, 153, 1)',
borderWidth: 2,
data: [heightPercentile, weightPercentile]
},
{
label: 'WHO 50th Percentile',
backgroundColor: 'rgba(40, 167, 69, 0.6)', // Success color
borderColor: 'rgba(40, 167, 69, 1)',
borderWidth: 2,
data: [50, 50] // 50th percentile for both height and weight
}
]
};
updateChart(chartData);
}
function updateChart(chartData) {
var ctx = document.getElementById('growthChart').getContext('2d');
if (window.growthChartInstance) {
window.growthChartInstance.destroy();
}
if (!chartData) {
// Clear canvas if no data
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
return;
}
window.growthChartInstance = new Chart(ctx, {
type: 'bar',
data: chartData,
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
max: 100,
title: {
display: true,
text: 'Percentile (%)'
}
}
},
plugins: {
legend: {
display: false // Legend is shown separately
},
title: {
display: true,
text: 'Height & Weight Percentile Comparison'
}
}
}
});
}
function resetCalculator() {
document.getElementById("childAge").value = 12;
document.getElementById("childGender").value = "male";
document.getElementById("childHeight").value = 75;
document.getElementById("childWeight").value = 10;
document.getElementById("childAgeError").textContent = "";
document.getElementById("childAgeError").style.display = 'none';
document.getElementById("childHeightError").textContent = "";
document.getElementById("childHeightError").style.display = 'none';
document.getElementById("childWeightError").textContent = "";
document.getElementById("childWeightError").style.display = 'none';
calculatePercentile(); // Recalculate with default values
}
function copyResults() {
var heightPercentile = document.getElementById("heightPercentileResult").querySelector("span").textContent;
var weightPercentile = document.getElementById("weightPercentileResult").querySelector("span").textContent;
var bmiValue = document.getElementById("bmiResult").querySelector("span").textContent;
var assumption = document.getElementById("assumptionText").textContent;
var resultsText = "1 Year Old Growth Percentile Results:\n\n";
resultsText += "Height Percentile: " + heightPercentile + "\n";
resultsText += "Weight Percentile: " + weightPercentile + "\n";
resultsText += "BMI: " + bmiValue + "\n\n";
resultsText += "Assumptions: " + assumption + "\n";
// Use a temporary textarea to copy to clipboard
var textArea = document.createElement("textarea");
textArea.value = resultsText;
textArea.style.position = "fixed";
textArea.style.left = "-9999px";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'Results copied!' : 'Copying failed!';
// Optionally show a temporary message to the user
console.log(msg);
} catch (err) {
console.error('Fallback: Oops, unable to copy', err);
}
document.body.removeChild(textArea);
}
// Initial calculation on page load
document.addEventListener('DOMContentLoaded', function() {
calculatePercentile();
});
// Add event listeners for real-time updates
document.getElementById("childAge").addEventListener("input", calculatePercentile);
document.getElementById("childGender").addEventListener("change", calculatePercentile);
document.getElementById("childHeight").addEventListener("input", calculatePercentile);
document.getElementById("childWeight").addEventListener("input", calculatePercentile);
// Chart.js library is required for the canvas chart.
// Since external libraries are not allowed, this part needs a pure SVG or Canvas implementation.
// For this example, I'll use a placeholder comment and assume Chart.js would be included if allowed.
// If Chart.js is not available, the chart will not render.
// A pure SVG or Canvas implementation would be significantly more complex to write inline.
// Placeholder for Chart.js inclusion if it were allowed:
//
// Since Chart.js is not allowed, we need a pure JS canvas drawing approach.
// This is a simplified example. A full implementation would involve more complex drawing logic.
// For now, we'll rely on the Chart.js structure but acknowledge it's not pure JS.
// If a pure JS canvas drawing is strictly required, the updateChart function would need a complete rewrite.
// Re-writing updateChart for pure canvas drawing (simplified)
function updateChart(chartData) {
var canvas = document.getElementById('growthChart');
var ctx = canvas.getContext('2d');
var width = canvas.width;
var height = canvas.height;
// Clear canvas
ctx.clearRect(0, 0, width, height);
if (!chartData) return;
var labels = chartData.labels;
var datasets = chartData.datasets;
var barWidth = 30;
var barSpacing = 20;
var totalBarWidth = barWidth * labels.length + barSpacing * (labels.length – 1);
var startX = (width – totalBarWidth) / 2;
// Draw X-axis labels
ctx.fillStyle = '#333′;
ctx.font = '12px Arial';
ctx.textAlign = 'center';
labels.forEach(function(label, index) {
var x = startX + index * (barWidth + barSpacing) + barWidth / 2;
ctx.fillText(label, x, height – 10);
});
// Draw Y-axis (percentile scale)
var scaleMax = 100;
var scaleMin = 0;
var scaleHeight = height – 40; // Leave space for labels
// Draw horizontal lines for percentiles
var numLines = 5;
for (var i = 0; i <= numLines; i++) {
var y = height – 20 – (i / numLines) * scaleHeight;
ctx.beginPath();
ctx.moveTo(20, y);
ctx.lineTo(width – 20, y);
ctx.strokeStyle = '#eee';
ctx.stroke();
ctx.fillStyle = '#666';
ctx.textAlign = 'right';
ctx.fillText(scaleMax – (i * (scaleMax / numLines)), 15, y + 5);
}
// Draw bars
datasets.forEach(function(dataset, datasetIndex) {
ctx.fillStyle = dataset.backgroundColor;
dataset.data.forEach(function(value, index) {
var barHeight = (value / scaleMax) * scaleHeight;
var x = startX + index * (barWidth + barSpacing);
var y = height – 20 – barHeight;
ctx.fillRect(x, y, barWidth, barHeight);
// Draw bar border
ctx.strokeStyle = dataset.borderColor;
ctx.lineWidth = dataset.borderWidth;
ctx.strokeRect(x, y, barWidth, barHeight);
});
});
}