From e99f27ff5b45967a49a59d3f0e23d4081ff92d1d Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 30 Sep 2024 16:40:13 -0300 Subject: [PATCH] playing a bit with charts --- chartstest/Cargo.lock | 79 ++ chartstest/Cargo.toml | 7 + chartstest/README.md | 1 + chartstest/graph.svg | 1712 ++++++++++++++++++++++++++++++++++++++++ chartstest/src/main.rs | 185 +++++ 5 files changed, 1984 insertions(+) create mode 100644 chartstest/Cargo.lock create mode 100644 chartstest/Cargo.toml create mode 100644 chartstest/README.md create mode 100644 chartstest/graph.svg create mode 100644 chartstest/src/main.rs diff --git a/chartstest/Cargo.lock b/chartstest/Cargo.lock new file mode 100644 index 0000000..4ce1fc8 --- /dev/null +++ b/chartstest/Cargo.lock @@ -0,0 +1,79 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "charts" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d1617102454184fed74f5a24e5cc1d8f2a69a2e9b1ba25f869189dc79b2b2e6" +dependencies = [ + "format_num", + "svg", +] + +[[package]] +name = "chartstest" +version = "0.1.0" +dependencies = [ + "charts", +] + +[[package]] +name = "format_num" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14ac05eb8d2eb4ed1eeff847911deae077b0b53332465de9d6a26b0ea9961bc8" +dependencies = [ + "regex", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "regex" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "svg" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3685c82a045a6af0c488f0550b0f52b4c77d2a52b0ca8aba719f9d268fa96965" diff --git a/chartstest/Cargo.toml b/chartstest/Cargo.toml new file mode 100644 index 0000000..a8eaa32 --- /dev/null +++ b/chartstest/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "chartstest" +version = "0.1.0" +edition = "2021" + +[dependencies] +charts = "0.3.0" diff --git a/chartstest/README.md b/chartstest/README.md new file mode 100644 index 0000000..4bc44f9 --- /dev/null +++ b/chartstest/README.md @@ -0,0 +1 @@ +Testing charts (https://github.com/askanium/rustplotlib) diff --git a/chartstest/graph.svg b/chartstest/graph.svg new file mode 100644 index 0000000..7af57a4 --- /dev/null +++ b/chartstest/graph.svg @@ -0,0 +1,1712 @@ + + + + + + + + channel395_0 + + + + + + meshBlockPipe_0 + + + + + + 3DValve_0 + + + + + + forwardStepPar_2 + + + + + + pitzDaily_0 + + + + + + cavityBox + + + + + + rightAngledDuctFlow_0 + + + + + + BernardCells_0 + + + + + + shockTube_0 + + + + + + aerofoilNACA0012_0 + + + + + + backwardFacingStep + + + + + + pollutantPlumePar_0 + + + + + + KCS_Fn026Par_0 + + + + + + acousticAnalogyPar_0 + + + + + + trainTunnelPar_0 + + + + + + angledDuctPorous_0 + + + + + + wing + + + + + + 2DMixer + + + + + + mixerVessel2D_1 + + + + + + meshBlockSphere_0 + + + + + + twoThrustersPar_0 + + + + + + singleChannelPump_3 + + + + + + 2DcavityBlay_0 + + + + + + hotRoom_3 + + + + + + Channelf4st_p2_0 + + + + + + 2DRotatingBox_0 + + + + + + 2DcavityNielsen_0 + + + + + + cylindricalDomainWindPar_3 + + + + + + airFoil2D_0 + + + + + + channelPorousBafflePressure_0 + + + + + + 2DCylinderPar_1 + + + + + + fuelSloshing_0 + + + + + + meshCavityPar_0 + + + + + + irvineForest_0 + + + + + + meshMotorBikePar_0 + + + + + + meshAddLayersToFaceZone_0 + + + + + + twoBladeMixerPar_0 + + + + + + meshRelativeMotion_0 + + + + + + boundaryWallFunctions_2 + + + + + + 2DCylinderPar_2 + + + + + + pitzDaily_4 + + + + + + lateralCavity_0 + + + + + + rightAngledDuct + + + + + + channelWithLumpedBCs_0 + + + + + + interfaceQadd_0 + + + + + + porousBlockage_0 + + + + + + pitzDailyCoupled_0 + + + + + + windAroundBuildingsPar_0 + + + + + + irvineForest_1 + + + + + + cylindricalPeriodicSectors_0 + + + + + + mixerVessel2D_0 + + + + + + 2DcavityBettsBokhari_0 + + + + + + boundaryLaunderSharma_0 + + + + + + rotorDisk_0 + + + + + + meshGapDetectionPar_0 + + + + + + underHoodCarChannel_0 + + + + + + hotRoom_0 + + + + + + resonantSloshing_0 + + + + + + meshFilterPar_0 + + + + + + pisoFoamCavity_0 + + + + + + boundaryPatchSwitch_0 + + + + + + 2DManifold + + + + + + meshAirfoilPar_1 + + + + + + nacaAirfoil_0 + + + + + + meshPumpPar_0 + + + + + + leafHeatBalance_0 + + + + + + simpleCar_0 + + + + + + hotRoom_2 + + + + + + porousTubePar_0 + + + + + + boundaryWallFunctions_1 + + + + + + meshBlockSphere7ProjectedEdges_0 + + + + + + injection_0 + + + + + + ovoidRadiationPar_0 + + + + + + rotatingHeatedDiscPar_0 + + + + + + damBreakHydro_0 + + + + + + cylindricalDomainWindPar_4 + + + + + + jouleHeatingSolidPar_0 + + + + + + fallingSphere_0 + + + + + + porousDamBreak_0 + + + + + + 2DCavityTransient_0 + + + + + + meshExtrudePipesPar_0 + + + + + + planarContraction_0 + + + + + + rotSector_0 + + + + + + meshBlockSphere7_0 + + + + + + shadowingTree_0 + + + + + + hotMovingCone_0 + + + + + + windProfilePar_0 + + + + + + cylinderAdjustFlowUFixPar_1 + + + + + + meshIglooWithFridges_0 + + + + + + solidConductionBlock_0 + + + + + + 3DBox + + + + + + oneraM6Par_0 + + + + + + nacaAirfoil_1 + + + + + + pitzDailyTransient_0 + + + + + + phaseSettling_0 + + + + + + meshFlange_0 + + + + + + sunDirModel_0 + + + + + + brakeDisk_0 + + + + + + buildingWithWindowsAndSolarPar_0 + + + + + + rae2822Par_0 + + + + + + meshAirfoilPar_2 + + + + + + cylindricalDomainWindPar_2 + + + + + + ovoidRadiationPar_1 + + + + + + annularThermalMixer_0 + + + + + + meshBox_0 + + + + + + ovoidRadiationPar_3 + + + + + + T3A_0 + + + + + + fallingObject_0 + + + + + + forwardStepPar_1 + + + + + + electricHeatingElement_0 + + + + + + boundaryWallFunctions_0 + + + + + + rae2822_0 + + + + + + objectFallingToWater_0 + + + + + + singleChannelPump_0 + + + + + + ovoidRadiationPar_2 + + + + + + turbineSiting_0 + + + + + + forwardStepPar_0 + + + + + + cylinderAdjustFlowPFixPar_1 + + + + + + cylinderAdjustFlowPFixPar_0 + + + + + + cylinderAdjustFlowUFixPar_0 + + + + + + cavityCoupledU_0 + + + + + + ovoidHumidity_1 + + + + + + singleChannelPump_2 + + + + + + naca0012 + + + + + + twoRegionAnisoSolid_0 + + + + + + meshSnakeRiverCanyon_0 + + + + + + 2DRotatingBox_1 + + + + + + linearSloshingPar_0 + + + + + + meshWindTunnelRotationPar_0 + + + + + + singleChannelPump_1 + + + + + + cylindricalDomainWindPar_0 + + + + + + solidConductionBlock_1 + + + + + + Ahmed25deg_1 + + + + + + reconstructWindProfilePar_0 + + + + + + wingMotion2D_0 + + + + + + meshAirfoilPar_0 + + + + + + 2DCylinderPar_0 + + + + + + + + +0.0 + + + + + +50 + + + + + +100 + + + + + +150 + + + + + +200 + + + + + +250 + + + + + +300 + + + + + + + + +6.17 + + + + + +16.85 + + + + + +66.24 + + + + + +6.12 + + + + + +49.68 + + + + + +45.02 + + + + + +1.84 + + + + + +9.52 + + + + + +81.48 + + + + + +1.95 + + + + + +23.97 + + + + + +12.5 + + + + + +5.48 + + + + + +6.71 + + + + + +10.38 + + + + + +89.8 + + + + + +76.2 + + + + + +32.05 + + + +1.8 + + + + + +6.9 + + + + + +44.14 + + + + + +10.63 + + + + + +4.59 + + + + + +5.67 + + + + + +27.2 + + + + + +54.09 + + + + + +1.85 + + + + + +0.19 + + + + + +59.51 + + + + + +87.77 + + + + + +7.85 + + + + + +14.2 + + + + + +38.14 + + + + + +16.8 + + + + + +39.93 + + + + + +8.89 + + + + + +10.08 + + + + + +16.66 + + + + + +11.35 + + + + + +233.94 + + + + + +16.75 + + + + + +0.87 + + + + + +9.65 + + + + + +19.19 + + + + + +85.8 + + + + + +0.63 + + + + + +12.78 + + + + + +33.42 + + + + + +12.28 + + + + + +1.48 + + + + + +1.28 + + + + + +28.51 + + + + + +1.12 + + + + + +35.22 + + + + + +0.59 + + + + + +19.89 + + + + + +47 + + + + + +17.15 + + + + + +36.4 + + + + + +38.32 + + + + + +37.49 + + + + + +34.31 + + + + + +17.62 + + + + + +2.28 + + + + + +12.63 + + + + + +2.11 + + + + + +124.93 + + + + + +7.01 + + + + + +1.15 + + + +13.66 + + + + + +91.62 + + + + + +11.31 + + + + + +54.87 + + + +2.07 + + + + + +3.99 + + + + + +71.12 + + + + + +9.15 + + + + + +202.25 + + + + + +0.78 + + + + + +0.24 + + + + + +5.86 + + + + + +9.64 + + + + + +18.72 + + + + + +0.79 + + + + + +73.99 + + + + + +29.11 + + + + + +2.75 + + + + + +0.26 + + + + + +12.35 + + + + + +7.51 + + + + + +0.64 + + + + + +48.59 + + + + + +4.27 + + + + + +7.61 + + + + + +24.75 + + + + + +18.69 + + + + + +0.24 + + + + + +10.92 + + + + + +143.88 + + + + + +14.85 + + + + + +27.98 + + + + + +128.58 + + + + + +38.35 + + + + + +18.37 + + + + + +13.26 + + + + + +0.64 + + + + + +4.75 + + + + + +51.92 + + + + + +9.62 + + + + + +100.9 + + + + + +18.2 + + + + + +49.84 + + + + + +33.22 + + + + + +0.16 + + + + + +0.45 + + + + + +1.01 + + + + + +12.48 + + + + + +16.89 + + + + + +7.94 + + + + + +3.91 + + + + + +1.27 + + + + + +0.83 + + + + + +62.53 + + + + + +6 + + + + + +70.18 + + + + + +2.82 + + + + + +46.54 + + + + + +45.55 + + + + + +4.5 + + + + + +18.48 + + + + + +13.19 + + + + + +11.17 + + + + + +2.55 + + + + + +99.13 + + + + + +38.05 + + + + + +92.84 + + + + + +10.29 + + + + + +15.49 + + + + + +330.78 + + + + + +3.78 + + + + + + \ No newline at end of file diff --git a/chartstest/src/main.rs b/chartstest/src/main.rs new file mode 100644 index 0000000..4b04d6b --- /dev/null +++ b/chartstest/src/main.rs @@ -0,0 +1,185 @@ +use charts::{BarLabelPosition, Chart, ScaleBand, ScaleLinear, VerticalBarView}; + +fn main() { + let width = 2560; + let height = 1440; + let padding_top = 90; + let padding_right = 40; + let padding_bottom = 450; + let padding_left = 60; + + let values = [ + ("channel395_0", 7.94f32), + ("meshBlockPipe_0", 0.19), + ("3DValve_0", 73.99), + ("forwardStepPar_2", 35.22), + ("pitzDaily_0", 4.75), + ("cavityBox", 18.48), + ("rightAngledDuctFlow_0", 6.00), + ("BernardCells_0", 3.91), + ("shockTube_0", 1.12), + ("aerofoilNACA0012_0", 23.97), + ("backwardFacingStep", 1.15), + ("pollutantPlumePar_0", 14.85), + ("KCS_Fn026Par_0", 143.88), + ("acousticAnalogyPar_0", 99.13), + ("trainTunnelPar_0", 202.25), + ("angledDuctPorous_0", 9.52), + ("wing", 54.87), + ("2DMixer", 6.17), + ("mixerVessel2D_1", 1.85), + ("meshBlockSphere_0", 0.16), + ("twoThrustersPar_0", 59.51), + ("singleChannelPump_3", 91.62), + ("2DcavityBlay_0", 1.01), + ("hotRoom_3", 2.75), + ("Channelf4st_p2_0", 89.80), + ("2DRotatingBox_0", 15.49), + ("2DcavityNielsen_0", 5.67), + ("cylindricalDomainWindPar_3", 18.20), + ("airFoil2D_0", 4.27), + ("channelPorousBafflePressure_0", 2.82), + ("2DCylinderPar_1", 12.63), + ("fuelSloshing_0", 9.65), + ("meshCavityPar_0", 1.28), + ("irvineForest_0", 12.50), + ("meshMotorBikePar_0", 19.19), + ("meshAddLayersToFaceZone_0", 0.26), + ("twoBladeMixerPar_0", 47.00), + ("meshRelativeMotion_0", 6.90), + ("boundaryWallFunctions_2", 0.64), + ("2DCylinderPar_2", 7.61), + ("pitzDaily_4", 3.99), + ("lateralCavity_0", 1.27), + ("rightAngledDuct", 54.09), + ("channelWithLumpedBCs_0", 2.28), + ("interfaceQadd_0", 11.35), + ("porousBlockage_0", 2.11), + ("pitzDailyCoupled_0", 7.01), + ("windAroundBuildingsPar_0", 45.02), + ("irvineForest_1", 12.35), + ("cylindricalPeriodicSectors_0", 0.59), + ("mixerVessel2D_0", 16.89), + ("2DcavityBettsBokhari_0", 12.28), + ("boundaryLaunderSharma_0", 0.78), + ("rotorDisk_0", 39.93), + ("meshGapDetectionPar_0", 0.83), + ("underHoodCarChannel_0", 70.18), + ("hotRoom_0", 6.12), + ("resonantSloshing_0", 0.63), + ("meshFilterPar_0", 1.84), + ("pisoFoamCavity_0", 0.87), + ("boundaryPatchSwitch_0", 66.24), + ("2DManifold", 32.05), + ("meshAirfoilPar_1", 13.19), + ("nacaAirfoil_0", 11.31), + ("meshPumpPar_0", 18.37), + ("leafHeatBalance_0", 11.17), + ("simpleCar_0", 4.59), + ("hotRoom_2", 2.55), + ("porousTubePar_0", 27.20), + ("boundaryWallFunctions_1", 0.64), + ("meshBlockSphere7ProjectedEdges_0", 0.24), + ("injection_0", 49.68), + ("ovoidRadiationPar_0", 38.14), + ("rotatingHeatedDiscPar_0", 71.12), + ("damBreakHydro_0", 1.95), + ("cylindricalDomainWindPar_4", 51.92), + ("jouleHeatingSolidPar_0", 24.75), + ("fallingSphere_0", 85.80), + ("porousDamBreak_0", 124.93), + ("2DCavityTransient_0", 38.32), + ("meshExtrudePipesPar_0", 12.78), + ("planarContraction_0", 12.48), + ("wing", 2.07), + ("rotSector_0", 29.11), + ("meshBlockSphere7_0", 0.24), + ("shadowingTree_0", 14.20), + ("hotMovingCone_0", 18.69), + ("windProfilePar_0", 5.48), + ("cylinderAdjustFlowUFixPar_1", 9.64), + ("meshIglooWithFridges_0", 9.15), + ("solidConductionBlock_0", 16.80), + ("3DBox", 16.75), + ("oneraM6Par_0", 49.84), + ("nacaAirfoil_1", 8.89), + ("pitzDailyTransient_0", 16.85), + ("phaseSettling_0", 17.62), + ("meshFlange_0", 7.85), + ("sunDirModel_0", 10.29), + ("brakeDisk_0", 62.53), + ("buildingWithWindowsAndSolarPar_0", 33.42), + ("rae2822Par_0", 10.08), + ("meshAirfoilPar_2", 10.38), + ("cylindricalDomainWindPar_2", 37.49), + ("ovoidRadiationPar_1", 34.31), + ("annularThermalMixer_0", 44.14), + ("meshBox_0", 4.50), + ("ovoidRadiationPar_3", 46.54), + ("T3A_0", 18.72), + ("fallingObject_0", 87.77), + ("forwardStepPar_1", 38.35), + ("electricHeatingElement_0", 38.05), + ("boundaryWallFunctions_0", 1.48), + ("rae2822_0", 27.98), + ("objectFallingToWater_0", 92.84), + ("singleChannelPump_0", 330.78), + ("ovoidRadiationPar_2", 33.22), + ("turbineSiting_0", 36.40), + ("forwardStepPar_0", 28.51), + ("cylinderAdjustFlowPFixPar_1", 9.62), + ("cylinderAdjustFlowPFixPar_0", 10.63), + ("cylinderAdjustFlowUFixPar_0", 10.92), + ("cavityCoupledU_0", 0.79), + ("ovoidHumidity_1", 45.55), + ("singleChannelPump_2", 128.58), + ("naca0012", 81.48), + ("twoRegionAnisoSolid_0", 0.45), + ("meshSnakeRiverCanyon_0", 3.78), + ("2DRotatingBox_1", 16.66), + ("linearSloshingPar_0", 233.94), + ("meshWindTunnelRotationPar_0", 17.15), + ("singleChannelPump_1", 100.90), + ("backwardFacingStep", 13.66), + ("cylindricalDomainWindPar_0", 48.59), + ("solidConductionBlock_1", 7.51), + ("Ahmed25deg_1", 76.20), + ("reconstructWindProfilePar_0", 5.86), + ("wingMotion2D_0", 19.89), + ("meshAirfoilPar_0", 6.71), + ("2DManifold", 1.80), + ("2DCylinderPar_0", 13.26), + ]; + + let formatted = values + .iter() + .map(|(name, value)| (format!("{name:>40}"), *value)) + .collect::>(); + + let x_labels = ScaleBand::new() + .set_domain(formatted.iter().map(|(name, _)| name.to_string()).collect()) + .set_range(vec![0, width - padding_left - padding_right]); + let max = values + .iter() + .fold(f32::MIN, |current, incoming| current.max(incoming.1)); + let y_labels = ScaleLinear::new() + .set_domain(vec![0f32, max]) + .set_range(vec![height - padding_top - padding_bottom, 0]); + let view = VerticalBarView::new() + .set_x_scale(&x_labels) + .set_y_scale(&y_labels) + .load_data(&formatted) + .unwrap(); + + Chart::new() + .set_width(width) + .set_height(height) + .set_margins(padding_top, padding_right, padding_bottom, padding_left) + .add_view(&view) + .add_axis_bottom(&x_labels) + .add_axis_left(&y_labels) + .set_bottom_axis_tick_label_rotation(-90) + .set_left_axis_tick_label_format(".2s") + .save("graph.svg") + .unwrap(); +}