##// END OF EJS Templates
revert donutchart back to original
Jani Honkonen -
r1876:f742f8cdc33a
parent child
Show More
@@ -1,62 +1,62
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
20
21 #include <QApplication>
21 #include <QApplication>
22 #include <QMainWindow>
22 #include <QMainWindow>
23 #include <QChartView>
23 #include <QChartView>
24 #include <QPieSeries>
24 #include <QPieSeries>
25 #include <QPieSlice>
25 #include <QPieSlice>
26 #include <QDebug>
26 #include <QDebug>
27 QTCOMMERCIALCHART_USE_NAMESPACE
27 QTCOMMERCIALCHART_USE_NAMESPACE
28
28
29 int main(int argc, char *argv[])
29 int main(int argc, char *argv[])
30 {
30 {
31 QApplication a(argc, argv);
31 QApplication a(argc, argv);
32
32
33 //![1]
33 //![1]
34 QPieSeries *series = new QPieSeries();
34 QPieSeries *series = new QPieSeries();
35 series->setHoleSize(0.35);
35 series->setHoleSize(0.35);
36 series->append("Protein 4.2%", 4.2);
36 series->append("Protein 4.2%", 4.2);
37 QPieSlice *slice = series->append("Fat 15.6%", 15.6);
37 QPieSlice *slice = series->append("Fat 15.6%", 15.6);
38 slice->setExploded();
38 slice->setExploded();
39 slice->setLabelVisible();
39 slice->setLabelVisible();
40 series->append("Other 23.8%", 23.8);
40 series->append("Other 23.8%", 23.8);
41 series->append("Carbs 56.4%", 56.4);
41 series->append("Carbs 56.4%", 56.4);
42 //![1]
42 //![1]
43
43
44 //![2]
44 //![2]
45 QChartView* chartView = new QChartView();
45 QChartView* chartView = new QChartView();
46 chartView->setRenderHint(QPainter::Antialiasing);
46 chartView->setRenderHint(QPainter::Antialiasing);
47 chartView->chart()->setTitle("Donut with a lemon glaze (100g)");
47 chartView->chart()->setTitle("Donut with a lemon glaze (100g)");
48 chartView->chart()->addSeries(series);
48 chartView->chart()->addSeries(series);
49 chartView->chart()->legend()->setAlignment(Qt::AlignLeft);
49 chartView->chart()->legend()->setAlignment(Qt::AlignBottom);
50 chartView->chart()->setTheme(QChart::ChartThemeBlueCerulean);
50 chartView->chart()->setTheme(QChart::ChartThemeBlueCerulean);
51 //chartView->chart()->legend()->setFont(QFont("Arial", 7));
51 chartView->chart()->legend()->setFont(QFont("Arial", 7));
52 //![2]
52 //![2]
53
53
54 //![3]
54 //![3]
55 QMainWindow window;
55 QMainWindow window;
56 window.setCentralWidget(chartView);
56 window.setCentralWidget(chartView);
57 window.resize(400, 300);
57 window.resize(400, 300);
58 window.show();
58 window.show();
59 //![3]
59 //![3]
60
60
61 return a.exec();
61 return a.exec();
62 }
62 }
General Comments 0
You need to be logged in to leave comments. Login now