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

#228 in Visualization

Download history 60/week @ 2024-09-03 51/week @ 2024-09-10 106/week @ 2024-09-17 75/week @ 2024-09-24 13/week @ 2024-10-01 67/week @ 2024-10-08 68/week @ 2024-10-15 19/week @ 2024-10-22 46/week @ 2024-10-29 37/week @ 2024-11-05 18/week @ 2024-11-12 29/week @ 2024-11-19 58/week @ 2024-11-26 46/week @ 2024-12-03 49/week @ 2024-12-10 66/week @ 2024-12-17

232 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
~344K SLoC