Skip to content

Commit 5edbc8b

Browse files
committed
Fix not being able to update color and label of columns
It was no longer possible to update the labels and colors of the detected columns because they were always overwritten by the default values. Fix this by only settings label and color once after column changes, like it was done before. This bug was introduced in #119.
1 parent 6727350 commit 5edbc8b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/gui.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,15 @@ impl MyApp {
320320
ui.vertical(|ui| {
321321
if let Ok(gui_data) = self.data_lock.read() {
322322
self.data = gui_data.clone();
323-
self.labels = gui_data.plots.iter().map(|d| d.0.clone()).collect();
324-
self.colors = (0..max(self.labels.len(), 1))
325-
.map(|i| COLORS[i % COLORS.len()])
326-
.collect();
327-
self.color_vals = (0..max(self.data.plots.len(), 1)).map(|_| 0.0).collect();
323+
if self.data.plots.len() != self.labels.len() {
324+
self.labels = gui_data.plots.iter().map(|d| d.0.clone()).collect();
325+
}
326+
if self.colors.len() != self.labels.len() {
327+
self.colors = (0..max(self.labels.len(), 1))
328+
.map(|i| COLORS[i % COLORS.len()])
329+
.collect();
330+
self.color_vals = (0..max(self.data.plots.len(), 1)).map(|_| 0.0).collect();
331+
}
328332
}
329333

330334
// TODO what about self.data.loaded_from_file

0 commit comments

Comments
 (0)