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