Skip to content

Commit 91e6b1b

Browse files
authored
Merge pull request #127 from Rahix/fix-color-label-update
Fix not being able to update color and label of columns
2 parents ecce378 + 5edbc8b commit 91e6b1b

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)