diff --git a/histogram.cpp b/histogram.cpp index c3ec0ff..a745700 100644 --- a/histogram.cpp +++ b/histogram.cpp @@ -40,7 +40,8 @@ void Histogram::paintEvent(QPaintEvent *) uint64_t end =(i+1) * m_histogram.size() / w; for(uint64_t o = start; o < end; o++) sum += m_histogram[o]; - m_points.push_back(sum); + if(start != end) + m_points.push_back(sum); } float scale = *std::max_element(m_points.begin(), m_points.end()); if(m_log) @@ -57,7 +58,7 @@ void Histogram::paintEvent(QPaintEvent *) points.push_back(QPointF(0, h)); for(size_t i = 0; i < m_points.size(); i++) { - points.push_back(QPointF(i, h - m_points[i] * h)); + points.push_back(QPointF((float)i * w / m_points.size(), h - m_points[i] * h)); } points.push_back(QPoint(w, h)); painter.setBrush(Qt::gray);