cabana: Fix the incorrect Y axis (#25984)

old-commit-hash: 2d9e797259
taco
Dean Lee 3 years ago committed by GitHub
parent a3e4d96bf1
commit 0bc6e0dc46
  1. 5
      tools/cabana/chartswidget.cc

@ -136,6 +136,7 @@ void ChartWidget::updateSeries() {
vals.clear(); vals.clear();
vals.reserve(3 * 60 * 100); vals.reserve(3 * 60 * 100);
double min_y = 0, max_y = 0;
uint64_t route_start_time = parser->replay->routeStartTime(); uint64_t route_start_time = parser->replay->routeStartTime();
for (auto &evt : *events) { for (auto &evt : *events) {
if (evt->which == cereal::Event::Which::CAN) { if (evt->which == cereal::Event::Which::CAN) {
@ -147,6 +148,9 @@ void ChartWidget::updateSeries() {
val -= ((val >> (sig->size - 1)) & 0x1) ? (1ULL << sig->size) : 0; val -= ((val >> (sig->size - 1)) & 0x1) ? (1ULL << sig->size) : 0;
} }
double value = val * sig->factor + sig->offset; double value = val * sig->factor + sig->offset;
if (value < min_y) min_y = value;
if (value > max_y) max_y = value;
double ts = (evt->mono_time - route_start_time) / (double)1e9; // seconds double ts = (evt->mono_time - route_start_time) / (double)1e9; // seconds
vals.push_back({ts, value}); vals.push_back({ts, value});
} }
@ -157,6 +161,7 @@ void ChartWidget::updateSeries() {
series->replace(vals); series->replace(vals);
auto [begin, end] = parser->range(); auto [begin, end] = parser->range();
chart_view->chart()->axisX()->setRange(begin, end); chart_view->chart()->axisX()->setRange(begin, end);
chart_view->chart()->axisY()->setRange(min_y * 0.95, max_y * 1.05);
} }
void ChartWidget::rangeChanged(qreal min, qreal max) { void ChartWidget::rangeChanged(qreal min, qreal max) {

Loading…
Cancel
Save