UNPKG

react-sparklines-ts

Version:

Beautiful and expressive Sparklines component for React (continued)

11 lines (10 loc) 567 B
import { jsx as _jsx } from "react/jsx-runtime"; import { mean } from "./dataProcessing/mean"; import { stdev } from "./dataProcessing/stdev"; export default function SparklinesNormalBand(props) { const { points, margin, style } = props; const ypoints = points.map((p) => p.y); const dataMean = mean(ypoints); const dataStdev = stdev(ypoints); return (_jsx("rect", { x: points[0].x, y: dataMean - dataStdev + margin, width: points[points.length - 1].x - points[0].x, height: dataStdev * 2, style: style ?? { fill: "red", fillOpacity: 0.1 } })); }