Move visualization logic into separate module
Dependencies
- [2]
OPTMCUTBUse timings `duration` to set size of rendered node - [3]
475UXTLYUse multiple force-directed layout algorithms to improve graph readability - [4]
B2L26LOAStore index of dependency nodes - [5]
JVYWRCPTAdd basic chart visualisation - [6]
Q3Z6XMP5Migrate dependency tree to `petgraph::Graph` - [7]
UXJFRBBLMove graph functionality into `graph` module - [8]
UQJO24KBUse `forceatlas2` to construct graph layout - [9]
7CVIL7UJCreate simple metadata parser - [10]
ZPFD3275Switch from `cargo_metadata`+`petgraph` to `guppy` - [11]
LOR3KOXGParse JSON output from `cargo build --timings`
Change contents
- file addition: visualize[4.15]
- file addition: mod.rs[0.21]
use crate::timings;use charming::series::{GraphLayoutForce, Series};use charming::{series, Chart, HtmlRenderer};use guppy::graph::PackageGraph;mod graph;#[derive(Clone, Copy, Debug)]pub enum Style {Graph,}pub fn for_style(style: Style, graph: &PackageGraph, timings: &timings::Output) {let series: Series = match style {Style::Graph => {series::Graph::new()// Use charming's force-directed layout, in combination with// `graph::layout()` using `forceatlas2`, as they seem to get the best results// when used together..layout(charming::series::GraphLayout::Force).force(GraphLayoutForce::new().layout_animation(false)).roam(true).data(graph::data(graph, timings)).into()}};let chart = Chart::new().series(series);let mut renderer = HtmlRenderer::new("Cargo dependencies", 1000, 800);renderer.save(&chart, "/tmp/chart.html").unwrap();} - file move: graph.rs → graph.rs
- edit in src/main.rs at line 1
use charming::{series::GraphLayoutForce, Chart, HtmlRenderer}; - edit in src/main.rs at line 3
mod graph; - edit in src/main.rs at line 4
mod visualize; - replacement in src/main.rs at line 14[4.897]→[4.1299:1336](∅→∅),[4.1336]→[4.1275:1314](∅→∅),[4.1314]→[4.1357:1397](∅→∅),[4.1357]→[4.1357:1397](∅→∅),[4.1397]→[3.64:389](∅→∅),[3.389]→[4.1436:1460](∅→∅),[4.1372]→[4.1436:1460](∅→∅),[4.1436]→[4.1436:1460](∅→∅),[4.1460]→[2.182:240](∅→∅),[4.112]→[4.1499:1636](∅→∅),[2.240]→[4.1499:1636](∅→∅),[4.1336]→[4.1499:1636](∅→∅),[4.1417]→[4.1499:1636](∅→∅),[4.1499]→[4.1499:1636](∅→∅)
let chart = Chart::new().series(charming::series::Graph::new().name("Cargo dependencies")// Use charming's force-directed layout, in combination with// `graph::layout()` using `forceatlas2`, as they seem to get the best results// when used together..layout(charming::series::GraphLayout::Force).force(GraphLayoutForce::new().layout_animation(false)).roam(true).data(graph::data(&package_graph, &timings)),);let mut renderer = HtmlRenderer::new("Cargo dependencies", 1000, 800);renderer.save(&chart, "/tmp/chart.html").unwrap();visualize::for_style(visualize::Style::Graph, &package_graph, &timings);