add graph example

This commit is contained in:
Christoph J. Scherr 2025-01-09 02:33:16 +01:00
commit edf1e381fd
4 changed files with 342 additions and 73 deletions

253
Cargo.lock generated
View File

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4
[[package]]
name = "ab_glyph"
@ -970,6 +970,12 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "color_quant"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]]
name = "colorchoice"
version = "1.0.1"
@ -1102,6 +1108,18 @@ dependencies = [
"libc",
]
[[package]]
name = "core-text"
version = "20.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9d2790b5c08465d49f8dc05c8bcae9fea467855947db39b0f8145c091aaced5"
dependencies = [
"core-foundation",
"core-graphics",
"foreign-types",
"libc",
]
[[package]]
name = "cpufeatures"
version = "0.2.12"
@ -1459,6 +1477,27 @@ dependencies = [
"subtle",
]
[[package]]
name = "dirs"
version = "5.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs-sys"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
dependencies = [
"libc",
"option-ext",
"redox_users",
"windows-sys 0.48.0",
]
[[package]]
name = "dispatch"
version = "0.2.0"
@ -1526,6 +1565,18 @@ dependencies = [
"syn 2.0.68",
]
[[package]]
name = "dwrote"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70182709525a3632b2ba96b6569225467b18ecb4a77f46d255f713a6bebf05fd"
dependencies = [
"lazy_static",
"libc",
"winapi",
"wio",
]
[[package]]
name = "echargs"
version = "0.1.0"
@ -1556,7 +1607,7 @@ dependencies = [
"glow",
"glutin",
"glutin-winit",
"image",
"image 0.25.2",
"js-sys",
"log",
"objc2 0.5.2",
@ -1825,6 +1876,12 @@ dependencies = [
"miniz_oxide",
]
[[package]]
name = "float-ord"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ce81f49ae8a0482e4c55ea62ebbd7e5a686af544c00b9d090bba3ff9be97b3d"
[[package]]
name = "fluent"
version = "0.16.1"
@ -1883,6 +1940,31 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "font-kit"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b64b34f4efd515f905952d91bc185039863705592c0c53ae6d979805dd154520"
dependencies = [
"bitflags 2.6.0",
"byteorder",
"core-foundation",
"core-graphics",
"core-text",
"dirs",
"dwrote",
"float-ord",
"freetype-sys",
"lazy_static",
"libc",
"log",
"pathfinder_geometry",
"pathfinder_simd",
"walkdir",
"winapi",
"yeslogic-fontconfig-sys",
]
[[package]]
name = "foreign-types"
version = "0.5.0"
@ -1919,6 +2001,17 @@ dependencies = [
"percent-encoding",
]
[[package]]
name = "freetype-sys"
version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e7edc5b9669349acfda99533e9e0bcf26a51862ab43b08ee7745c55d28eb134"
dependencies = [
"cc",
"libc",
"pkg-config",
]
[[package]]
name = "future_stream"
version = "0.1.0"
@ -2122,6 +2215,16 @@ dependencies = [
"typed-builder",
]
[[package]]
name = "gif"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80792593675e051cf94a4b111980da2ba60d4a83e43e0048c5693baab3977045"
dependencies = [
"color_quant",
"weezl",
]
[[package]]
name = "gimli"
version = "0.29.0"
@ -2326,6 +2429,13 @@ dependencies = [
"bitflags 2.6.0",
]
[[package]]
name = "graph"
version = "0.1.0"
dependencies = [
"plotters",
]
[[package]]
name = "gtk-sys"
version = "0.18.0"
@ -2621,6 +2731,20 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "image"
version = "0.24.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d"
dependencies = [
"bytemuck",
"byteorder",
"color_quant",
"jpeg-decoder",
"num-traits",
"png",
]
[[package]]
name = "image"
version = "0.25.2"
@ -2783,6 +2907,12 @@ dependencies = [
"libc",
]
[[package]]
name = "jpeg-decoder"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0"
[[package]]
name = "js-sys"
version = "0.3.69"
@ -2922,6 +3052,16 @@ dependencies = [
"redox_syscall 0.4.1",
]
[[package]]
name = "libredox"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
dependencies = [
"bitflags 2.6.0",
"libc",
]
[[package]]
name = "libsqlite3-sys"
version = "0.28.0"
@ -3460,13 +3600,19 @@ version = "11.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
[[package]]
name = "option-ext"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
[[package]]
name = "orbclient"
version = "0.3.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52f0d54bde9774d3a51dcf281a5def240c71996bc6ca05d2c847ec8b2b216166"
dependencies = [
"libredox",
"libredox 0.0.2",
]
[[package]]
@ -3491,7 +3637,7 @@ version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "490d3a563d3122bf7c911a59b0add9389e5ec0f5f0c3ac6b91ff235a0e6a7f90"
dependencies = [
"ttf-parser",
"ttf-parser 0.24.1",
]
[[package]]
@ -3556,6 +3702,25 @@ version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "pathfinder_geometry"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b7e7b4ea703700ce73ebf128e1450eb69c3a8329199ffbfb9b2a0418e5ad3"
dependencies = [
"log",
"pathfinder_simd",
]
[[package]]
name = "pathfinder_simd"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cf07ef4804cfa9aea3b04a7bbdd5a40031dbb6b4f2cbaf2b011666c80c5b4f2"
dependencies = [
"rustc_version",
]
[[package]]
name = "peg"
version = "0.6.3"
@ -3693,13 +3858,20 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
[[package]]
name = "plotters"
version = "0.3.6"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3"
checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747"
dependencies = [
"chrono",
"font-kit",
"image 0.24.9",
"lazy_static",
"num-traits",
"pathfinder_geometry",
"plotters-backend",
"plotters-bitmap",
"plotters-svg",
"ttf-parser 0.20.0",
"wasm-bindgen",
"web-sys",
]
@ -3710,6 +3882,17 @@ version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7"
[[package]]
name = "plotters-bitmap"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72ce181e3f6bf82d6c1dc569103ca7b1bd964c60ba03d7e6cdfbb3e3eb7f7405"
dependencies = [
"gif",
"image 0.24.9",
"plotters-backend",
]
[[package]]
name = "plotters-svg"
version = "0.3.6"
@ -3937,6 +4120,17 @@ dependencies = [
"bitflags 2.6.0",
]
[[package]]
name = "redox_users"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
dependencies = [
"getrandom",
"libredox 0.1.3",
"thiserror",
]
[[package]]
name = "regex"
version = "1.10.5"
@ -4073,6 +4267,15 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustc_version"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
dependencies = [
"semver",
]
[[package]]
name = "rustix"
version = "0.37.27"
@ -4173,6 +4376,12 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a"
[[package]]
name = "semver"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba"
[[package]]
name = "serde"
version = "1.0.203"
@ -4977,6 +5186,12 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "ttf-parser"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4"
[[package]]
name = "ttf-parser"
version = "0.24.1"
@ -5477,6 +5692,12 @@ dependencies = [
"web-sys",
]
[[package]]
name = "weezl"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
[[package]]
name = "wgpu"
version = "0.20.1"
@ -5942,6 +6163,15 @@ dependencies = [
"memchr",
]
[[package]]
name = "wio"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5"
dependencies = [
"winapi",
]
[[package]]
name = "x11-dl"
version = "2.21.0"
@ -6015,6 +6245,17 @@ version = "0.8.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "539a77ee7c0de333dcc6da69b177380a0b81e0dacfa4f7344c465a36871ee601"
[[package]]
name = "yeslogic-fontconfig-sys"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "503a066b4c037c440169d995b869046827dbc71263f6e8f3be6d77d4f3229dbd"
dependencies = [
"dlib",
"once_cell",
"pkg-config",
]
[[package]]
name = "zbus"
version = "3.15.2"

View File

@ -1,80 +1,83 @@
[workspace]
members = [
".",
"members/criterion-demo",
"members/cucumber-demo",
"members/panic-calm",
"members/pest-demo",
"members/revsqrt",
"members/serde-json-demo",
"members/shortc",
"members/socker",
"members/tokryon",
"members/tokio-send-sync",
"members/matchmatchmatch",
"members/future_stream",
"members/mpsc",
"members/mpsc-full",
"members/echargs",
"members/claptest",
"members/rest",
"members/rest-queued",
"members/fluent-demo",
"members/onlytoken",
"members/sqlite-demo",
"members/diesel-demo",
"members/ptlog",
"members/hello-world",
"members/statusline",
"members/clap-repl-demo",
"members/arithmetics",
"members/egui-demo",
"members/rfd-demo",
"members/iter-prod", "members/tpdemo",
".",
"members/criterion-demo",
"members/cucumber-demo",
"members/panic-calm",
"members/pest-demo",
"members/revsqrt",
"members/serde-json-demo",
"members/shortc",
"members/socker",
"members/tokryon",
"members/tokio-send-sync",
"members/matchmatchmatch",
"members/future_stream",
"members/mpsc",
"members/mpsc-full",
"members/echargs",
"members/claptest",
"members/rest",
"members/rest-queued",
"members/fluent-demo",
"members/onlytoken",
"members/sqlite-demo",
"members/diesel-demo",
"members/ptlog",
"members/hello-world",
"members/statusline",
"members/clap-repl-demo",
"members/arithmetics",
"members/egui-demo",
"members/rfd-demo",
"members/iter-prod",
"members/tpdemo",
"members/graph",
]
default-members = [
".",
"members/iter-prod",
"members/rfd-demo",
"members/egui-demo",
"members/arithmetics",
"members/statusline",
"members/ptlog",
"members/diesel-demo",
"members/onlytoken",
"members/fluent-demo",
"members/echargs",
"members/revsqrt",
"members/claptest",
"members/mpsc",
"members/mpsc-full",
"members/criterion-demo",
"members/shortc",
"members/pest-demo",
"members/serde-json-demo",
"members/cucumber-demo",
"members/panic-calm",
"members/socker",
"members/tokryon",
"members/tokio-send-sync",
"members/matchmatchmatch",
"members/future_stream",
"members/rest",
"members/rest-queued",
"members/sqlite-demo",
".",
"members/iter-prod",
"members/rfd-demo",
"members/egui-demo",
"members/arithmetics",
"members/statusline",
"members/ptlog",
"members/diesel-demo",
"members/onlytoken",
"members/fluent-demo",
"members/echargs",
"members/revsqrt",
"members/claptest",
"members/mpsc",
"members/mpsc-full",
"members/criterion-demo",
"members/shortc",
"members/pest-demo",
"members/serde-json-demo",
"members/cucumber-demo",
"members/panic-calm",
"members/socker",
"members/tokryon",
"members/tokio-send-sync",
"members/matchmatchmatch",
"members/future_stream",
"members/rest",
"members/rest-queued",
"members/sqlite-demo",
"members/graph",
]
[workspace.dependencies]
anyhow = "1.0.79"
thiserror = "1.0.56"
tokio = { version = "1.35.1", features = [
"net",
"rt",
"macros",
"rt-multi-thread",
"io-util",
"time",
"sync",
"net",
"rt",
"macros",
"rt-multi-thread",
"io-util",
"time",
"sync",
] }
futures = { version = "0.3.30", features = ["executor"] }
serde = { version = "1.0.171", features = ["derive"] }

7
members/graph/Cargo.toml Normal file
View File

@ -0,0 +1,7 @@
[package]
name = "graph"
version = "0.1.0"
edition = "2021"
[dependencies]
plotters = "0.3.7"

18
members/graph/src/main.rs Normal file
View File

@ -0,0 +1,18 @@
use plotters::prelude::*;
fn main() {
let root_area = BitMapBackend::new("images/2.5.png", (600, 400)).into_drawing_area();
root_area.fill(&WHITE).unwrap();
let mut ctx = ChartBuilder::on(&root_area)
.set_label_area_size(LabelAreaPosition::Left, 40)
.set_label_area_size(LabelAreaPosition::Bottom, 40)
.caption("Line Plot Demo", ("sans-serif", 40))
.build_cartesian_2d(-10..10, 0..100)
.unwrap();
ctx.configure_mesh().draw().unwrap();
ctx.draw_series(LineSeries::new((-10..=10).map(|x| (x, x * x)), &GREEN))
.unwrap();
}