##// END OF EJS Templates
Adds missing functions to qchart API
Michal Klocek -
r1542:6d402eea8412
parent child
Show More
@@ -557,7 +557,8 QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q):
557 557 m_labelsAngle(0),
558 558 m_shadesVisible(false),
559 559 m_shadesBrush(Qt::SolidPattern),
560 m_shadesOpacity(1.0)
560 m_shadesOpacity(1.0),
561 m_orientation(Qt::Orientation(0))
561 562 {
562 563
563 564 }
@@ -65,6 +65,8 protected:
65 65 QBrush m_shadesBrush;
66 66 qreal m_shadesOpacity;
67 67
68 Qt::Orientation m_orientation;
69
68 70 friend class QAbstractAxis;
69 71 };
70 72
@@ -53,9 +53,6 ChartDataSet::~ChartDataSet()
53 53
54 54 void ChartDataSet::addSeries(QAbstractSeries* series)
55 55 {
56 //TODO: if(axisY==0) axisY = m_axisY;
57 QAbstractAxis* axisY = m_axisY;
58
59 56 QAbstractAxis* axis = m_seriesAxisMap.value(series);
60 57
61 58 if(axis) {
@@ -63,15 +60,18 void ChartDataSet::addSeries(QAbstractSeries* series)
63 60 return;
64 61 }
65 62
63 QAbstractAxis* axisX = m_axisX ; //series->d_ptr->createAxisX();
64 QAbstractAxis* axisY = m_axisY ; //series->d_ptr->createAxisY();
65
66 66 series->setParent(this); // take ownership
67 axisY->setParent(this); // take ownership
67 //axisY->setParent(this); // take ownership
68 68
69 69 Domain* domain = m_axisDomainMap.value(axisY);
70 70
71 71 if(!domain) {
72 72 domain = new Domain(axisY);
73 73 QObject::connect(axisY->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool)));
74 QObject::connect(axisX()->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int)));
74 QObject::connect(axisX->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int)));
75 75 QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axisY->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int)));
76 76 //initialize
77 77 m_axisDomainMap.insert(axisY,domain);
@@ -91,8 +91,8 void ChartDataSet::addSeries(QAbstractSeries* series)
91 91 series->d_ptr->scaleDomain(*domain);
92 92
93 93 if (series->type()== QAbstractSeries::SeriesTypePie && m_seriesAxisMap.count() == 0) {
94 axisX()->hide();
95 this->axisY()->hide();
94 axisX->hide();
95 axisY->hide();
96 96 }
97 97
98 98 m_seriesAxisMap.insert(series,axisY);
@@ -157,7 +157,7 QAbstractAxis* ChartDataSet::removeSeries(QAbstractSeries* series)
157 157 if(m_seriesAxisMap.values().size()==0)
158 158 {
159 159 m_axisXInitialized=false;
160 emit axisRemoved(axisX());
160 emit axisRemoved(m_axisX);
161 161 }
162 162
163 163 return axis;
@@ -169,7 +169,7 void ChartDataSet::removeAllSeries()
169 169 QList<QAbstractAxis*> axes;
170 170 foreach(QAbstractSeries *s , series) {
171 171 QAbstractAxis* axis = removeSeries(s);
172 if(axis==axisY()) continue;
172 if(axis==m_axisY) continue;
173 173 int i = axes.indexOf(axis);
174 174 if(i==-1){
175 175 axes<<axis;
@@ -187,7 +187,7 void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size)
187 187 {
188 188 QMapIterator<QAbstractAxis*, Domain*> i(m_axisDomainMap);
189 189 //main domain has to be the last one;
190 Domain *domain = m_axisDomainMap.value(axisY());
190 Domain *domain = m_axisDomainMap.value(m_axisY);
191 191 Q_ASSERT(domain);
192 192 while (i.hasNext()) {
193 193 i.next();
@@ -201,7 +201,7 void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size)
201 201 {
202 202 QMapIterator<QAbstractAxis*, Domain*> i(m_axisDomainMap);
203 203 //main domain has to be the last one;
204 Domain *domain = m_axisDomainMap.value(axisY());
204 Domain *domain = m_axisDomainMap.value(m_axisY);
205 205 Q_ASSERT(domain);
206 206 while (i.hasNext()) {
207 207 i.next();
@@ -239,6 +239,12 QAbstractAxis* ChartDataSet::axisY(QAbstractSeries *series) const
239 239 return m_seriesAxisMap.value(series);
240 240 }
241 241
242 QAbstractAxis* ChartDataSet::axisX(QAbstractSeries *series) const
243 {
244 Q_UNUSED(series)
245 return m_axisX;
246 }
247
242 248 Domain* ChartDataSet::domain(QAbstractSeries *series) const
243 249 {
244 250 QAbstractAxis* axis = m_seriesAxisMap.value(series);
@@ -250,8 +256,8 Domain* ChartDataSet::domain(QAbstractSeries *series) const
250 256
251 257 Domain* ChartDataSet::domain(QAbstractAxis* axis) const
252 258 {
253 if(!axis || axis==axisX()) {
254 return m_axisDomainMap.value(axisY());
259 if(!axis || axis==m_axisX) {
260 return m_axisDomainMap.value(m_axisY);
255 261 }
256 262 else {
257 263 return m_axisDomainMap.value(axis);
@@ -262,7 +268,7 void ChartDataSet::scrollDomain(qreal dx,qreal dy,const QSizeF& size)
262 268 {
263 269 QMapIterator<QAbstractAxis*, Domain*> i( m_axisDomainMap);
264 270 //main domain has to be the last one;
265 Domain *domain = m_axisDomainMap.value(axisY());
271 Domain *domain = m_axisDomainMap.value(m_axisY);
266 272 while (i.hasNext()) {
267 273 i.next();
268 274 if(i.value()==domain) continue;
@@ -60,8 +60,8 public:
60 60 Domain* domain(QAbstractSeries* series) const;
61 61 Domain* domain(QAbstractAxis* axis) const;
62 62
63 QAbstractAxis* axisX() const { return m_axisX; }
64 QAbstractAxis* axisY(QAbstractSeries *series = 0) const;
63 QAbstractAxis* axisX(QAbstractSeries *series) const;
64 QAbstractAxis* axisY(QAbstractSeries *series) const;
65 65
66 66 QList<QAbstractSeries*> series() const;
67 67
@@ -71,7 +71,7 void ChartPresenter::handleAxisAdded(QAbstractAxis* axis,Domain* domain)
71 71 {
72 72 ChartAxis* item;
73 73
74 if(axis == m_dataset->axisX()){
74 if(axis == m_dataset->axisX(0)){
75 75 item = new ChartAxisX(axis,this);
76 76 }else{
77 77 item = new ChartAxisY(axis,this);
@@ -82,7 +82,7 void ChartPresenter::handleAxisAdded(QAbstractAxis* axis,Domain* domain)
82 82 item->setAnimation(new AxisAnimation(item));
83 83 }
84 84
85 if(axis==m_dataset->axisX()){
85 if(axis==m_dataset->axisX(0)){
86 86 m_chartTheme->decorate(axis,true);
87 87 QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int)));
88 88 //initialize
@@ -40,6 +40,7 class Chart;
40 40 class LegendMarker;
41 41 class QLegend;
42 42 class ChartDataSet;
43 class QAbstractAxis;
43 44
44 45 class QAbstractSeriesPrivate : public QObject
45 46 {
@@ -51,6 +52,8 public:
51 52 virtual void scaleDomain(Domain& domain) = 0;
52 53 virtual Chart* createGraphics(ChartPresenter* presenter) = 0;
53 54 virtual QList<LegendMarker*> createLegendMarker(QLegend* legend) = 0;
55 virtual QAbstractAxis* createAxisX() { return 0; }
56 virtual QAbstractAxis* createAxisY() { return 0; }
54 57
55 58 protected:
56 59 QAbstractSeries *q_ptr;
@@ -308,9 +308,9 void QChart::zoom(qreal factor)
308 308 /*!
309 309 Returns the pointer to the x axis object of the chart
310 310 */
311 QAbstractAxis* QChart::axisX() const
311 QAbstractAxis* QChart::axisX(QAbstractSeries* series) const
312 312 {
313 return d_ptr->m_dataset->axisX();
313 return d_ptr->m_dataset->axisX(series);
314 314 }
315 315
316 316 /*!
@@ -78,6 +78,9 public:
78 78 void setAxisX(QAbstractSeries *series, QAbstractAxis* axis);
79 79 void setAxisY(QAbstractSeries *series, QAbstractAxis* axis);
80 80
81 QAbstractAxis* axisX(QAbstractSeries* series = 0) const;
82 QAbstractAxis* axisY(QAbstractSeries* series = 0) const;
83
81 84 void setTheme(QChart::ChartTheme theme);
82 85 QChart::ChartTheme theme() const;
83 86
@@ -110,9 +113,6 public:
110 113 void scrollDown();
111 114 void scroll(const QPointF &delta);
112 115
113 QAbstractAxis* axisX() const;
114 QAbstractAxis* axisY(QAbstractSeries* series = 0) const;
115
116 116 QLegend* legend() const;
117 117
118 118 void setMarginsMinimum(const QRectF& margins);
General Comments 0
You need to be logged in to leave comments. Login now