##// END OF EJS Templates
Adds mulitbarvalueaxis eample to charviewer
Michal Klocek -
r2143:394c0457c4c4
parent child
Show More
@@ -0,0 +1,108
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 "qlineseries.h"
24 #include "qvalueaxis.h"
25 #include "qcategoryaxis.h"
26 #include "qbarseries.h"
27 #include "qbarset.h"
28 #include "qbarcategoryaxis.h"
29
30 class MultiValueBarAxis: public Chart
31 {
32 public:
33 QString name()
34 {
35 return "Axis";
36 }
37 QString category()
38 {
39 return QObject::tr("MultiAxis");
40 }
41 QString subCategory()
42 {
43 return "MultiBarAxis";
44 }
45
46 QChart *createChart(const DataTable &table)
47 {
48 QChart *chart = new QChart();
49 QValueAxis *axisX;
50 QValueAxis *axisY;
51 QBarSeries *series = new QBarSeries();
52 QBarCategoryAxis *barcategory = new QBarCategoryAxis();
53
54 chart->setTitle("MultiBarAxis");
55
56 QString name("Series");
57 int nameIndex = 1;
58 for (int i(0); i < 2; i++) {
59 QLineSeries *series = new QLineSeries(chart);
60 foreach (Data data, table.at(i))
61 series->append(data.first);
62 series->setName(name + QString::number(nameIndex));
63
64 chart->addSeries(series);
65 axisX = new QValueAxis();
66 axisX->setLinePenColor(series->pen().color());
67 axisX->setTitle("ValueAxis for series" + QString::number(nameIndex));
68 if (nameIndex % 2)
69 axisX->setAlignment(Qt::AlignTop);
70 else
71 axisX->setAlignment(Qt::AlignBottom);
72 axisY = new QValueAxis();
73 axisY->setLinePenColor(series->pen().color());
74 axisY->setTitle("ValueAxis for series" + QString::number(nameIndex));
75
76 if (nameIndex % 2)
77 axisY->setAlignment(Qt::AlignRight);
78 else
79 axisY->setAlignment(Qt::AlignLeft);
80
81 chart->setAxisX(axisX, series);
82 chart->setAxisY(axisY, series);
83 nameIndex++;
84 }
85
86 QBarSet *set = new QBarSet("Bar set ");
87 foreach (Data data, table.at(2))
88 *set << data.first.y();
89
90 int count = set->count();
91 for (int i = 0; i < count; i++) {
92 barcategory->append("BarSet " + QString::number(i));
93 }
94 series->append(set);
95 chart->addSeries(series);
96
97 barcategory->setLinePen(set->brush().color());
98 barcategory->setGridLinePen(set->brush().color());
99 barcategory->setTitle("BarCategoryAxis Title");
100
101 chart->setAxisX(barcategory, series);
102
103 return chart;
104 }
105 };
106
107
108 DECLARE_CHART(MultiValueBarAxis);
@@ -1,26 +1,27
1 1 INCLUDEPATH += $$PWD
2 2 DEPENDPATH += $$PWD
3 3 SOURCES += \
4 4 font/font.cpp \
5 5 xyseries/linechart.cpp \
6 6 xyseries/scatterchart.cpp \
7 7 xyseries/splinechart.cpp \
8 8 xyseries/areachart.cpp \
9 9 barseries/verticalstackedbarchart.cpp \
10 10 barseries/horizontalstackedbarchart.cpp \
11 11 barseries/verticalbarchart.cpp \
12 12 barseries/horizontalbarchart.cpp \
13 13 barseries/horizontalpercentbarchart.cpp \
14 14 barseries/verticalpercentbarchart.cpp \
15 15 pieseries/piechart.cpp \
16 16 pieseries/donutchart.cpp \
17 17 axis/valueaxis.cpp \
18 18 axis/categoryaxis.cpp \
19 19 axis/barcategoryaxisx.cpp \
20 20 axis/barcategoryaxisy.cpp \
21 21 axis/datetimeaxisx.cpp \
22 22 axis/datetimeaxisy.cpp \
23 axis/multivalueaxis.cpp \
24 axis/multivalueaxis2.cpp \
25 axis/multivalueaxis3.cpp \
26 axis/multivalueaxis4.cpp No newline at end of file
23 multiaxis/multivalueaxis.cpp \
24 multiaxis/multivalueaxis2.cpp \
25 multiaxis/multivalueaxis3.cpp \
26 multiaxis/multivalueaxis4.cpp \
27 multiaxis/multivaluebaraxis.cpp No newline at end of file
@@ -1,83 +1,83
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
21 21 #include "charts.h"
22 22 #include "qchart.h"
23 23 #include "qlineseries.h"
24 24 #include "qvalueaxis.h"
25 25 #include "qcategoryaxis.h"
26 26
27 27 class MultiValueAxis: public Chart
28 28 {
29 29 public:
30 30 QString name()
31 31 {
32 32 return "AxisSet 1";
33 33 }
34 34 QString category()
35 35 {
36 return QObject::tr("Axis");
36 return QObject::tr("MultiAxis");
37 37 }
38 38 QString subCategory()
39 39 {
40 40 return "MultiValueAxis";
41 41 }
42 42
43 43 QChart *createChart(const DataTable &table)
44 44 {
45 45 QChart *chart = new QChart();
46 46 QValueAxis *axisX;
47 47 QValueAxis *axisY;
48 48
49 49 chart->setTitle("MultiValueAxis1");
50 50
51 51 QString name("Series");
52 52 int nameIndex = 0;
53 53 foreach (DataList list, table) {
54 54 QLineSeries *series = new QLineSeries(chart);
55 55 foreach (Data data, list)
56 56 series->append(data.first);
57 57 series->setName(name + QString::number(nameIndex));
58 58
59 59 chart->addSeries(series);
60 60 axisX = new QValueAxis();
61 61 axisX->setLinePenColor(series->pen().color());
62 62 if (nameIndex % 2)
63 63 axisX->setAlignment(Qt::AlignTop);
64 64 else
65 65 axisX->setAlignment(Qt::AlignBottom);
66 66 axisY = new QValueAxis();
67 67 axisY->setLinePenColor(series->pen().color());
68 68
69 69 if (nameIndex % 2)
70 70 axisY->setAlignment(Qt::AlignRight);
71 71 else
72 72 axisY->setAlignment(Qt::AlignLeft);
73 73
74 74 chart->setAxisX(axisX, series);
75 75 chart->setAxisY(axisY, series);
76 76 nameIndex++;
77 77 }
78 78
79 79 return chart;
80 80 }
81 81 };
82 82
83 83 DECLARE_CHART(MultiValueAxis);
@@ -1,83 +1,83
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
21 21 #include "charts.h"
22 22 #include "qchart.h"
23 23 #include "qlineseries.h"
24 24 #include "qvalueaxis.h"
25 25 #include "qcategoryaxis.h"
26 26
27 27 class MultiValueAxis2: public Chart
28 28 {
29 29 public:
30 30 QString name()
31 31 {
32 32 return "AxisSet 2";
33 33 }
34 34 QString category()
35 35 {
36 return QObject::tr("Axis");
36 return QObject::tr("MultiAxis");
37 37 }
38 38 QString subCategory()
39 39 {
40 40 return "MultiValueAxis";
41 41 }
42 42
43 43 QChart *createChart(const DataTable &table)
44 44 {
45 45 QChart *chart = new QChart();
46 46 QValueAxis *axisX;
47 47 QValueAxis *axisY;
48 48
49 49 chart->setTitle("MultiValueAxis2");
50 50
51 51 QString name("Series");
52 52 int nameIndex = 1;
53 53 foreach (DataList list, table) {
54 54 QLineSeries *series = new QLineSeries(chart);
55 55 foreach (Data data, list)
56 56 series->append(data.first);
57 57 series->setName(name + QString::number(nameIndex));
58 58
59 59 chart->addSeries(series);
60 60 axisX = new QValueAxis();
61 61 axisX->setLinePenColor(series->pen().color());
62 62 if (nameIndex % 2)
63 63 axisX->setAlignment(Qt::AlignTop);
64 64 else
65 65 axisX->setAlignment(Qt::AlignBottom);
66 66 axisY = new QValueAxis();
67 67 axisY->setLinePenColor(series->pen().color());
68 68
69 69 if (nameIndex % 2)
70 70 axisY->setAlignment(Qt::AlignRight);
71 71 else
72 72 axisY->setAlignment(Qt::AlignLeft);
73 73
74 74 chart->setAxisX(axisX, series);
75 75 chart->setAxisY(axisY, series);
76 76 nameIndex++;
77 77 }
78 78
79 79 return chart;
80 80 }
81 81 };
82 82
83 83 DECLARE_CHART(MultiValueAxis2);
@@ -1,88 +1,88
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
21 21 #include "charts.h"
22 22 #include "qchart.h"
23 23 #include "qlineseries.h"
24 24 #include "qvalueaxis.h"
25 25 #include "qcategoryaxis.h"
26 26
27 27 class MultiValueAxis3: public Chart
28 28 {
29 29 public:
30 30 QString name()
31 31 {
32 32 return "AxisSet 3";
33 33 }
34 34 QString category()
35 35 {
36 return QObject::tr("Axis");
36 return QObject::tr("MultiAxis");
37 37 }
38 38 QString subCategory()
39 39 {
40 40 return "MultiValueAxis";
41 41 }
42 42
43 43 QChart *createChart(const DataTable &table)
44 44 {
45 45 QChart *chart = new QChart();
46 46 QValueAxis *axisX;
47 47 QValueAxis *axisY;
48 48
49 49 chart->setTitle("MultiValueAxis3");
50 50
51 51 QString name("Series");
52 52 int nameIndex = 0;
53 53 foreach (DataList list, table) {
54 54 QLineSeries *series = new QLineSeries(chart);
55 55 foreach (Data data, list)
56 56 series->append(data.first);
57 57 series->setName(name + QString::number(nameIndex));
58 58
59 59 chart->addSeries(series);
60 60 axisX = new QValueAxis();
61 61 axisX->setLinePenColor(series->pen().color());
62 62 if (nameIndex % 2){
63 63 axisX->setAlignment(Qt::AlignTop);
64 64 } else{
65 65 axisX->setAlignment(Qt::AlignBottom);
66 66 }
67 67 axisX->setTitle("ValueAxis for series" + QString::number(nameIndex));
68 68
69 69 axisY = new QValueAxis();
70 70 axisY->setLinePenColor(series->pen().color());
71 71
72 72 if (nameIndex % 2){
73 73 axisY->setAlignment(Qt::AlignRight);
74 74 }else{
75 75 axisY->setAlignment(Qt::AlignLeft);
76 76 }
77 77 axisY->setTitle("ValueAxis for series" + QString::number(nameIndex));
78 78
79 79 chart->setAxisX(axisX, series);
80 80 chart->setAxisY(axisY, series);
81 81 nameIndex++;
82 82 }
83 83
84 84 return chart;
85 85 }
86 86 };
87 87
88 88 DECLARE_CHART(MultiValueAxis3);
@@ -1,85 +1,85
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
21 21 #include "charts.h"
22 22 #include "qchart.h"
23 23 #include "qlineseries.h"
24 24 #include "qvalueaxis.h"
25 25 #include "qcategoryaxis.h"
26 26
27 27 class MultiValueAxis4: public Chart
28 28 {
29 29 public:
30 30 QString name()
31 31 {
32 32 return "AxisSet 4";
33 33 }
34 34 QString category()
35 35 {
36 return QObject::tr("Axis");
36 return QObject::tr("MultiAxis");
37 37 }
38 38 QString subCategory()
39 39 {
40 40 return "MultiValueAxis";
41 41 }
42 42
43 43 QChart *createChart(const DataTable &table)
44 44 {
45 45 QChart *chart = new QChart();
46 46 QValueAxis *axisX;
47 47 QValueAxis *axisY;
48 48
49 49 chart->setTitle("MultiValueAxis4");
50 50
51 51 QString name("Series");
52 52 int nameIndex = 1;
53 53 foreach (DataList list, table) {
54 54 QLineSeries *series = new QLineSeries(chart);
55 55 foreach (Data data, list)
56 56 series->append(data.first);
57 57 series->setName(name + QString::number(nameIndex));
58 58
59 59 chart->addSeries(series);
60 60 axisX = new QValueAxis();
61 61 axisX->setLinePenColor(series->pen().color());
62 62 axisX->setTitle("ValueAxis for series" + QString::number(nameIndex));
63 63 if (nameIndex % 2)
64 64 axisX->setAlignment(Qt::AlignTop);
65 65 else
66 66 axisX->setAlignment(Qt::AlignBottom);
67 67 axisY = new QValueAxis();
68 68 axisY->setLinePenColor(series->pen().color());
69 69 axisY->setTitle("ValueAxis for series" + QString::number(nameIndex));
70 70
71 71 if (nameIndex % 2)
72 72 axisY->setAlignment(Qt::AlignRight);
73 73 else
74 74 axisY->setAlignment(Qt::AlignLeft);
75 75
76 76 chart->setAxisX(axisX, series);
77 77 chart->setAxisY(axisY, series);
78 78 nameIndex++;
79 79 }
80 80
81 81 return chart;
82 82 }
83 83 };
84 84
85 85 DECLARE_CHART(MultiValueAxis4);
General Comments 0
You need to be logged in to leave comments. Login now