##// END OF EJS Templates
Bugfix shades not updated aftet tick changed
Michal Klocek -
r241:0019f0f15db3
parent child
Show More
@@ -1,299 +1,298
1 #include "axisitem_p.h"
1 #include "axisitem_p.h"
2 #include "qchartaxis.h"
2 #include "qchartaxis.h"
3 #include <QPainter>
3 #include <QPainter>
4 #include <QDebug>
4 #include <QDebug>
5
5
6 static int label_padding = 5;
6 static int label_padding = 5;
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 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_type(type),
12 m_type(type),
13 m_labelsAngle(0),
13 m_labelsAngle(0),
14 m_shadesEnabled(true),
14 m_shadesEnabled(true),
15 m_grid(parent),
15 m_grid(parent),
16 m_shades(parent),
16 m_shades(parent),
17 m_labels(parent)
17 m_labels(parent)
18 {
18 {
19 //initial initialization
19 //initial initialization
20 m_shades.setZValue(0);
20 m_shades.setZValue(0);
21 m_grid.setZValue(2);
21 m_grid.setZValue(2);
22 }
22 }
23
23
24 AxisItem::~AxisItem()
24 AxisItem::~AxisItem()
25 {
25 {
26 }
26 }
27
27
28 QRectF AxisItem::boundingRect() const
28 QRectF AxisItem::boundingRect() const
29 {
29 {
30 return m_rect;
30 return m_rect;
31 }
31 }
32
32
33 void AxisItem::createItems(int count)
33 void AxisItem::createItems(int count)
34 {
34 {
35 for (int i = 0; i < count; ++i) {
35 for (int i = 0; i < count; ++i) {
36 m_grid.addToGroup(new QGraphicsLineItem(this));
36 m_grid.addToGroup(new QGraphicsLineItem(this));
37 m_labels.addToGroup(new QGraphicsSimpleTextItem(this));
37 m_labels.addToGroup(new QGraphicsSimpleTextItem(this));
38 if(i%2) m_shades.addToGroup(new QGraphicsRectItem(this));
38 if(i%2) m_shades.addToGroup(new QGraphicsRectItem(this));
39 }
39 }
40 }
40 }
41
41
42 void AxisItem::clear()
42 void AxisItem::clear()
43 {
43 {
44 foreach(QGraphicsItem* item , m_shades.childItems()) {
44 foreach(QGraphicsItem* item , m_shades.childItems()) {
45 delete item;
45 delete item;
46 }
46 }
47
47
48 foreach(QGraphicsItem* item , m_grid.childItems()) {
48 foreach(QGraphicsItem* item , m_grid.childItems()) {
49 delete item;
49 delete item;
50 }
50 }
51
51
52 foreach(QGraphicsItem* item , m_labels.childItems()) {
52 foreach(QGraphicsItem* item , m_labels.childItems()) {
53 delete item;
53 delete item;
54 }
54 }
55
55
56 m_thicksList.clear();
56 m_thicksList.clear();
57
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)
61 {
61 {
62
62
63 }
63 }
64
64
65 void AxisItem::updateItem(int count)
65 void AxisItem::updateItem(int count)
66 {
66 {
67
67
68 QList<QGraphicsItem *> lines = m_grid.childItems();
68 QList<QGraphicsItem *> lines = m_grid.childItems();
69 QList<QGraphicsItem *> labels = m_labels.childItems();
69 QList<QGraphicsItem *> labels = m_labels.childItems();
70 QList<QGraphicsItem *> shades = m_shades.childItems();
70 QList<QGraphicsItem *> shades = m_shades.childItems();
71
71
72 switch (m_type)
72 switch (m_type)
73 {
73 {
74 case X_AXIS:
74 case X_AXIS:
75 {
75 {
76 const qreal deltaX = m_rect.width() / (count-1);
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 < count; ++i) {
80 for (int i = 0; i < count; ++i) {
81 int x = i * deltaX + m_rect.left();
81 int x = i * deltaX + m_rect.left();
82 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
82 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
83 lineItem->setLine(x, m_rect.top(), x, m_rect.bottom());
83 lineItem->setLine(x, m_rect.top(), x, m_rect.bottom());
84 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
84 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
85 labelItem->setText(m_thicksList.at(i));
85 labelItem->setText(m_thicksList.at(i));
86 QPointF center = labelItem->boundingRect().center();
86 QPointF center = labelItem->boundingRect().center();
87 labelItem->setTransformOriginPoint(center.x(), center.y());
87 labelItem->setTransformOriginPoint(center.x(), center.y());
88 labelItem->setPos(x - center.x(), m_rect.bottom() + label_padding);
88 labelItem->setPos(x - center.x(), m_rect.bottom() + label_padding);
89
89
90 if(i%2){
90 if(i%2){
91 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
91 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
92 rectItem->setRect(x,m_rect.top(),deltaX,m_rect.height());
92 rectItem->setRect(x,m_rect.top(),deltaX,m_rect.height());
93 rectItem->setOpacity( 0.5 );
94 }
93 }
95 }
94 }
96 }
95 }
97 break;
96 break;
98
97
99 case Y_AXIS:
98 case Y_AXIS:
100 {
99 {
101 const qreal deltaY = m_rect.height()/ (count-1);
100 const qreal deltaY = m_rect.height()/ (count-1);
102
101
103 m_axis.setLine(m_rect.left() , m_rect.top(), m_rect.left(), m_rect.bottom());
102 m_axis.setLine(m_rect.left() , m_rect.top(), m_rect.left(), m_rect.bottom());
104
103
105 for (int i = 0; i < count; ++i) {
104 for (int i = 0; i < count; ++i) {
106 int y = i * -deltaY + m_rect.bottom();
105 int y = i * -deltaY + m_rect.bottom();
107 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
106 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
108 lineItem->setLine(m_rect.left() , y, m_rect.right(), y);
107 lineItem->setLine(m_rect.left() , y, m_rect.right(), y);
109 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
108 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
110 labelItem->setText(m_thicksList.at(i));
109 labelItem->setText(m_thicksList.at(i));
111 QPointF center = labelItem->boundingRect().center();
110 QPointF center = labelItem->boundingRect().center();
112 labelItem->setTransformOriginPoint(center.x(), center.y());
111 labelItem->setTransformOriginPoint(center.x(), center.y());
113 labelItem->setPos(m_rect.left() - labelItem->boundingRect().width() - label_padding , y-center.y());
112 labelItem->setPos(m_rect.left() - labelItem->boundingRect().width() - label_padding , y-center.y());
114 if(i%2){
113 if(i%2){
115 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
114 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
116 rectItem->setRect(m_rect.left(),y,m_rect.width(),deltaY);
115 rectItem->setRect(m_rect.left(),y,m_rect.width(),deltaY);
117
118 }
116 }
119 }
117 }
120 }
118 }
121 break;
119 break;
122 default:
120 default:
123 qDebug()<<"Unknown axis type";
121 qDebug()<<"Unknown axis type";
124 break;
122 break;
125 }
123 }
126 }
124 }
127
125
128 void AxisItem::handleAxisUpdate(QChartAxis* axis)
126 void AxisItem::handleAxisUpdate(QChartAxis* axis)
129 {
127 {
130 if(axis->isAxisVisible()) {
128 if(axis->isAxisVisible()) {
131 setAxisOpacity(100);
129 setAxisOpacity(100);
132 }
130 }
133 else {
131 else {
134 setAxisOpacity(0);
132 setAxisOpacity(0);
135 }
133 }
136
134
137 if(axis->isGridVisible()) {
135 if(axis->isGridVisible()) {
138 setGridOpacity(100);
136 setGridOpacity(100);
139 }
137 }
140 else {
138 else {
141 setGridOpacity(0);
139 setGridOpacity(0);
142 }
140 }
143
141
144 if(axis->isLabelsVisible())
142 if(axis->isLabelsVisible())
145 {
143 {
146 setLabelsOpacity(100);
144 setLabelsOpacity(100);
147 }
145 }
148 else {
146 else {
149 setLabelsOpacity(0);
147 setLabelsOpacity(0);
150 }
148 }
151
149
152 if(axis->isShadesVisible()) {
150 if(axis->isShadesVisible()) {
153 setShadesOpacity(axis->shadesOpacity());
151 setShadesOpacity(axis->shadesOpacity());
154 }
152 }
155 else {
153 else {
156 setShadesOpacity(0);
154 setShadesOpacity(0);
157 }
155 }
158
156
159 setLabelsAngle(axis->labelsAngle());
157 setLabelsAngle(axis->labelsAngle());
160 setAxisPen(axis->axisPen());
158 setAxisPen(axis->axisPen());
161 setLabelsPen(axis->labelsPen());
159 setLabelsPen(axis->labelsPen());
162 setLabelsBrush(axis->labelsBrush());
160 setLabelsBrush(axis->labelsBrush());
163 setLabelsFont(axis->labelFont());
161 setLabelsFont(axis->labelFont());
164 setGridPen(axis->gridPen());
162 setGridPen(axis->gridPen());
165 setShadesPen(axis->shadesPen());
163 setShadesPen(axis->shadesPen());
166 setShadesBrush(axis->shadesBrush());
164 setShadesBrush(axis->shadesBrush());
167 }
165 }
168
166
169 void AxisItem::handleLabelsChanged(const QStringList& labels)
167 void AxisItem::handleLabelsChanged(QChartAxis* axis,const QStringList& labels)
170 {
168 {
171 m_thicksList=labels;
169 m_thicksList=labels;
172 QList<QGraphicsItem*> items = m_labels.childItems();
170 QList<QGraphicsItem*> items = m_labels.childItems();
173 if(items.size()!=m_thicksList.size()){
171 if(items.size()!=m_thicksList.size()){
174 clear();
172 clear();
175 m_thicksList=labels;
173 m_thicksList=labels;
176 createItems(m_thicksList.size());
174 createItems(m_thicksList.size());
177 items = m_labels.childItems();
175 items = m_labels.childItems();
176 handleAxisUpdate(axis);
178 }
177 }
179
178
180 Q_ASSERT(items.size()==m_thicksList.size());
179 Q_ASSERT(items.size()==m_thicksList.size());
181
180
182 int i=0;
181 int i=0;
183 foreach(QGraphicsItem* item, items){
182 foreach(QGraphicsItem* item, items){
184 static_cast<QGraphicsSimpleTextItem*>(item)->setText(m_thicksList.at(i));
183 static_cast<QGraphicsSimpleTextItem*>(item)->setText(m_thicksList.at(i));
185 i++;
184 i++;
186 }
185 }
187 update();
186 update();
188 }
187 }
189
188
190 void AxisItem::handleGeometryChanged(const QRectF& rect)
189 void AxisItem::handleGeometryChanged(const QRectF& rect)
191 {
190 {
192 m_rect = rect;
191 m_rect = rect;
193 updateItem(m_thicksList.size());
192 updateItem(m_thicksList.size());
194 update();
193 update();
195 }
194 }
196
195
197 void AxisItem::setAxisOpacity(qreal opacity)
196 void AxisItem::setAxisOpacity(qreal opacity)
198 {
197 {
199 m_axis.setOpacity(opacity);
198 m_axis.setOpacity(opacity);
200 }
199 }
201
200
202 qreal AxisItem::axisOpacity() const
201 qreal AxisItem::axisOpacity() const
203 {
202 {
204 return m_axis.opacity();
203 return m_axis.opacity();
205 }
204 }
206
205
207 void AxisItem::setGridOpacity(qreal opacity)
206 void AxisItem::setGridOpacity(qreal opacity)
208 {
207 {
209 m_grid.setOpacity(opacity);
208 m_grid.setOpacity(opacity);
210 }
209 }
211
210
212
211
213 qreal AxisItem::gridOpacity() const
212 qreal AxisItem::gridOpacity() const
214 {
213 {
215 return m_grid.opacity();
214 return m_grid.opacity();
216 }
215 }
217
216
218 void AxisItem::setLabelsOpacity(qreal opacity)
217 void AxisItem::setLabelsOpacity(qreal opacity)
219 {
218 {
220 m_labels.setOpacity(opacity);
219 m_labels.setOpacity(opacity);
221 }
220 }
222
221
223 qreal AxisItem::labelsOpacity() const
222 qreal AxisItem::labelsOpacity() const
224 {
223 {
225 return m_labels.opacity();
224 return m_labels.opacity();
226 }
225 }
227
226
228 void AxisItem::setShadesOpacity(qreal opacity)
227 void AxisItem::setShadesOpacity(qreal opacity)
229 {
228 {
230 m_shades.setOpacity(opacity);
229 m_shades.setOpacity(opacity);
231 }
230 }
232
231
233 qreal AxisItem::shadesOpacity() const
232 qreal AxisItem::shadesOpacity() const
234 {
233 {
235 return m_shades.opacity();
234 return m_shades.opacity();
236 }
235 }
237
236
238 void AxisItem::setLabelsAngle(int angle)
237 void AxisItem::setLabelsAngle(int angle)
239 {
238 {
240 foreach(QGraphicsItem* item , m_labels.childItems()) {
239 foreach(QGraphicsItem* item , m_labels.childItems()) {
241 QPointF center = item->boundingRect().center();
240 QPointF center = item->boundingRect().center();
242 item->setRotation(angle);
241 item->setRotation(angle);
243 }
242 }
244
243
245 m_labelsAngle=angle;
244 m_labelsAngle=angle;
246 }
245 }
247
246
248 void AxisItem::setLabelsPen(const QPen& pen)
247 void AxisItem::setLabelsPen(const QPen& pen)
249 {
248 {
250 foreach(QGraphicsItem* item , m_labels.childItems()) {
249 foreach(QGraphicsItem* item , m_labels.childItems()) {
251 static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen);
250 static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen);
252 }
251 }
253 }
252 }
254
253
255 void AxisItem::setLabelsBrush(const QBrush& brush)
254 void AxisItem::setLabelsBrush(const QBrush& brush)
256 {
255 {
257 foreach(QGraphicsItem* item , m_labels.childItems()) {
256 foreach(QGraphicsItem* item , m_labels.childItems()) {
258 static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush);
257 static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush);
259 }
258 }
260 }
259 }
261
260
262 void AxisItem::setLabelsFont(const QFont& font)
261 void AxisItem::setLabelsFont(const QFont& font)
263 {
262 {
264 foreach(QGraphicsItem* item , m_labels.childItems()) {
263 foreach(QGraphicsItem* item , m_labels.childItems()) {
265 static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font);
264 static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font);
266 }
265 }
267 }
266 }
268
267
269 void AxisItem::setShadesBrush(const QBrush& brush)
268 void AxisItem::setShadesBrush(const QBrush& brush)
270 {
269 {
271 foreach(QGraphicsItem* item , m_shades.childItems()) {
270 foreach(QGraphicsItem* item , m_shades.childItems()) {
272 static_cast<QGraphicsRectItem*>(item)->setBrush(brush);
271 static_cast<QGraphicsRectItem*>(item)->setBrush(brush);
273 }
272 }
274 }
273 }
275
274
276 void AxisItem::setShadesPen(const QPen& pen)
275 void AxisItem::setShadesPen(const QPen& pen)
277 {
276 {
278 foreach(QGraphicsItem* item , m_shades.childItems()) {
277 foreach(QGraphicsItem* item , m_shades.childItems()) {
279 static_cast<QGraphicsRectItem*>(item)->setPen(pen);
278 static_cast<QGraphicsRectItem*>(item)->setPen(pen);
280 }
279 }
281 }
280 }
282
281
283 void AxisItem::setAxisPen(const QPen& pen)
282 void AxisItem::setAxisPen(const QPen& pen)
284 {
283 {
285 m_axis.setPen(pen);
284 m_axis.setPen(pen);
286 }
285 }
287
286
288 void AxisItem::setGridPen(const QPen& pen)
287 void AxisItem::setGridPen(const QPen& pen)
289 {
288 {
290 foreach(QGraphicsItem* item , m_grid.childItems()) {
289 foreach(QGraphicsItem* item , m_grid.childItems()) {
291 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
290 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
292 }
291 }
293 }
292 }
294
293
295
294
296 //TODO "nice numbers algorithm"
295 //TODO "nice numbers algorithm"
297 #include "moc_axisitem_p.cpp"
296 #include "moc_axisitem_p.cpp"
298
297
299 QTCOMMERCIALCHART_END_NAMESPACE
298 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,76 +1,76
1 #ifndef AXISITEM_H_
1 #ifndef AXISITEM_H_
2 #define AXISITEM_H_
2 #define AXISITEM_H_
3
3
4 #include "domain_p.h"
4 #include "domain_p.h"
5 #include "chartitem_p.h"
5 #include "chartitem_p.h"
6 #include <QGraphicsItem>
6 #include <QGraphicsItem>
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 class QChartAxis;
10 class QChartAxis;
11
11
12 class AxisItem : public QObject, public ChartItem
12 class AxisItem : public QObject, public ChartItem
13 {
13 {
14 Q_OBJECT
14 Q_OBJECT
15 public:
15 public:
16 enum AxisType{X_AXIS,Y_AXIS};
16 enum AxisType{X_AXIS,Y_AXIS};
17
17
18 AxisItem(AxisType type = X_AXIS,QGraphicsItem* parent = 0);
18 AxisItem(AxisType type = X_AXIS,QGraphicsItem* parent = 0);
19 ~AxisItem();
19 ~AxisItem();
20
20
21 //from QGraphicsItem
21 //from QGraphicsItem
22 QRectF boundingRect() const;
22 QRectF boundingRect() const;
23 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
23 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
24
24
25 AxisType axisType() const {return m_type;};
25 AxisType axisType() const {return m_type;};
26
26
27 void setAxisOpacity(qreal opacity);
27 void setAxisOpacity(qreal opacity);
28 qreal axisOpacity() const;
28 qreal axisOpacity() const;
29
29
30 void setGridOpacity(qreal opacity);
30 void setGridOpacity(qreal opacity);
31 qreal gridOpacity() const;
31 qreal gridOpacity() const;
32
32
33 void setLabelsOpacity(qreal opacity);
33 void setLabelsOpacity(qreal opacity);
34 qreal labelsOpacity() const;
34 qreal labelsOpacity() const;
35
35
36 void setShadesOpacity(qreal opacity);
36 void setShadesOpacity(qreal opacity);
37 qreal shadesOpacity() const;
37 qreal shadesOpacity() const;
38
38
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 setShadesBrush(const QBrush& brush);
42 void setShadesBrush(const QBrush& brush);
43 void setShadesPen(const QPen& pen);
43 void setShadesPen(const QPen& pen);
44
44
45 void setAxisPen(const QPen& pen);
45 void setAxisPen(const QPen& pen);
46 void setGridPen(const QPen& pen);
46 void setGridPen(const QPen& pen);
47
47
48 void setLabelsPen(const QPen& pen);
48 void setLabelsPen(const QPen& pen);
49 void setLabelsBrush(const QBrush& brush);
49 void setLabelsBrush(const QBrush& brush);
50 void setLabelsFont(const QFont& font);
50 void setLabelsFont(const QFont& font);
51
51
52 public slots:
52 public slots:
53 void handleAxisUpdate(QChartAxis* axis);
53 void handleAxisUpdate(QChartAxis* axis);
54 void handleLabelsChanged(const QStringList& labels);
54 void handleLabelsChanged(QChartAxis* axis,const QStringList& labels);
55 void handleGeometryChanged(const QRectF& size);
55 void handleGeometryChanged(const QRectF& size);
56 protected:
56 protected:
57 void updateItem(int count);
57 void updateItem(int count);
58 private:
58 private:
59 void clear();
59 void clear();
60 void createItems(int count);
60 void createItems(int count);
61 private:
61 private:
62 AxisType m_type;
62 AxisType m_type;
63 QRectF m_rect;
63 QRectF m_rect;
64 int m_labelsAngle;
64 int m_labelsAngle;
65 bool m_shadesEnabled;
65 bool m_shadesEnabled;
66 QGraphicsItemGroup m_grid;
66 QGraphicsItemGroup m_grid;
67 QGraphicsItemGroup m_shades;
67 QGraphicsItemGroup m_shades;
68 QGraphicsItemGroup m_labels;
68 QGraphicsItemGroup m_labels;
69 QGraphicsLineItem m_axis;
69 QGraphicsLineItem m_axis;
70 QStringList m_thicksList;
70 QStringList m_thicksList;
71
71
72 };
72 };
73
73
74 QTCOMMERCIALCHART_END_NAMESPACE
74 QTCOMMERCIALCHART_END_NAMESPACE
75
75
76 #endif /* AXISITEM_H_ */
76 #endif /* AXISITEM_H_ */
@@ -1,334 +1,334
1 #include "chartdataset_p.h"
1 #include "chartdataset_p.h"
2 #include "qchartaxis.h"
2 #include "qchartaxis.h"
3 //series
3 //series
4 #include "qlinechartseries.h"
4 #include "qlinechartseries.h"
5 #include "qbarchartseries.h"
5 #include "qbarchartseries.h"
6 #include "qstackedbarchartseries.h"
6 #include "qstackedbarchartseries.h"
7 #include "qpercentbarchartseries.h"
7 #include "qpercentbarchartseries.h"
8 #include "qpieseries.h"
8 #include "qpieseries.h"
9 #include "qscatterseries.h"
9 #include "qscatterseries.h"
10
10
11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
12
12
13 ChartDataSet::ChartDataSet(QObject *parent):QObject(parent),
13 ChartDataSet::ChartDataSet(QObject *parent):QObject(parent),
14 m_axisX(new QChartAxis(this)),
14 m_axisX(new QChartAxis(this)),
15 m_axisY(new QChartAxis(this)),
15 m_axisY(new QChartAxis(this)),
16 m_domainIndex(0),
16 m_domainIndex(0),
17 m_axisXInitialized(false)
17 m_axisXInitialized(false)
18 {
18 {
19 }
19 }
20
20
21 ChartDataSet::~ChartDataSet()
21 ChartDataSet::~ChartDataSet()
22 {
22 {
23 // TODO Auto-generated destructor stub
23 // TODO Auto-generated destructor stub
24 }
24 }
25
25
26 const Domain ChartDataSet::domain(QChartAxis *axisY) const
26 const Domain ChartDataSet::domain(QChartAxis *axisY) const
27 {
27 {
28 int i = m_domainMap.count(axisY);
28 int i = m_domainMap.count(axisY);
29 if(i == 0){
29 if(i == 0){
30 return Domain();
30 return Domain();
31 }
31 }
32 i = i - m_domainIndex -1;
32 i = i - m_domainIndex -1;
33 return m_domainMap.values(axisY).at(i);
33 return m_domainMap.values(axisY).at(i);
34 }
34 }
35
35
36 void ChartDataSet::addSeries(QChartSeries* series, QChartAxis *axisY)
36 void ChartDataSet::addSeries(QChartSeries* series, QChartAxis *axisY)
37 {
37 {
38 // TODO: we should check the series not already added
38 // TODO: we should check the series not already added
39 series->setParent(this); // take ownership
39 series->setParent(this); // take ownership
40
40
41 series->setParent(this); // take ownership
41 series->setParent(this); // take ownership
42 clearDomains();
42 clearDomains();
43
43
44 if(axisY==0) axisY = m_axisY;
44 if(axisY==0) axisY = m_axisY;
45
45
46 QList<QChartSeries*> seriesList = m_seriesMap.values(axisY);
46 QList<QChartSeries*> seriesList = m_seriesMap.values(axisY);
47
47
48 QList<Domain> domainList = m_domainMap.values(axisY);
48 QList<Domain> domainList = m_domainMap.values(axisY);
49
49
50 Q_ASSERT(domainList.size()<=1);
50 Q_ASSERT(domainList.size()<=1);
51
51
52 Domain domain;
52 Domain domain;
53
53
54 if(domainList.size()>0) domain = domainList.at(0);
54 if(domainList.size()>0) domain = domainList.at(0);
55
55
56 switch(series->type())
56 switch(series->type())
57 {
57 {
58 case QChartSeries::SeriesTypeLine: {
58 case QChartSeries::SeriesTypeLine: {
59
59
60 QLineChartSeries* xyseries = static_cast<QLineChartSeries*>(series);
60 QLineChartSeries* xyseries = static_cast<QLineChartSeries*>(series);
61
61
62 for (int i = 0; i < xyseries->count(); i++)
62 for (int i = 0; i < xyseries->count(); i++)
63 {
63 {
64 qreal x = xyseries->x(i);
64 qreal x = xyseries->x(i);
65 qreal y = xyseries->y(i);
65 qreal y = xyseries->y(i);
66 domain.m_minX = qMin(domain.m_minX,x);
66 domain.m_minX = qMin(domain.m_minX,x);
67 domain.m_minY = qMin(domain.m_minY,y);
67 domain.m_minY = qMin(domain.m_minY,y);
68 domain.m_maxX = qMax(domain.m_maxX,x);
68 domain.m_maxX = qMax(domain.m_maxX,x);
69 domain.m_maxY = qMax(domain.m_maxY,y);
69 domain.m_maxY = qMax(domain.m_maxY,y);
70 }
70 }
71 break;
71 break;
72 }
72 }
73 case QChartSeries::SeriesTypeBar: {
73 case QChartSeries::SeriesTypeBar: {
74 qDebug() << "QChartSeries::SeriesTypeBar";
74 qDebug() << "QChartSeries::SeriesTypeBar";
75 QBarChartSeries* barSeries = static_cast<QBarChartSeries*>(series);
75 QBarChartSeries* barSeries = static_cast<QBarChartSeries*>(series);
76 qreal x = barSeries->countCategories();
76 qreal x = barSeries->countCategories();
77 qreal y = barSeries->max();
77 qreal y = barSeries->max();
78 domain.m_minX = qMin(domain.m_minX,x);
78 domain.m_minX = qMin(domain.m_minX,x);
79 domain.m_minY = qMin(domain.m_minY,y);
79 domain.m_minY = qMin(domain.m_minY,y);
80 domain.m_maxX = qMax(domain.m_maxX,x);
80 domain.m_maxX = qMax(domain.m_maxX,x);
81 domain.m_maxY = qMax(domain.m_maxY,y);
81 domain.m_maxY = qMax(domain.m_maxY,y);
82 break;
82 break;
83 }
83 }
84 case QChartSeries::SeriesTypeStackedBar: {
84 case QChartSeries::SeriesTypeStackedBar: {
85 qDebug() << "QChartSeries::SeriesTypeStackedBar";
85 qDebug() << "QChartSeries::SeriesTypeStackedBar";
86
86
87 QStackedBarChartSeries* stackedBarSeries = static_cast<QStackedBarChartSeries*>(series);
87 QStackedBarChartSeries* stackedBarSeries = static_cast<QStackedBarChartSeries*>(series);
88 qreal x = stackedBarSeries->countCategories();
88 qreal x = stackedBarSeries->countCategories();
89 qreal y = stackedBarSeries->maxCategorySum();
89 qreal y = stackedBarSeries->maxCategorySum();
90 domain.m_minX = qMin(domain.m_minX,x);
90 domain.m_minX = qMin(domain.m_minX,x);
91 domain.m_minY = qMin(domain.m_minY,y);
91 domain.m_minY = qMin(domain.m_minY,y);
92 domain.m_maxX = qMax(domain.m_maxX,x);
92 domain.m_maxX = qMax(domain.m_maxX,x);
93 domain.m_maxY = qMax(domain.m_maxY,y);
93 domain.m_maxY = qMax(domain.m_maxY,y);
94 break;
94 break;
95 }
95 }
96 case QChartSeries::SeriesTypePercentBar: {
96 case QChartSeries::SeriesTypePercentBar: {
97 qDebug() << "QChartSeries::SeriesTypePercentBar";
97 qDebug() << "QChartSeries::SeriesTypePercentBar";
98
98
99 QPercentBarChartSeries* percentBarSeries = static_cast<QPercentBarChartSeries*>(series);
99 QPercentBarChartSeries* percentBarSeries = static_cast<QPercentBarChartSeries*>(series);
100 qreal x = percentBarSeries->countCategories();
100 qreal x = percentBarSeries->countCategories();
101 domain.m_minX = qMin(domain.m_minX,x);
101 domain.m_minX = qMin(domain.m_minX,x);
102 domain.m_minY = 0;
102 domain.m_minY = 0;
103 domain.m_maxX = qMax(domain.m_maxX,x);
103 domain.m_maxX = qMax(domain.m_maxX,x);
104 domain.m_maxY = 100;
104 domain.m_maxY = 100;
105 break;
105 break;
106 }
106 }
107
107
108 case QChartSeries::SeriesTypePie: {
108 case QChartSeries::SeriesTypePie: {
109 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
109 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
110 // TODO: domain stuff
110 // TODO: domain stuff
111 break;
111 break;
112 }
112 }
113
113
114 case QChartSeries::SeriesTypeScatter: {
114 case QChartSeries::SeriesTypeScatter: {
115 QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series);
115 QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series);
116 Q_ASSERT(scatterSeries);
116 Q_ASSERT(scatterSeries);
117 foreach (QPointF point, scatterSeries->data()) {
117 foreach (QPointF point, scatterSeries->data()) {
118 domain.m_minX = qMin(domain.m_minX, point.x());
118 domain.m_minX = qMin(domain.m_minX, point.x());
119 domain.m_maxX = qMax(domain.m_maxX, point.x());
119 domain.m_maxX = qMax(domain.m_maxX, point.x());
120 domain.m_minY = qMin(domain.m_minY, point.y());
120 domain.m_minY = qMin(domain.m_minY, point.y());
121 domain.m_maxY = qMax(domain.m_maxY, point.y());
121 domain.m_maxY = qMax(domain.m_maxY, point.y());
122 }
122 }
123 break;
123 break;
124 }
124 }
125
125
126 default: {
126 default: {
127 qDebug()<<__FUNCTION__<<"type" << series->type()<<"not supported";
127 qDebug()<<__FUNCTION__<<"type" << series->type()<<"not supported";
128 return;
128 return;
129 break;
129 break;
130 }
130 }
131
131
132 }
132 }
133
133
134 if(!m_domainMap.contains(axisY))
134 if(!m_domainMap.contains(axisY))
135 {
135 {
136 emit axisAdded(axisY);
136 emit axisAdded(axisY);
137 QObject::connect(axisY,SIGNAL(minChanged(qreal)),this,SLOT(handleMinChanged(qreal)));
137 QObject::connect(axisY,SIGNAL(minChanged(qreal)),this,SLOT(handleMinChanged(qreal)));
138 QObject::connect(axisY,SIGNAL(maxChanged(qreal)),this,SLOT(handleMaxChanged(qreal)));
138 QObject::connect(axisY,SIGNAL(maxChanged(qreal)),this,SLOT(handleMaxChanged(qreal)));
139 QObject::connect(axisY,SIGNAL(ticksChanged(QChartAxis*)),this,SLOT(handleTickChanged(QChartAxis*)));
139 QObject::connect(axisY,SIGNAL(ticksChanged(QChartAxis*)),this,SLOT(handleTickChanged(QChartAxis*)));
140 }
140 }
141 m_domainMap.replace(axisY,domain);
141 m_domainMap.replace(axisY,domain);
142 m_seriesMap.insert(axisY,series);
142 m_seriesMap.insert(axisY,series);
143
143
144 if(!m_axisXInitialized)
144 if(!m_axisXInitialized)
145 {
145 {
146 emit axisAdded(axisX());
146 emit axisAdded(axisX());
147 QObject::connect(axisX(),SIGNAL(minChanged(qreal)),this,SLOT(handleMinChanged(qreal)));
147 QObject::connect(axisX(),SIGNAL(minChanged(qreal)),this,SLOT(handleMinChanged(qreal)));
148 QObject::connect(axisX(),SIGNAL(maxChanged(qreal)),this,SLOT(handleMaxChanged(qreal)));
148 QObject::connect(axisX(),SIGNAL(maxChanged(qreal)),this,SLOT(handleMaxChanged(qreal)));
149 QObject::connect(axisX(),SIGNAL(ticksChanged(QChartAxis*)),this,SLOT(handleTickChanged(QChartAxis*)));
149 QObject::connect(axisX(),SIGNAL(ticksChanged(QChartAxis*)),this,SLOT(handleTickChanged(QChartAxis*)));
150 m_axisXInitialized=true;
150 m_axisXInitialized=true;
151 }
151 }
152
152
153
153
154 emit seriesAdded(series);
154 emit seriesAdded(series);
155 QStringList ylabels = createLabels(axisY,domain.m_minY,domain.m_maxY);
155 QStringList ylabels = createLabels(axisY,domain.m_minY,domain.m_maxY);
156 QStringList xlabels = createLabels(axisX(),domain.m_minX,domain.m_maxX);
156 QStringList xlabels = createLabels(axisX(),domain.m_minX,domain.m_maxX);
157 emit axisLabelsChanged(axisY,ylabels);
157 emit axisLabelsChanged(axisY,ylabels);
158 emit axisLabelsChanged(axisX(),xlabels);
158 emit axisLabelsChanged(axisX(),xlabels);
159 emit seriesDomainChanged(series,domain);
159 emit seriesDomainChanged(series,domain);
160
160
161 }
161 }
162
162
163 void ChartDataSet::removeSeries(QChartSeries* series)
163 void ChartDataSet::removeSeries(QChartSeries* series)
164 {
164 {
165 QList<QChartAxis*> keys = m_seriesMap.uniqueKeys();
165 QList<QChartAxis*> keys = m_seriesMap.uniqueKeys();
166 foreach(QChartAxis* axis , keys) {
166 foreach(QChartAxis* axis , keys) {
167 if(m_seriesMap.contains(axis,series)){
167 if(m_seriesMap.contains(axis,series)){
168 emit seriesRemoved(series);
168 emit seriesRemoved(series);
169 m_seriesMap.remove(axis,series);
169 m_seriesMap.remove(axis,series);
170 //remove axis if no longer there
170 //remove axis if no longer there
171 if(!m_seriesMap.contains(axis) && axis != m_axisY){
171 if(!m_seriesMap.contains(axis) && axis != m_axisY){
172 emit axisRemoved(axis);
172 emit axisRemoved(axis);
173 m_domainMap.remove(axis);
173 m_domainMap.remove(axis);
174 delete axis;
174 delete axis;
175 }
175 }
176 break;
176 break;
177 }
177 }
178 }
178 }
179 }
179 }
180
180
181 bool ChartDataSet::nextDomain()
181 bool ChartDataSet::nextDomain()
182 {
182 {
183 int limit = (m_domainMap.values().size()/m_domainMap.uniqueKeys().size())-1;
183 int limit = (m_domainMap.values().size()/m_domainMap.uniqueKeys().size())-1;
184
184
185 if (m_domainIndex < limit) {
185 if (m_domainIndex < limit) {
186 m_domainIndex++;
186 m_domainIndex++;
187 setDomain(m_domainIndex);
187 setDomain(m_domainIndex);
188 return true;
188 return true;
189 }
189 }
190 else {
190 else {
191 return false;
191 return false;
192 }
192 }
193 }
193 }
194
194
195 bool ChartDataSet::previousDomain()
195 bool ChartDataSet::previousDomain()
196 {
196 {
197 if (m_domainIndex > 0) {
197 if (m_domainIndex > 0) {
198 m_domainIndex--;
198 m_domainIndex--;
199 setDomain(m_domainIndex);
199 setDomain(m_domainIndex);
200 return true;
200 return true;
201 }
201 }
202 else {
202 else {
203 return false;
203 return false;
204 }
204 }
205 }
205 }
206
206
207 void ChartDataSet::setDomain(int index)
207 void ChartDataSet::setDomain(int index)
208 {
208 {
209 QList<QChartAxis*> domainList = m_domainMap.uniqueKeys();
209 QList<QChartAxis*> domainList = m_domainMap.uniqueKeys();
210 foreach (QChartAxis* axis , domainList) {
210 foreach (QChartAxis* axis , domainList) {
211 int i = m_domainMap.count(axis) - index -1;
211 int i = m_domainMap.count(axis) - index -1;
212 Q_ASSERT(i>=0);
212 Q_ASSERT(i>=0);
213 Domain domain = m_domainMap.values(axis).at(i);
213 Domain domain = m_domainMap.values(axis).at(i);
214 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
214 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
215 QList<QChartSeries*> seriesList = m_seriesMap.values(axis);
215 QList<QChartSeries*> seriesList = m_seriesMap.values(axis);
216 foreach(QChartSeries* series, seriesList) {
216 foreach(QChartSeries* series, seriesList) {
217 emit seriesDomainChanged(series,domain);
217 emit seriesDomainChanged(series,domain);
218 }
218 }
219 emit axisLabelsChanged(axis,labels);
219 emit axisLabelsChanged(axis,labels);
220 }
220 }
221
221
222 Domain domain = m_domainMap.value(axisY());
222 Domain domain = m_domainMap.value(axisY());
223 QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX);
223 QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX);
224 emit axisLabelsChanged(axisX(),labels);
224 emit axisLabelsChanged(axisX(),labels);
225 }
225 }
226
226
227 void ChartDataSet::clearDomains(int toIndex)
227 void ChartDataSet::clearDomains(int toIndex)
228 {
228 {
229 Q_ASSERT(toIndex>=0);
229 Q_ASSERT(toIndex>=0);
230
230
231 m_domainIndex = toIndex;
231 m_domainIndex = toIndex;
232
232
233 QList<QChartAxis*> keys = m_domainMap.uniqueKeys();
233 QList<QChartAxis*> keys = m_domainMap.uniqueKeys();
234
234
235 foreach (QChartAxis* key , keys)
235 foreach (QChartAxis* key , keys)
236 {
236 {
237 QList<Domain> domains = m_domainMap.values(key);
237 QList<Domain> domains = m_domainMap.values(key);
238 m_domainMap.remove(key);
238 m_domainMap.remove(key);
239 int i = domains.size() - toIndex - 1;
239 int i = domains.size() - toIndex - 1;
240 while(i--){
240 while(i--){
241 domains.removeFirst();
241 domains.removeFirst();
242 }
242 }
243 for(int j=domains.size()-1; j>=0 ;j--)
243 for(int j=domains.size()-1; j>=0 ;j--)
244 m_domainMap.insert(key,domains.at(j));
244 m_domainMap.insert(key,domains.at(j));
245 }
245 }
246 }
246 }
247
247
248 void ChartDataSet::addDomain(const QRectF& rect, const QRectF& viewport)
248 void ChartDataSet::addDomain(const QRectF& rect, const QRectF& viewport)
249 {
249 {
250 Q_ASSERT(rect.isValid());
250 Q_ASSERT(rect.isValid());
251 Q_ASSERT(viewport.isValid());
251 Q_ASSERT(viewport.isValid());
252
252
253 clearDomains(m_domainIndex);
253 clearDomains(m_domainIndex);
254
254
255 QList<QChartAxis*> domainList = m_domainMap.uniqueKeys();
255 QList<QChartAxis*> domainList = m_domainMap.uniqueKeys();
256
256
257 foreach (QChartAxis* axis , domainList){
257 foreach (QChartAxis* axis , domainList){
258 Domain domain(m_domainMap.value(axis).subDomain(rect,viewport.width(),viewport.height()));
258 Domain domain(m_domainMap.value(axis).subDomain(rect,viewport.width(),viewport.height()));
259 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
259 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
260 QList<QChartSeries*> seriesList = m_seriesMap.values(axis);
260 QList<QChartSeries*> seriesList = m_seriesMap.values(axis);
261 foreach(QChartSeries* series, seriesList){
261 foreach(QChartSeries* series, seriesList){
262 emit seriesDomainChanged(series,domain);
262 emit seriesDomainChanged(series,domain);
263 }
263 }
264 emit axisLabelsChanged(axis,labels);
264 emit axisLabelsChanged(axis,labels);
265 m_domainMap.insert(axis,domain);
265 m_domainMap.insert(axis,domain);
266 }
266 }
267
267
268 Domain domain = m_domainMap.value(axisY());
268 Domain domain = m_domainMap.value(axisY());
269 QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX);
269 QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX);
270 emit axisLabelsChanged(axisX(),labels);
270 emit axisLabelsChanged(axisX(),labels);
271
271
272 m_domainIndex++;
272 m_domainIndex++;
273 }
273 }
274
274
275 QChartAxis* ChartDataSet::axisY(QChartSeries* series) const
275 QChartAxis* ChartDataSet::axisY(QChartSeries* series) const
276 {
276 {
277 if(series == 0) return m_axisY;
277 if(series == 0) return m_axisY;
278
278
279 QList<QChartAxis*> keys = m_seriesMap.uniqueKeys();
279 QList<QChartAxis*> keys = m_seriesMap.uniqueKeys();
280
280
281 foreach(QChartAxis* axis , keys) {
281 foreach(QChartAxis* axis , keys) {
282 if(m_seriesMap.contains(axis,series)){
282 if(m_seriesMap.contains(axis,series)){
283 return axis;
283 return axis;
284 }
284 }
285 }
285 }
286 return 0;
286 return 0;
287 }
287 }
288
288
289 QStringList ChartDataSet::createLabels(QChartAxis* axis,qreal min, qreal max)
289 QStringList ChartDataSet::createLabels(QChartAxis* axis,qreal min, qreal max)
290 {
290 {
291 Q_ASSERT(max>=min);
291 Q_ASSERT(max>=min);
292
292
293 QStringList labels;
293 QStringList labels;
294
294
295 int ticks = axis->ticksCount();
295 int ticks = axis->ticksCount()-1;
296
296
297 for(int i=0; i<= ticks; i++){
297 for(int i=0; i<= ticks; i++){
298 qreal value = min + (i * (max - min)/ ticks);
298 qreal value = min + (i * (max - min)/ ticks);
299 QString label = axis->axisTickLabel(value);
299 QString label = axis->axisTickLabel(value);
300 if(label.isEmpty()){
300 if(label.isEmpty()){
301 labels << QString::number(value);
301 labels << QString::number(value);
302 }else{
302 }else{
303 labels << label;
303 labels << label;
304 }
304 }
305 }
305 }
306 return labels;
306 return labels;
307 }
307 }
308
308
309
309
310 void ChartDataSet::handleMinChanged(qreal min)
310 void ChartDataSet::handleMinChanged(qreal min)
311 {
311 {
312
312
313 }
313 }
314
314
315 void ChartDataSet::handleMaxChanged(qreal max)
315 void ChartDataSet::handleMaxChanged(qreal max)
316 {
316 {
317
317
318 }
318 }
319
319
320 void ChartDataSet::handleTickChanged(QChartAxis* axis)
320 void ChartDataSet::handleTickChanged(QChartAxis* axis)
321 {
321 {
322 Domain domain = m_domainMap.value(axisY());
322 Domain domain = m_domainMap.value(axisY());
323 if(axis==axisX()){
323 if(axis==axisX()){
324 QStringList labels = createLabels(axis,domain.m_minX,domain.m_maxX);
324 QStringList labels = createLabels(axis,domain.m_minX,domain.m_maxX);
325 emit axisLabelsChanged(axis,labels);
325 emit axisLabelsChanged(axis,labels);
326 }else{
326 }else{
327 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
327 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
328 emit axisLabelsChanged(axis,labels);
328 emit axisLabelsChanged(axis,labels);
329 }
329 }
330 }
330 }
331
331
332 #include "moc_chartdataset_p.cpp"
332 #include "moc_chartdataset_p.cpp"
333
333
334 QTCOMMERCIALCHART_END_NAMESPACE
334 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,223 +1,223
1 #include "qchart.h"
1 #include "qchart.h"
2 #include "qchartaxis.h"
2 #include "qchartaxis.h"
3 #include "chartpresenter_p.h"
3 #include "chartpresenter_p.h"
4 #include "chartdataset_p.h"
4 #include "chartdataset_p.h"
5 #include "charttheme_p.h"
5 #include "charttheme_p.h"
6 //series
6 //series
7 #include "qbarchartseries.h"
7 #include "qbarchartseries.h"
8 #include "qstackedbarchartseries.h"
8 #include "qstackedbarchartseries.h"
9 #include "qpercentbarchartseries.h"
9 #include "qpercentbarchartseries.h"
10 #include "qlinechartseries.h"
10 #include "qlinechartseries.h"
11 #include "qpieseries.h"
11 #include "qpieseries.h"
12 #include "qscatterseries.h"
12 #include "qscatterseries.h"
13 //items
13 //items
14 #include "axisitem_p.h"
14 #include "axisitem_p.h"
15 #include "barpresenter.h"
15 #include "barpresenter.h"
16 #include "stackedbarpresenter.h"
16 #include "stackedbarpresenter.h"
17 #include "linechartitem_p.h"
17 #include "linechartitem_p.h"
18 #include "percentbarpresenter.h"
18 #include "percentbarpresenter.h"
19 #include "linechartanimationitem_p.h"
19 #include "linechartanimationitem_p.h"
20 #include "piepresenter.h"
20 #include "piepresenter.h"
21 #include "scatterpresenter_p.h"
21 #include "scatterpresenter_p.h"
22
22
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24
24
25 ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart),
25 ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart),
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_marginSize(0),
29 m_marginSize(0),
30 m_rect(QRectF(QPoint(0,0),m_chart->size()))
30 m_rect(QRectF(QPoint(0,0),m_chart->size()))
31 {
31 {
32 createConnections();
32 createConnections();
33 setChartTheme(QChart::ChartThemeDefault);
33 setChartTheme(QChart::ChartThemeDefault);
34
34
35 }
35 }
36
36
37 ChartPresenter::~ChartPresenter()
37 ChartPresenter::~ChartPresenter()
38 {
38 {
39 }
39 }
40
40
41 void ChartPresenter::createConnections()
41 void ChartPresenter::createConnections()
42 {
42 {
43 QObject::connect(m_chart,SIGNAL(geometryChanged()),this,SLOT(handleGeometryChanged()));
43 QObject::connect(m_chart,SIGNAL(geometryChanged()),this,SLOT(handleGeometryChanged()));
44 QObject::connect(m_dataset,SIGNAL(seriesAdded(QChartSeries*)),this,SLOT(handleSeriesAdded(QChartSeries*)));
44 QObject::connect(m_dataset,SIGNAL(seriesAdded(QChartSeries*)),this,SLOT(handleSeriesAdded(QChartSeries*)));
45 QObject::connect(m_dataset,SIGNAL(seriesRemoved(QChartSeries*)),this,SLOT(handleSeriesRemoved(QChartSeries*)));
45 QObject::connect(m_dataset,SIGNAL(seriesRemoved(QChartSeries*)),this,SLOT(handleSeriesRemoved(QChartSeries*)));
46 QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*)),this,SLOT(handleAxisAdded(QChartAxis*)));
46 QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*)),this,SLOT(handleAxisAdded(QChartAxis*)));
47 QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),this,SLOT(handleAxisRemoved(QChartAxis*)));
47 QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),this,SLOT(handleAxisRemoved(QChartAxis*)));
48 QObject::connect(m_dataset,SIGNAL(seriesDomainChanged(QChartSeries*,const Domain&)),this,SLOT(handleSeriesDomainChanged(QChartSeries*,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&)));
49 QObject::connect(m_dataset,SIGNAL(axisLabelsChanged(QChartAxis*,const QStringList&)),this,SLOT(handleAxisLabelsChanged(QChartAxis*,const QStringList&)));
50 }
50 }
51
51
52
52
53 QRectF ChartPresenter::geometry() const
53 QRectF ChartPresenter::geometry() const
54 {
54 {
55 return m_rect;
55 return m_rect;
56 }
56 }
57
57
58 void ChartPresenter::handleGeometryChanged()
58 void ChartPresenter::handleGeometryChanged()
59 {
59 {
60 m_rect = QRectF(QPoint(0,0),m_chart->size());
60 m_rect = QRectF(QPoint(0,0),m_chart->size());
61 m_rect.adjust(m_marginSize,m_marginSize, -m_marginSize, -m_marginSize);
61 m_rect.adjust(m_marginSize,m_marginSize, -m_marginSize, -m_marginSize);
62 Q_ASSERT(m_rect.isValid());
62 Q_ASSERT(m_rect.isValid());
63 emit geometryChanged(m_rect);
63 emit geometryChanged(m_rect);
64 }
64 }
65
65
66 int ChartPresenter::margin() const
66 int ChartPresenter::margin() const
67 {
67 {
68 return m_marginSize;
68 return m_marginSize;
69 }
69 }
70
70
71 void ChartPresenter::setMargin(int margin)
71 void ChartPresenter::setMargin(int margin)
72 {
72 {
73 m_marginSize = margin;
73 m_marginSize = margin;
74 }
74 }
75
75
76 void ChartPresenter::handleAxisAdded(QChartAxis* axis)
76 void ChartPresenter::handleAxisAdded(QChartAxis* axis)
77 {
77 {
78 AxisItem* item ;
78 AxisItem* item ;
79
79
80 if(axis==m_dataset->axisX()){
80 if(axis==m_dataset->axisX()){
81 item = new AxisItem(AxisItem::X_AXIS,m_chart);
81 item = new AxisItem(AxisItem::X_AXIS,m_chart);
82 }else{
82 }else{
83 item = new AxisItem(AxisItem::Y_AXIS,m_chart);
83 item = new AxisItem(AxisItem::Y_AXIS,m_chart);
84 }
84 }
85 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
85 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
86 QObject::connect(axis,SIGNAL(update(QChartAxis*)),item,SLOT(handleAxisUpdate(QChartAxis*)));
86 QObject::connect(axis,SIGNAL(update(QChartAxis*)),item,SLOT(handleAxisUpdate(QChartAxis*)));
87 m_chartTheme->decorate(axis,item);
87 m_chartTheme->decorate(axis,item);
88 m_axisItems.insert(axis,item);
88 m_axisItems.insert(axis,item);
89 }
89 }
90
90
91 void ChartPresenter::handleAxisRemoved(QChartAxis* axis)
91 void ChartPresenter::handleAxisRemoved(QChartAxis* axis)
92 {
92 {
93 AxisItem* item = m_axisItems.take(axis);
93 AxisItem* item = m_axisItems.take(axis);
94 Q_ASSERT(item);
94 Q_ASSERT(item);
95 delete item;
95 delete item;
96 }
96 }
97
97
98
98
99 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
99 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
100 {
100 {
101 switch(series->type())
101 switch(series->type())
102 {
102 {
103 case QChartSeries::SeriesTypeLine: {
103 case QChartSeries::SeriesTypeLine: {
104 QLineChartSeries* lineSeries = static_cast<QLineChartSeries*>(series);
104 QLineChartSeries* lineSeries = static_cast<QLineChartSeries*>(series);
105 LineChartItem* item = new LineChartAnimationItem(this,lineSeries,m_chart);
105 LineChartItem* item = new LineChartAnimationItem(this,lineSeries,m_chart);
106 m_chartTheme->decorate(item,lineSeries,m_chartItems.count());
106 m_chartTheme->decorate(item,lineSeries,m_chartItems.count());
107 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&)));
108 QObject::connect(lineSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
108 QObject::connect(lineSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
109 m_chartItems.insert(series,item);
109 m_chartItems.insert(series,item);
110 break;
110 break;
111 }
111 }
112
112
113 case QChartSeries::SeriesTypeBar: {
113 case QChartSeries::SeriesTypeBar: {
114 QBarChartSeries* barSeries = static_cast<QBarChartSeries*>(series);
114 QBarChartSeries* barSeries = static_cast<QBarChartSeries*>(series);
115 BarPresenter* item = new BarPresenter(barSeries->model(),m_chart);
115 BarPresenter* item = new BarPresenter(barSeries->model(),m_chart);
116 m_chartTheme->decorate(item,barSeries,m_chartItems.count());
116 m_chartTheme->decorate(item,barSeries,m_chartItems.count());
117 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&)));
118 QObject::connect(barSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
118 QObject::connect(barSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
119 m_chartItems.insert(series,item);
119 m_chartItems.insert(series,item);
120 // m_axisXItem->setVisible(false);
120 // m_axisXItem->setVisible(false);
121 break;
121 break;
122 }
122 }
123
123
124 case QChartSeries::SeriesTypeStackedBar: {
124 case QChartSeries::SeriesTypeStackedBar: {
125
125
126 QStackedBarChartSeries* stackedBarSeries = static_cast<QStackedBarChartSeries*>(series);
126 QStackedBarChartSeries* stackedBarSeries = static_cast<QStackedBarChartSeries*>(series);
127 StackedBarPresenter* item = new StackedBarPresenter(stackedBarSeries->model(),m_chart);
127 StackedBarPresenter* item = new StackedBarPresenter(stackedBarSeries->model(),m_chart);
128 m_chartTheme->decorate(item,stackedBarSeries,m_chartItems.count());
128 m_chartTheme->decorate(item,stackedBarSeries,m_chartItems.count());
129 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&)));
130 QObject::connect(stackedBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
130 QObject::connect(stackedBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
131 m_chartItems.insert(series,item);
131 m_chartItems.insert(series,item);
132 break;
132 break;
133 }
133 }
134
134
135 case QChartSeries::SeriesTypePercentBar: {
135 case QChartSeries::SeriesTypePercentBar: {
136
136
137 QPercentBarChartSeries* percentBarSeries = static_cast<QPercentBarChartSeries*>(series);
137 QPercentBarChartSeries* percentBarSeries = static_cast<QPercentBarChartSeries*>(series);
138 PercentBarPresenter* item = new PercentBarPresenter(percentBarSeries->model(),m_chart);
138 PercentBarPresenter* item = new PercentBarPresenter(percentBarSeries->model(),m_chart);
139 m_chartTheme->decorate(item,percentBarSeries ,m_chartItems.count());
139 m_chartTheme->decorate(item,percentBarSeries ,m_chartItems.count());
140 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&)));
141 QObject::connect(percentBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
141 QObject::connect(percentBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
142 m_chartItems.insert(series,item);
142 m_chartItems.insert(series,item);
143 break;
143 break;
144 }
144 }
145 case QChartSeries::SeriesTypeScatter: {
145 case QChartSeries::SeriesTypeScatter: {
146 QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series);
146 QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series);
147 ScatterPresenter *scatterPresenter = new ScatterPresenter(scatterSeries, m_chart);
147 ScatterPresenter *scatterPresenter = new ScatterPresenter(scatterSeries, m_chart);
148 QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)),
148 QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)),
149 scatterPresenter, SLOT(handleGeometryChanged(const QRectF&)));
149 scatterPresenter, SLOT(handleGeometryChanged(const QRectF&)));
150 m_chartTheme->decorate(scatterPresenter, scatterSeries, m_chartItems.count());
150 m_chartTheme->decorate(scatterPresenter, scatterSeries, m_chartItems.count());
151 m_chartItems.insert(scatterSeries, scatterPresenter);
151 m_chartItems.insert(scatterSeries, scatterPresenter);
152 break;
152 break;
153 }
153 }
154 case QChartSeries::SeriesTypePie: {
154 case QChartSeries::SeriesTypePie: {
155 QPieSeries *s = qobject_cast<QPieSeries *>(series);
155 QPieSeries *s = qobject_cast<QPieSeries *>(series);
156 PiePresenter* pie = new PiePresenter(m_chart, s);
156 PiePresenter* pie = new PiePresenter(m_chart, s);
157 m_chartTheme->decorate(pie, s, m_chartItems.count());
157 m_chartTheme->decorate(pie, s, m_chartItems.count());
158 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&)));
159 m_chartItems.insert(series, pie);
159 m_chartItems.insert(series, pie);
160 break;
160 break;
161 }
161 }
162 default: {
162 default: {
163 qDebug()<< "Series type" << series->type() << "not implemented.";
163 qDebug()<< "Series type" << series->type() << "not implemented.";
164 break;
164 break;
165 }
165 }
166 }
166 }
167
167
168 if(m_rect.isValid()) emit geometryChanged(m_rect);
168 if(m_rect.isValid()) emit geometryChanged(m_rect);
169 }
169 }
170
170
171 void ChartPresenter::handleSeriesRemoved(QChartSeries* series)
171 void ChartPresenter::handleSeriesRemoved(QChartSeries* series)
172 {
172 {
173 ChartItem* item = m_chartItems.take(series);
173 ChartItem* item = m_chartItems.take(series);
174 delete item;
174 delete item;
175 }
175 }
176
176
177 void ChartPresenter::handleSeriesChanged(QChartSeries* series)
177 void ChartPresenter::handleSeriesChanged(QChartSeries* series)
178 {
178 {
179 //TODO:
179 //TODO:
180 }
180 }
181
181
182 void ChartPresenter::handleSeriesDomainChanged(QChartSeries* series, const Domain& domain)
182 void ChartPresenter::handleSeriesDomainChanged(QChartSeries* series, const Domain& domain)
183 {
183 {
184 m_chartItems.value(series)->handleDomainChanged(domain);
184 m_chartItems.value(series)->handleDomainChanged(domain);
185 }
185 }
186
186
187 void ChartPresenter::handleAxisLabelsChanged(QChartAxis* axis,const QStringList& labels)
187 void ChartPresenter::handleAxisLabelsChanged(QChartAxis* axis,const QStringList& labels)
188 {
188 {
189 m_axisItems.value(axis)->handleLabelsChanged(labels);
189 m_axisItems.value(axis)->handleLabelsChanged(axis,labels);
190 }
190 }
191
191
192 void ChartPresenter::setChartTheme(QChart::ChartTheme theme)
192 void ChartPresenter::setChartTheme(QChart::ChartTheme theme)
193 {
193 {
194 delete m_chartTheme;
194 delete m_chartTheme;
195
195
196 m_chartTheme = ChartTheme::createTheme(theme);
196 m_chartTheme = ChartTheme::createTheme(theme);
197
197
198 m_chartTheme->decorate(m_chart);
198 m_chartTheme->decorate(m_chart);
199 QMapIterator<QChartSeries*,ChartItem*> i(m_chartItems);
199 QMapIterator<QChartSeries*,ChartItem*> i(m_chartItems);
200
200
201 int index=0;
201 int index=0;
202 while (i.hasNext()) {
202 while (i.hasNext()) {
203 i.next();
203 i.next();
204 index++;
204 index++;
205 m_chartTheme->decorate(i.value(),i.key(),index);
205 m_chartTheme->decorate(i.value(),i.key(),index);
206 }
206 }
207
207
208 QMapIterator<QChartAxis*,AxisItem*> j(m_axisItems);
208 QMapIterator<QChartAxis*,AxisItem*> j(m_axisItems);
209 while (j.hasNext()) {
209 while (j.hasNext()) {
210 j.next();
210 j.next();
211 m_chartTheme->decorate(j.key(),j.value());
211 m_chartTheme->decorate(j.key(),j.value());
212 }
212 }
213 }
213 }
214
214
215 QChart::ChartTheme ChartPresenter::chartTheme()
215 QChart::ChartTheme ChartPresenter::chartTheme()
216 {
216 {
217 return m_chartTheme->id();
217 return m_chartTheme->id();
218 }
218 }
219
219
220
220
221 #include "moc_chartpresenter_p.cpp"
221 #include "moc_chartpresenter_p.cpp"
222
222
223 QTCOMMERCIALCHART_END_NAMESPACE
223 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,154 +1,154
1 #include "qchartaxis.h"
1 #include "qchartaxis.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 QChartAxis::QChartAxis(QObject* parent):QObject(parent),
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_labelsAngle(0),
10 m_shadesVisible(true),
10 m_shadesVisible(true),
11 m_shadesOpacity(1.0),
11 m_shadesOpacity(1.0),
12 m_min(0),
12 m_min(0),
13 m_max(0),
13 m_max(0),
14 m_ticksCount(4)
14 m_ticksCount(5)
15 {
15 {
16
16
17 }
17 }
18
18
19 QChartAxis::~QChartAxis()
19 QChartAxis::~QChartAxis()
20 {
20 {
21 }
21 }
22
22
23 void QChartAxis::setAxisPen(const QPen& pen)
23 void QChartAxis::setAxisPen(const QPen& pen)
24 {
24 {
25 m_axisPen=pen;
25 m_axisPen=pen;
26 emit update(this);
26 emit update(this);
27 }
27 }
28
28
29 void QChartAxis::setAxisVisible(bool visible)
29 void QChartAxis::setAxisVisible(bool visible)
30 {
30 {
31 m_axisVisible=visible;
31 m_axisVisible=visible;
32 emit update(this);
32 emit update(this);
33 }
33 }
34
34
35 void QChartAxis::setGridVisible(bool visible)
35 void QChartAxis::setGridVisible(bool visible)
36 {
36 {
37 m_gridVisible=visible;
37 m_gridVisible=visible;
38 emit update(this);
38 emit update(this);
39 }
39 }
40
40
41 void QChartAxis::setGridPen(const QPen& pen)
41 void QChartAxis::setGridPen(const QPen& pen)
42 {
42 {
43 m_gridPen=pen;
43 m_gridPen=pen;
44 emit update(this);
44 emit update(this);
45 }
45 }
46
46
47 void QChartAxis::setLabelsVisible(bool visible)
47 void QChartAxis::setLabelsVisible(bool visible)
48 {
48 {
49 m_labelsVisible=visible;
49 m_labelsVisible=visible;
50 emit update(this);
50 emit update(this);
51 }
51 }
52
52
53 void QChartAxis::setLabelsPen(const QPen& pen)
53 void QChartAxis::setLabelsPen(const QPen& pen)
54 {
54 {
55 m_labelsPen=pen;
55 m_labelsPen=pen;
56 emit update(this);
56 emit update(this);
57 }
57 }
58
58
59 void QChartAxis::setLabelsBrush(const QBrush& brush)
59 void QChartAxis::setLabelsBrush(const QBrush& brush)
60 {
60 {
61 m_labelsBrush=brush;
61 m_labelsBrush=brush;
62 emit update(this);
62 emit update(this);
63 }
63 }
64
64
65 void QChartAxis::setLabelsFont(const QFont& font)
65 void QChartAxis::setLabelsFont(const QFont& font)
66 {
66 {
67 m_labelsFont=font;
67 m_labelsFont=font;
68 emit update(this);
68 emit update(this);
69 }
69 }
70
70
71 void QChartAxis::setLabelsAngle(int angle)
71 void QChartAxis::setLabelsAngle(int angle)
72 {
72 {
73 m_labelsAngle=angle;
73 m_labelsAngle=angle;
74 emit update(this);
74 emit update(this);
75 }
75 }
76
76
77 void QChartAxis::setShadesVisible(bool visible)
77 void QChartAxis::setShadesVisible(bool visible)
78 {
78 {
79 m_shadesVisible=visible;
79 m_shadesVisible=visible;
80 emit update(this);
80 emit update(this);
81 }
81 }
82
82
83 void QChartAxis::setShadesPen(const QPen& pen)
83 void QChartAxis::setShadesPen(const QPen& pen)
84 {
84 {
85 m_shadesPen=pen;
85 m_shadesPen=pen;
86 emit update(this);
86 emit update(this);
87 }
87 }
88
88
89 void QChartAxis::setShadesBrush(const QBrush& brush)
89 void QChartAxis::setShadesBrush(const QBrush& brush)
90 {
90 {
91 m_shadesBrush=brush;
91 m_shadesBrush=brush;
92 emit update(this);
92 emit update(this);
93 }
93 }
94
94
95 void QChartAxis::setShadesOpacity(qreal opacity)
95 void QChartAxis::setShadesOpacity(qreal opacity)
96 {
96 {
97 m_shadesOpacity=opacity;
97 m_shadesOpacity=opacity;
98 emit update(this);
98 emit update(this);
99 }
99 }
100
100
101 void QChartAxis::setMin(qreal min)
101 void QChartAxis::setMin(qreal min)
102 {
102 {
103 if(m_min!=min){
103 if(m_min!=min){
104 m_min=min;
104 m_min=min;
105 emit minChanged(m_min);
105 emit minChanged(m_min);
106 }
106 }
107 }
107 }
108
108
109 void QChartAxis::setMax(qreal max)
109 void QChartAxis::setMax(qreal max)
110 {
110 {
111 if(m_max!=max){
111 if(m_max!=max){
112 m_max=max;
112 m_max=max;
113 emit maxChanged(m_max);
113 emit maxChanged(m_max);
114 }
114 }
115 }
115 }
116
116
117 void QChartAxis::setRange(qreal min, qreal max)
117 void QChartAxis::setRange(qreal min, qreal max)
118 {
118 {
119 setMin(min);
119 setMin(min);
120 setMax(max);
120 setMax(max);
121 }
121 }
122
122
123 void QChartAxis::setTicksCount(int count)
123 void QChartAxis::setTicksCount(int count)
124 {
124 {
125 m_ticksCount=count;
125 m_ticksCount=count;
126 emit ticksChanged(this);
126 emit ticksChanged(this);
127 }
127 }
128
128
129 void QChartAxis::addAxisTickLabel(qreal value,const QString& label)
129 void QChartAxis::addAxisTickLabel(qreal value,const QString& label)
130 {
130 {
131 m_ticks.insert(value,label);
131 m_ticks.insert(value,label);
132 emit ticksChanged(this);
132 emit ticksChanged(this);
133 }
133 }
134
134
135 void QChartAxis::removeAxisTickLabel(qreal value)
135 void QChartAxis::removeAxisTickLabel(qreal value)
136 {
136 {
137 m_ticks.remove(value);
137 m_ticks.remove(value);
138 emit ticksChanged(this);
138 emit ticksChanged(this);
139 }
139 }
140
140
141 QString QChartAxis::axisTickLabel(qreal value) const
141 QString QChartAxis::axisTickLabel(qreal value) const
142 {
142 {
143 return m_ticks.value(value);
143 return m_ticks.value(value);
144 }
144 }
145
145
146 void QChartAxis::clearAxisTickLabels()
146 void QChartAxis::clearAxisTickLabels()
147 {
147 {
148 m_ticks.clear();
148 m_ticks.clear();
149 emit ticksChanged(this);
149 emit ticksChanged(this);
150 }
150 }
151
151
152 #include "moc_qchartaxis.cpp"
152 #include "moc_qchartaxis.cpp"
153
153
154 QTCOMMERCIALCHART_END_NAMESPACE
154 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now