bug: Fix incorrect cpu colour matching again in all position (#349)

Turns out there was yet another bug with the CPU colour allocation. I had forgotten to use the same index calculation for the "all" position.
This commit is contained in:
Clement Tsang 2020-12-11 16:14:17 -05:00 committed by GitHub
parent 74f4b386d7
commit 86135e466c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View file

@ -15,6 +15,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Bug Fixes
## [0.5.5] - Unreleased
## Bug Fixes
- [#349](https://github.com/ClementTsang/bottom/pull/349): Fixed CPU graph colours not matching the legend in the "all" state.
## [0.5.4] - 2020-12-10
## Changes

View file

@ -199,9 +199,16 @@ impl CpuGraphWidget for Painter {
})
.style(if show_avg_cpu && itx == AVG_POSITION {
self.colours.avg_colour_style
} else if itx == ALL_POSITION {
self.colours.all_colour_style
} else {
self.colours.cpu_colour_styles
[itx % self.colours.cpu_colour_styles.len()]
self.colours.cpu_colour_styles[(itx - 1 // Because of the all position
- (if show_avg_cpu {
AVG_POSITION
} else {
0
}))
% self.colours.cpu_colour_styles.len()]
})
.data(&cpu.cpu_data[..])
.graph_type(tui::widgets::GraphType::Line)