##// END OF EJS Templates
added map for yaxises methods to set axis
sauimone -
r1554:9a708aa57671
parent child
Show More
@@ -53,14 +53,14 ChartDataSet::~ChartDataSet()
53 53
54 54 void ChartDataSet::addSeries(QAbstractSeries* series)
55 55 {
56 QAbstractAxis* axis = m_seriesAxisMap.value(series);
56 QAbstractAxis* axis = m_seriesAxisXMap.value(series);
57 57
58 58 if(axis) {
59 59 qWarning() << "Can not add series. Series already on the chart";
60 60 return;
61 61 }
62 62
63 QAbstractAxis* axisX = m_axisX ; //series->d_ptr->createAxisX();
63 QAbstractAxis* axisX = series->d_ptr->createAxisX();
64 64 QAbstractAxis* axisY = m_axisY ; //series->d_ptr->createAxisY();
65 65
66 66 series->setParent(this); // take ownership
@@ -80,7 +80,8 void ChartDataSet::addSeries(QAbstractSeries* series)
80 80
81 81 if(!m_axisXInitialized){
82 82 m_axisXInitialized=true;
83 emit axisAdded(m_axisX,domain);
83 // emit axisAdded(m_axisX,domain);
84 emit axisAdded(axisX,domain);
84 85 }
85 86
86 87 if(!m_axisYInitialized && axisY==m_axisY){
@@ -90,12 +91,12 void ChartDataSet::addSeries(QAbstractSeries* series)
90 91
91 92 series->d_ptr->scaleDomain(*domain);
92 93
93 if (series->type()== QAbstractSeries::SeriesTypePie && m_seriesAxisMap.count() == 0) {
94 if (series->type()== QAbstractSeries::SeriesTypePie && m_seriesAxisXMap.count() == 0) {
94 95 axisX->hide();
95 96 axisY->hide();
96 97 }
97 98
98 m_seriesAxisMap.insert(series,axisY);
99 m_seriesAxisXMap.insert(series,axisY);
99 100
100 101 QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap);
101 102
@@ -119,7 +120,7 void ChartDataSet::addSeries(QAbstractSeries* series)
119 120
120 121 QAbstractAxis* ChartDataSet::removeSeries(QAbstractSeries* series)
121 122 {
122 QAbstractAxis* axis = m_seriesAxisMap.value(series);
123 QAbstractAxis* axis = m_seriesAxisXMap.value(series);
123 124
124 125 if(!axis){
125 126 qWarning()<<"Can not remove series. Series not found on the chart.";
@@ -128,7 +129,7 QAbstractAxis* ChartDataSet::removeSeries(QAbstractSeries* series)
128 129
129 130 emit seriesRemoved(series);
130 131
131 m_seriesAxisMap.remove(series);
132 m_seriesAxisXMap.remove(series);
132 133 int key = seriesIndex(series);
133 134 Q_ASSERT(key!=-1);
134 135
@@ -138,7 +139,7 QAbstractAxis* ChartDataSet::removeSeries(QAbstractSeries* series)
138 139 series->d_ptr->m_chart = 0;
139 140 series->d_ptr->m_dataset = 0;
140 141
141 QList<QAbstractAxis*> axes = m_seriesAxisMap.values();
142 QList<QAbstractAxis*> axes = m_seriesAxisXMap.values();
142 143
143 144 int i = axes.indexOf(axis);
144 145
@@ -154,7 +155,7 QAbstractAxis* ChartDataSet::removeSeries(QAbstractSeries* series)
154 155 }
155 156 }
156 157
157 if(m_seriesAxisMap.values().size()==0)
158 if(m_seriesAxisXMap.values().size()==0)
158 159 {
159 160 m_axisXInitialized=false;
160 161 emit axisRemoved(m_axisX);
@@ -165,7 +166,7 QAbstractAxis* ChartDataSet::removeSeries(QAbstractSeries* series)
165 166
166 167 void ChartDataSet::removeAllSeries()
167 168 {
168 QList<QAbstractSeries*> series = m_seriesAxisMap.keys();
169 QList<QAbstractSeries*> series = m_seriesAxisXMap.keys();
169 170 QList<QAbstractAxis*> axes;
170 171 foreach(QAbstractSeries *s , series) {
171 172 QAbstractAxis* axis = removeSeries(s);
@@ -176,7 +177,7 void ChartDataSet::removeAllSeries()
176 177 }
177 178 }
178 179
179 Q_ASSERT(m_seriesAxisMap.count()==0);
180 Q_ASSERT(m_seriesAxisXMap.count()==0);
180 181 Q_ASSERT(m_axisDomainMap.count()==1);
181 182
182 183 qDeleteAll(series);
@@ -214,7 +215,7 void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size)
214 215 int ChartDataSet::seriesCount(QAbstractSeries::SeriesType type)
215 216 {
216 217 int count=0;
217 QMapIterator<QAbstractSeries*, QAbstractAxis*> i(m_seriesAxisMap);
218 QMapIterator<QAbstractSeries*, QAbstractAxis*> i(m_seriesAxisXMap);
218 219 while (i.hasNext()) {
219 220 i.next();
220 221 if(i.key()->type()==type) count++;
@@ -233,21 +234,32 int ChartDataSet::seriesIndex(QAbstractSeries *series)
233 234 return -1;
234 235 }
235 236
237 QAbstractAxis* ChartDataSet::axisX(QAbstractSeries *series) const
238 {
239 qDebug() << "axisX";
240 if (series == 0) return m_axisX;
241 return m_seriesAxisXMap.value(series);
242 }
243
236 244 QAbstractAxis* ChartDataSet::axisY(QAbstractSeries *series) const
237 245 {
238 246 if(series == 0) return m_axisY;
239 return m_seriesAxisMap.value(series);
247 return m_seriesAxisYMap.value(series);
240 248 }
241 249
242 QAbstractAxis* ChartDataSet::axisX(QAbstractSeries *series) const
250 void ChartDataSet::setAxisX(QAbstractSeries *series, QAbstractAxis *axis)
251 {
252 m_seriesAxisXMap.insert(series,axis);
253 }
254
255 void ChartDataSet::setAxisY(QAbstractSeries *series, QAbstractAxis *axis)
243 256 {
244 Q_UNUSED(series)
245 return m_axisX;
257 m_seriesAxisYMap.insert(series,axis);
246 258 }
247 259
248 260 Domain* ChartDataSet::domain(QAbstractSeries *series) const
249 261 {
250 QAbstractAxis* axis = m_seriesAxisMap.value(series);
262 QAbstractAxis* axis = m_seriesAxisXMap.value(series);
251 263 if(axis){
252 264 return m_axisDomainMap.value(axis);
253 265 }else
@@ -279,7 +291,7 void ChartDataSet::scrollDomain(qreal dx,qreal dy,const QSizeF& size)
279 291
280 292 QList<QAbstractSeries*> ChartDataSet::series() const
281 293 {
282 return m_seriesAxisMap.keys();
294 return m_seriesAxisXMap.keys();
283 295 }
284 296
285 297 void ChartDataSet::updateSeries(QAbstractSeries *series)
@@ -63,6 +63,9 public:
63 63 QAbstractAxis* axisX(QAbstractSeries *series) const;
64 64 QAbstractAxis* axisY(QAbstractSeries *series) const;
65 65
66 void setAxisX(QAbstractSeries *series, QAbstractAxis *axis);
67 void setAxisY(QAbstractSeries *series, QAbstractAxis *axis);
68
66 69 QList<QAbstractSeries*> series() const;
67 70
68 71 Q_SIGNALS:
@@ -77,7 +80,8 private:
77 80 void calculateDomain(QAbstractSeries* series,Domain* domain);
78 81
79 82 private:
80 QMap<QAbstractSeries*, QAbstractAxis*> m_seriesAxisMap;
83 QMap<QAbstractSeries*, QAbstractAxis*> m_seriesAxisXMap;
84 QMap<QAbstractSeries*, QAbstractAxis*> m_seriesAxisYMap;
81 85 QMap<QAbstractAxis*, Domain*> m_axisDomainMap;
82 86 QMap<int, QAbstractSeries*> m_indexSeriesMap;
83 87 QAbstractAxis* m_axisX;
@@ -398,14 +398,16 void QChart::setMarginsMinimum(const QRectF& margins)
398 398
399 399 void QChart::setAxisX(QAbstractSeries *series, QAbstractAxis* axis)
400 400 {
401 Q_UNUSED(series);
402 Q_UNUSED(axis);
401 // Q_UNUSED(series);
402 // Q_UNUSED(axis);
403 d_ptr->m_dataset->setAxisX(series, axis);
403 404 }
404 405
405 406 void QChart::setAxisY(QAbstractSeries *series, QAbstractAxis* axis)
406 407 {
407 Q_UNUSED(series);
408 Q_UNUSED(axis);
408 // Q_UNUSED(series);
409 // Q_UNUSED(axis);
410 d_ptr->m_dataset->setAxisY(series, axis);
409 411 }
410 412
411 413 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
General Comments 0
You need to be logged in to leave comments. Login now