@@ -1,66 +1,80 | |||||
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 "qbarseries.h" |
|
23 | #include "qbarseries.h" | |
24 | #include "qbarset.h" |
|
24 | #include "qbarset.h" | |
25 | #include "qvalueaxis.h" |
|
25 | #include "qvalueaxis.h" | |
26 | #include "qbarcategoryaxis.h" |
|
26 | #include "qbarcategoryaxis.h" | |
27 |
|
27 | |||
28 | class BarCategoryAxisX: public Chart |
|
28 | class BarCategoryAxisX: public Chart | |
29 | { |
|
29 | { | |
30 | public: |
|
30 | public: | |
31 | QString name() { return "AxisX"; } |
|
31 | QString name() { return "AxisX"; } | |
32 | QString category() { return QObject::tr("Axis"); } |
|
32 | QString category() { return QObject::tr("Axis"); } | |
33 | QString subCategory() { return "BarCategoryAxis"; } |
|
33 | QString subCategory() { return "BarCategoryAxis"; } | |
34 |
|
34 | |||
35 | QChart *createChart(const DataTable &table) |
|
35 | QChart *createChart(const DataTable &table) | |
36 | { |
|
36 | { | |
37 | QChart *chart = new QChart(); |
|
37 | QChart *chart = new QChart(); | |
38 | chart->setTitle(" BarCateogry X , Value Y"); |
|
38 | chart->setTitle(" BarCateogry X , Value Y"); | |
39 |
|
39 | |||
40 | QString name("Series "); |
|
40 | QString name("Series "); | |
41 | QBarSeries *series = new QBarSeries(chart); |
|
41 | QBarSeries *series = new QBarSeries(chart); | |
42 | QValueAxis *valueaxis = new QValueAxis(); |
|
42 | QValueAxis *valueaxis = new QValueAxis(); | |
43 | QBarCategoryAxis *barcategory = new QBarCategoryAxis(); |
|
43 | QBarCategoryAxis *barcategory = new QBarCategoryAxis(); | |
44 | for (int i(0); i < table.count(); i++) { |
|
44 | for (int i(0); i < table.count(); i++) { | |
45 | QBarSet *set = new QBarSet("Bar set " + QString::number(i)); |
|
45 | QBarSet *set = new QBarSet("Bar set " + QString::number(i)); | |
46 | foreach (Data data, table[i]) |
|
46 | foreach (Data data, table[i]) | |
47 | *set << data.first.y(); |
|
47 | *set << data.first.y(); | |
48 | series->append(set); |
|
48 | series->append(set); | |
49 | } |
|
49 | } | |
50 | chart->addSeries(series); |
|
50 | chart->addSeries(series); | |
51 |
|
51 | |||
52 | int count = series->barSets().first()->count(); |
|
52 | int count = series->barSets().first()->count(); | |
53 |
|
53 | |||
54 |
|
54 | |||
55 | for (int i = 0; i < count; i++) { |
|
55 | for (int i = 0; i < count; i++) { | |
56 | barcategory->append("BarSet " + QString::number(i)); |
|
56 | barcategory->append("BarSet " + QString::number(i)); | |
57 | } |
|
57 | } | |
58 |
|
58 | |||
59 | chart->setAxisY(valueaxis, series); |
|
59 | chart->setAxisY(valueaxis, series); | |
60 | chart->setAxisX(barcategory, series); |
|
60 | chart->setAxisX(barcategory, series); | |
61 |
|
61 | |||
62 | return chart; |
|
62 | return chart; | |
63 | } |
|
63 | } | |
64 | }; |
|
64 | }; | |
65 |
|
65 | |||
|
66 | class BarCategoryAxisXTitle: public BarCategoryAxisX | |||
|
67 | { | |||
|
68 | QString name() { return "AxisX Title"; } | |||
|
69 | QChart *createChart(const DataTable &table) | |||
|
70 | { | |||
|
71 | QChart *chart = BarCategoryAxisX::createChart(table); | |||
|
72 | chart->axisX()->setTitle("Axis X"); | |||
|
73 | chart->axisY()->setTitle("Axis Y"); | |||
|
74 | chart->setTitle(" BarCateogry X , Value Y, title"); | |||
|
75 | return chart; | |||
|
76 | } | |||
|
77 | }; | |||
|
78 | ||||
66 | DECLARE_CHART(BarCategoryAxisX); |
|
79 | DECLARE_CHART(BarCategoryAxisX); | |
|
80 | DECLARE_CHART(BarCategoryAxisXTitle); |
@@ -1,65 +1,84 | |||||
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 "qhorizontalbarseries.h" |
|
23 | #include "qhorizontalbarseries.h" | |
24 | #include "qbarset.h" |
|
24 | #include "qbarset.h" | |
25 | #include "qvalueaxis.h" |
|
25 | #include "qvalueaxis.h" | |
26 | #include "qbarcategoryaxis.h" |
|
26 | #include "qbarcategoryaxis.h" | |
27 |
|
27 | |||
28 | class BarCategoryAxisY: public Chart |
|
28 | class BarCategoryAxisY: public Chart | |
29 | { |
|
29 | { | |
30 | public: |
|
30 | public: | |
31 | QString name() { return "AxisY"; } |
|
31 | QString name() { return "AxisY"; } | |
32 | QString category() { return QObject::tr("Axis"); } |
|
32 | QString category() { return QObject::tr("Axis"); } | |
33 | QString subCategory() { return "BarCategoryAxis"; } |
|
33 | QString subCategory() { return "BarCategoryAxis"; } | |
34 |
|
34 | |||
35 | QChart *createChart(const DataTable &table) |
|
35 | QChart *createChart(const DataTable &table) | |
36 | { |
|
36 | { | |
37 | QChart *chart = new QChart(); |
|
37 | QChart *chart = new QChart(); | |
38 | chart->setTitle(" BarCateogry Y , Value X"); |
|
38 | chart->setTitle(" BarCateogry Y , Value X"); | |
39 |
|
39 | |||
40 | QString name("Series "); |
|
40 | QString name("Series "); | |
41 | QHorizontalBarSeries *series = new QHorizontalBarSeries(chart); |
|
41 | QHorizontalBarSeries *series = new QHorizontalBarSeries(chart); | |
42 | QValueAxis *valueaxis = new QValueAxis(); |
|
42 | QValueAxis *valueaxis = new QValueAxis(); | |
43 | QBarCategoryAxis *barcategory = new QBarCategoryAxis(); |
|
43 | QBarCategoryAxis *barcategory = new QBarCategoryAxis(); | |
44 | for (int i(0); i < table.count(); i++) { |
|
44 | for (int i(0); i < table.count(); i++) { | |
45 | QBarSet *set = new QBarSet("Bar set " + QString::number(i)); |
|
45 | QBarSet *set = new QBarSet("Bar set " + QString::number(i)); | |
46 | foreach(Data data, table[i]) |
|
46 | foreach(Data data, table[i]) | |
47 | *set << data.first.y(); |
|
47 | *set << data.first.y(); | |
48 | series->append(set); |
|
48 | series->append(set); | |
49 | } |
|
49 | } | |
50 | chart->addSeries(series); |
|
50 | chart->addSeries(series); | |
51 |
|
51 | |||
52 | int count = series->barSets().first()->count(); |
|
52 | int count = series->barSets().first()->count(); | |
53 |
|
53 | |||
54 | for (int i = 0; i < count; i++) { |
|
54 | for (int i = 0; i < count; i++) { | |
55 | barcategory->append("BarSet " + QString::number(i)); |
|
55 | barcategory->append("BarSet " + QString::number(i)); | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | chart->setAxisX(valueaxis, series); |
|
58 | chart->setAxisX(valueaxis, series); | |
59 | chart->setAxisY(barcategory, series); |
|
59 | chart->setAxisY(barcategory, series); | |
60 |
|
60 | |||
61 | return chart; |
|
61 | return chart; | |
62 | } |
|
62 | } | |
63 | }; |
|
63 | }; | |
64 |
|
64 | |||
|
65 | class BarCategoryAxisYTitle: public BarCategoryAxisY | |||
|
66 | { | |||
|
67 | public: | |||
|
68 | QString name() | |||
|
69 | { | |||
|
70 | return "AxisY Title"; | |||
|
71 | } | |||
|
72 | ||||
|
73 | QChart *createChart(const DataTable &table) | |||
|
74 | { | |||
|
75 | QChart *chart = BarCategoryAxisY::createChart(table); | |||
|
76 | chart->axisX()->setTitle("Axis X"); | |||
|
77 | chart->axisY()->setTitle("Axis Y"); | |||
|
78 | chart->setTitle(" BarCateogry Y , Value X, title"); | |||
|
79 | return chart; | |||
|
80 | } | |||
|
81 | }; | |||
|
82 | ||||
65 | DECLARE_CHART(BarCategoryAxisY); |
|
83 | DECLARE_CHART(BarCategoryAxisY); | |
|
84 | DECLARE_CHART(BarCategoryAxisYTitle); |
@@ -1,68 +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 <QCategoryAxis> |
|
24 | #include <QCategoryAxis> | |
25 |
|
25 | |||
26 | class CategoryLineChart: public Chart |
|
26 | class CategoryLineChart: public Chart | |
27 | { |
|
27 | { | |
28 | public: |
|
28 | public: | |
29 | QString name() { return QObject::tr("CategoryAxis"); } |
|
29 | QString name() { return QObject::tr("CategoryAxis"); } | |
30 | QString category() { return QObject::tr("Axis"); } |
|
30 | QString category() { return QObject::tr("Axis"); } | |
31 | QString subCategory() { return QString::null; } |
|
31 | QString subCategory() { return QString::null; } | |
32 |
|
32 | |||
33 |
QChart *createChart(const DataTable &table) |
|
33 | QChart *createChart(const DataTable &table) | |
34 | { |
|
34 | { | |
35 | QChart *chart = new QChart(); |
|
35 | QChart *chart = new QChart(); | |
36 | chart->setTitle("Category X , Category Y "); |
|
36 | chart->setTitle("Category X , Category Y "); | |
37 |
|
37 | |||
38 | QString name("Series "); |
|
38 | QString name("Series "); | |
39 | int nameIndex = 0; |
|
39 | int nameIndex = 0; | |
40 | foreach (DataList list, table) { |
|
40 | foreach (DataList list, table) { | |
41 | QLineSeries *series = new QLineSeries(chart); |
|
41 | QLineSeries *series = new QLineSeries(chart); | |
42 | foreach (Data data, list) |
|
42 | foreach (Data data, list) | |
43 | series->append(data.first); |
|
43 | series->append(data.first); | |
44 | series->setName(name + QString::number(nameIndex)); |
|
44 | series->setName(name + QString::number(nameIndex)); | |
45 | nameIndex++; |
|
45 | nameIndex++; | |
46 | chart->addSeries(series); |
|
46 | chart->addSeries(series); | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | QCategoryAxis *axisX = new QCategoryAxis; |
|
49 | QCategoryAxis *axisX = new QCategoryAxis; | |
50 | axisX->append("low", 5); |
|
50 | axisX->append("low", 5); | |
51 | axisX->append("avg.", 12); |
|
51 | axisX->append("avg.", 12); | |
52 | axisX->append("high", 19); |
|
52 | axisX->append("high", 19); | |
53 | axisX->setRange(0, 20); |
|
53 | axisX->setRange(0, 20); | |
54 | chart->setAxisX(axisX, chart->series().at(0)); |
|
54 | chart->setAxisX(axisX, chart->series().at(0)); | |
55 |
|
55 | |||
56 | QCategoryAxis *axisY = new QCategoryAxis; |
|
56 | QCategoryAxis *axisY = new QCategoryAxis; | |
57 | axisY->append("cheap", 5); |
|
57 | axisY->append("cheap", 5); | |
58 | axisY->append("fair", 12); |
|
58 | axisY->append("fair", 12); | |
59 | axisY->append("pricy", 20); |
|
59 | axisY->append("pricy", 20); | |
60 | axisY->setRange(0, 20); |
|
60 | axisY->setRange(0, 20); | |
61 | chart->setAxisY(axisY, chart->series().at(0)); |
|
61 | chart->setAxisY(axisY, chart->series().at(0)); | |
62 |
|
62 | |||
63 | return chart; |
|
63 | return chart; | |
64 | } |
|
64 | } | |
65 | }; |
|
65 | }; | |
66 |
|
66 | |||
67 | DECLARE_CHART(CategoryLineChart) |
|
67 | class CategoryLineChartTitle: public CategoryLineChart | |
|
68 | { | |||
|
69 | public: | |||
|
70 | QString name() { return QObject::tr("CategoryAxis, Title"); } | |||
|
71 | ||||
|
72 | QChart *createChart(const DataTable &table) | |||
|
73 | { | |||
|
74 | QChart *chart = CategoryLineChart::createChart(table); | |||
|
75 | chart->axisX()->setTitle("Axis X"); | |||
|
76 | chart->axisY()->setTitle("Axis Y"); | |||
|
77 | chart->setTitle("Category X , Category Y,title "); | |||
|
78 | return chart; | |||
|
79 | } | |||
|
80 | }; | |||
68 |
|
81 | |||
|
82 | DECLARE_CHART(CategoryLineChart) | |||
|
83 | DECLARE_CHART(CategoryLineChartTitle) |
@@ -1,62 +1,79 | |||||
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 "qdatetimeaxis.h" |
|
25 | #include "qdatetimeaxis.h" | |
26 |
|
26 | |||
27 | class DateTimeAxisX: public Chart |
|
27 | class DateTimeAxisX: public Chart | |
28 | { |
|
28 | { | |
29 | public: |
|
29 | public: | |
30 | QString name() { return "AxisX"; } |
|
30 | QString name() { return "AxisX"; } | |
31 | QString category() { return QObject::tr("Axis"); } |
|
31 | QString category() { return QObject::tr("Axis"); } | |
32 | QString subCategory() { return "DateTimeAxis"; } |
|
32 | QString subCategory() { return "DateTimeAxis"; } | |
33 |
|
33 | |||
34 | QChart *createChart(const DataTable &table) |
|
34 | QChart *createChart(const DataTable &table) | |
35 | { |
|
35 | { | |
36 | QChart *chart = new QChart(); |
|
36 | QChart *chart = new QChart(); | |
37 | chart->setTitle("DateTime X , Value Y"); |
|
37 | chart->setTitle("DateTime X , Value Y"); | |
38 | QValueAxis *valueaxis = new QValueAxis(); |
|
38 | QValueAxis *valueaxis = new QValueAxis(); | |
39 | QDateTimeAxis *datetimeaxis = new QDateTimeAxis(); |
|
39 | QDateTimeAxis *datetimeaxis = new QDateTimeAxis(); | |
40 | datetimeaxis->setTickCount(10); |
|
40 | datetimeaxis->setTickCount(10); | |
41 | datetimeaxis->setFormat("yyyy"); |
|
41 | datetimeaxis->setFormat("yyyy"); | |
42 |
|
42 | |||
43 | QString name("Series "); |
|
43 | QString name("Series "); | |
44 | int nameIndex = 0; |
|
44 | int nameIndex = 0; | |
45 | foreach (DataList list, table) { |
|
45 | foreach (DataList list, table) { | |
46 | QLineSeries *series = new QLineSeries(chart); |
|
46 | QLineSeries *series = new QLineSeries(chart); | |
47 | foreach (Data data, list) { |
|
47 | foreach (Data data, list) { | |
48 | QPointF point = data.first; |
|
48 | QPointF point = data.first; | |
49 | series->append(1000l * 60l * 60l * 24l * 365l * 30l + point.x() * 1000l * 60l * 60l * 24l * 365l, point.y()); |
|
49 | series->append(1000l * 60l * 60l * 24l * 365l * 30l + point.x() * 1000l * 60l * 60l * 24l * 365l, point.y()); | |
50 | } |
|
50 | } | |
51 | series->setName(name + QString::number(nameIndex)); |
|
51 | series->setName(name + QString::number(nameIndex)); | |
52 | nameIndex++; |
|
52 | nameIndex++; | |
53 | chart->addSeries(series); |
|
53 | chart->addSeries(series); | |
54 | chart->setAxisX(datetimeaxis, series); |
|
54 | chart->setAxisX(datetimeaxis, series); | |
55 | chart->setAxisY(valueaxis, series); |
|
55 | chart->setAxisY(valueaxis, series); | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | return chart; |
|
58 | return chart; | |
59 | } |
|
59 | } | |
60 | }; |
|
60 | }; | |
61 |
|
61 | |||
|
62 | class DateTimeAxisXTitle: public DateTimeAxisX | |||
|
63 | { | |||
|
64 | public: | |||
|
65 | QString name() { return "AxisX Title"; } | |||
|
66 | ||||
|
67 | QChart *createChart(const DataTable &table) | |||
|
68 | { | |||
|
69 | QChart *chart = DateTimeAxisX::createChart(table); | |||
|
70 | chart->axisX()->setTitle("Axis X"); | |||
|
71 | chart->axisY()->setTitle("Axis Y"); | |||
|
72 | chart->setTitle("DateTime X , Value Y, Title"); | |||
|
73 | return chart; | |||
|
74 | } | |||
|
75 | }; | |||
|
76 | ||||
|
77 | ||||
62 | DECLARE_CHART(DateTimeAxisX); |
|
78 | DECLARE_CHART(DateTimeAxisX); | |
|
79 | DECLARE_CHART(DateTimeAxisXTitle); |
@@ -1,62 +1,78 | |||||
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 "qdatetimeaxis.h" |
|
25 | #include "qdatetimeaxis.h" | |
26 |
|
26 | |||
27 | class DateTimeAxisY: public Chart |
|
27 | class DateTimeAxisY: public Chart | |
28 | { |
|
28 | { | |
29 | public: |
|
29 | public: | |
30 | QString name() { return "AxisY"; } |
|
30 | QString name() { return "AxisY"; } | |
31 | QString category() { return QObject::tr("Axis"); } |
|
31 | QString category() { return QObject::tr("Axis"); } | |
32 | QString subCategory() { return "DateTimeAxis"; } |
|
32 | QString subCategory() { return "DateTimeAxis"; } | |
33 |
|
33 | |||
34 | QChart *createChart(const DataTable &table) |
|
34 | QChart *createChart(const DataTable &table) | |
35 | { |
|
35 | { | |
36 | QChart *chart = new QChart(); |
|
36 | QChart *chart = new QChart(); | |
37 | chart->setTitle("Value X , DateTime Y"); |
|
37 | chart->setTitle("Value X , DateTime Y"); | |
38 | QValueAxis *valueaxis = new QValueAxis(); |
|
38 | QValueAxis *valueaxis = new QValueAxis(); | |
39 | QDateTimeAxis *datetimeaxis = new QDateTimeAxis(); |
|
39 | QDateTimeAxis *datetimeaxis = new QDateTimeAxis(); | |
40 | datetimeaxis->setTickCount(10); |
|
40 | datetimeaxis->setTickCount(10); | |
41 | datetimeaxis->setFormat("yyyy"); |
|
41 | datetimeaxis->setFormat("yyyy"); | |
42 |
|
42 | |||
43 | QString name("Series "); |
|
43 | QString name("Series "); | |
44 | int nameIndex = 0; |
|
44 | int nameIndex = 0; | |
45 | foreach (DataList list, table) { |
|
45 | foreach (DataList list, table) { | |
46 | QLineSeries *series = new QLineSeries(chart); |
|
46 | QLineSeries *series = new QLineSeries(chart); | |
47 | foreach (Data data, list) { |
|
47 | foreach (Data data, list) { | |
48 | QPointF point = data.first; |
|
48 | QPointF point = data.first; | |
49 | series->append(point.x(), 1000l * 60l * 60l * 24l * 365l * 30l + point.y() * 1000l * 60l * 60l * 24l * 365l); |
|
49 | series->append(point.x(), 1000l * 60l * 60l * 24l * 365l * 30l + point.y() * 1000l * 60l * 60l * 24l * 365l); | |
50 | } |
|
50 | } | |
51 | series->setName(name + QString::number(nameIndex)); |
|
51 | series->setName(name + QString::number(nameIndex)); | |
52 | nameIndex++; |
|
52 | nameIndex++; | |
53 | chart->addSeries(series); |
|
53 | chart->addSeries(series); | |
54 | chart->setAxisY(datetimeaxis, series); |
|
54 | chart->setAxisY(datetimeaxis, series); | |
55 | chart->setAxisX(valueaxis, series); |
|
55 | chart->setAxisX(valueaxis, series); | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | return chart; |
|
58 | return chart; | |
59 | } |
|
59 | } | |
60 | }; |
|
60 | }; | |
61 |
|
61 | |||
|
62 | class DateTimeAxisYTitle: public DateTimeAxisY | |||
|
63 | { | |||
|
64 | public: | |||
|
65 | QString name() { return "AxisY Title"; } | |||
|
66 | ||||
|
67 | QChart *createChart(const DataTable &table) | |||
|
68 | { | |||
|
69 | QChart *chart = DateTimeAxisY::createChart(table); | |||
|
70 | chart->axisX()->setTitle("Axis X"); | |||
|
71 | chart->axisY()->setTitle("Axis Y"); | |||
|
72 | chart->setTitle("Value X , DateTime Y, Title"); | |||
|
73 | return chart; | |||
|
74 | } | |||
|
75 | }; | |||
|
76 | ||||
62 | DECLARE_CHART(DateTimeAxisY); |
|
77 | DECLARE_CHART(DateTimeAxisY); | |
|
78 | DECLARE_CHART(DateTimeAxisYTitle); |
@@ -1,59 +1,75 | |||||
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 ValueAxis: public Chart |
|
27 | class ValueAxis: public Chart | |
28 | { |
|
28 | { | |
29 | public: |
|
29 | public: | |
30 | QString name() { return "ValueAxis"; } |
|
30 | QString name() { return "ValueAxis"; } | |
31 | QString category() { return QObject::tr("Axis"); } |
|
31 | QString category() { return QObject::tr("Axis"); } | |
32 | QString subCategory() { return QString::null; } |
|
32 | QString subCategory() { return QString::null; } | |
33 |
|
33 | |||
34 | QChart *createChart(const DataTable &table) |
|
34 | QChart *createChart(const DataTable &table) | |
35 | { |
|
35 | { | |
36 | QChart *chart = new QChart(); |
|
36 | QChart *chart = new QChart(); | |
37 | chart->setTitle("Value X , Value Y"); |
|
37 | chart->setTitle("Value X , Value Y"); | |
38 |
|
38 | |||
39 | QString name("Series "); |
|
39 | QString name("Series "); | |
40 | int nameIndex = 0; |
|
40 | int nameIndex = 0; | |
41 | foreach (DataList list, table) { |
|
41 | foreach (DataList list, table) { | |
42 | QLineSeries *series = new QLineSeries(chart); |
|
42 | QLineSeries *series = new QLineSeries(chart); | |
43 | foreach (Data data, list) |
|
43 | foreach (Data data, list) | |
44 | series->append(data.first); |
|
44 | series->append(data.first); | |
45 | series->setName(name + QString::number(nameIndex)); |
|
45 | series->setName(name + QString::number(nameIndex)); | |
46 | nameIndex++; |
|
46 | nameIndex++; | |
47 | chart->addSeries(series); |
|
47 | chart->addSeries(series); | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | chart->createDefaultAxes(); |
|
50 | chart->createDefaultAxes(); | |
51 | QValueAxis *axis = new QValueAxis(); |
|
51 | QValueAxis *axis = new QValueAxis(); | |
52 | foreach (QAbstractSeries *series, chart->series()) |
|
52 | foreach (QAbstractSeries *series, chart->series()) | |
53 | chart->setAxisX(axis, series); |
|
53 | chart->setAxisX(axis, series); | |
54 |
|
54 | |||
55 | return chart; |
|
55 | return chart; | |
56 | } |
|
56 | } | |
57 | }; |
|
57 | }; | |
58 |
|
58 | |||
|
59 | class ValueAxisTitle: public ValueAxis | |||
|
60 | { | |||
|
61 | public: | |||
|
62 | QString name() { return "ValueAxis Title"; } | |||
|
63 | ||||
|
64 | QChart *createChart(const DataTable &table) | |||
|
65 | { | |||
|
66 | QChart *chart = ValueAxis::createChart(table); | |||
|
67 | chart->axisX()->setTitle("Axis X"); | |||
|
68 | chart->axisY()->setTitle("Axis Y"); | |||
|
69 | chart->setTitle("Value X , Value Y, title"); | |||
|
70 | return chart; | |||
|
71 | } | |||
|
72 | }; | |||
|
73 | ||||
59 | DECLARE_CHART(ValueAxis); |
|
74 | DECLARE_CHART(ValueAxis); | |
|
75 | DECLARE_CHART(ValueAxisTitle); |
@@ -1,33 +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/valueaxis2.cpp \ |
|
|||
24 | axis/categoryaxis2.cpp \ |
|
|||
25 | axis/barcategoryaxisx2.cpp \ |
|
|||
26 | axis/barcategoryaxisy2.cpp \ |
|
|||
27 | axis/datetimeaxisx2.cpp \ |
|
|||
28 | axis/datetimeaxisy2.cpp \ |
|
|||
29 | multiaxis/multivalueaxis.cpp \ |
|
23 | multiaxis/multivalueaxis.cpp \ | |
30 | multiaxis/multivalueaxis2.cpp \ |
|
24 | multiaxis/multivalueaxis2.cpp \ | |
31 | multiaxis/multivalueaxis3.cpp \ |
|
25 | multiaxis/multivalueaxis3.cpp \ | |
32 | multiaxis/multivalueaxis4.cpp \ |
|
26 | multiaxis/multivalueaxis4.cpp \ | |
33 | multiaxis/multivaluebaraxis.cpp No newline at end of file |
|
27 | multiaxis/multivaluebaraxis.cpp |
General Comments 0
You need to be logged in to leave comments.
Login now