diff --git a/doc/src/example-splinechart.qdoc b/doc/src/example-splinechart.qdoc index 1d777ad..a8c2005 100644 --- a/doc/src/example-splinechart.qdoc +++ b/doc/src/example-splinechart.qdoc @@ -9,34 +9,25 @@ To create spline chart we need to put our data into QSplineSeries. QSplineSeries automatically calculates spline segment control points that are needed to properly draw the spline. - \snippet ../examples/splinechart/splinewidget.cpp 1 + \snippet ../examples/splinechart/main.cpp 1 Customize the look of the spline, by setting its pen's color and pen's width - \snippet ../examples/splinechart/splinewidget.cpp 2 + \snippet ../examples/splinechart/main.cpp 2 Now lets add some data points to the series. - \snippet ../examples/splinechart/splinewidget.cpp add points to series + \snippet ../examples/splinechart/main.cpp 3 -The data series has been populated. To display it on a chart we create QChartView object and add the data series to it. We also set the ranges on both axises, so that our chart is fully visible and there is some excess of space for adding more data points. +The data series has been populated. To display it on a chart we create QChart object and add the data series to it. We also set the title and the values range on y axis, so that our chart is better visible. - \snippet ../examples/splinechart/splinewidget.cpp 3 + \snippet ../examples/splinechart/main.cpp 4 - Then we add two buttons for adding and removing data points. Buttons clicked() signals are connected to handler functions. +Then we created a QChartView object with QChart as a parameter. This way we don't need to create QGraphicsView scene ourselves. We also set the Antialiasing on to have the rendered lines look nicer. - \snippet ../examples/splinechart/splinewidget.cpp 4 + \snippet ../examples/splinechart/main.cpp 5 - In the end we add the chart and the buttons to the widget's layout. - - \snippet ../examples/splinechart/splinewidget.cpp 5 - -Here is the handler function for add new data point button: - -\snippet ../examples/splinechart/splinewidget.cpp add point - -And here is one for remove the last data point in the series: - -\snippet ../examples/splinechart/splinewidget.cpp remove point + In the end we set the QChartView as the windows's central widget. + \snippet ../examples/splinechart/main.cpp 6 */ diff --git a/examples/splinechart/main.cpp b/examples/splinechart/main.cpp index a14d6b5..7998e54 100644 --- a/examples/splinechart/main.cpp +++ b/examples/splinechart/main.cpp @@ -29,40 +29,43 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); -//![1] + //![1] QSplineSeries* series = new QSplineSeries(); + //![1] + + //![2] QPen red(Qt::red); red.setWidth(3); series->setPen(red); -//![1] + //![2] -//![2] + //![3] series->append(0, 6); series->append(2, 4); series->append(3, 8); series->append(7, 4); series->append(10, 5); *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2); -//![2] + //![3] -//![3] + //![4] QChart* chart = new QChart(); chart->addSeries(series); chart->setTitle("Simple spline chart example"); chart->axisY()->setRange(0, 10); -//![3] + //![4] -//![4] + //![5] QChartView* chartView = new QChartView(chart); chartView->setRenderHint(QPainter::Antialiasing); -//![4] + //![5] -//![5] + //![6] QMainWindow window; window.setCentralWidget(chartView); window.resize(400, 300); window.show(); -//![5] + //![6] return a.exec(); } diff --git a/src/barchart/qbarseries.cpp b/src/barchart/qbarseries.cpp index 7983fc4..683bc80 100644 --- a/src/barchart/qbarseries.cpp +++ b/src/barchart/qbarseries.cpp @@ -108,7 +108,7 @@ void QBarSeries::appendBarSets(QList sets) } /*! - Removes a list of barsets from series. Releases ownership of \a set. Doesnt delete \a sets. + Removes a list of barsets from series. Releases ownership of \a sets. Doesnt delete \a sets. Disconnects the clicked(QString, Qt::MouseButtons) signal of \a sets from this series */ @@ -121,17 +121,30 @@ void QBarSeries::removeBarSets(QList sets) emit restructuredBars(); } +/*! + Inserts new \a set on the \a i position. + The barset that is currently at this postion is moved to postion i + 1 +*/ void QBarSeries::insertBarSet(int i, QBarSet *set) { m_internalModel->insertBarSet(i, set); // emit barsetChanged(); } +/*! + Inserts new \a category on the \a i position. + The category that is currently at this postion is moved to postion i + 1 + \sa removeCategory() +*/ void QBarSeries::insertCategory(int i, QString category) { m_internalModel->insertCategory(i, category); } +/*! + Removes the category specified by \a i + \sa insertCategory() +*/ void QBarSeries::removeCategory(int i) { m_internalModel->removeCategory(i); diff --git a/src/barchart/qbarset.cpp b/src/barchart/qbarset.cpp index 0beb7ba..1da4be8 100644 --- a/src/barchart/qbarset.cpp +++ b/src/barchart/qbarset.cpp @@ -102,11 +102,20 @@ QBarSet& QBarSet::operator << (const qreal &value) return *this; } +/*! + Inserts new \a value on the \a i position. + The value that is currently at this postion is moved to postion i + 1 + \sa removeValue() +*/ void QBarSet::insertValue(int i, qreal value) { m_values.insert(i, value); } +/*! + Removes the value specified by \a i + \sa insertValue() +*/ void QBarSet::removeValue(int i) { m_values.removeAt(i);