$ show toorshia/justgage
JustGage is a modern, zero-dependency JavaScript library for creating animated SVG dashboard gauges. It is a complete rewrite of the legacy RaphaelJS-based v1.x, using native SVG APIs and ES6+ class-based architecture. The library provides a highly customizable gauge with support for donut, differential, pointer, target lines, custom sectors, and multiple animation easing functions. The source is organized into modular components: core gauge logic (`src/core/JustGage.js`), configuration handling (`src/core/config.js`), a requestAnimationFrame-based animator (`src/core/GaugeAnimator.js`), a native SVG renderer with a Raphael-like wrapper (`src/rendering/svg.js`), and utility modules for colors, formatting, DOM, and general helpers. The build system uses esbuild to produce ESM, CJS, and UMD outputs, and tests are run with the Node.js native test runner and jsdom. The codebase demonstrates good engineering practices: separation of concerns, comprehensive test coverage (unit, integration, edge cases), and CI/CD pipelines. However, the main `JustGage` class is large (857 lines) and contains some duplicated geometry/path logic between gauge types, and the SVG renderer is tightly coupled to gauge geometry via a constant import. Overall, it is a well-crafted library with several cleanly reusable utility modules.
The LLM identified 3 files worth highlighting for reuse:
Provides two standalone, reusable formatting functions: `humanFriendlyNumber` (converts large numbers to K/M/G/T suffixes) and `formatNumber` (adds comma separators). Zero internal dependencies, can be extracted into any JavaScript project for number display.
Contains `isHexColor` for validation, `cutHex` for stripping '#' prefixes, and `getColor` which interpolates between color stops or selects from custom sector ranges. No internal imports; the color interpolation logic is non-trivial and reusable in any visualization or charting library.
Implements a requestAnimationFrame-based animation engine with configurable duration, easing (linear, ease-in, ease-out, ease-in-out, bounce, elastic, backIn/Out), and callback hooks (onUpdate, onComplete, onCounterUpdate). Fully self-contained with no dependencies on the rest of JustGage; could be extracted as a generic animation utility for DOM or SVG transitions.