From 145a5bfaccbf5b470812dffa7acce1030fdb45ae 2012-03-05 13:08:27 From: Marek Rosa Date: 2012-03-05 13:08:27 Subject: [PATCH] Spline series fix --- diff --git a/example/axischart/main.cpp b/example/axischart/main.cpp index 4df8c0b..5576366 100644 --- a/example/axischart/main.cpp +++ b/example/axischart/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) categoriesX.insert(100,"High"); axisX->setMin(-10); - axisX->setMax(200); + axisX->setMax(2200); QChartAxis* axisY = chartView->axisY(); axisY->setLabelsAngle(45); diff --git a/example/example.pro b/example/example.pro index dc13dc2..738ee74 100644 --- a/example/example.pro +++ b/example/example.pro @@ -16,6 +16,6 @@ SUBDIRS += linechart \ presenterchart \ chartview \ scatterinteractions \ - #splinechart \ + splinechart \ areachart \ stackedbarchartdrilldown diff --git a/example/splinechart/splinewidget.cpp b/example/splinechart/splinewidget.cpp index 3b45ce0..98a65c5 100644 --- a/example/splinechart/splinewidget.cpp +++ b/example/splinechart/splinewidget.cpp @@ -14,7 +14,7 @@ SplineWidget::SplineWidget(QWidget *parent) qsrand(time(NULL)); //! [1] //create QSplineSeries - series = new QSplineSeries(this); + series = new QSplineSeries; //! [1] //! [2] @@ -47,8 +47,15 @@ SplineWidget::SplineWidget(QWidget *parent) QChartView* chart = new QChartView; chart->addSeries(series); - chart->axisX()->setRange(0, 1500); - chart->axisY()->setRange(0, 400); + chart->setChartTitle("Spline chart example"); + +// chart->setMinimumSize(800,600); +// chart->axisX()->setRange(0, 1500); + +// chart->axisX()->setMax(1500); +// chart->axisY()->setRange(0, 400); + chart->axisX()->setMax(1500); +// chart-> chart->setMinimumSize(800,600); //! [3] diff --git a/src/chartpresenter.cpp b/src/chartpresenter.cpp index d8db236..b8e4fa8 100644 --- a/src/chartpresenter.cpp +++ b/src/chartpresenter.cpp @@ -253,6 +253,8 @@ void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain) QSplineSeries* splineSeries = qobject_cast(series); SplinePresenter* splinePresenter = new SplinePresenter(splineSeries, m_chart); QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), splinePresenter, SLOT(handleGeometryChanged(const QRectF&))); + //initialize + splinePresenter->handleDomainChanged(domain->minX(),domain->maxX(),domain->minY(),domain->maxY()); m_chartTheme->decorate(splinePresenter, splineSeries, m_chartItems.count()); m_chartItems.insert(splineSeries, splinePresenter); break; diff --git a/src/splinechart/splinepresenter.cpp b/src/splinechart/splinepresenter.cpp index 96db4bc..b2fe80b 100644 --- a/src/splinechart/splinepresenter.cpp +++ b/src/splinechart/splinepresenter.cpp @@ -53,7 +53,7 @@ void SplinePresenter::paint(QPainter *painter, const QStyleOptionGraphicsItem *o painter->drawPath(m_path); QSplineSeries* splineSeries = qobject_cast(m_series); - for (int i = 0; i < splineSeries->count() - 1; i++) + for (int i = 0; i < m_points.size() - 1; i++) { painter->setPen(Qt::red); painter->drawEllipse(m_points[i], 2, 2);