Drawing tools

Alerts

Get notified when new data crosses a line the user has drawn.

onCross(drawing, direction, bar) fires when new data (an appended or updated last point) crosses a horizontal line, horizontal ray, cross line or trend line. direction is "up" when the value crossed from below. Users drag the lines to change the thresholds; combine it with realtime data for monitoring dashboards:

const drawings = useDrawings({
  onCross: (drawing, direction) => notify(`${drawing.style.text ?? "Threshold"} crossed ${direction}`),
});

<Drawings controller={drawings} source={(d) => d.temp} />;

The value checked is close, value or y by default; pick another field with source. Custom tools take part by implementing crossValue. Store your own alert ids in drawing.meta.