Expand description
Platform-independent input events and the interaction state machine: panning with kinetic scrolling, wheel and pinch zoom, axis dragging, keyboard navigation and the crosshair.
Bindings (winit, DOM, native) translate their events into InputEvents
in CSS pixels; the chart multiplies by the device pixel ratio. Input never
allocates: the state machine keeps a fixed-size velocity history.
Clock: kinetic scrolling compares time_ms of pointer events with the
now_ms passed to Chart::build_frame, so both must come from the same
clock (e.g. performance.now() or Instant since start).
With several panes, price-axis drags, wheel zoom over the axis and vertical panning act on the pane under the pointer; dragging a separator resizes the two panes next to it.
Drawings: with a tool armed, clicks create a drawing (click per anchor, or press-drag-release for the first two); otherwise a press on a drawing selects it and drags it (or the handle under the pointer) unless it is locked. Escape cancels, Delete removes the selection, Ctrl/⌘+Z undoes, Ctrl/⌘+Shift+Z and Ctrl/⌘+Y redo.
Structs§
- Input
Result - Result of
Chart::handle_input. - Modifiers
- Keyboard modifiers. Plain flags mirror the DOM/winit events they come from.
- Velocity
Tracker - Release velocity of a drag along one axis, from a fixed number of recent
pointer samples (no allocation). Used by the chart’s kinetic panning and
by
ferrochart-plot.
Enums§
- Button
- Mouse button.
- Crosshair
Mode - Crosshair behavior.
- Cursor
Icon - Mouse cursor the host should show.
- Gesture
Phase - Phase of a continuous gesture.
- Input
Event - A platform-independent input event. Positions are in CSS pixels relative to the chart’s top-left corner.
- Key
- Keys the chart reacts to.
- Wheel
Delta - Scroll amount of a wheel event.
Constants§
- KINETIC_
MIN_ SPEED - Kinetic scrolling starts above / stops below this speed (physical px per ms).
- KINETIC_
TAU_ MS - Kinetic velocity decay time constant: after a release at speed
v, the speed isv · exp(-t / KINETIC_TAU_MS).