mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 03:35:51 +03:00
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:
parent
98d26d8979
commit
50e8a94946
@ -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<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) {
|
||||
(ctx.upload(self.unzoomed), ctx.upload(self.zoomed))
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user