diff --git a/tools/cabana/chartswidget.cc b/tools/cabana/chartswidget.cc index 26c05cf119..9f5b4acbd1 100644 --- a/tools/cabana/chartswidget.cc +++ b/tools/cabana/chartswidget.cc @@ -469,6 +469,18 @@ void ChartView::updatePlot(double cur, double min, double max) { axis_x->setRange(min, max); updateAxisY(); } + + // Show points when zoomed in enough + for (auto &s : sigs) { + auto begin = std::lower_bound(s.vals.begin(), s.vals.end(), axis_x->min(), [](auto &p, double x) { return p.x() < x; }); + auto end = std::lower_bound(s.vals.begin(), s.vals.end(), axis_x->max(), [](auto &p, double x) { return p.x() < x; }); + + int num_points = std::max(end - begin, 1); + int pixels_per_point = width() / num_points; + + s.series->setPointsVisible(pixels_per_point > 20); + } + scene()->invalidate({}, QGraphicsScene::ForegroundLayer); }