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