##// END OF EJS Templates
Updated spline chart example documentation and added some more docs to barseries
Marek Rosa -
r901:087f347c6433
parent child
Show More
@@ -9,34 +9,25
9 9
10 10 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.
11 11
12 \snippet ../examples/splinechart/splinewidget.cpp 1
12 \snippet ../examples/splinechart/main.cpp 1
13 13
14 14 Customize the look of the spline, by setting its pen's color and pen's width
15 15
16 \snippet ../examples/splinechart/splinewidget.cpp 2
16 \snippet ../examples/splinechart/main.cpp 2
17 17
18 18 Now lets add some data points to the series.
19 19
20 \snippet ../examples/splinechart/splinewidget.cpp add points to series
20 \snippet ../examples/splinechart/main.cpp 3
21 21
22 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.
22 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.
23 23
24 \snippet ../examples/splinechart/splinewidget.cpp 3
24 \snippet ../examples/splinechart/main.cpp 4
25 25
26 Then we add two buttons for adding and removing data points. Buttons clicked() signals are connected to handler functions.
26 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.
27 27
28 \snippet ../examples/splinechart/splinewidget.cpp 4
28 \snippet ../examples/splinechart/main.cpp 5
29 29
30 In the end we add the chart and the buttons to the widget's layout.
31
32 \snippet ../examples/splinechart/splinewidget.cpp 5
33
34 Here is the handler function for add new data point button:
35
36 \snippet ../examples/splinechart/splinewidget.cpp add point
37
38 And here is one for remove the last data point in the series:
39
40 \snippet ../examples/splinechart/splinewidget.cpp remove point
30 In the end we set the QChartView as the windows's central widget.
41 31
32 \snippet ../examples/splinechart/main.cpp 6
42 33 */
@@ -31,38 +31,41 int main(int argc, char *argv[])
31 31
32 32 //![1]
33 33 QSplineSeries* series = new QSplineSeries();
34 //![1]
35
36 //![2]
34 37 QPen red(Qt::red);
35 38 red.setWidth(3);
36 39 series->setPen(red);
37 //![1]
38
39 40 //![2]
41
42 //![3]
40 43 series->append(0, 6);
41 44 series->append(2, 4);
42 45 series->append(3, 8);
43 46 series->append(7, 4);
44 47 series->append(10, 5);
45 48 *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);
46 //![2]
47
48 49 //![3]
50
51 //![4]
49 52 QChart* chart = new QChart();
50 53 chart->addSeries(series);
51 54 chart->setTitle("Simple spline chart example");
52 55 chart->axisY()->setRange(0, 10);
53 //![3]
54
55 56 //![4]
57
58 //![5]
56 59 QChartView* chartView = new QChartView(chart);
57 60 chartView->setRenderHint(QPainter::Antialiasing);
58 //![4]
59
60 61 //![5]
62
63 //![6]
61 64 QMainWindow window;
62 65 window.setCentralWidget(chartView);
63 66 window.resize(400, 300);
64 67 window.show();
65 //![5]
68 //![6]
66 69
67 70 return a.exec();
68 71 }
@@ -108,7 +108,7 void QBarSeries::appendBarSets(QList<QBarSet* > sets)
108 108 }
109 109
110 110 /*!
111 Removes a list of barsets from series. Releases ownership of \a set. Doesnt delete \a sets.
111 Removes a list of barsets from series. Releases ownership of \a sets. Doesnt delete \a sets.
112 112 Disconnects the clicked(QString, Qt::MouseButtons) signal
113 113 of \a sets from this series
114 114 */
@@ -121,17 +121,30 void QBarSeries::removeBarSets(QList<QBarSet* > sets)
121 121 emit restructuredBars();
122 122 }
123 123
124 /*!
125 Inserts new \a set on the \a i position.
126 The barset that is currently at this postion is moved to postion i + 1
127 */
124 128 void QBarSeries::insertBarSet(int i, QBarSet *set)
125 129 {
126 130 m_internalModel->insertBarSet(i, set);
127 131 // emit barsetChanged();
128 132 }
129 133
134 /*!
135 Inserts new \a category on the \a i position.
136 The category that is currently at this postion is moved to postion i + 1
137 \sa removeCategory()
138 */
130 139 void QBarSeries::insertCategory(int i, QString category)
131 140 {
132 141 m_internalModel->insertCategory(i, category);
133 142 }
134 143
144 /*!
145 Removes the category specified by \a i
146 \sa insertCategory()
147 */
135 148 void QBarSeries::removeCategory(int i)
136 149 {
137 150 m_internalModel->removeCategory(i);
@@ -102,11 +102,20 QBarSet& QBarSet::operator << (const qreal &value)
102 102 return *this;
103 103 }
104 104
105 /*!
106 Inserts new \a value on the \a i position.
107 The value that is currently at this postion is moved to postion i + 1
108 \sa removeValue()
109 */
105 110 void QBarSet::insertValue(int i, qreal value)
106 111 {
107 112 m_values.insert(i, value);
108 113 }
109 114
115 /*!
116 Removes the value specified by \a i
117 \sa insertValue()
118 */
110 119 void QBarSet::removeValue(int i)
111 120 {
112 121 m_values.removeAt(i);
General Comments 0
You need to be logged in to leave comments. Login now