4 releases (2 breaking)

0.3.0 Feb 16, 2024
0.2.0 Dec 12, 2022
0.1.1 Nov 5, 2022
0.1.0 Nov 3, 2022

#245 in Visualization

Download history 20/week @ 2024-11-13 35/week @ 2024-11-20 65/week @ 2024-11-27 34/week @ 2024-12-04 59/week @ 2024-12-11 50/week @ 2024-12-18 37/week @ 2025-01-08 25/week @ 2025-01-15 64/week @ 2025-01-22 54/week @ 2025-01-29 51/week @ 2025-02-05 114/week @ 2025-02-12 34/week @ 2025-02-19 13/week @ 2025-02-26

234 downloads per month

MIT license

14KB

yew-plotly

GitHub open issues

Example

use yew::prelude::*;
use yew_plotly::plotly::common::Mode;
use yew_plotly::plotly::{Plot, Scatter};
use yew_plotly::Plotly;

#[function_component]
fn App() -> Html {
    let mut plot = Plot::new();
    let x_values = vec![1, 2, 3];
    let y_values = vec![1, 3, 2];

    let trace = Scatter::new(x_values, y_values)
        .mode(Mode::LinesMarkersText)
        .name("Scatter");
        
    plot.add_trace(trace);

    html! { <Plotly plot={plot}/> }
}

fn main() {
    yew::Renderer::<App>::new().render();
}

Setup

Load plotly.js in index.html

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>Yew App</title>
    <script src="https://cdn.plot.ly/plotly-2.16.1.min.js"></script>
</head>

</html>

Install yew-plotly

cargo add yew-plotly

Dependencies

~21–30MB
~343K SLoC