@@ -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 |
INCLUDEPATH += $$PWD |
|
1 | INCLUDEPATH += $$PWD | |
2 | DEPENDPATH += $$PWD |
|
2 | DEPENDPATH += $$PWD | |
3 |
|
3 | SOURCES += linechart.cpp \ | ||
4 | SOURCES+= \ |
|
4 | scatterchart.cpp \ | |
5 |
|
|
5 | splinechart.cpp \ | |
6 |
|
|
6 | verticalstackedbarchart.cpp \ | |
7 | splinechart.cpp \ |
|
7 | horizontalstackedbarchart.cpp \ | |
8 |
|
|
8 | verticalbarchart.cpp \ | |
9 |
|
|
9 | horizontalbarchart.cpp \ | |
10 |
|
|
10 | horizontalpercentbarchart.cpp \ | |
11 |
|
|
11 | verticalpercentbarchart.cpp \ | |
12 |
|
|
12 | areachart.cpp \ | |
13 |
|
|
13 | piechart.cpp \ | |
|
14 | donutchart.cpp |
@@ -296,6 +296,8 void Window::checkTemplate() | |||||
296 | if (m_template == index || index == 0) |
|
296 | if (m_template == index || index == 0) | |
297 | return; |
|
297 | return; | |
298 |
|
298 | |||
|
299 | m_template = index; | |||
|
300 | ||||
299 | QString category = m_templateComboBox->itemData(index).toString(); |
|
301 | QString category = m_templateComboBox->itemData(index).toString(); | |
300 | Charts::ChartList list = Charts::chartList(); |
|
302 | Charts::ChartList list = Charts::chartList(); | |
301 |
|
303 |
General Comments 0
You need to be logged in to leave comments.
Login now