##// END OF EJS Templates
Refactors axis handling...
Michal Klocek -
r223:c82178b4ef05
parent child
Show More
@@ -9,7 +9,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 AxisItem::AxisItem(AxisType type,QGraphicsItem* parent) :
10 AxisItem::AxisItem(AxisType type,QGraphicsItem* parent) :
11 ChartItem(parent),
11 ChartItem(parent),
12 m_ticks(4),
13 m_type(type),
12 m_type(type),
14 m_labelsAngle(0),
13 m_labelsAngle(0),
15 m_shadesEnabled(true),
14 m_shadesEnabled(true),
@@ -20,7 +19,6 m_labels(parent)
20 //initial initialization
19 //initial initialization
21 m_shades.setZValue(0);
20 m_shades.setZValue(0);
22 m_grid.setZValue(2);
21 m_grid.setZValue(2);
23 createItems();
24 }
22 }
25
23
26 AxisItem::~AxisItem()
24 AxisItem::~AxisItem()
@@ -32,9 +30,9 QRectF AxisItem::boundingRect() const
32 return m_rect;
30 return m_rect;
33 }
31 }
34
32
35 void AxisItem::createItems()
33 void AxisItem::createItems(int count)
36 {
34 {
37 for (int i = 0; i <= m_ticks; ++i) {
35 for (int i = 0; i < count; ++i) {
38 m_grid.addToGroup(new QGraphicsLineItem(this));
36 m_grid.addToGroup(new QGraphicsLineItem(this));
39 m_labels.addToGroup(new QGraphicsSimpleTextItem(this));
37 m_labels.addToGroup(new QGraphicsSimpleTextItem(this));
40 if(i%2) m_shades.addToGroup(new QGraphicsRectItem(this));
38 if(i%2) m_shades.addToGroup(new QGraphicsRectItem(this));
@@ -55,6 +53,8 void AxisItem::clear()
55 delete item;
53 delete item;
56 }
54 }
57
55
56 m_thicksList.clear();
57
58 }
58 }
59
59
60 void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
60 void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
@@ -62,7 +62,7 void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
62
62
63 }
63 }
64
64
65 void AxisItem::updateDomain()
65 void AxisItem::updateItem(int count)
66 {
66 {
67
67
68 QList<QGraphicsItem *> lines = m_grid.childItems();
68 QList<QGraphicsItem *> lines = m_grid.childItems();
@@ -73,21 +73,16 void AxisItem::updateDomain()
73 {
73 {
74 case X_AXIS:
74 case X_AXIS:
75 {
75 {
76 const qreal deltaX = m_rect.width() / m_ticks;
76 const qreal deltaX = m_rect.width() / (count-1);
77
77
78 m_axis.setLine(m_rect.left(), m_rect.bottom(), m_rect.right(), m_rect.bottom());
78 m_axis.setLine(m_rect.left(), m_rect.bottom(), m_rect.right(), m_rect.bottom());
79
79
80 for (int i = 0; i <= m_ticks; ++i) {
80 for (int i = 0; i < count; ++i) {
81
82 int x = i * deltaX + m_rect.left();
81 int x = i * deltaX + m_rect.left();
83
84 qreal label = m_domain.m_minX + (i * m_domain.spanX()/ m_ticks);
85
86 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
82 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
87 lineItem->setLine(x, m_rect.top(), x, m_rect.bottom());
83 lineItem->setLine(x, m_rect.top(), x, m_rect.bottom());
88
89 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
84 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
90 labelItem->setText(QString::number(label));
85 labelItem->setText(m_thicksList.at(i));
91 QPointF center = labelItem->boundingRect().center();
86 QPointF center = labelItem->boundingRect().center();
92 labelItem->setTransformOriginPoint(center.x(), center.y());
87 labelItem->setTransformOriginPoint(center.x(), center.y());
93 labelItem->setPos(x - center.x(), m_rect.bottom() + label_padding);
88 labelItem->setPos(x - center.x(), m_rect.bottom() + label_padding);
@@ -103,26 +98,19 void AxisItem::updateDomain()
103
98
104 case Y_AXIS:
99 case Y_AXIS:
105 {
100 {
106 const qreal deltaY = m_rect.height()/ m_ticks;
101 const qreal deltaY = m_rect.height()/ (count-1);
107
102
108 m_axis.setLine(m_rect.left() , m_rect.top(), m_rect.left(), m_rect.bottom());
103 m_axis.setLine(m_rect.left() , m_rect.top(), m_rect.left(), m_rect.bottom());
109
104
110 for (int i = 0; i <= m_ticks; ++i) {
105 for (int i = 0; i < count; ++i) {
111
112 int y = i * -deltaY + m_rect.bottom();
106 int y = i * -deltaY + m_rect.bottom();
113
114 qreal label = m_domain.m_minY + (i * m_domain.spanY()/ m_ticks);
115
116 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
107 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
117 lineItem->setLine(m_rect.left() , y, m_rect.right(), y);
108 lineItem->setLine(m_rect.left() , y, m_rect.right(), y);
118
119 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
109 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
120 labelItem->setText(QString::number(label));
110 labelItem->setText(m_thicksList.at(i));
121 QPointF center = labelItem->boundingRect().center();
111 QPointF center = labelItem->boundingRect().center();
122 labelItem->setTransformOriginPoint(center.x(), center.y());
112 labelItem->setTransformOriginPoint(center.x(), center.y());
123 labelItem->setPos(m_rect.left() - labelItem->boundingRect().width() - label_padding , y-center.y());
113 labelItem->setPos(m_rect.left() - labelItem->boundingRect().width() - label_padding , y-center.y());
124
125
126 if(i%2){
114 if(i%2){
127 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
115 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
128 rectItem->setRect(m_rect.left(),y,m_rect.width(),deltaY);
116 rectItem->setRect(m_rect.left(),y,m_rect.width(),deltaY);
@@ -137,23 +125,23 void AxisItem::updateDomain()
137 }
125 }
138 }
126 }
139
127
140 void AxisItem::handleAxisChanged(const QChartAxis& axis)
128 void AxisItem::handleAxisUpdate(QChartAxis* axis)
141 {
129 {
142 if(axis.isAxisVisible()) {
130 if(axis->isAxisVisible()) {
143 setAxisOpacity(100);
131 setAxisOpacity(100);
144 }
132 }
145 else {
133 else {
146 setAxisOpacity(0);
134 setAxisOpacity(0);
147 }
135 }
148
136
149 if(axis.isGridVisible()) {
137 if(axis->isGridVisible()) {
150 setGridOpacity(100);
138 setGridOpacity(100);
151 }
139 }
152 else {
140 else {
153 setGridOpacity(0);
141 setGridOpacity(0);
154 }
142 }
155
143
156 if(axis.isLabelsVisible())
144 if(axis->isLabelsVisible())
157 {
145 {
158 setLabelsOpacity(100);
146 setLabelsOpacity(100);
159 }
147 }
@@ -161,49 +149,48 void AxisItem::handleAxisChanged(const QChartAxis& axis)
161 setLabelsOpacity(0);
149 setLabelsOpacity(0);
162 }
150 }
163
151
164 if(axis.isShadesVisible()) {
152 if(axis->isShadesVisible()) {
165 setShadesOpacity(axis.shadesOpacity());
153 setShadesOpacity(axis->shadesOpacity());
166 }
154 }
167 else {
155 else {
168 setShadesOpacity(0);
156 setShadesOpacity(0);
169 }
157 }
170
158
171 switch(axis.labelsOrientation())
159 setLabelsAngle(axis->labelsAngle());
172 {
160 setAxisPen(axis->axisPen());
173 case QChartAxis::LabelsOrientationHorizontal:
161 setLabelsPen(axis->labelsPen());
174 setLabelsAngle(0);
162 setLabelsBrush(axis->labelsBrush());
175 break;
163 setLabelsFont(axis->labelFont());
176 case QChartAxis::LabelsOrientationVertical:
164 setGridPen(axis->gridPen());
177 setLabelsAngle(90);
165 setShadesPen(axis->shadesPen());
178 break;
166 setShadesBrush(axis->shadesBrush());
179 case QChartAxis::LabelsOrientationSlide:
180 setLabelsAngle(-45);
181 break;
182 default:
183 break;
184 }
185
186 setAxisPen(axis.axisPen());
187 setLabelsPen(axis.labelsPen());
188 setLabelsBrush(axis.labelsBrush());
189 setLabelsFont(axis.labelFont());
190 setGridPen(axis.gridPen());
191 setShadesPen(axis.shadesPen());
192 setShadesBrush(axis.shadesBrush());
193
194 }
167 }
195
168
196 void AxisItem::handleDomainChanged(const Domain& domain)
169 void AxisItem::handleLabelsChanged(const QStringList& labels)
197 {
170 {
198 m_domain = domain;
171 m_thicksList=labels;
199 updateDomain();
172 QList<QGraphicsItem*> items = m_labels.childItems();
173 if(items.size()!=m_thicksList.size()){
174 clear();
175 m_thicksList=labels;
176 createItems(m_thicksList.size());
177 items = m_labels.childItems();
178 }
179
180 Q_ASSERT(items.size()==m_thicksList.size());
181
182 int i=0;
183 foreach(QGraphicsItem* item, items){
184 static_cast<QGraphicsSimpleTextItem*>(item)->setText(m_thicksList.at(i));
185 i++;
186 }
200 update();
187 update();
201 }
188 }
202
189
203 void AxisItem::handleGeometryChanged(const QRectF& rect)
190 void AxisItem::handleGeometryChanged(const QRectF& rect)
204 {
191 {
205 m_rect = rect;
192 m_rect = rect;
206 updateDomain();
193 updateItem(m_thicksList.size());
207 update();
194 update();
208 }
195 }
209
196
@@ -305,14 +292,6 void AxisItem::setGridPen(const QPen& pen)
305 }
292 }
306 }
293 }
307
294
308 void AxisItem::setTicks(int count)
309 {
310 if(count!=m_ticks){
311 clear();
312 m_ticks=count;
313 createItems();
314 }
315 }
316
295
317 //TODO "nice numbers algorithm"
296 //TODO "nice numbers algorithm"
318 #include "moc_axisitem_p.cpp"
297 #include "moc_axisitem_p.cpp"
@@ -39,9 +39,6 public:
39 void setLabelsAngle(int angle);
39 void setLabelsAngle(int angle);
40 int labelsAngle()const { return m_labelsAngle; }
40 int labelsAngle()const { return m_labelsAngle; }
41
41
42 void setTicks(int count);
43 int ticks() const { return m_ticks;}
44
45 void setShadesBrush(const QBrush& brush);
42 void setShadesBrush(const QBrush& brush);
46 void setShadesPen(const QPen& pen);
43 void setShadesPen(const QPen& pen);
47
44
@@ -53,18 +50,16 public:
53 void setLabelsFont(const QFont& font);
50 void setLabelsFont(const QFont& font);
54
51
55 public slots:
52 public slots:
56 void handleAxisChanged(const QChartAxis& axis);
53 void handleAxisUpdate(QChartAxis* axis);
57 void handleDomainChanged(const Domain& domain);
54 void handleLabelsChanged(const QStringList& labels);
58 void handleGeometryChanged(const QRectF& size);
55 void handleGeometryChanged(const QRectF& size);
59 protected:
56 protected:
60 void updateDomain();
57 void updateItem(int count);
61 private:
58 private:
62 void clear();
59 void clear();
63 void createItems();
60 void createItems(int count);
64 private:
61 private:
65 AxisType m_type;
62 AxisType m_type;
66 int m_ticks;
67 Domain m_domain;
68 QRectF m_rect;
63 QRectF m_rect;
69 int m_labelsAngle;
64 int m_labelsAngle;
70 bool m_shadesEnabled;
65 bool m_shadesEnabled;
@@ -72,6 +67,7 private:
72 QGraphicsItemGroup m_shades;
67 QGraphicsItemGroup m_shades;
73 QGraphicsItemGroup m_labels;
68 QGraphicsItemGroup m_labels;
74 QGraphicsLineItem m_axis;
69 QGraphicsLineItem m_axis;
70 QStringList m_thicksList;
75
71
76 };
72 };
77
73
@@ -1,4 +1,5
1 #include "chartdataset_p.h"
1 #include "chartdataset_p.h"
2 #include "qchartaxis.h"
2 //series
3 //series
3 #include "qlinechartseries.h"
4 #include "qlinechartseries.h"
4 #include "qbarchartseries.h"
5 #include "qbarchartseries.h"
@@ -9,10 +10,12
9
10
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11
12
12 ChartDataSet::ChartDataSet(QObject *parent):QObject(parent)
13 ChartDataSet::ChartDataSet(QObject *parent):QObject(parent),
14 m_axisX(new QChartAxis(this)),
15 m_axisY(new QChartAxis(this)),
16 m_domainIndex(0),
17 m_axisXInitialized(false)
13 {
18 {
14 Domain domain;
15 m_domains<<domain;
16 }
19 }
17
20
18 ChartDataSet::~ChartDataSet()
21 ChartDataSet::~ChartDataSet()
@@ -20,20 +23,34 ChartDataSet::~ChartDataSet()
20 // TODO Auto-generated destructor stub
23 // TODO Auto-generated destructor stub
21 }
24 }
22
25
23 const Domain& ChartDataSet::domain() const
26 const Domain ChartDataSet::domain(QChartAxis *axisY) const
24 {
27 {
25 return m_domains[m_domainIndex];
28 int i = m_domainMap.count(axisY);
29 if(i == 0){
30 return Domain();
31 }
32 i = i - m_domainIndex -1;
33 return m_domainMap.values(axisY).at(i);
26 }
34 }
27
35
28 void ChartDataSet::addSeries(QChartSeries* series)
36 void ChartDataSet::addSeries(QChartSeries* series, QChartAxis *axisY)
29 {
37 {
30 // TODO: we should check the series not already added
38 // TODO: we should check the series not already added
31 m_chartSeries << series;
32 series->setParent(this); // take ownership
39 series->setParent(this); // take ownership
33 m_domainIndex = 0;
34 m_domains.resize(1);
35
40
36 Domain& domain = m_domains[m_domainIndex];
41 clearDomains();
42
43 if(axisY==0) axisY = m_axisY;
44
45 QList<QChartSeries*> seriesList = m_seriesMap.values(axisY);
46
47 QList<Domain> domainList = m_domainMap.values(axisY);
48
49 Q_ASSERT(domainList.size()<=1);
50
51 Domain domain;
52
53 if(domainList.size()>0) domain = domainList.at(0);
37
54
38 switch(series->type())
55 switch(series->type())
39 {
56 {
@@ -113,15 +130,60 void ChartDataSet::addSeries(QChartSeries* series)
113
130
114 }
131 }
115
132
133 if(!m_domainMap.contains(axisY))
134 {
135 emit axisAdded(axisY);
136 QObject::connect(axisY,SIGNAL(minChanged(qreal)),this,SLOT(handleMinChanged(qreal)));
137 QObject::connect(axisY,SIGNAL(maxChanged(qreal)),this,SLOT(handleMaxChanged(qreal)));
138 QObject::connect(axisY,SIGNAL(ticksChanged(QChartAxis*)),this,SLOT(handleTickChanged(QChartAxis*)));
139 }
140 m_domainMap.replace(axisY,domain);
141 m_seriesMap.insert(axisY,series);
142
143 if(!m_axisXInitialized)
144 {
145 emit axisAdded(axisX());
146 QObject::connect(axisX(),SIGNAL(minChanged(qreal)),this,SLOT(handleMinChanged(qreal)));
147 QObject::connect(axisX(),SIGNAL(maxChanged(qreal)),this,SLOT(handleMaxChanged(qreal)));
148 QObject::connect(axisX(),SIGNAL(ticksChanged(QChartAxis*)),this,SLOT(handleTickChanged(QChartAxis*)));
149 m_axisXInitialized=true;
150 }
151
152
116 emit seriesAdded(series);
153 emit seriesAdded(series);
117 emit domainChanged(domain);
154 QStringList ylabels = createLabels(axisY,domain.m_minY,domain.m_maxY);
155 QStringList xlabels = createLabels(axisX(),domain.m_minX,domain.m_maxX);
156 emit axisLabelsChanged(axisY,ylabels);
157 emit axisLabelsChanged(axisX(),xlabels);
158 emit seriesDomainChanged(series,domain);
159
160 }
161
162 void ChartDataSet::removeSeries(QChartSeries* series)
163 {
164 QList<QChartAxis*> keys = m_seriesMap.uniqueKeys();
165 foreach(QChartAxis* axis , keys) {
166 if(m_seriesMap.contains(axis,series)){
167 emit seriesRemoved(series);
168 m_seriesMap.remove(axis,series);
169 //remove axis if no longer there
170 if(!m_seriesMap.contains(axis) && axis != m_axisY){
171 emit axisRemoved(axis);
172 m_domainMap.remove(axis);
173 delete axis;
174 }
175 break;
176 }
177 }
118 }
178 }
119
179
120 bool ChartDataSet::nextDomain()
180 bool ChartDataSet::nextDomain()
121 {
181 {
122 if (m_domainIndex < m_domains.count() - 1) {
182 int limit = (m_domainMap.values().size()/m_domainMap.uniqueKeys().size())-1;
183
184 if (m_domainIndex < limit) {
123 m_domainIndex++;
185 m_domainIndex++;
124 emit domainChanged(m_domains[m_domainIndex]);
186 setDomain(m_domainIndex);
125 return true;
187 return true;
126 }
188 }
127 else {
189 else {
@@ -133,7 +195,7 bool ChartDataSet::previousDomain()
133 {
195 {
134 if (m_domainIndex > 0) {
196 if (m_domainIndex > 0) {
135 m_domainIndex--;
197 m_domainIndex--;
136 emit domainChanged(m_domains[m_domainIndex]);
198 setDomain(m_domainIndex);
137 return true;
199 return true;
138 }
200 }
139 else {
201 else {
@@ -141,21 +203,129 bool ChartDataSet::previousDomain()
141 }
203 }
142 }
204 }
143
205
144 void ChartDataSet::clearDomains()
206 void ChartDataSet::setDomain(int index)
145 {
207 {
146 if (m_domainIndex > 0) {
208 QList<QChartAxis*> domainList = m_domainMap.uniqueKeys();
147 m_domainIndex = 0;
209 foreach (QChartAxis* axis , domainList) {
148 emit domainChanged(m_domains[m_domainIndex]);
210 int i = m_domainMap.count(axis) - index -1;
211 Q_ASSERT(i>=0);
212 Domain domain = m_domainMap.values(axis).at(i);
213 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
214 QList<QChartSeries*> seriesList = m_seriesMap.values(axis);
215 foreach(QChartSeries* series, seriesList) {
216 emit seriesDomainChanged(series,domain);
217 }
218 emit axisLabelsChanged(axis,labels);
219 }
220
221 Domain domain = m_domainMap.value(axisY());
222 QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX);
223 emit axisLabelsChanged(axisX(),labels);
224 }
225
226 void ChartDataSet::clearDomains(int toIndex)
227 {
228 Q_ASSERT(toIndex>=0);
229
230 m_domainIndex = toIndex;
231
232 QList<QChartAxis*> keys = m_domainMap.uniqueKeys();
233
234 foreach (QChartAxis* key , keys)
235 {
236 QList<Domain> domains = m_domainMap.values(key);
237 m_domainMap.remove(key);
238 int i = domains.size() - toIndex - 1;
239 while(i--){
240 domains.removeFirst();
241 }
242 for(int j=domains.size()-1; j>=0 ;j--)
243 m_domainMap.insert(key,domains.at(j));
149 }
244 }
150 }
245 }
151
246
152 void ChartDataSet::addDomain(const Domain& domain)
247 void ChartDataSet::addDomain(const QRectF& rect, const QRectF& viewport)
153 {
248 {
154 m_domains.resize(m_domainIndex + 1);
249 Q_ASSERT(rect.isValid());
155 m_domains << domain;
250 Q_ASSERT(viewport.isValid());
251
252 clearDomains(m_domainIndex);
253
254 QList<QChartAxis*> domainList = m_domainMap.uniqueKeys();
255
256 foreach (QChartAxis* axis , domainList){
257 Domain domain(m_domainMap.value(axis).subDomain(rect,viewport.width(),viewport.height()));
258 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
259 QList<QChartSeries*> seriesList = m_seriesMap.values(axis);
260 foreach(QChartSeries* series, seriesList){
261 emit seriesDomainChanged(series,domain);
262 }
263 emit axisLabelsChanged(axis,labels);
264 m_domainMap.insert(axis,domain);
265 }
266
267 Domain domain = m_domainMap.value(axisY());
268 QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX);
269 emit axisLabelsChanged(axisX(),labels);
270
156 m_domainIndex++;
271 m_domainIndex++;
272 }
273
274 QChartAxis* ChartDataSet::axisY(QChartSeries* series) const
275 {
276 if(series == 0) return m_axisY;
277
278 QList<QChartAxis*> keys = m_seriesMap.uniqueKeys();
279
280 foreach(QChartAxis* axis , keys) {
281 if(m_seriesMap.contains(axis,series)){
282 return axis;
283 }
284 }
285 return 0;
286 }
287
288 QStringList ChartDataSet::createLabels(QChartAxis* axis,qreal min, qreal max)
289 {
290 Q_ASSERT(max>=min);
157
291
158 emit domainChanged(domain);
292 QStringList labels;
293
294 int ticks = axis->ticksCount();
295
296 for(int i=0; i<= ticks; i++){
297 qreal value = min + (i * (max - min)/ ticks);
298 QString label = axis->axisTickLabel(value);
299 if(label.isEmpty()){
300 labels << QString::number(value);
301 }else{
302 labels << label;
303 }
304 }
305 return labels;
306 }
307
308
309 void ChartDataSet::handleMinChanged(qreal min)
310 {
311
312 }
313
314 void ChartDataSet::handleMaxChanged(qreal max)
315 {
316
317 }
318
319 void ChartDataSet::handleTickChanged(QChartAxis* axis)
320 {
321 Domain domain = m_domainMap.value(axisY());
322 if(axis==axisX()){
323 QStringList labels = createLabels(axis,domain.m_minX,domain.m_maxX);
324 emit axisLabelsChanged(axis,labels);
325 }else{
326 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
327 emit axisLabelsChanged(axis,labels);
328 }
159 }
329 }
160
330
161 #include "moc_chartdataset_p.cpp"
331 #include "moc_chartdataset_p.cpp"
@@ -1,34 +1,57
1 #ifndef CHARTENGINE_P_H_
1 #ifndef CHARTDATASET_P_H_
2 #define CHARTENGINE_P_H_
2 #define CHARTDATASET_P_H_
3
3
4 #include <qchartseries.h>
4 #include "qchartseries.h"
5 #include "domain_p.h"
5 #include "domain_p.h"
6 #include <QVector>
6 #include <QVector>
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 class QChartAxis;
11
10 class ChartDataSet : public QObject
12 class ChartDataSet : public QObject
11 {
13 {
12 Q_OBJECT
14 Q_OBJECT
13 public:
15 public:
14 ChartDataSet(QObject* parent =0);
16 ChartDataSet(QObject* parent=0);
15 virtual ~ChartDataSet();
17 virtual ~ChartDataSet();
16
18
17 void addSeries(QChartSeries* series);
19 void addSeries(QChartSeries* series,QChartAxis *axisY = 0);
18 void addDomain(const Domain& domain);
20 void removeSeries(QChartSeries* series);
21 void addDomain(const QRectF& rect, const QRectF& viewport);
19 bool nextDomain();
22 bool nextDomain();
20 bool previousDomain();
23 bool previousDomain();
21 void clearDomains();
24 void clearDomains(int toIndex =0);
22 const Domain& domain() const;
25 const Domain domain(QChartAxis *axisY) const;
26 int domainIndex() const {return m_domainIndex;}
27
28 QChartAxis* axisX() const { return m_axisX;};
29 QChartAxis* axisY(QChartSeries* series = 0) const;
23
30
24 signals:
31 signals:
25 void seriesAdded(QChartSeries* series);
32 void seriesAdded(QChartSeries* series);
26 void domainChanged(const Domain& domain);
33 void seriesRemoved(QChartSeries* series);
34 void axisAdded(QChartAxis* axis);
35 void axisRemoved(QChartAxis* axis);
36 void axisLabelsChanged(QChartAxis* axis, const QStringList& labels);
37 void seriesDomainChanged(QChartSeries* series,const Domain& domain);
38
39 private slots:
40 void handleMinChanged(qreal min);
41 void handleMaxChanged(qreal max);
42 void handleTickChanged(QChartAxis*);
43
44 private:
45 void setDomain(int index);
46 QStringList createLabels(QChartAxis* axis,qreal min, qreal max);
27
47
28 private:
48 private:
29 QList<QChartSeries*> m_chartSeries;
49 QMultiMap<QChartAxis*, Domain> m_domainMap;
30 QVector<Domain> m_domains;
50 QMultiMap<QChartAxis*, QChartSeries*> m_seriesMap;
51 QChartAxis* m_axisX;
52 QChartAxis* m_axisY;
31 int m_domainIndex;
53 int m_domainIndex;
54 bool m_axisXInitialized;
32 };
55 };
33
56
34 QTCOMMERCIALCHART_END_NAMESPACE
57 QTCOMMERCIALCHART_END_NAMESPACE
@@ -13,6 +13,9 class ChartItem : public QGraphicsItem
13 enum ChartItemTypes{ AXIS_ITEM = UserType+1, XYLINE_ITEM};
13 enum ChartItemTypes{ AXIS_ITEM = UserType+1, XYLINE_ITEM};
14 public:
14 public:
15 ChartItem(QGraphicsItem* parent = 0):QGraphicsItem(parent){};
15 ChartItem(QGraphicsItem* parent = 0):QGraphicsItem(parent){};
16 //TODO make pure
17 virtual void handleGeometryChanged(const QRectF&){};
18 virtual void handleDomainChanged(const Domain& domain){};
16 virtual ~ChartItem(){};
19 virtual ~ChartItem(){};
17 };
20 };
18
21
@@ -26,14 +26,12 ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(char
26 m_chart(chart),
26 m_chart(chart),
27 m_dataset(dataset),
27 m_dataset(dataset),
28 m_chartTheme(0),
28 m_chartTheme(0),
29 m_axisXItem(new AxisItem(AxisItem::X_AXIS,m_chart)),
30 m_axisYItem(new AxisItem(AxisItem::Y_AXIS,m_chart)),
31 m_domainIndex(0),
32 m_marginSize(0),
29 m_marginSize(0),
33 m_rect(QRectF(QPoint(0,0),m_chart->size()))
30 m_rect(QRectF(QPoint(0,0),m_chart->size()))
34 {
31 {
32 createConnections();
35 setChartTheme(QChart::ChartThemeDefault);
33 setChartTheme(QChart::ChartThemeDefault);
36 createConnections();
34
37 }
35 }
38
36
39 ChartPresenter::~ChartPresenter()
37 ChartPresenter::~ChartPresenter()
@@ -44,10 +42,17 void ChartPresenter::createConnections()
44 {
42 {
45 QObject::connect(m_chart,SIGNAL(geometryChanged()),this,SLOT(handleGeometryChanged()));
43 QObject::connect(m_chart,SIGNAL(geometryChanged()),this,SLOT(handleGeometryChanged()));
46 QObject::connect(m_dataset,SIGNAL(seriesAdded(QChartSeries*)),this,SLOT(handleSeriesAdded(QChartSeries*)));
44 QObject::connect(m_dataset,SIGNAL(seriesAdded(QChartSeries*)),this,SLOT(handleSeriesAdded(QChartSeries*)));
47 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),m_axisXItem,SLOT(handleGeometryChanged(const QRectF&)));
45 QObject::connect(m_dataset,SIGNAL(seriesRemoved(QChartSeries*)),this,SLOT(handleSeriesRemoved(QChartSeries*)));
48 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),m_axisXItem,SLOT(handleDomainChanged(const Domain&)));
46 QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*)),this,SLOT(handleAxisAdded(QChartAxis*)));
49 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),m_axisYItem,SLOT(handleGeometryChanged(const QRectF&)));
47 QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),this,SLOT(handleAxisRemoved(QChartAxis*)));
50 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),m_axisYItem,SLOT(handleDomainChanged(const Domain&)));
48 QObject::connect(m_dataset,SIGNAL(seriesDomainChanged(QChartSeries*,const Domain&)),this,SLOT(handleSeriesDomainChanged(QChartSeries*,const Domain&)));
49 QObject::connect(m_dataset,SIGNAL(axisLabelsChanged(QChartAxis*,const QStringList&)),this,SLOT(handleAxisLabelsChanged(QChartAxis*,const QStringList&)));
50 }
51
52
53 QRectF ChartPresenter::geometry() const
54 {
55 return m_rect;
51 }
56 }
52
57
53 void ChartPresenter::handleGeometryChanged()
58 void ChartPresenter::handleGeometryChanged()
@@ -68,9 +73,31 void ChartPresenter::setMargin(int margin)
68 m_marginSize = margin;
73 m_marginSize = margin;
69 }
74 }
70
75
76 void ChartPresenter::handleAxisAdded(QChartAxis* axis)
77 {
78 AxisItem* item ;
79
80 if(axis==m_dataset->axisX()){
81 item = new AxisItem(AxisItem::X_AXIS,m_chart);
82 }else{
83 item = new AxisItem(AxisItem::Y_AXIS,m_chart);
84 }
85 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
86 QObject::connect(axis,SIGNAL(update(QChartAxis*)),item,SLOT(handleAxisUpdate(QChartAxis*)));
87 m_chartTheme->decorate(axis,item);
88 m_axisItems.insert(axis,item);
89 }
90
91 void ChartPresenter::handleAxisRemoved(QChartAxis* axis)
92 {
93 AxisItem* item = m_axisItems.take(axis);
94 Q_ASSERT(item);
95 delete item;
96 }
97
98
71 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
99 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
72 {
100 {
73 qDebug() << " ChartPresenter::handleSeriesAdded";
74 switch(series->type())
101 switch(series->type())
75 {
102 {
76 case QChartSeries::SeriesTypeLine: {
103 case QChartSeries::SeriesTypeLine: {
@@ -78,7 +105,6 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
78 LineChartItem* item = new LineChartAnimationItem(this,lineSeries,m_chart);
105 LineChartItem* item = new LineChartAnimationItem(this,lineSeries,m_chart);
79 m_chartTheme->decorate(item,lineSeries,m_chartItems.count());
106 m_chartTheme->decorate(item,lineSeries,m_chartItems.count());
80 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
107 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
81 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
82 QObject::connect(lineSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
108 QObject::connect(lineSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
83 m_chartItems.insert(series,item);
109 m_chartItems.insert(series,item);
84 break;
110 break;
@@ -89,7 +115,6 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
89 BarPresenter* item = new BarPresenter(barSeries->model(),m_chart);
115 BarPresenter* item = new BarPresenter(barSeries->model(),m_chart);
90 m_chartTheme->decorate(item,barSeries,m_chartItems.count());
116 m_chartTheme->decorate(item,barSeries,m_chartItems.count());
91 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
117 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
92 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
93 QObject::connect(barSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
118 QObject::connect(barSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
94 m_chartItems.insert(series,item);
119 m_chartItems.insert(series,item);
95 // m_axisXItem->setVisible(false);
120 // m_axisXItem->setVisible(false);
@@ -102,7 +127,6 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
102 StackedBarPresenter* item = new StackedBarPresenter(stackedBarSeries->model(),m_chart);
127 StackedBarPresenter* item = new StackedBarPresenter(stackedBarSeries->model(),m_chart);
103 m_chartTheme->decorate(item,stackedBarSeries,m_chartItems.count());
128 m_chartTheme->decorate(item,stackedBarSeries,m_chartItems.count());
104 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
129 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
105 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
106 QObject::connect(stackedBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
130 QObject::connect(stackedBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
107 m_chartItems.insert(series,item);
131 m_chartItems.insert(series,item);
108 break;
132 break;
@@ -114,7 +138,6 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
114 PercentBarPresenter* item = new PercentBarPresenter(percentBarSeries->model(),m_chart);
138 PercentBarPresenter* item = new PercentBarPresenter(percentBarSeries->model(),m_chart);
115 m_chartTheme->decorate(item,percentBarSeries ,m_chartItems.count());
139 m_chartTheme->decorate(item,percentBarSeries ,m_chartItems.count());
116 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
140 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
117 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
118 QObject::connect(percentBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
141 QObject::connect(percentBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
119 m_chartItems.insert(series,item);
142 m_chartItems.insert(series,item);
120 break;
143 break;
@@ -124,8 +147,6 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
124 ScatterPresenter *scatterPresenter = new ScatterPresenter(scatterSeries, m_chart);
147 ScatterPresenter *scatterPresenter = new ScatterPresenter(scatterSeries, m_chart);
125 QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)),
148 QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)),
126 scatterPresenter, SLOT(handleGeometryChanged(const QRectF&)));
149 scatterPresenter, SLOT(handleGeometryChanged(const QRectF&)));
127 QObject::connect(m_dataset, SIGNAL(domainChanged(const Domain&)),
128 scatterPresenter, SLOT(handleDomainChanged(const Domain&)));
129 m_chartTheme->decorate(scatterPresenter, scatterSeries, m_chartItems.count());
150 m_chartTheme->decorate(scatterPresenter, scatterSeries, m_chartItems.count());
130 m_chartItems.insert(scatterSeries, scatterPresenter);
151 m_chartItems.insert(scatterSeries, scatterPresenter);
131 break;
152 break;
@@ -135,7 +156,6 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
135 PiePresenter* pie = new PiePresenter(m_chart, s);
156 PiePresenter* pie = new PiePresenter(m_chart, s);
136 m_chartTheme->decorate(pie, s, m_chartItems.count());
157 m_chartTheme->decorate(pie, s, m_chartItems.count());
137 QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), pie, SLOT(handleGeometryChanged(const QRectF&)));
158 QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), pie, SLOT(handleGeometryChanged(const QRectF&)));
138 QObject::connect(m_dataset, SIGNAL(domainChanged(const Domain&)), pie, SLOT(handleDomainChanged(const Domain&)));
139 m_chartItems.insert(series, pie);
159 m_chartItems.insert(series, pie);
140 break;
160 break;
141 }
161 }
@@ -148,40 +168,25 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
148 if(m_rect.isValid()) emit geometryChanged(m_rect);
168 if(m_rect.isValid()) emit geometryChanged(m_rect);
149 }
169 }
150
170
151 void ChartPresenter::handleSeriesChanged(QChartSeries* series)
171 void ChartPresenter::handleSeriesRemoved(QChartSeries* series)
152 {
153 //TODO:
154 }
155
156 void ChartPresenter::zoomInToRect(const QRectF& rect)
157 {
172 {
158 if(!rect.isValid()) return;
173 ChartItem* item = m_chartItems.take(series);
159 QRectF r = rect.normalized();
174 delete item;
160 r.translate(-m_marginSize, -m_marginSize);
161 Domain domain (m_dataset->domain().subDomain(r,m_rect.width(),m_rect.height()));
162 m_dataset->addDomain(domain);
163 }
175 }
164
176
165 void ChartPresenter::zoomIn()
177 void ChartPresenter::handleSeriesChanged(QChartSeries* series)
166 {
178 {
167 if (!m_dataset->nextDomain()) {
179 //TODO:
168 QRectF rect = m_rect;
169 rect.setWidth(rect.width()/2);
170 rect.setHeight(rect.height()/2);
171 rect.moveCenter(m_rect.center());
172 Domain domain (m_dataset->domain().subDomain(rect,m_rect.width(),m_rect.height()));
173 m_dataset->addDomain(domain);
174 }
175 }
180 }
176
181
177 void ChartPresenter::zoomOut()
182 void ChartPresenter::handleSeriesDomainChanged(QChartSeries* series, const Domain& domain)
178 {
183 {
179 m_dataset->previousDomain();
184 m_chartItems.value(series)->handleDomainChanged(domain);
180 }
185 }
181
186
182 void ChartPresenter::zoomReset()
187 void ChartPresenter::handleAxisLabelsChanged(QChartAxis* axis,const QStringList& labels)
183 {
188 {
184 m_dataset->clearDomains();
189 m_axisItems.value(axis)->handleLabelsChanged(labels);
185 }
190 }
186
191
187 void ChartPresenter::setChartTheme(QChart::ChartTheme theme)
192 void ChartPresenter::setChartTheme(QChart::ChartTheme theme)
@@ -200,69 +205,18 void ChartPresenter::setChartTheme(QChart::ChartTheme theme)
200 m_chartTheme->decorate(i.value(),i.key(),index);
205 m_chartTheme->decorate(i.value(),i.key(),index);
201 }
206 }
202
207
203 m_chartTheme->decorate(m_axisX, m_axisXItem);
208 QMapIterator<QChartAxis*,AxisItem*> j(m_axisItems);
204 m_chartTheme->decorate(m_axisY, m_axisYItem);
209 while (j.hasNext()) {
205
210 j.next();
211 m_chartTheme->decorate(j.key(),j.value());
212 }
206 }
213 }
207
214
208
209 QChart::ChartTheme ChartPresenter::chartTheme()
215 QChart::ChartTheme ChartPresenter::chartTheme()
210 {
216 {
211 return m_chartTheme->id();
217 return m_chartTheme->id();
212 }
218 }
213
219
214 void ChartPresenter::setDefaultAxisX(const QChartAxis& axis)
215 {
216 //if(m_axisX != axis) {
217 m_axisX = axis;
218 m_axisXItem->handleAxisChanged(m_axisX);
219 //}
220 }
221
222 void ChartPresenter::setDefaultAxisY(const QChartAxis& axis)
223 {
224 // if(m_axisY != axis) {
225 m_axisY = axis;
226 m_axisYItem->handleAxisChanged(m_axisY);
227 //}
228 }
229
230 QChartAxis ChartPresenter::defaultAxisX() const
231 {
232 return m_axisX;
233 }
234
235 QChartAxis ChartPresenter::defaultAxisY() const
236 {
237 return m_axisY;
238 }
239
240 QChartAxis ChartPresenter::axisY(int id) const
241 {
242 return m_axis.value(id);
243 }
244
245 int ChartPresenter::addAxisY(const QChartAxis& axis)
246 {
247 int key =0 ;
248
249 while(m_axis.contains(key)){
250 key++;
251 //TODO overflow
252 }
253
254 m_axis.insert(key,axis);
255 m_axisItems.insert(key,new AxisItem(AxisItem::Y_AXIS,m_chart));
256
257 return key;
258 }
259
260
261 void ChartPresenter::removeAxisY(int id)
262 {
263 m_axis.remove(id);
264 delete m_axisItems.take(id);
265 }
266
220
267 #include "moc_chartpresenter_p.cpp"
221 #include "moc_chartpresenter_p.cpp"
268
222
@@ -26,46 +26,31 public:
26 void setMargin(int margin);
26 void setMargin(int margin);
27 int margin() const;
27 int margin() const;
28
28
29 void zoomInToRect(const QRectF& rectangle);
29 QRectF geometry() const;
30 void zoomIn();
31 void zoomOut();
32 void zoomReset();
33
30
34 void setChartTheme(QChart::ChartTheme theme);
31 void setChartTheme(QChart::ChartTheme theme);
35 QChart::ChartTheme chartTheme();
32 QChart::ChartTheme chartTheme();
36
33
37 void setDefaultAxisX(const QChartAxis& axis);
38 void setDefaultAxisY(const QChartAxis& axis);
39 QChartAxis defaultAxisX() const;
40 QChartAxis defaultAxisY() const;
41 QChartAxis axisY(int id) const;
42 int addAxisY(const QChartAxis& axis);
43 void removeAxisY(int id);
44
45 private:
34 private:
46 void createConnections();
35 void createConnections();
47
36
48 public slots:
37 public slots:
49 void handleSeriesAdded(QChartSeries* series);
38 void handleSeriesAdded(QChartSeries* series);
50 void handleSeriesRemoved(QChartSeries* series){};
39 void handleSeriesRemoved(QChartSeries* series);
40 void handleAxisAdded(QChartAxis* axis);
41 void handleAxisRemoved(QChartAxis* axis);
42 void handleSeriesDomainChanged(QChartSeries* series, const Domain& domain);
43 void handleAxisLabelsChanged(QChartAxis* axis, const QStringList& labels);
51 void handleSeriesChanged(QChartSeries* series);
44 void handleSeriesChanged(QChartSeries* series);
52 //void handleDomainChanged(Domain oldDomain,Domain newDomain);
53 void handleGeometryChanged();
45 void handleGeometryChanged();
54 signals:
46 signals:
55 void geometryChanged(const QRectF& rect);
47 void geometryChanged(const QRectF& rect);
56 private:
48 private:
57 QMap<QChartSeries*,ChartItem*> m_chartItems;
49 QMap<QChartSeries*,ChartItem*> m_chartItems;
58 QMap<int,AxisItem*> m_axisItems;
50 QMap<QChartAxis*,AxisItem*> m_axisItems;
59 QMap<int,QChartAxis> m_axis;
60 QChart* m_chart;
51 QChart* m_chart;
61 ChartDataSet* m_dataset;
52 ChartDataSet* m_dataset;
62 QVector<Domain> m_domains;
63 ChartTheme *m_chartTheme;
53 ChartTheme *m_chartTheme;
64 QChartAxis m_axisX;
65 AxisItem* m_axisXItem;
66 QChartAxis m_axisY;
67 AxisItem* m_axisYItem;
68 int m_domainIndex;
69 int m_marginSize;
54 int m_marginSize;
70 QRectF m_rect;
55 QRectF m_rect;
71
56
@@ -217,15 +217,13 void ChartTheme::decorate(PiePresenter* item, QPieSeries* series, int /*count*/)
217 }
217 }
218
218
219
219
220 void ChartTheme::decorate(QChartAxis& axis,AxisItem* item)
220 void ChartTheme::decorate(QChartAxis* axis,AxisItem* item)
221 {
221 {
222 //TODO: dummy defults for now
222 //TODO: dummy defults for now
223
223 axis->setLabelsBrush(Qt::black);
224 axis.setLabelsBrush(Qt::black);
224 axis->setLabelsPen(Qt::NoPen);
225 axis.setLabelsPen(Qt::NoPen);
225 axis->setShadesPen(Qt::NoPen);
226 axis.setShadesPen(Qt::NoPen);
226 axis->setShadesOpacity(0.5);
227 axis.setShadesOpacity(0.5);
228 item->handleAxisChanged(axis);
229 }
227 }
230
228
231 QTCOMMERCIALCHART_END_NAMESPACE
229 QTCOMMERCIALCHART_END_NAMESPACE
@@ -37,7 +37,7 public:
37 void decorate(PercentBarPresenter* item, QPercentBarChartSeries* series,int count);
37 void decorate(PercentBarPresenter* item, QPercentBarChartSeries* series,int count);
38 void decorate(ScatterPresenter* presenter, QScatterSeries* series, int count);
38 void decorate(ScatterPresenter* presenter, QScatterSeries* series, int count);
39 void decorate(PiePresenter* item, QPieSeries* series, int count);
39 void decorate(PiePresenter* item, QPieSeries* series, int count);
40 void decorate(QChartAxis& axis,AxisItem* item);
40 void decorate(QChartAxis* axis,AxisItem* item);
41
41
42 protected:
42 protected:
43 QChart::ChartTheme m_id;
43 QChart::ChartTheme m_id;
@@ -3,6 +3,7
3 #include "chartpresenter_p.h"
3 #include "chartpresenter_p.h"
4 #include "chartdataset_p.h"
4 #include "chartdataset_p.h"
5
5
6 <<<<<<< HEAD
6 //series
7 //series
7 #include "qbarchartseries.h"
8 #include "qbarchartseries.h"
8 #include "qstackedbarchartseries.h"
9 #include "qstackedbarchartseries.h"
@@ -11,7 +12,6
11 #include "qscatterseries.h"
12 #include "qscatterseries.h"
12 //#include "scatterseries_p.h"
13 //#include "scatterseries_p.h"
13 #include "qpieseries.h"
14 #include "qpieseries.h"
14
15 #include <QGraphicsScene>
15 #include <QGraphicsScene>
16 #include <QGraphicsSceneResizeEvent>
16 #include <QGraphicsSceneResizeEvent>
17 #include <QDebug>
17 #include <QDebug>
@@ -28,86 +28,55 m_presenter(new ChartPresenter(this,m_dataset))
28
28
29 QChart::~QChart() {}
29 QChart::~QChart() {}
30
30
31 void QChart::addSeries(QChartSeries* series)
31 void QChart::addSeries(QChartSeries* series,QChartAxis* axisY)
32 {
32 {
33 m_dataset->addSeries(series);
33 m_dataset->addSeries(series,axisY);
34 }
34 }
35
36 //TODO on review, is it really needed ??
37 QChartSeries* QChart::createSeries(QChartSeries::QChartSeriesType type)
38 {
39 QChartSeries *series(0);
40
41 switch (type) {
42 case QChartSeries::SeriesTypeLine: {
43 series = new QLineChartSeries(this);
44 break;
45 }
46 case QChartSeries::SeriesTypeBar: {
47 //series = new BarChartSeries(this);
48 break;
49 }
50 case QChartSeries::SeriesTypeStackedBar: {
51 //series = new StackedBarChartSeries(this);
52 break;
53 }
54 case QChartSeries::SeriesTypePercentBar: {
55 //series = new PercentBarChartSeries(this);
56 break;
57 }
58 case QChartSeries::SeriesTypeScatter: {
59 series = new QScatterSeries(this);
60 break;
61 }
62 case QChartSeries::SeriesTypePie: {
63 series = new QPieSeries(this);
64 break;
65 }
66 default:
67 Q_ASSERT(false);
68 break;
69 }
70
35
71 addSeries(series);
36 void QChart::removeSeries(QChartSeries* series)
72 return series;
37 {
38 m_dataset->removeSeries(series);
73 }
39 }
74
40
75 void QChart::setChartBackgroundBrush(const QBrush& brush)
41 void QChart::setChartBackgroundBrush(const QBrush& brush)
76 {
42 {
77
43 createChartBackgroundItem();
78 if(!m_backgroundItem) {
79 m_backgroundItem = new QGraphicsRectItem(this);
80 m_backgroundItem->setZValue(-1);
81 }
82
83 m_backgroundItem->setBrush(brush);
44 m_backgroundItem->setBrush(brush);
84 m_backgroundItem->update();
45 m_backgroundItem->update();
85 }
46 }
86
47
87 void QChart::setChartBackgroundPen(const QPen& pen)
48 void QChart::setChartBackgroundPen(const QPen& pen)
88 {
49 {
89
50 createChartBackgroundItem();
90 if(!m_backgroundItem) {
91 m_backgroundItem = new QGraphicsRectItem(this);
92 m_backgroundItem->setZValue(-1);
93 }
94
95 m_backgroundItem->setPen(pen);
51 m_backgroundItem->setPen(pen);
96 m_backgroundItem->update();
52 m_backgroundItem->update();
97 }
53 }
98
54
99 void QChart::setChartTitle(const QString& title)
55 void QChart::setChartTitle(const QString& title)
100 {
56 {
101 if(!m_titleItem) m_titleItem = new QGraphicsTextItem(this);
57 createChartTitleItem();
102 m_titleItem->setPlainText(title);
58 m_titleItem->setPlainText(title);
103 }
59 }
104
60
105 void QChart::setChartTitleFont(const QFont& font)
61 void QChart::setChartTitleFont(const QFont& font)
106 {
62 {
107 if(!m_titleItem) m_titleItem = new QGraphicsTextItem(this);
63 createChartTitleItem();
108 m_titleItem->setFont(font);
64 m_titleItem->setFont(font);
109 }
65 }
110
66
67 void QChart::createChartBackgroundItem()
68 {
69 if(!m_backgroundItem) {
70 m_backgroundItem = new QGraphicsRectItem(this);
71 m_backgroundItem->setZValue(-1);
72 }
73 }
74
75 void QChart::createChartTitleItem()
76 {
77 if(!m_titleItem) m_titleItem = new QGraphicsTextItem(this);
78 }
79
111 int QChart::margin() const
80 int QChart::margin() const
112 {
81 {
113 return m_presenter->margin();
82 return m_presenter->margin();
@@ -128,59 +97,44 QChart::ChartTheme QChart::chartTheme() const
128 return m_presenter->chartTheme();
97 return m_presenter->chartTheme();
129 }
98 }
130
99
131 void QChart::zoomInToRect(const QRectF& rectangle)
100 void QChart::zoomIn()
132 {
101 {
133 m_presenter->zoomInToRect(rectangle);
102 if (!m_dataset->nextDomain()) {
103 QRectF rect = m_presenter->geometry();
104 rect.setWidth(rect.width()/2);
105 rect.setHeight(rect.height()/2);
106 rect.moveCenter(m_presenter->geometry().center());
107 zoomIn(rect);
108 }
134 }
109 }
135
110
136 void QChart::zoomIn()
111 void QChart::zoomIn(const QRectF& rect)
137 {
112 {
138 m_presenter->zoomIn();
113 if(!rect.isValid()) return;
114 QRectF r = rect.normalized();
115 int margin = m_presenter->margin();
116 r.translate(-margin, -margin);
117 m_dataset->addDomain(r,m_presenter->geometry());
139 }
118 }
140
119
141 void QChart::zoomOut()
120 void QChart::zoomOut()
142 {
121 {
143 m_presenter->zoomOut();
122 m_dataset->previousDomain();
144 }
123 }
145
124
146 void QChart::zoomReset()
125 void QChart::zoomReset()
147 {
126 {
148 m_presenter->zoomReset();
127 m_dataset->clearDomains();
149 }
150
151 void QChart::setDefaultAxisX(const QChartAxis& axis)
152 {
153 m_presenter->setDefaultAxisX(axis);
154 }
155
156 void QChart::setDefaultAxisY(const QChartAxis& axis)
157 {
158 m_presenter->setDefaultAxisY(axis);
159 }
160
161 QChartAxis QChart::defaultAxisX() const
162 {
163 return m_presenter->defaultAxisX();
164 }
165
166 QChartAxis QChart::defaultAxisY() const
167 {
168 return m_presenter->defaultAxisY();
169 }
170
171 int QChart::addAxisY(const QChartAxis& axis)
172 {
173 return m_presenter->addAxisY(axis);
174 }
128 }
175
129
176 QChartAxis QChart::axisY(int id) const
130 QChartAxis* QChart::axisX() const
177 {
131 {
178 return m_presenter->axisY(id);
132 return m_dataset->axisX();
179 }
133 }
180
134
181 void QChart::removeAxisY(int id)
135 QChartAxis* QChart::axisY() const
182 {
136 {
183 m_presenter->removeAxisY(id);
137 return m_dataset->axisY();
184 }
138 }
185
139
186 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
140 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
@@ -21,11 +21,6 class ChartItem;
21 class ChartDataSet;
21 class ChartDataSet;
22 class ChartPresenter;
22 class ChartPresenter;
23
23
24 // TODO: We don't need to have QChart tied to QGraphicsItem:
25 //class QTCOMMERCIALCHART_EXPORT QChart
26 //class QTCOMMERCIALCHART_EXPORT QChartGraphicsItem : public QGraphicsItem {
27 // public: QChartGraphicsItem(QChart &chart);
28
29 /*!
24 /*!
30 * TODO: define the responsibilities
25 * TODO: define the responsibilities
31 */
26 */
@@ -47,11 +42,8 public:
47 QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
42 QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
48 ~QChart();
43 ~QChart();
49
44
50 void addSeries(QChartSeries* series);
45 void addSeries(QChartSeries* series,QChartAxis *axisY=0);
51
46 void removeSeries(QChartSeries* series);
52 //TODO: QChartSeries* createSeries(QSeriesData *data, QChartSeries::QChartSeriesType type);
53 // TODO: who owns the series now? maybe owned by chart and returned a reference instead...
54 QChartSeries* createSeries(QChartSeries::QChartSeriesType type);
55
47
56 void setMargin(int margin);
48 void setMargin(int margin);
57 int margin() const;
49 int margin() const;
@@ -63,23 +55,22 public:
63 void setChartBackgroundBrush(const QBrush& brush);
55 void setChartBackgroundBrush(const QBrush& brush);
64 void setChartBackgroundPen(const QPen& pen);
56 void setChartBackgroundPen(const QPen& pen);
65
57
66 void zoomInToRect(const QRectF& rectangle);
67 void zoomIn();
58 void zoomIn();
59 void zoomIn(const QRectF& rect);
68 void zoomOut();
60 void zoomOut();
69 void zoomReset();
61 void zoomReset();
70
62
71 void setDefaultAxisX(const QChartAxis& axis);
63 QChartAxis* axisX() const;
72 void setDefaultAxisY(const QChartAxis& axis);
64 QChartAxis* axisY() const;
73 QChartAxis defaultAxisX() const;
74 QChartAxis defaultAxisY() const;
75 QChartAxis axisY(int id) const;
76 int addAxisY(const QChartAxis& axis);
77 void removeAxisY(int id);
78
65
79 protected:
66 protected:
80 void resizeEvent(QGraphicsSceneResizeEvent *event);
67 void resizeEvent(QGraphicsSceneResizeEvent *event);
81
68
82 private:
69 private:
70 inline void createChartBackgroundItem();
71 inline void createChartTitleItem();
72
73 private:
83 Q_DISABLE_COPY(QChart)
74 Q_DISABLE_COPY(QChart)
84 QGraphicsRectItem* m_backgroundItem;
75 QGraphicsRectItem* m_backgroundItem;
85 QGraphicsTextItem* m_titleItem;
76 QGraphicsTextItem* m_titleItem;
@@ -2,85 +2,153
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 QChartAxis::QChartAxis():
5 QChartAxis::QChartAxis(QObject* parent):QObject(parent),
6 m_axisVisible(true),
6 m_axisVisible(true),
7 m_gridVisible(true),
7 m_gridVisible(true),
8 m_labelsVisible(true),
8 m_labelsVisible(true),
9 m_labelsAngle(0),
9 m_shadesVisible(true),
10 m_shadesVisible(true),
10 m_shadesOpacity(1.0)
11 m_shadesOpacity(1.0),
12 m_min(0),
13 m_max(0),
14 m_ticksCount(4)
11 {
15 {
12 // TODO Auto-generated constructor stub
13
16
14 }
17 }
15
18
16 QChartAxis::~QChartAxis()
19 QChartAxis::~QChartAxis()
17 {
20 {
18 // TODO Auto-generated destructor stub
19 }
21 }
20
22
21 void QChartAxis::setAxisPen(const QPen& pen)
23 void QChartAxis::setAxisPen(const QPen& pen)
22 {
24 {
23 m_axisPen=pen;
25 m_axisPen=pen;
26 emit update(this);
24 }
27 }
25
28
26 void QChartAxis::setAxisVisible(bool visible)
29 void QChartAxis::setAxisVisible(bool visible)
27 {
30 {
28 m_axisVisible=visible;
31 m_axisVisible=visible;
32 emit update(this);
29 }
33 }
30
34
31 void QChartAxis::setGridVisible(bool visible)
35 void QChartAxis::setGridVisible(bool visible)
32 {
36 {
33 m_gridVisible=visible;
37 m_gridVisible=visible;
38 emit update(this);
34 }
39 }
35
40
36 void QChartAxis::setGridPen(const QPen& pen)
41 void QChartAxis::setGridPen(const QPen& pen)
37 {
42 {
38 m_gridPen=pen;
43 m_gridPen=pen;
44 emit update(this);
39 }
45 }
40
46
41 void QChartAxis::setLabelsVisible(bool visible)
47 void QChartAxis::setLabelsVisible(bool visible)
42 {
48 {
43 m_labelsVisible=visible;
49 m_labelsVisible=visible;
50 emit update(this);
44 }
51 }
45
52
46 void QChartAxis::setLabelsPen(const QPen& pen)
53 void QChartAxis::setLabelsPen(const QPen& pen)
47 {
54 {
48 m_labelsPen=pen;
55 m_labelsPen=pen;
56 emit update(this);
49 }
57 }
50
58
51 void QChartAxis::setLabelsBrush(const QBrush& brush)
59 void QChartAxis::setLabelsBrush(const QBrush& brush)
52 {
60 {
53 m_labelsBrush=brush;
61 m_labelsBrush=brush;
62 emit update(this);
54 }
63 }
55
64
56 void QChartAxis::setLabelsFont(const QFont& font)
65 void QChartAxis::setLabelsFont(const QFont& font)
57 {
66 {
58 m_labelsFont=font;
67 m_labelsFont=font;
68 emit update(this);
59 }
69 }
60
70
61 void QChartAxis::setLabelsOrientation(LabelsOrientation orientation)
71 void QChartAxis::setLabelsAngle(int angle)
62 {
72 {
63 m_labelsOrientation=orientation;
73 m_labelsAngle=angle;
74 emit update(this);
64 }
75 }
65
76
66 void QChartAxis::setShadesVisible(bool visible)
77 void QChartAxis::setShadesVisible(bool visible)
67 {
78 {
68 m_shadesVisible=visible;
79 m_shadesVisible=visible;
80 emit update(this);
69 }
81 }
70
82
71 void QChartAxis::setShadesPen(const QPen& pen)
83 void QChartAxis::setShadesPen(const QPen& pen)
72 {
84 {
73 m_shadesPen=pen;
85 m_shadesPen=pen;
86 emit update(this);
74 }
87 }
75
88
76 void QChartAxis::setShadesBrush(const QBrush& brush)
89 void QChartAxis::setShadesBrush(const QBrush& brush)
77 {
90 {
78 m_shadesBrush=brush;
91 m_shadesBrush=brush;
92 emit update(this);
79 }
93 }
80
94
81 void QChartAxis::setShadesOpacity(qreal opacity)
95 void QChartAxis::setShadesOpacity(qreal opacity)
82 {
96 {
83 m_shadesOpacity=opacity;
97 m_shadesOpacity=opacity;
98 emit update(this);
84 }
99 }
85
100
101 void QChartAxis::setMin(qreal min)
102 {
103 if(m_min!=min){
104 m_min=min;
105 emit minChanged(m_min);
106 }
107 }
108
109 void QChartAxis::setMax(qreal max)
110 {
111 if(m_max!=max){
112 m_max=max;
113 emit maxChanged(m_max);
114 }
115 }
116
117 void QChartAxis::setRange(qreal min, qreal max)
118 {
119 setMin(min);
120 setMax(max);
121 }
122
123 void QChartAxis::setTicksCount(int count)
124 {
125 m_ticksCount=count;
126 emit ticksChanged(this);
127 }
128
129 void QChartAxis::addAxisTickLabel(qreal value,const QString& label)
130 {
131 m_ticks.insert(value,label);
132 emit ticksChanged(this);
133 }
134
135 void QChartAxis::removeAxisTickLabel(qreal value)
136 {
137 m_ticks.remove(value);
138 emit ticksChanged(this);
139 }
140
141 QString QChartAxis::axisTickLabel(qreal value) const
142 {
143 return m_ticks.value(value);
144 }
145
146 void QChartAxis::clearAxisTickLabels()
147 {
148 m_ticks.clear();
149 emit ticksChanged(this);
150 }
151
152 #include "moc_qchartaxis.cpp"
153
86 QTCOMMERCIALCHART_END_NAMESPACE
154 QTCOMMERCIALCHART_END_NAMESPACE
@@ -8,15 +8,14
8
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
10
11 class QTCOMMERCIALCHART_EXPORT QChartAxis
11 class QTCOMMERCIALCHART_EXPORT QChartAxis : public QObject
12 {
12 {
13 Q_OBJECT
13 public:
14 public:
14 enum LabelsOrientation{ LabelsOrientationHorizontal, LabelsOrientationVertical , LabelsOrientationSlide };
15 QChartAxis(QObject* parent =0);
16 ~QChartAxis();
15
17
16 QChartAxis();
18 //axis handling
17 virtual ~QChartAxis();
18
19 //axis
20 bool isAxisVisible() const { return m_axisVisible;};
19 bool isAxisVisible() const { return m_axisVisible;};
21 void setAxisVisible(bool visible);
20 void setAxisVisible(bool visible);
22 void setAxisPen(const QPen& pen);
21 void setAxisPen(const QPen& pen);
@@ -24,13 +23,13 public:
24 void setAxisBrush(const QBrush& brush);
23 void setAxisBrush(const QBrush& brush);
25 QBrush axisBrush() const { return m_axisBrush;};
24 QBrush axisBrush() const { return m_axisBrush;};
26
25
27 //grid
26 //grid handling
28 bool isGridVisible() const { return m_gridVisible;};
27 bool isGridVisible() const { return m_gridVisible;};
29 void setGridVisible(bool visible);
28 void setGridVisible(bool visible);
30 void setGridPen(const QPen& pen);
29 void setGridPen(const QPen& pen);
31 QPen gridPen() const {return m_gridPen;}
30 QPen gridPen() const {return m_gridPen;}
32
31
33 //labels
32 //labels handling
34 bool isLabelsVisible() const { return m_labelsVisible;};
33 bool isLabelsVisible() const { return m_labelsVisible;};
35 void setLabelsVisible(bool visible);
34 void setLabelsVisible(bool visible);
36 void setLabelsPen(const QPen& pen);
35 void setLabelsPen(const QPen& pen);
@@ -39,10 +38,10 public:
39 QBrush labelsBrush() const { return m_labelsBrush;}
38 QBrush labelsBrush() const { return m_labelsBrush;}
40 void setLabelsFont(const QFont& font);
39 void setLabelsFont(const QFont& font);
41 QFont labelFont() const { return m_labelsFont;}
40 QFont labelFont() const { return m_labelsFont;}
42 void setLabelsOrientation(LabelsOrientation orientation);
41 void setLabelsAngle(int angle);
43 LabelsOrientation labelsOrientation() const { return m_labelsOrientation;};
42 int labelsAngle() const { return m_labelsAngle;};
44
43
45 //shades
44 //shades handling
46 bool isShadesVisible() const { return m_shadesVisible;};
45 bool isShadesVisible() const { return m_shadesVisible;};
47 void setShadesVisible(bool visible);
46 void setShadesVisible(bool visible);
48 void setShadesPen(const QPen& pen);
47 void setShadesPen(const QPen& pen);
@@ -52,10 +51,29 public:
52 void setShadesOpacity(qreal opacity);
51 void setShadesOpacity(qreal opacity);
53 qreal shadesOpacity() const { return m_shadesOpacity;}
52 qreal shadesOpacity() const { return m_shadesOpacity;}
54
53
55
54 //range handling
55 void setMin(qreal min);
56 qreal min() const { return m_min;};
57 void setMax(qreal max);
58 qreal max() const { return m_max;};
59 void setRange(qreal min, qreal max);
60
61 //ticks handling
62 void setTicksCount(int count);
63 int ticksCount() const { return m_ticksCount;}
64 void addAxisTickLabel(qreal value,const QString& label);
65 void removeAxisTickLabel(qreal value);
66 QString axisTickLabel(qreal value) const ;
67 void clearAxisTickLabels();
68
69 signals:
70 void minChanged(qreal min);
71 void maxChanged(qreal max);
72 //private signal
73 void update(QChartAxis*);
74 void ticksChanged(QChartAxis*);
56
75
57 private:
76 private:
58
59 bool m_axisVisible;
77 bool m_axisVisible;
60 QPen m_axisPen;
78 QPen m_axisPen;
61 QBrush m_axisBrush;
79 QBrush m_axisBrush;
@@ -67,15 +85,18 private:
67 QPen m_labelsPen;
85 QPen m_labelsPen;
68 QBrush m_labelsBrush;
86 QBrush m_labelsBrush;
69 QFont m_labelsFont;
87 QFont m_labelsFont;
88 int m_labelsAngle;
70
89
71 bool m_shadesVisible;
90 bool m_shadesVisible;
72 QPen m_shadesPen;
91 QPen m_shadesPen;
73 QBrush m_shadesBrush;
92 QBrush m_shadesBrush;
74
75 qreal m_shadesOpacity;
93 qreal m_shadesOpacity;
76
94
95 qreal m_min;
96 qreal m_max;
77
97
78 LabelsOrientation m_labelsOrientation;
98 int m_ticksCount;
99 QMap<qreal, QString> m_ticks;
79 };
100 };
80
101
81 QTCOMMERCIALCHART_END_NAMESPACE
102 QTCOMMERCIALCHART_END_NAMESPACE
@@ -36,25 +36,19 void QChartView::resizeEvent(QResizeEvent *event)
36 QWidget::resizeEvent(event);
36 QWidget::resizeEvent(event);
37 }
37 }
38
38
39 void QChartView::addSeries(QChartSeries* series)
39 void QChartView::addSeries(QChartSeries* series,QChartAxis *axisY)
40 {
40 {
41 m_chart->addSeries(series);
41 m_chart->addSeries(series,axisY);
42 }
42 }
43
43
44 QChartSeries* QChartView::createSeries(QChartSeries::QChartSeriesType type)
44 void QChartView::zoomIn()
45 {
45 {
46
46 m_chart->zoomIn();
47 return m_chart->createSeries(type);
48 }
47 }
49
48
50 void QChartView::zoomInToRect(const QRect& rectangle)
49 void QChartView::zoomIn(const QRect& rect)
51 {
50 {
52 m_chart->zoomInToRect(rectangle);
51 m_chart->zoomIn(rect);
53 }
54
55 void QChartView::zoomIn()
56 {
57 m_chart->zoomIn();
58 }
52 }
59
53
60 void QChartView::zoomOut()
54 void QChartView::zoomOut()
@@ -167,7 +161,7 void QChartView::mouseReleaseEvent(QMouseEvent *event)
167 if (event->button() == Qt::LeftButton && m_rubberBand->isVisible()) {
161 if (event->button() == Qt::LeftButton && m_rubberBand->isVisible()) {
168 m_rubberBand->hide();
162 m_rubberBand->hide();
169 QRect rect = m_rubberBand->geometry();
163 QRect rect = m_rubberBand->geometry();
170 m_chart->zoomInToRect(rect);
164 m_chart->zoomIn(rect);
171 event->accept();
165 event->accept();
172 }
166 }
173
167
@@ -204,38 +198,14 QChart::ChartTheme QChartView::chartTheme() const
204 return m_chart->chartTheme();
198 return m_chart->chartTheme();
205 }
199 }
206
200
207 void QChartView::setDefaultAxisX(const QChartAxis& axis)
201 QChartAxis* QChartView::axisX() const
208 {
209 m_chart->setDefaultAxisX(axis);
210 }
211
212 void QChartView::setDefaultAxisY(const QChartAxis& axis)
213 {
202 {
214 m_chart->setDefaultAxisY(axis);
203 return m_chart->axisX();
215 }
204 }
216
205
217 QChartAxis QChartView::defaultAxisX() const
206 QChartAxis* QChartView::axisY() const
218 {
207 {
219 return m_chart->defaultAxisX();
208 return m_chart->axisY();
220 }
209 }
221
210
222 QChartAxis QChartView::defaultAxisY() const
223 {
224 return m_chart->defaultAxisY();
225 }
226
227 int QChartView::addAxisY(const QChartAxis& axis)
228 {
229 return m_chart->addAxisY(axis);
230 }
231
232 QChartAxis QChartView::axisY(int id) const
233 {
234 return m_chart->axisY(id);
235 }
236
237 void QChartView::removeAxisY(int id)
238 {
239 m_chart->removeAxisY(id);
240 }
241 QTCOMMERCIALCHART_END_NAMESPACE
211 QTCOMMERCIALCHART_END_NAMESPACE
@@ -23,11 +23,9 public:
23
23
24 //implement from QWidget
24 //implement from QWidget
25 void resizeEvent(QResizeEvent *event);
25 void resizeEvent(QResizeEvent *event);
26
26
27 void addSeries(QChartSeries* series); // takes ownership
27 void addSeries(QChartSeries* series,QChartAxis* axisY=0) ;// takes ownership
28
28 void removeSeries(QChartSeries* series);
29 // Convenience function
30 QChartSeries* createSeries(QChartSeries::QChartSeriesType type);
31
29
32 int margin() const;
30 int margin() const;
33
31
@@ -36,8 +34,8 public:
36 void setChartBackgroundBrush(const QBrush& brush);
34 void setChartBackgroundBrush(const QBrush& brush);
37 void setChartBackgroundPen(const QPen& pen);
35 void setChartBackgroundPen(const QPen& pen);
38
36
39 void zoomInToRect(const QRect& rectangle);
40 void zoomIn();
37 void zoomIn();
38 void zoomIn(const QRect& rect);
41 void zoomOut();
39 void zoomOut();
42
40
43 void setRubberBandPolicy(const RubberBandPolicy );
41 void setRubberBandPolicy(const RubberBandPolicy );
@@ -46,13 +44,8 public:
46 void setChartTheme(QChart::ChartTheme theme);
44 void setChartTheme(QChart::ChartTheme theme);
47 QChart::ChartTheme chartTheme() const;
45 QChart::ChartTheme chartTheme() const;
48
46
49 void setDefaultAxisX(const QChartAxis& axis);
47 QChartAxis* axisX() const;
50 void setDefaultAxisY(const QChartAxis& axis);
48 QChartAxis* axisY() const;
51 QChartAxis defaultAxisX() const;
52 QChartAxis defaultAxisY() const;
53 QChartAxis axisY(int id) const;
54 int addAxisY(const QChartAxis& axis);
55 void removeAxisY(int id);
56
49
57 protected:
50 protected:
58 void mousePressEvent(QMouseEvent *event);
51 void mousePressEvent(QMouseEvent *event);
General Comments 0
You need to be logged in to leave comments. Login now