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