Fix position calculation

This commit is contained in:
Emil Sawicki
2022-03-13 07:02:52 +01:00
parent a77225af5d
commit f684acd53b
3 changed files with 39 additions and 7 deletions

View File

@@ -70,7 +70,12 @@ void LinesChart::drawDesignMode(QPainter* painter, qreal hStep, qreal vStep, qre
qreal LinesChart::calculatePos(const AxisData &data, qreal value, qreal rectSize) const
{
return (data.rangeMax() - value) / data.delta() * rectSize;
if (data.reverseDirection() && data.rangeMin() >= 0) {
// Not flipping for minimum less than 0 because lower number is at the bottom.
return (1 - (data.rangeMax() - value) / data.delta()) * rectSize;
} else {
return (data.rangeMax() - value) / data.delta() * rectSize;
}
}
void LinesChart::paintSeries(QPainter *painter, SeriesItem *series, QRectF barsRect)