##// END OF EJS Templates
minor. formating
Michal Klocek -
r422:d5d550c80366
parent child
Show More
@@ -1,30 +1,30
1 1 /*!
2 2 \example example/areachart
3 3 \title AreaChart Example
4 4 \subtitle
5 5
6 6 The example shows how to create simple area chart.
7 7
8 8 \image areachart.png
9 9
10 10 To create area charts, we need two QLineSeries instances. They are going to define upper and lower boundary of the area.
11 11
12 12 \snippet ../example/areachart/main.cpp 1
13 13
14 14 We add data to both series, we use stream operator.
15 15
16 16 \snippet ../example/areachart/main.cpp 2
17 17
18 18 Now we create QAreaSeries instance using two line series objects. We set the custom gradient fill and width of the outline.
19 19
20 20 \snippet ../example/areachart/main.cpp 3
21 21
22 In the end we create QChartView instance, set title, set anti-aliasing and add area series. We also set the specific range for axes.
22 In the end we create QChartView instance, set title, set anti-aliasing and add area series. We also set the specific range for axes.
23 23
24 24 \snippet ../example/areachart/main.cpp 4
25 25
26 26 Chart is ready to be shown.
27 27
28 28 \snippet ../example/areachart/main.cpp 5
29 29
30 30 */ No newline at end of file
@@ -1,59 +1,59
1 1 #include <QApplication>
2 2 #include <QMainWindow>
3 3 #include <qchartview.h>
4 4 #include <qlineseries.h>
5 5 #include <qareaseries.h>
6 6 #include <qchart.h>
7 7 #include <qchartaxis.h>
8 8 #include <cmath>
9 9
10 10 QTCOMMERCIALCHART_USE_NAMESPACE
11 11
12 12 int main(int argc, char *argv[])
13 13 {
14 14 QApplication a(argc, argv);
15 15
16 16 //![1]
17 17
18 18 QLineSeries* series0 = new QLineSeries();
19 19 QLineSeries* series1 = new QLineSeries();
20 20
21 21 //![1]
22 22
23 23 //![2]
24 *series0 << QPointF(1, 5) << QPointF(3, 7) << QPointF(7, 6) << QPointF(9, 7) << QPointF(12,6)<<QPointF(16,7)<<QPointF(18,5);
25 *series1 << QPointF(1, 3) << QPointF(3, 4) << QPointF(7, 3) << QPointF(8, 2) << QPointF(12,3)<<QPointF(16,4)<<QPointF(18,3);
24 *series0 << QPointF(1, 5) << QPointF(3, 7) << QPointF(7, 6) << QPointF(9, 7) << QPointF(12,6) << QPointF(16,7) << QPointF(18,5);
25 *series1 << QPointF(1, 3) << QPointF(3, 4) << QPointF(7, 3) << QPointF(8, 2) << QPointF(12,3) << QPointF(16,4) << QPointF(18,3);
26 26 //![2]
27 27 //![3]
28 28
29 29 QAreaSeries* series = new QAreaSeries(series0,series1);
30 30 QPen pen(0x059605);
31 31 pen.setWidth(3);
32 32 series->setPen(pen);
33 33
34 34 QLinearGradient gradient(QPointF(0, 0), QPointF(0, 1));
35 35 gradient.setColorAt(0.0,0x3cc63c);
36 36 gradient.setColorAt(1.0, 0x26f626);
37 37 gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
38 38 series->setBrush(gradient);
39 39
40 40 //![3]
41 41 //![4]
42 42 QMainWindow window;
43 43 QChartView* chartView = new QChartView(&window);
44 44
45 45 chartView->setChartTitle("Basic area chart example");
46 46 chartView->setRenderHint(QPainter::Antialiasing);
47 47
48 48 chartView->addSeries(series);
49 49 chartView->axisX()->setRange(0,20);
50 50 chartView->axisY()->setRange(0,10);
51 51 //![4]
52 52 //![5]
53 53 window.setCentralWidget(chartView);
54 54 window.resize(400, 300);
55 55 window.show();
56 56 //![5]
57 57
58 58 return a.exec();
59 59 }
General Comments 0
You need to be logged in to leave comments. Login now