yew-plotly

Crates.ioyew-plotly
lib.rsyew-plotly
version0.3.0
sourcesrc
created_at2022-11-03 19:41:56.308697
updated_at2024-02-16 20:17:46.875669
descriptionyew wrapper for plotly.js
homepage
repositoryhttps://github.com/butzist/yew-plotly.git
max_upload_size
id704587
size49,288
Adam M. Szalkowski (butzist)

documentation

https://docs.rs/yew-plotly

README

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

Links

Commit count: 9

cargo fmt