Skip to main content

bar_animation_origin

Function bar_animation_origin 

Source
pub fn bar_animation_origin(
    x: f64,
    y: f64,
    width: f64,
    height: f64,
    is_horizontal: bool,
    is_negative: bool,
) -> (f64, f64)
Expand description

Compute the CSS transform-origin anchor for a bar’s entrance animation.

The anchor is the bar’s value-baseline edge midpoint, in absolute SVG coordinates, so a scaleX/scaleY keyframe grows the bar from the axis outward toward its value end:

  • vertical, positive value → bottom-center (grows up)
  • vertical, negative value → top-center (grows down)
  • horizontal, positive value → left-center (grows right)
  • horizontal, negative value → right-center (grows left)

Computing the anchor at emission time is essential: the renderer cannot recover orientation/sign from <rect>/<path> geometry alone (the historical width > height heuristic guessed wrong for square bars and for any negative bar). See chartml-leptos/src/element.rs, where the heuristic was deleted in favor of consuming this value.