Instruction file imported from elimuinformatics/charts-on-fhir (
.github/instructions/libs.instructions.md). Copyright stays with the author.
ngx-charts-on-fhir Library Instructions
This directory contains the core Angular component library.
Library Structure
Core Components
fhir-chart/: Main chart component using Chart.jsfhir-chart-layout/: Layout wrapper for chartsfhir-chart-legend/: Custom legend for FHIR datadata-layer/: Core data layer abstractiondata-layer-selector/: Multi-select for data layerssummary-range-selector/: Date range pickerpatient-browser/: Patient selection component
Services
fhir-data/: FHIR resource fetching and processingfhir-mappers/: Transform FHIR Observations to chart datacolor-picker/: Color palette management
Development Patterns
Component Design
- Use Angular standalone components with
importsarray - Implement OnInit, OnDestroy lifecycle hooks
- Always destroy Chart.js instances in ngOnDestroy
FHIR Integration
- Use
@types/fhirfor TypeScript types - Handle missing/malformed FHIR data gracefully
- Validate FHIR resource structure before processing
Chart.js Usage
- Register required plugins: annotation, zoom, scaleStackDivider
- Use Chart.js plugins for custom interactions
- Handle chart resize for responsive layouts
Adding New Components
- Create component in appropriate subdirectory
- Use standalone component pattern with imports array
- Add FHIR data mapper if needed
- Write unit tests
- Export from
index.ts