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