mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-23 16:22:58 +03:00
Fix position calculation
This commit is contained in:
parent
a77225af5d
commit
f684acd53b
@ -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)
|
||||
|
@ -798,16 +798,17 @@ AxisData &AbstractSeriesChart::yAxisData() const
|
||||
|
||||
void AbstractSeriesChart::updateMinAndMaxValues()
|
||||
{
|
||||
qreal maxYValue = 0;
|
||||
qreal minYValue = 0;
|
||||
qreal maxXValue = 0;
|
||||
qreal minXValue = 0;
|
||||
if (m_chartItem->itemMode() == DesignMode) {
|
||||
m_chartItem->xAxisData()->updateForDesignMode();
|
||||
m_chartItem->yAxisData()->updateForDesignMode();
|
||||
return;
|
||||
}
|
||||
|
||||
qreal maxYValue = 0;
|
||||
qreal minYValue = 0;
|
||||
qreal maxXValue = 0;
|
||||
qreal minXValue = 0;
|
||||
|
||||
for (SeriesItem* series : m_chartItem->series()){
|
||||
for (qreal value : series->data()->values()){
|
||||
minYValue = std::min(minYValue, value);
|
||||
|
@ -14,6 +14,22 @@ AxisData::AxisData(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
QString AxisData::toString() const
|
||||
{
|
||||
// Just for debug purposes
|
||||
QString str;
|
||||
QTextStream stream(&str);
|
||||
stream << "{ "
|
||||
<< "min: " << m_minValue << ", max: " << m_maxValue << ", step: " << m_step
|
||||
<< ", range min: " << m_rangeMin << ", range max: " << m_rangeMax << ", segments: " << m_segmentCount
|
||||
<< ", reverseDiection: " << m_reverseDirection << ", calculateAxisScale: " << m_calculateAxisScale
|
||||
<< ", manualMaxEnabled: " << !m_isMaximumAutomatic << ", manualMinEnabled: " << !m_isMinimumAutomatic
|
||||
<< ", manualStepEnabled: " << !m_isStepAutomatic << ", manualMax: " << m_manualMaximum
|
||||
<< ", manualMin: " << m_manualMinimum << ", manualStep: " << m_manualStep
|
||||
<< " }";
|
||||
return str;
|
||||
}
|
||||
|
||||
void AxisData::copy(AxisData *other)
|
||||
{
|
||||
m_calculateAxisScale = other->calculateAxisScale();
|
||||
@ -101,8 +117,18 @@ void AxisData::calculateRoundedAxisScale()
|
||||
const bool calculateMinimum = isMinimumAutomatic();
|
||||
const bool calculateMaximum = isMaximumAutomatic();
|
||||
|
||||
qreal temporaryMin = calculateMinimum ? minValue() < 0 ? minValue() : 0 : manualMinimum();
|
||||
qreal temporaryMax = calculateMaximum ? maxValue() : manualMaximum();
|
||||
qreal temporaryMin = 0;
|
||||
qreal temporaryMax = 0;
|
||||
if (calculateMinimum) {
|
||||
temporaryMin = qMax(0.0, minValue());
|
||||
} else {
|
||||
temporaryMin = qMin(manualMinimum(), minValue());
|
||||
}
|
||||
if (calculateMaximum) {
|
||||
temporaryMax = maxValue();
|
||||
} else {
|
||||
temporaryMax = qMax(manualMaximum(), maxValue());
|
||||
}
|
||||
m_step = calculateStep ? 0 : manualStep();
|
||||
|
||||
if (temporaryMax == temporaryMin) {
|
||||
|
Loading…
Reference in New Issue
Block a user