From d83729eb88d8684e7e5d902567faeecb3a6a074f 2012-07-16 14:54:16 From: Marek Rosa Date: 2012-07-16 14:54:16 Subject: [PATCH] Values and Intervals axes ranges are now initialized only if they haven't been preset earlier --- diff --git a/examples/customchart/main.cpp b/examples/customchart/main.cpp index e472f4c..733d5f6 100644 --- a/examples/customchart/main.cpp +++ b/examples/customchart/main.cpp @@ -32,7 +32,7 @@ int main(int argc, char *argv[]) //![1] QLineSeries* series = new QLineSeries(); - *series << QPointF(0, 6) << QPointF(9, 4) << QPointF(15, 20) << QPointF(25, 12) << QPointF(29, 26); + *series << QPointF(0, 6) << QPointF(9, 4) << QPointF(15, 20) << QPointF(25, 12) << QPointF(39, 36); QChart* chart = new QChart(); chart->legend()->hide(); chart->addSeries(series); @@ -95,18 +95,14 @@ int main(int argc, char *argv[]) axisX->append("optimal", 20); axisX->append("high", 30); axisX->setRange(0, 30); -// axisX->setRange("low","high"); axisY->append("slow", 10); axisY->append("med", 20); axisY->append("fast", 30); axisY->setRange(0, 30); -// axisY->setRange("slow","fast"); chart->setAxisX(axisX, series); chart->setAxisY(axisY, series); - axisX->setRange(0, 30); - axisY->setRange(0, 30); //![4] //![5] diff --git a/src/axis/intervalsaxis/qintervalsaxis.cpp b/src/axis/intervalsaxis/qintervalsaxis.cpp index 52e1c53..f2260e0 100644 --- a/src/axis/intervalsaxis/qintervalsaxis.cpp +++ b/src/axis/intervalsaxis/qintervalsaxis.cpp @@ -87,7 +87,7 @@ void QIntervalsAxis::append(const QString& intervalLabel, qreal interval) d->m_intervalsMap.insert(intervalLabel, Range(range.second,interval)); d->m_intervals.append(intervalLabel); } - setRange(d->m_min,interval); +// setRange(d->m_min,interval); } } diff --git a/src/axis/valuesaxis/qvaluesaxis.cpp b/src/axis/valuesaxis/qvaluesaxis.cpp index 4fa085e..554ecae 100644 --- a/src/axis/valuesaxis/qvaluesaxis.cpp +++ b/src/axis/valuesaxis/qvaluesaxis.cpp @@ -318,6 +318,12 @@ void QValuesAxisPrivate::intializeDomain(Domain* domain) m_min = domain->minX(); m_max = domain->maxX(); } + } else { + if(m_orientation==Qt::Vertical){ + domain->setRangeY(m_min, m_max); + }else{ + domain->setRangeX(m_min, m_max); + } } }