@@ -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); |
@@ -20,7 +20,8 SOURCES += \ | |||
|
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 |
@@ -33,7 +33,7 public: | |||
|
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 | { |
@@ -33,7 +33,7 public: | |||
|
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 | { |
General Comments 0
You need to be logged in to leave comments.
Login now