From 3a7f39a6da04478b4a86f757e17b00c4f490f9bc Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Thu, 4 Feb 2021 11:27:57 -0800 Subject: [PATCH] Downsample points on a line-series plot for drawing. Otherwise, the arrivals plot on a border intersection in downtown winds up with more than 2^16 points. --- widgetry/src/widgets/line_plot.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/widgetry/src/widgets/line_plot.rs b/widgetry/src/widgets/line_plot.rs index d5eb5b5c2c..f3a5f2be79 100644 --- a/widgetry/src/widgets/line_plot.rs +++ b/widgetry/src/widgets/line_plot.rs @@ -151,7 +151,9 @@ impl> LinePlot { (1.0 - percent_y) * height, )); } - pts.dedup(); + // Downsample to avoid creating polygons with a huge number of points. 1m is untuned, + // and here "meters" is really pixels. + pts = Pt2D::approx_dedupe(pts, Distance::meters(1.0)); if pts.len() >= 2 { closest.add(s.label.clone(), &pts); batch.push(s.color, thick_lineseries(pts, Distance::meters(5.0)));