Files
temetro/frontend/components/charts/y-axis-ticks.ts
T
Khalid Abdi 321a6298a4 frontend: pharmacy inventory, lab add-result & analysis charts
- Pharmacy: the sidebar entry now expands into Pharmacy + a new Inventory page
  (searchable medication stock with derived in-stock/low/out availability,
  backed by /api/inventory). Fix the dispensing-queue "Expiring" badge so it
  only flags courses ending within the next 7 days, not ones already elapsed.
- Lab "Add analysis result": the patient picker no longer lists patients until
  you type and supports arrow-key + Enter selection; the test field offers a
  catalog of common analyses with an Advanced option (custom analysis + ref
  range); submitted results now show immediately in a Recent results feed.
- Analysis: add a Live panel (real-time line chart) and replace the flat trend
  sparklines with bklit-ui area + bar charts (installed from the @bklit shadcn
  registry; chart CSS variables wired into the theme for light and dark).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 19:22:07 +03:00

26 lines
819 B
TypeScript

export const Y_AXIS_DEFAULT_TICK_COUNT = 5;
/** Minimum valid `numTicks` for `scale.ticks()` — values ≤ 0 yield no ticks. */
export const Y_AXIS_MIN_TICK_COUNT = 1;
/**
* Upper bound for the tick count hint. D3 may return more "nice" ticks above ~10;
* keeping the hint in a modest range avoids overcrowded axes.
*/
export const Y_AXIS_MAX_TICK_COUNT = 10;
/** Clamps a user `numTicks` value to a valid d3 tick-count hint. */
export function resolveYAxisTickCount(numTicks?: number): number {
if (numTicks == null || !Number.isFinite(numTicks)) {
return Y_AXIS_DEFAULT_TICK_COUNT;
}
const rounded = Math.round(numTicks);
if (rounded < Y_AXIS_MIN_TICK_COUNT) {
return Y_AXIS_MIN_TICK_COUNT;
}
if (rounded > Y_AXIS_MAX_TICK_COUNT) {
return Y_AXIS_MAX_TICK_COUNT;
}
return rounded;
}