import React from 'react'; import type { Goal, Observation } from 'fhir/r4'; import { buildGoalChart, CHART_HEIGHT, CHART_WIDTH } from '../../../../utils/goalChart'; import './GoalChart.css'; interface Props { goal: Goal; observations: Observation[]; } /** The goal's readings as a line, the target dashed across it. Renders nothing below two readings. */ export const GoalChart: React.FC = ({ goal, observations }) => { const chart = buildGoalChart(goal, observations); if (!chart) return null; const latest = chart.points[chart.points.length - 1]; return (
{chart.target && ( <> {chart.target.label} )} {chart.ticks.map((tick) => ( {tick.label} ))} `${point.x},${point.y}`).join(' ')} /> {chart.points.map((point, index) => ( {point.label} ))} {latest.label} {chart.months.map((month) => ( {month.label} ))}
); }; export default GoalChart;