Changes before trying iced
This commit is contained in:
parent
a4c3b37019
commit
726dfefadf
|
@ -5,6 +5,7 @@
|
||||||
!/Cargo.lock
|
!/Cargo.lock
|
||||||
!/Cargo.toml
|
!/Cargo.toml
|
||||||
!/config.toml
|
!/config.toml
|
||||||
|
!/rust-toolchain.toml
|
||||||
|
|
||||||
!/Shots/
|
!/Shots/
|
||||||
!/src/
|
!/src/
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
11
Cargo.toml
11
Cargo.toml
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
authors = ["David Holland <info@dustvoice.de>"]
|
authors = ["David Holland <info@dustvoice.de>"]
|
||||||
name = "beanconqueror"
|
name = "rustybeans"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
@ -8,13 +8,12 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
calamine = "0.18.0"
|
calamine = "0.18.0"
|
||||||
chrono = "0.4.22"
|
chrono = { version = "0.4.22", features = ["wasmbind"] }
|
||||||
colourado = "0.2.0"
|
console_error_panic_hook = "0.1.7"
|
||||||
|
dioxus = { version = "0.2.4", features = ["desktop"] }
|
||||||
fast-float = "0.2.0"
|
fast-float = "0.2.0"
|
||||||
palette = "0.6.1"
|
palette = "0.6.1"
|
||||||
plotly = { version = "=0.8.1", features = ["wasm"] }
|
plotly = { version = "0.8.1", features = ["wasm"] }
|
||||||
serde = "1.0.144"
|
serde = "1.0.144"
|
||||||
serde_derive = "1.0.144"
|
serde_derive = "1.0.144"
|
||||||
toml = "0.5.9"
|
toml = "0.5.9"
|
||||||
yew = "0.19.0"
|
|
||||||
yew-hooks = "0.1.56"
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
shot_dir = "Shots"
|
shot_dir = "shots"
|
||||||
output_dir = "images"
|
output_dir = "images"
|
||||||
|
|
||||||
width = 1600
|
width = 1600
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
[toolchain]
|
||||||
|
channel = "nightly"
|
||||||
|
components = [ "rustfmt", "rust-analyzer" ]
|
70
src/main.rs
70
src/main.rs
|
@ -1,18 +1,20 @@
|
||||||
|
extern crate console_error_panic_hook;
|
||||||
|
use std::panic;
|
||||||
|
|
||||||
use calamine::{open_workbook, Reader, Xlsx};
|
use calamine::{open_workbook, Reader, Xlsx};
|
||||||
use chrono::{Duration, NaiveTime};
|
use chrono::{Duration, NaiveTime};
|
||||||
use colourado::{ColorPalette, PaletteType};
|
|
||||||
use serde_derive::Deserialize;
|
use serde_derive::Deserialize;
|
||||||
|
|
||||||
use plotly::{
|
use plotly::{
|
||||||
|
common::{Mode, Title},
|
||||||
Layout, Plot, Scatter,
|
Layout, Plot, Scatter,
|
||||||
common::{Mode, Title}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use yew::prelude::*;
|
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct Shot {
|
struct Shot {
|
||||||
filename: String,
|
filename: String,
|
||||||
|
@ -174,52 +176,28 @@ pub fn generate_plots() -> Vec<(String, Plot)> {
|
||||||
let layout = Layout::new().title(Title::new(&chart.1.title));
|
let layout = Layout::new().title(Title::new(&chart.1.title));
|
||||||
plot.set_layout(layout);
|
plot.set_layout(layout);
|
||||||
|
|
||||||
result.push((chart.1.title, plot))
|
plot.use_local_plotly();
|
||||||
// plot.use_local_plotly();
|
plot.write_html(filename);
|
||||||
// plot.write_html(filename);
|
result.push((chart.1.title, plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
#[function_component(App)]
|
|
||||||
pub fn plot_component() -> Html {
|
|
||||||
let plot_compounds: Vec<(String, Plot)> = generate_plots();
|
|
||||||
let (names, plots): (Vec<_>, Vec<_>) = plot_compounds.into_iter().unzip();
|
|
||||||
let ids = names.clone();
|
|
||||||
|
|
||||||
let p = yew_hooks::use_async::<_, _, ()>({
|
|
||||||
async move {
|
|
||||||
for i in names.iter().zip(plots.iter()) {
|
|
||||||
let (name, plot) = i;
|
|
||||||
plotly::bindings::new_plot(&name, &plot).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
use_effect_with_deps(
|
|
||||||
move |_| {
|
|
||||||
p.run();
|
|
||||||
|| ()
|
|
||||||
},
|
|
||||||
(),
|
|
||||||
);
|
|
||||||
|
|
||||||
html! {
|
|
||||||
<div id="plot-div">
|
|
||||||
{
|
|
||||||
ids.into_iter().map(|name| {
|
|
||||||
html!{
|
|
||||||
<div id={name}></div>
|
|
||||||
}
|
|
||||||
}).collect::<Html>()
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
yew::start_app::<App>();
|
panic::set_hook(Box::new(console_error_panic_hook::hook));
|
||||||
|
dioxus::desktop::launch(app);
|
||||||
|
generate_plots();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn app(cx: Scope) -> Element {
|
||||||
|
cx.render(rsx! (
|
||||||
|
section { class: "rustybeans",
|
||||||
|
style { [include_str!("style.css")] }
|
||||||
|
div { class: "container row",
|
||||||
|
div { "Hello, world!" }
|
||||||
|
button { "Click me!" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
:root {
|
||||||
|
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 24px;
|
||||||
|
font-weight: 400;
|
||||||
|
|
||||||
|
color: #0f0f0f;
|
||||||
|
background-color: #f6f6f6;
|
||||||
|
|
||||||
|
font-synthesis: none;
|
||||||
|
text-rendering: optimizeLegibility;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
-webkit-text-size-adjust: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
margin: 0;
|
||||||
|
/* padding-top: 10vh; */
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
font-weight: 500;
|
||||||
|
color: #646cff;
|
||||||
|
text-decoration: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: #535bf2;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
input,
|
||||||
|
button {
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
padding: 0.6em 1.2em;
|
||||||
|
font-size: 1em;
|
||||||
|
font-weight: 500;
|
||||||
|
font-family: inherit;
|
||||||
|
color: #0f0f0f;
|
||||||
|
background-color: #ffffff;
|
||||||
|
transition: border-color 0.25s;
|
||||||
|
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
border-color: #396cd8;
|
||||||
|
}
|
||||||
|
|
||||||
|
input,
|
||||||
|
button {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
color: #f6f6f6;
|
||||||
|
background-color: #2f2f2f;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: #24c8db;
|
||||||
|
}
|
||||||
|
|
||||||
|
input,
|
||||||
|
button {
|
||||||
|
color: #ffffff;
|
||||||
|
background-color: #0f0f0f98;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue