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

#199 in Visualization

Download history 47/week @ 2024-07-20 28/week @ 2024-07-27 39/week @ 2024-08-03 70/week @ 2024-08-10 54/week @ 2024-08-17 66/week @ 2024-08-24 69/week @ 2024-08-31 38/week @ 2024-09-07 115/week @ 2024-09-14 68/week @ 2024-09-21 33/week @ 2024-09-28 35/week @ 2024-10-05 96/week @ 2024-10-12 22/week @ 2024-10-19 42/week @ 2024-10-26 44/week @ 2024-11-02

210 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

~18–27MB
~340K SLoC