##// END OF EJS Templates
Update donutbreakdown data source (again)
Jani Honkonen -
r1954:7b92a2c2f2ec
parent child
Show More
@@ -1,78 +1,77
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20 #include <QApplication>
20 #include <QApplication>
21 #include <QMainWindow>
21 #include <QMainWindow>
22 #include <QStatusBar>
22 #include <QStatusBar>
23 #include <QChartView>
23 #include <QChartView>
24 #include "donutbreakdownchart.h"
24 #include "donutbreakdownchart.h"
25
25
26 QTCOMMERCIALCHART_USE_NAMESPACE
26 QTCOMMERCIALCHART_USE_NAMESPACE
27
27
28 int main(int argc, char *argv[])
28 int main(int argc, char *argv[])
29 {
29 {
30 QApplication a(argc, argv);
30 QApplication a(argc, argv);
31
31
32 //![1]
32 //![1]
33 // Graph is based on data of 'Total consumption of energy increased by 10 per cent in 2010'
34 // Statistics Finland, 13 December 2011
35 // http://www.stat.fi/til/ekul/2010/ekul_2010_2011-12-13_tie_001_en.html
36
33 QPieSeries *series1 = new QPieSeries();
37 QPieSeries *series1 = new QPieSeries();
34 series1->setName("Fossil fuels");
38 series1->setName("Fossil fuels");
35 series1->append("Oil", 353295);
39 series1->append("Oil", 353295);
36 series1->append("Coal", 188500);
40 series1->append("Coal", 188500);
37 series1->append("Natural gas", 148680);
41 series1->append("Natural gas", 148680);
38 series1->append("Peat", 94545);
42 series1->append("Peat", 94545);
39
43
40 QPieSeries *series2 = new QPieSeries();
44 QPieSeries *series2 = new QPieSeries();
41 series2->setName("Renewables");
45 series2->setName("Renewables");
42 series2->append("Wood fuels", 319663);
46 series2->append("Wood fuels", 319663);
43 series2->append("Hydro power", 45875);
47 series2->append("Hydro power", 45875);
44 series2->append("Wind power", 1060);
48 series2->append("Wind power", 1060);
45
49
46 QPieSeries *series3 = new QPieSeries();
50 QPieSeries *series3 = new QPieSeries();
47 series3->setName("Others");
51 series3->setName("Others");
48 series3->append("Nuclear energy", 238789);
52 series3->append("Nuclear energy", 238789);
49 series3->append("Import energy", 37802);
53 series3->append("Import energy", 37802);
50 series3->append("Other", 32441);
54 series3->append("Other", 32441);
51 //![1]
55 //![1]
52
56
53 //![2]
57 //![2]
54 DonutBreakdownChart *donutBreakdown = new DonutBreakdownChart();
58 DonutBreakdownChart *donutBreakdown = new DonutBreakdownChart();
55 donutBreakdown->setAnimationOptions(QChart::AllAnimations);
59 donutBreakdown->setAnimationOptions(QChart::AllAnimations);
56 donutBreakdown->setTitle("Total consumption of energy in Finland 2010");
60 donutBreakdown->setTitle("Total consumption of energy in Finland 2010");
57 donutBreakdown->legend()->setVisible(false);
61 donutBreakdown->legend()->setVisible(false);
58 donutBreakdown->addBreakdownSeries(series1, Qt::red);
62 donutBreakdown->addBreakdownSeries(series1, Qt::red);
59 donutBreakdown->addBreakdownSeries(series2, Qt::darkGreen);
63 donutBreakdown->addBreakdownSeries(series2, Qt::darkGreen);
60 donutBreakdown->addBreakdownSeries(series3, Qt::darkBlue);
64 donutBreakdown->addBreakdownSeries(series3, Qt::darkBlue);
61 //![2]
65 //![2]
62
66
63 //![3]
67 //![3]
64 QMainWindow window;
68 QMainWindow window;
65 QChartView* chartView = new QChartView(donutBreakdown);
69 QChartView* chartView = new QChartView(donutBreakdown);
66 chartView->setRenderHint(QPainter::Antialiasing);
70 chartView->setRenderHint(QPainter::Antialiasing);
67 window.setCentralWidget(chartView);
71 window.setCentralWidget(chartView);
68 window.resize(800, 600);
72 window.resize(800, 600);
69 window.show();
73 window.show();
70 //![3]
74 //![3]
71
72 // Data is taken from Statistics Finland:
73 // http://www.stat.fi/til/ekul/2010/ekul_2010_2011-12-13_tie_001_en.html
74 window.statusBar()->setFont(QFont("Arial", 7));
75 window.statusBar()->showMessage("Graph is based on data of 'Total consumption of energy increased by 10 per cent in 2010' Statistics Finland, 13 December 2011");
76
75
77 return a.exec();
76 return a.exec();
78 }
77 }
General Comments 0
You need to be logged in to leave comments. Login now