4 个版本 (2 个重大更新)

0.3.0 2024年2月16日
0.2.0 2022年12月12日
0.1.1 2022年11月5日
0.1.0 2022年11月3日

#124 in 可视化

Download history 20/week @ 2024-04-28 1/week @ 2024-05-05 6/week @ 2024-05-19 10/week @ 2024-05-26 11/week @ 2024-06-02 6/week @ 2024-06-09 1/week @ 2024-06-16 3/week @ 2024-06-23 69/week @ 2024-06-30 32/week @ 2024-07-07 18/week @ 2024-07-14 46/week @ 2024-07-21

每月下载量:165

MIT 许可证

14KB

yew-plotly

GitHub open issues

示例

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();
}

设置

index.html 中加载 plotly.js

<!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>

安装 yew-plotly

cargo add yew-plotly

依赖

~22MB
~328K SLoC