Skip to content

Legend animation ​

Resting the pointer on a legend row animates its series and brings that series to the front of the chart. The legend itself never reorders. The effect is off for every other row, starts at the first hover frame, and respects reduced motion. The same effects apply to every Plot3D series: lines, bars, and surface cells blend, pulse, and glow.

Live demo
Pick one of the 13 effects, then hover a legend row to see it on lines, areas, steps, markers, and bars.Open in a tab ↗
rust
use egui_workbench::components::plot::{
    AnimationEasing, LegendAnimation, LegendHoverConfig, Plot,
};

Plot::new("signal")
    .legend_hover(LegendHoverConfig {
        enabled: true,
        animation: LegendAnimation::DashMarch,
        easing: AnimationEasing::Sine,
        period: 1.4,
        highlight: None, // white/black blink; theme warning in other effects
    })
    .series(Series::line("signal", &data))
    .show(ui, &mut icons, &mut state);

Every field also has a builder shorthand:

rust
Plot::new("signal")
    .legend_animation(LegendAnimation::Blink)
    .series(Series::line("signal", &data));

Draw order ​

The hovered series draws last, above every other series: a line over bars, a pie slice over its neighbors, a radar polygon over the others. The legend rows keep their original order, so hiding and showing series still targets the same row.

The settings ​

FieldDefaultMeaning
enabledtruePlay the effect while a legend row is hovered
animationBlinkOne of the animations below
easingLinearHow the cycle is shaped
period1.2 sOne full cycle; clamped to 0.2–10 s
highlightNoneExtreme/second color for the effects; Blink uses white on dark themes and black on light themes when None

LegendHoverConfig lives in PlotConfig::legend_hover, so the starter's chart settings dialog edits it in its Motion section. PlotConfig::sanitize clamps the period.

The animations ​

AnimationWhat moves
BlinkOn dark themes, white ↔ series color; on light themes, black ↔ series color
FadePulses the opacity
ThrobPulses the stroke width
DashMarchScrolls the dashes along the line (marching ants)
DashToggleGrows the dashes in and out of a solid line
GlowDraws a soft halo around the line
SweepA bright segment travels along the line
WiggleMoves the line perpendicular to its local direction
RevealDraws the line again and again from its first point
MarkerBounceBounces markers and radar vertices
MarkerPulseGrows and shrinks markers
TwinklePuts small sparkles along the line
WaveWashes the color from left to right

The line effects apply to lines, areas, steps, and reference lines; markers apply to scatter, line vertices, and radar points. Pie slices lift out of the ring, radar polygons breathe, and gauges pulse their value arc. Heatmaps tint their hovered cells. Waterfall and candle bars blend toward the highlight color.

Easing ​

AnimationEasing shapes one cycle:

EasingShape
LinearConstant speed (default)
EaseInSlow start
EaseOutSlow end
EaseInOutSlow at both ends
StepHolds, then jumps at the midpoint
SineSmooth back-and-forth with no abrupt turn

Reduced motion ​

theme::motion_enabled(ctx) gates every effect. When reduced motion is on, legend rows still shade on hover but no animation runs; the plot does not request repaints.

Direction arrow ​

The direction arrow marks the newest sample of line-like series. It uses the last points finite samples (5 by default) so a noisy stream still shows where the buffer is growing.

rust
Plot::new("telemetry")
    .x_window(30.0)
    .direction_arrow(true)
    .direction_points(5)
    .series(Series::line("sensor", &samples))
    .show(ui, &mut icons, &mut state);

DirectionArrowConfig lives in PlotConfig::direction:

FieldDefaultMeaning
enabledfalseDraw the arrow beside the newest point
points5Trailing samples used to measure direction (2–64)
length26.0 ptShaft length
width2.0 ptShaft width
head8.0 ptHead length
colorNoneThe series color when None

Per-series overrides win over the global switch:

rust
let mut config = PlotConfig::default();
config.direction.enabled = true;
config.series_style_mut("noise").direction_arrow = Some(false);

The arrow applies to line, area, step, and candles; reference lines, bars, scatter, heatmaps, waterfalls, and the non-cartesian families never draw it. It is part of the scene, so exports include it.

Released under MIT OR Apache-2.0. Icons: Lucide (ISC) and Material Icon Theme (MIT).