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