Skip to content

About

Client-side growth percentile calculator (Astro + TypeScript)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

Repository files navigation

growth-chart-calculator

Client-side growth percentile calculator. Converts (sex, birth date, measurement date, type, value) into a WHO or CDC percentile and z-score using the LMS method (Cole & Green, 1992).

Everything runs in the browser — no data leaves the device.

Live: https://growthchartcalculator.com

Tech

  • Astro + TypeScript
  • Chart.js for the optional growth chart view
  • LMS reference tables (WHO 2006, CDC 2000) bundled at build time via Vite's ?raw loader

Develop

npm install
npm run dev       # Vite dev server
npm run build     # tsc + vite build → dist/
npm run preview   # serve the built dist/

npm run build is the full check — tsc is the only type check; there's no separate lint step.

Structure

  • src/references.ts — loads the CSV LMS tables from src/data/ and exposes getReference(standard, sex, type, age).
  • src/growth.ts — LMS math (Box-Cox / log fallback, normal CDF via Abramowitz & Stegun, inverse via Acklam). No deps.
  • src/main.ts — form wiring, percentile bands, optional chart rendering, and print output.
  • src/pages/ — Astro routes, including the calculator (index.astro) and landing pages (who-growth-chart, cdc-growth-chart, baby-percentile-calculator, etc.).

Reference data

src/data/ contains the LMS tables:

  • WHO (0–60 months): sex-specific files, month column.
  • CDC (0–240 months): single file per metric with Sex (1=boy, 2=girl) and Agemos.

getReference normalizes both into { month, L, M, S }.

The birth-to-24-month WHO weight-for-age and length-for-age L/M/S rows match the CSV files linked from the CDC WHO data files page. The CDC age-based tables match the CDC 2000 Growth Charts data files for weight-for-age and length/stature-for-age. npm test verifies representative source rows, CDC's published 9-month male weight-for-age LMS example, and the bundled CDC percentile columns against the LMS equations.

Results UI

After calculation, the default result view is a percentile-band summary with findings, visual percentile bands, and Low / Typical / High labels. Users can switch the visualization section to percentile charts with the Bands / Charts control; the selected view is saved in localStorage. Results include a medical disclaimer reminding users that growth charts are informational and should be discussed with a pediatrician or healthcare provider.

Deploy

Cloudflare Pages builds on every push to main:

  • Framework: Astro
  • Build command: npm run build
  • Output: dist

License

MIT

About

Client-side growth percentile calculator (Astro + TypeScript)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages