Skip to content

Commit 7675d25

Browse files
committed
handel case for heat
1 parent 456f377 commit 7675d25

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/sauce/home.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,35 @@ pub fn plot_component(props: &PlotProps) -> Html {
5353
let id = "plot-div";
5454
let mut plot = Plot::new();
5555

56+
let mut heat_or_damage_plotted: bool = false;
57+
let mut cross_section_plotted: bool = false;
58+
5659
for (i, (energy, cross_section)) in cache.energy_values.iter().zip(&cache.cross_section_values).enumerate() {
5760
if cache.checkbox_selected[i] {
5861
let trace = Scatter::new(energy.clone(), cross_section.clone())
5962
.name(&format!("{}", cache.labels[i]));
6063
plot.add_trace(trace);
64+
if cache.labels[i].contains("heat") || cache.labels[i].contains("damage") {
65+
heat_or_damage_plotted = true;
66+
}
67+
if !cache.labels[i].contains("heat") && !cache.labels[i].contains("damage") {
68+
cross_section_plotted = true;
69+
}
6170
}
6271
}
6372

73+
let x_axis_title = if cross_section_plotted && heat_or_damage_plotted {
74+
"Microscopic Cross Section [barns], Heating Cross Section [eV-barn]"
75+
} else if cross_section_plotted {
76+
"Microscopic Cross Section [barns]"
77+
} else if heat_or_damage_plotted {
78+
"Heating Cross Section [eV-barn]"
79+
} else {
80+
"" // no data plotted
81+
};
82+
6483
let y_axis = plotly::layout::Axis::new()
65-
.title("Cross section [barns]")
84+
.title(x_axis_title)
6685
// .show_line(true)
6786
.zero_line(true)
6887
// .range(0) not sure how to set lower value

0 commit comments

Comments
 (0)