Skip to main content

orbital_charts/shared/defs/
mod.rs

1//! SVG gradient and pattern definition helpers.
2
3use leptos::prelude::*;
4
5/// Register a linear gradient in chart SVG defs.
6#[component]
7pub fn ChartLinearGradient(
8    /// Unique gradient id referenced by series fill.
9    #[prop(into)]
10    id: String,
11    /// Gradient start color.
12    #[prop(into)]
13    from: String,
14    /// Gradient end color.
15    #[prop(into)]
16    to: String,
17) -> impl IntoView {
18    view! {
19        <linearGradient id=id x1="0%" y1="0%" x2="0%" y2="100%">
20            <stop offset="0%" stop-color=from />
21            <stop offset="100%" stop-color=to />
22        </linearGradient>
23    }
24}
25
26/// SVG defs container for gradients and patterns.
27#[component]
28pub fn ChartDefs(children: Children) -> impl IntoView {
29    view! {
30        <defs>{children()}</defs>
31    }
32}