##// END OF EJS Templates
Update scatter example and docs
Michal Klocek -
r471:b6db000cfc58
parent child
Show More
1 NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,26
1 /*!
2 \example example/scatterchart
3 \title ScatterChart Example
4 \subtitle
5
6 The example shows how to create simple scatter chart.
7
8 \image scatterchart.png
9
10 To create scatter charts, QScatterSeries instance is needed. Here we create scatter series instance and we set the type, color and width of outline for scatter points.
11
12 \snippet ../example/scatterchart/main.cpp 1
13
14 We add data to be shown. We can use add() member function or use stream operator.
15
16 \snippet ../example/scatterchart/main.cpp 2
17
18 In the end we create QChartView instance, set title, set anti-aliasing and add scatter series.
19
20 \snippet ../example/scatterchart/main.cpp 3
21
22 Chart is ready to be shown.
23
24 \snippet ../example/scatterchart/main.cpp 4
25
26 */ No newline at end of file
@@ -17,6 +17,7
17 17 <li><a href="example-barchart.html">Bar Chart example</a></li>
18 18 <li><a href="example-stackedbarchart.html">Stacked Bar Chart example</a></li>
19 19 <li><a href="example-percentbarchart.html">Percent Bar Chart example</a></li>
20 <li><a href="example-scatterchart.html">Scatter Chart example</a></li>
20 21 <li><a href="example-stackedbarchartdrilldown.html">Stacked Bar Chart Drilldown example</a></li>
21 22 <li><a href="example-linechart.html">Line Chart example</a></li>
22 23 <li><a href="example-piechart.html">Pie Chart example</a></li>
@@ -19,12 +19,12
19 19 <td><a href="example-areachart.html"><img src="images/areachart.png" alt="areachart" /></a></td>
20 20 </tr>
21 21 <tr>
22 <td><a href="example-scatterchart.html"><img src="images/scatterchart.png" alt="scatterchart" /></a></td>
22 23 <td><a href="example-barchart.html"><img src="images/barchart.png" alt="barchart" /></a></td>
23 <td><a href="example-percentbarchart.html"><img src="images/percentbarchart.png" alt="percentbarcchart" /></a></td>
24 24 </tr>
25 25 <tr>
26 26 <td><a href="example-stackedbarchart.html"><img src="images/stackedbarchart.png" alt="stackedbarchart" /></a></td>
27 <td><img src="images/chartview_example.jpg " alt="linechart" /></td>
27 <td><a href="example-percentbarchart.html"><img src="images/percentbarchart.png" alt="percentbarcchart" /></a></td>
28 28 </tr><tr>
29 29 <td><img src="images/chartview_example_scatter.jpg " alt="scatterchart" /></td>
30 30 <td><img src="images/chartview_example_theme.jpg " alt="themechart" /></td>
@@ -33,6 +33,9
33 33 <td><img src="images/chartview_example_bar.jpg " alt="barchart" /></td>
34 34 <td><img src="images/chartview_example_pie.jpg " alt="piechart" /></td>
35 35 </tr>
36 <tr>
37 <td><img src="images/chartview_example.jpg " alt="linechart" /></td>
38 </tr>
36 39 </table>
37 40 </div>
38 41 \endraw
@@ -5,7 +5,7 SUBDIRS += linechart \
5 5 barchart \
6 6 stackedbarchart \
7 7 percentbarchart \
8 scatter \
8 scatterchart \
9 9 piechart \
10 10 piechartcustomization \
11 11 piechartdrilldown \
@@ -11,41 +11,39 int main(int argc, char *argv[])
11 11 QApplication a(argc, argv);
12 12
13 13 //! [1]
14 // Create chart view
15 QChartView *chartView = new QChartView();
16 chartView->setRenderHint(QPainter::Antialiasing);
17 // Add scatter series with linear test data with random "noise"
18 14 QScatterSeries *scatter = new QScatterSeries();
15
16 QBrush brush(Qt::red);
17 QPen pen(Qt::black);
18 pen.setWidth(2);
19
20 scatter->setPen(pen);
21 scatter->setBrush(brush);
22 scatter->setShape(QScatterSeries::MarkerShapeCircle);
23 scatter->setSize(15.0);
24 //! [1]
25
26 //! [2]
19 27 for (qreal i(0.0); i < 20; i += 0.5) {
20 28 qreal x = i + (qreal)(rand() % 100) / 100.0;
21 29 qreal y = i + (qreal)(rand() % 100) / 100.0;
22 (*scatter) << QPointF(x, y);
30 scatter->add(x, y);
23 31 }
24 // Chart takes ownership
25 chartView->addSeries(scatter);
26 //! [1]
27
28 // And more
29 //! [2]
30 // *scatter << QPointF(2.0, 5.5) << QPointF(2.2, 5.4);
32 *scatter << QPointF(2.0, 5.5) << QPointF(2.2, 5.4);
31 33 //! [2]
32 34
33 35 //! [3]
34 QBrush brush(Qt::red);
35 scatter->setBrush(brush);
36 QPen pen(Qt::black);
37 pen.setWidth(3);
38 scatter->setPen(pen);
39 scatter->setShape(QScatterSeries::MarkerShapeCircle);
40 scatter->setSize(25.0);
36 QMainWindow window;
37 QChartView *chartView = new QChartView(&window);
38 chartView->setRenderHint(QPainter::Antialiasing);
39 chartView->setChartTitle("Basic scatter chart example");
40 chartView->addSeries(scatter);
41 41 //! [3]
42 42
43 // Use the chart widget as the central widget
44 QMainWindow w;
45 w.resize(400, 300);
46 w.setCentralWidget(chartView);
47 // w.setWindowFlags(Qt::FramelessWindowHint);
48 w.show();
49
43 //! [4]
44 window.setCentralWidget(chartView);
45 window.resize(400, 300);
46 window.show();
47 //! [4]
50 48 return a.exec();
51 49 }
@@ -1,5 +1,5
1 1 !include( ../example.pri ) {
2 2 error( "Couldn't find the example.pri file!" )
3 3 }
4 TARGET = scatter
4 TARGET = scatterchart
5 5 SOURCES += main.cpp
General Comments 0
You need to be logged in to leave comments. Login now