Use an absolute color scale for throughput, instead of the weird ranked thing. If a few roads have a ridiculously high throughput compared to others, we actually care about those outliers. And don't show counts in the legend after all; it just climbs over the whole day, and confusingly mixes roads/intersections, which're actually colored independently.

This commit is contained in:
Dustin Carlino 2020-10-03 16:44:36 -07:00
parent 98d26d8979
commit 50e8a94946
2 changed files with 10 additions and 10 deletions

View File

@ -306,6 +306,13 @@ impl<'a> ColorNetwork<'a> {
self.add_r(r, scale.eval((cnt as f64) / max)); 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<IntersectionID>, 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) { pub fn build(self, ctx: &mut EventCtx) -> (Drawable, Drawable) {
(ctx.upload(self.unzoomed), ctx.upload(self.zoomed)) (ctx.upload(self.unzoomed), ctx.upload(self.zoomed))

View File

@ -90,8 +90,8 @@ impl Backpressure {
.build(ctx); .build(ctx);
let mut colorer = ColorNetwork::new(app); let mut colorer = ColorNetwork::new(app);
colorer.ranked_roads(cnt_per_r, &app.cs.good_to_bad_red); colorer.pct_roads(cnt_per_r, &app.cs.good_to_bad_red);
colorer.ranked_intersections(cnt_per_i, &app.cs.good_to_bad_red); colorer.pct_intersections(cnt_per_i, &app.cs.good_to_bad_red);
let (unzoomed, zoomed) = colorer.build(ctx); let (unzoomed, zoomed) = colorer.build(ctx);
Backpressure { Backpressure {
@ -211,14 +211,7 @@ impl Throughput {
} else { } else {
Widget::nothing() Widget::nothing()
}, },
ColorLegend::gradient( ColorLegend::gradient(ctx, &app.cs.good_to_bad_red, vec!["0", "highest"]),
ctx,
&app.cs.good_to_bad_red,
vec![
"0".to_string(),
prettyprint_usize(road_counter.max().max(intersection_counter.max())),
],
),
])) ]))
.aligned(HorizontalAlignment::Right, VerticalAlignment::Center) .aligned(HorizontalAlignment::Right, VerticalAlignment::Center)
.build(ctx); .build(ctx);