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 可视化
每月下载量:165
14KB
yew-plotly
示例
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