@@ -0,0 +1,57 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | #include "charts.h" | |
|
22 | #include "qchart.h" | |
|
23 | #include "qpieseries.h" | |
|
24 | ||
|
25 | class DonutChart: public Chart | |
|
26 | { | |
|
27 | public: | |
|
28 | QString name() { return QObject::tr("DonutChart"); } | |
|
29 | QString category() { return QObject::tr("PieSeries"); } | |
|
30 | QString subCategory() { return QString::null; } | |
|
31 | ||
|
32 | QChart* createChart(const DataTable& table) | |
|
33 | { | |
|
34 | QChart* chart = new QChart(); | |
|
35 | chart->setTitle("Donut chart"); | |
|
36 | ||
|
37 | for (int i = 0, j = table.count(); i < table.count(); i++,j--) { | |
|
38 | QPieSeries *series = new QPieSeries(chart); | |
|
39 | foreach (Data data, table[i]) { | |
|
40 | QPieSlice *slice = series->append(data.second, data.first.y()); | |
|
41 | if (data == table[i].first()) { | |
|
42 | slice->setLabelVisible(); | |
|
43 | } | |
|
44 | } | |
|
45 | series->setPieSize( j / (qreal) table.count()); | |
|
46 | if(j>1) series->setHoleSize( (j-1)/ (qreal) table.count()+0.1); | |
|
47 | series->setHorizontalPosition(0.5); | |
|
48 | series->setVerticalPosition(0.5); | |
|
49 | chart->addSeries(series); | |
|
50 | } | |
|
51 | return chart; | |
|
52 | } | |
|
53 | ||
|
54 | }; | |
|
55 | ||
|
56 | DECLARE_CHART(DonutChart) | |
|
57 |
@@ -0,0 +1,55 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | #include "charts.h" | |
|
22 | #include "qchart.h" | |
|
23 | #include "qhorizontalpercentbarseries.h" | |
|
24 | #include "qbarset.h" | |
|
25 | ||
|
26 | class HorizontalPercentBarChart: public Chart | |
|
27 | { | |
|
28 | public: | |
|
29 | QString name() { return QObject::tr("HorizontalPercentBarChart"); } | |
|
30 | QString category() { return QObject::tr("BarSeries"); } | |
|
31 | QString subCategory() { return QObject::tr("Horizontal"); } | |
|
32 | ||
|
33 | QChart* createChart(const DataTable& table) | |
|
34 | { | |
|
35 | ||
|
36 | QChart* chart = new QChart(); | |
|
37 | ||
|
38 | chart->setTitle("Horizontal percent chart"); | |
|
39 | ||
|
40 | QHorizontalPercentBarSeries* series = new QHorizontalPercentBarSeries(chart); | |
|
41 | for (int i(0); i < table.count(); i++) { | |
|
42 | QBarSet *set = new QBarSet("Bar set " + QString::number(i)); | |
|
43 | foreach (Data data, table[i]) | |
|
44 | *set << data.first.y(); | |
|
45 | series->append(set); | |
|
46 | } | |
|
47 | chart->addSeries(series); | |
|
48 | chart->createDefaultAxes(); | |
|
49 | return chart; | |
|
50 | } | |
|
51 | ||
|
52 | }; | |
|
53 | ||
|
54 | DECLARE_CHART(HorizontalPercentBarChart) | |
|
55 |
@@ -0,0 +1,55 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | #include "charts.h" | |
|
22 | #include "qchart.h" | |
|
23 | #include "qpercentbarseries.h" | |
|
24 | #include "qbarset.h" | |
|
25 | ||
|
26 | class VerticalPercentBarChart: public Chart | |
|
27 | { | |
|
28 | public: | |
|
29 | QString name() { return QObject::tr("VerticalPercentBarChart"); } | |
|
30 | QString category() { return QObject::tr("BarSeries"); } | |
|
31 | QString subCategory() { return QObject::tr("Vertical"); } | |
|
32 | ||
|
33 | QChart* createChart(const DataTable& table) | |
|
34 | { | |
|
35 | ||
|
36 | QChart* chart = new QChart(); | |
|
37 | ||
|
38 | chart->setTitle("Stacked bar chart"); | |
|
39 | ||
|
40 | QPercentBarSeries* series = new QPercentBarSeries(chart); | |
|
41 | for (int i(0); i < table.count(); i++) { | |
|
42 | QBarSet *set = new QBarSet("Bar set " + QString::number(i)); | |
|
43 | foreach (Data data, table[i]) | |
|
44 | *set << data.first.y(); | |
|
45 | series->append(set); | |
|
46 | } | |
|
47 | chart->addSeries(series); | |
|
48 | chart->createDefaultAxes(); | |
|
49 | return chart; | |
|
50 | } | |
|
51 | ||
|
52 | }; | |
|
53 | ||
|
54 | DECLARE_CHART(VerticalPercentBarChart) | |
|
55 |
@@ -1,13 +1,14 | |||
|
1 | 1 |
INCLUDEPATH += $$PWD |
|
2 | 2 | DEPENDPATH += $$PWD |
|
3 | ||
|
4 | SOURCES+= \ | |
|
5 | linechart.cpp \ | |
|
3 | SOURCES += linechart.cpp \ | |
|
6 | 4 |
|
|
7 | 5 |
|
|
8 | piechart.cpp \ | |
|
9 | 6 |
|
|
10 | 7 |
|
|
11 | 8 |
|
|
12 | 9 |
|
|
13 | areachart.cpp No newline at end of file | |
|
10 | horizontalpercentbarchart.cpp \ | |
|
11 | verticalpercentbarchart.cpp \ | |
|
12 | areachart.cpp \ | |
|
13 | piechart.cpp \ | |
|
14 | donutchart.cpp |
General Comments 0
You need to be logged in to leave comments.
Login now