diff --git a/game/src/common/colors.rs b/game/src/common/colors.rs index 442ef00e63..d28f192087 100644 --- a/game/src/common/colors.rs +++ b/game/src/common/colors.rs @@ -306,6 +306,13 @@ impl<'a> ColorNetwork<'a> { self.add_r(r, scale.eval((cnt as f64) / max)); } } + // Interpolate a color for each intersection based on the max count. + pub fn pct_intersections(&mut self, counter: Counter, scale: &ColorScale) { + let max = counter.max() as f64; + for (i, cnt) in counter.consume() { + self.add_i(i, scale.eval((cnt as f64) / max)); + } + } pub fn build(self, ctx: &mut EventCtx) -> (Drawable, Drawable) { (ctx.upload(self.unzoomed), ctx.upload(self.zoomed)) diff --git a/game/src/layer/traffic.rs b/game/src/layer/traffic.rs index 0465a9267c..927cce1121 100644 --- a/game/src/layer/traffic.rs +++ b/game/src/layer/traffic.rs @@ -90,8 +90,8 @@ impl Backpressure { .build(ctx); let mut colorer = ColorNetwork::new(app); - colorer.ranked_roads(cnt_per_r, &app.cs.good_to_bad_red); - colorer.ranked_intersections(cnt_per_i, &app.cs.good_to_bad_red); + colorer.pct_roads(cnt_per_r, &app.cs.good_to_bad_red); + colorer.pct_intersections(cnt_per_i, &app.cs.good_to_bad_red); let (unzoomed, zoomed) = colorer.build(ctx); Backpressure { @@ -211,14 +211,7 @@ impl Throughput { } else { Widget::nothing() }, - ColorLegend::gradient( - ctx, - &app.cs.good_to_bad_red, - vec![ - "0".to_string(), - prettyprint_usize(road_counter.max().max(intersection_counter.max())), - ], - ), + ColorLegend::gradient(ctx, &app.cs.good_to_bad_red, vec!["0", "highest"]), ])) .aligned(HorizontalAlignment::Right, VerticalAlignment::Center) .build(ctx);