##// END OF EJS Templates
Adds size template to charveiwer
Michal Klocek -
r2149:15c75629b372
parent child
Show More
@@ -0,0 +1,140
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
26 class SizeChart: public Chart
27 {
28 public:
29 QString name() { return QObject::tr("PlotArea"); }
30 QString category() { return QObject::tr("Size"); }
31 QString subCategory() { return QString::null; }
32
33 QChart *createChart(const DataTable &table)
34 {
35
36 QChart *chart = new QChart();
37 QString name("Series");
38 int nameIndex = 0;
39 foreach (DataList list, table) {
40 QLineSeries *series = new QLineSeries(chart);
41 foreach (Data data, list)
42 series->append(data.first);
43 series->setName(name + QString::number(nameIndex));
44 nameIndex++;
45 chart->addSeries(series);
46 }
47 chart->setContentsMargins(0,0,0,0);
48 chart->setMargins(QMargins(0,0,0,0));
49 return chart;
50 }
51 };
52
53 class SizeChart2: public SizeChart
54 {
55 public:
56 QString name() { return QObject::tr("PA + T"); }
57
58 QChart *createChart(const DataTable &table)
59 {
60 QChart *chart = SizeChart::createChart(table);
61 chart->setTitle(name());
62 return chart;
63 }
64 };
65
66 class SizeChart3: public SizeChart2
67 {
68 public:
69 QString name() { return QObject::tr("PA+T+CM10"); }
70
71 QChart *createChart(const DataTable &table)
72 {
73 QChart *chart = SizeChart2::createChart(table);
74 chart->setContentsMargins(10,10,10,10);
75
76 return chart;
77 }
78 };
79
80 class SizeChart4: public SizeChart3
81 {
82 public:
83 QString name() { return QObject::tr("PA+T+CM10+M25"); }
84
85 QChart *createChart(const DataTable &table)
86 {
87 QChart *chart = SizeChart3::createChart(table);
88 chart->setMargins(QMargins(30,30,30,30));
89 return chart;
90 }
91 };
92
93 class SizeChart5: public SizeChart4
94 {
95 public:
96 QString name() { return QObject::tr("PA+T+CM10+M25+AX"); }
97
98 QChart *createChart(const DataTable &table)
99 {
100 QChart *chart = SizeChart4::createChart(table);
101 chart->createDefaultAxes();
102 chart->axisY()->hide();
103 return chart;
104 }
105 };
106
107 class SizeChart6: public SizeChart4
108 {
109 public:
110 QString name() { return QObject::tr("PA+T+CM10+M25+AY"); }
111
112 QChart *createChart(const DataTable &table)
113 {
114 QChart *chart = SizeChart4::createChart(table);
115 chart->createDefaultAxes();
116 chart->axisX()->hide();
117 return chart;
118 }
119 };
120
121 class SizeChart7: public SizeChart4
122 {
123 public:
124 QString name() { return QObject::tr("PA+T+CM10+M25+AX+AY"); }
125
126 QChart *createChart(const DataTable &table)
127 {
128 QChart *chart = SizeChart4::createChart(table);
129 chart->createDefaultAxes();
130 return chart;
131 }
132 };
133
134 DECLARE_CHART(SizeChart)
135 DECLARE_CHART(SizeChart2)
136 DECLARE_CHART(SizeChart3)
137 DECLARE_CHART(SizeChart4)
138 DECLARE_CHART(SizeChart5)
139 DECLARE_CHART(SizeChart6)
140 DECLARE_CHART(SizeChart7)
@@ -24,4 +24,5 SOURCES += \
24 multiaxis/multivalueaxis2.cpp \
24 multiaxis/multivalueaxis2.cpp \
25 multiaxis/multivalueaxis3.cpp \
25 multiaxis/multivalueaxis3.cpp \
26 multiaxis/multivalueaxis4.cpp \
26 multiaxis/multivalueaxis4.cpp \
27 multiaxis/multivaluebaraxis.cpp No newline at end of file
27 multiaxis/multivaluebaraxis.cpp \
28 size/sizecharts.cpp No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now