##// 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
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 <li><a href="example-barchart.html">Bar Chart example</a></li>
17 <li><a href="example-barchart.html">Bar Chart example</a></li>
18 <li><a href="example-stackedbarchart.html">Stacked Bar Chart example</a></li>
18 <li><a href="example-stackedbarchart.html">Stacked Bar Chart example</a></li>
19 <li><a href="example-percentbarchart.html">Percent Bar Chart example</a></li>
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 <li><a href="example-stackedbarchartdrilldown.html">Stacked Bar Chart Drilldown example</a></li>
21 <li><a href="example-stackedbarchartdrilldown.html">Stacked Bar Chart Drilldown example</a></li>
21 <li><a href="example-linechart.html">Line Chart example</a></li>
22 <li><a href="example-linechart.html">Line Chart example</a></li>
22 <li><a href="example-piechart.html">Pie Chart example</a></li>
23 <li><a href="example-piechart.html">Pie Chart example</a></li>
@@ -19,12 +19,12
19 <td><a href="example-areachart.html"><img src="images/areachart.png" alt="areachart" /></a></td>
19 <td><a href="example-areachart.html"><img src="images/areachart.png" alt="areachart" /></a></td>
20 </tr>
20 </tr>
21 <tr>
21 <tr>
22 <td><a href="example-scatterchart.html"><img src="images/scatterchart.png" alt="scatterchart" /></a></td>
22 <td><a href="example-barchart.html"><img src="images/barchart.png" alt="barchart" /></a></td>
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 </tr>
24 </tr>
25 <tr>
25 <tr>
26 <td><a href="example-stackedbarchart.html"><img src="images/stackedbarchart.png" alt="stackedbarchart" /></a></td>
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 </tr><tr>
28 </tr><tr>
29 <td><img src="images/chartview_example_scatter.jpg " alt="scatterchart" /></td>
29 <td><img src="images/chartview_example_scatter.jpg " alt="scatterchart" /></td>
30 <td><img src="images/chartview_example_theme.jpg " alt="themechart" /></td>
30 <td><img src="images/chartview_example_theme.jpg " alt="themechart" /></td>
@@ -33,6 +33,9
33 <td><img src="images/chartview_example_bar.jpg " alt="barchart" /></td>
33 <td><img src="images/chartview_example_bar.jpg " alt="barchart" /></td>
34 <td><img src="images/chartview_example_pie.jpg " alt="piechart" /></td>
34 <td><img src="images/chartview_example_pie.jpg " alt="piechart" /></td>
35 </tr>
35 </tr>
36 <tr>
37 <td><img src="images/chartview_example.jpg " alt="linechart" /></td>
38 </tr>
36 </table>
39 </table>
37 </div>
40 </div>
38 \endraw
41 \endraw
@@ -5,7 +5,7 SUBDIRS += linechart \
5 barchart \
5 barchart \
6 stackedbarchart \
6 stackedbarchart \
7 percentbarchart \
7 percentbarchart \
8 scatter \
8 scatterchart \
9 piechart \
9 piechart \
10 piechartcustomization \
10 piechartcustomization \
11 piechartdrilldown \
11 piechartdrilldown \
@@ -11,41 +11,39 int main(int argc, char *argv[])
11 QApplication a(argc, argv);
11 QApplication a(argc, argv);
12
12
13 //! [1]
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 QScatterSeries *scatter = new QScatterSeries();
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 for (qreal i(0.0); i < 20; i += 0.5) {
27 for (qreal i(0.0); i < 20; i += 0.5) {
20 qreal x = i + (qreal)(rand() % 100) / 100.0;
28 qreal x = i + (qreal) (rand() % 100) / 100.0;
21 qreal y = i + (qreal)(rand() % 100) / 100.0;
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
32 *scatter << QPointF(2.0, 5.5) << QPointF(2.2, 5.4);
25 chartView->addSeries(scatter);
26 //! [1]
27
28 // And more
29 //! [2]
30 // *scatter << QPointF(2.0, 5.5) << QPointF(2.2, 5.4);
31 //! [2]
33 //! [2]
32
34
33 //! [3]
35 //! [3]
34 QBrush brush(Qt::red);
36 QMainWindow window;
35 scatter->setBrush(brush);
37 QChartView *chartView = new QChartView(&window);
36 QPen pen(Qt::black);
38 chartView->setRenderHint(QPainter::Antialiasing);
37 pen.setWidth(3);
39 chartView->setChartTitle("Basic scatter chart example");
38 scatter->setPen(pen);
40 chartView->addSeries(scatter);
39 scatter->setShape(QScatterSeries::MarkerShapeCircle);
40 scatter->setSize(25.0);
41 //! [3]
41 //! [3]
42
42
43 // Use the chart widget as the central widget
43 //! [4]
44 QMainWindow w;
44 window.setCentralWidget(chartView);
45 w.resize(400, 300);
45 window.resize(400, 300);
46 w.setCentralWidget(chartView);
46 window.show();
47 // w.setWindowFlags(Qt::FramelessWindowHint);
47 //! [4]
48 w.show();
49
50 return a.exec();
48 return a.exec();
51 }
49 }
@@ -1,5 +1,5
1 !include( ../example.pri ) {
1 !include( ../example.pri ) {
2 error( "Couldn't find the example.pri file!" )
2 error( "Couldn't find the example.pri file!" )
3 }
3 }
4 TARGET = scatter
4 TARGET = scatterchart
5 SOURCES += main.cpp
5 SOURCES += main.cpp
General Comments 0
You need to be logged in to leave comments. Login now