|
@@
-53,14
+53,14
ChartDataSet::~ChartDataSet()
|
|
53
|
|
|
53
|
|
|
54
|
void ChartDataSet::addSeries(QAbstractSeries* series)
|
|
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
|
if(axis) {
|
|
58
|
if(axis) {
|
|
59
|
qWarning() << "Can not add series. Series already on the chart";
|
|
59
|
qWarning() << "Can not add series. Series already on the chart";
|
|
60
|
return;
|
|
60
|
return;
|
|
61
|
}
|
|
61
|
}
|
|
62
|
|
|
62
|
|
|
63
|
QAbstractAxis* axisX = m_axisX ; //series->d_ptr->createAxisX();
|
|
63
|
QAbstractAxis* axisX = series->d_ptr->createAxisX();
|
|
64
|
QAbstractAxis* axisY = m_axisY ; //series->d_ptr->createAxisY();
|
|
64
|
QAbstractAxis* axisY = m_axisY ; //series->d_ptr->createAxisY();
|
|
65
|
|
|
65
|
|
|
66
|
series->setParent(this); // take ownership
|
|
66
|
series->setParent(this); // take ownership
|
|
@@
-80,7
+80,8
void ChartDataSet::addSeries(QAbstractSeries* series)
|
|
80
|
|
|
80
|
|
|
81
|
if(!m_axisXInitialized){
|
|
81
|
if(!m_axisXInitialized){
|
|
82
|
m_axisXInitialized=true;
|
|
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
|
if(!m_axisYInitialized && axisY==m_axisY){
|
|
87
|
if(!m_axisYInitialized && axisY==m_axisY){
|
|
@@
-90,12
+91,12
void ChartDataSet::addSeries(QAbstractSeries* series)
|
|
90
|
|
|
91
|
|
|
91
|
series->d_ptr->scaleDomain(*domain);
|
|
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
|
axisX->hide();
|
|
95
|
axisX->hide();
|
|
95
|
axisY->hide();
|
|
96
|
axisY->hide();
|
|
96
|
}
|
|
97
|
}
|
|
97
|
|
|
98
|
|
|
98
|
m_seriesAxisMap.insert(series,axisY);
|
|
99
|
m_seriesAxisXMap.insert(series,axisY);
|
|
99
|
|
|
100
|
|
|
100
|
QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap);
|
|
101
|
QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap);
|
|
101
|
|
|
102
|
|
|
@@
-119,7
+120,7
void ChartDataSet::addSeries(QAbstractSeries* series)
|
|
119
|
|
|
120
|
|
|
120
|
QAbstractAxis* ChartDataSet::removeSeries(QAbstractSeries* series)
|
|
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
|
if(!axis){
|
|
125
|
if(!axis){
|
|
125
|
qWarning()<<"Can not remove series. Series not found on the chart.";
|
|
126
|
qWarning()<<"Can not remove series. Series not found on the chart.";
|
|
@@
-128,7
+129,7
QAbstractAxis* ChartDataSet::removeSeries(QAbstractSeries* series)
|
|
128
|
|
|
129
|
|
|
129
|
emit seriesRemoved(series);
|
|
130
|
emit seriesRemoved(series);
|
|
130
|
|
|
131
|
|
|
131
|
m_seriesAxisMap.remove(series);
|
|
132
|
m_seriesAxisXMap.remove(series);
|
|
132
|
int key = seriesIndex(series);
|
|
133
|
int key = seriesIndex(series);
|
|
133
|
Q_ASSERT(key!=-1);
|
|
134
|
Q_ASSERT(key!=-1);
|
|
134
|
|
|
135
|
|
|
@@
-138,7
+139,7
QAbstractAxis* ChartDataSet::removeSeries(QAbstractSeries* series)
|
|
138
|
series->d_ptr->m_chart = 0;
|
|
139
|
series->d_ptr->m_chart = 0;
|
|
139
|
series->d_ptr->m_dataset = 0;
|
|
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
|
int i = axes.indexOf(axis);
|
|
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
|
m_axisXInitialized=false;
|
|
160
|
m_axisXInitialized=false;
|
|
160
|
emit axisRemoved(m_axisX);
|
|
161
|
emit axisRemoved(m_axisX);
|
|
@@
-165,7
+166,7
QAbstractAxis* ChartDataSet::removeSeries(QAbstractSeries* series)
|
|
165
|
|
|
166
|
|
|
166
|
void ChartDataSet::removeAllSeries()
|
|
167
|
void ChartDataSet::removeAllSeries()
|
|
167
|
{
|
|
168
|
{
|
|
168
|
QList<QAbstractSeries*> series = m_seriesAxisMap.keys();
|
|
169
|
QList<QAbstractSeries*> series = m_seriesAxisXMap.keys();
|
|
169
|
QList<QAbstractAxis*> axes;
|
|
170
|
QList<QAbstractAxis*> axes;
|
|
170
|
foreach(QAbstractSeries *s , series) {
|
|
171
|
foreach(QAbstractSeries *s , series) {
|
|
171
|
QAbstractAxis* axis = removeSeries(s);
|
|
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
|
Q_ASSERT(m_axisDomainMap.count()==1);
|
|
181
|
Q_ASSERT(m_axisDomainMap.count()==1);
|
|
181
|
|
|
182
|
|
|
182
|
qDeleteAll(series);
|
|
183
|
qDeleteAll(series);
|
|
@@
-214,7
+215,7
void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size)
|
|
214
|
int ChartDataSet::seriesCount(QAbstractSeries::SeriesType type)
|
|
215
|
int ChartDataSet::seriesCount(QAbstractSeries::SeriesType type)
|
|
215
|
{
|
|
216
|
{
|
|
216
|
int count=0;
|
|
217
|
int count=0;
|
|
217
|
QMapIterator<QAbstractSeries*, QAbstractAxis*> i(m_seriesAxisMap);
|
|
218
|
QMapIterator<QAbstractSeries*, QAbstractAxis*> i(m_seriesAxisXMap);
|
|
218
|
while (i.hasNext()) {
|
|
219
|
while (i.hasNext()) {
|
|
219
|
i.next();
|
|
220
|
i.next();
|
|
220
|
if(i.key()->type()==type) count++;
|
|
221
|
if(i.key()->type()==type) count++;
|
|
@@
-233,21
+234,32
int ChartDataSet::seriesIndex(QAbstractSeries *series)
|
|
233
|
return -1;
|
|
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
|
QAbstractAxis* ChartDataSet::axisY(QAbstractSeries *series) const
|
|
244
|
QAbstractAxis* ChartDataSet::axisY(QAbstractSeries *series) const
|
|
237
|
{
|
|
245
|
{
|
|
238
|
if(series == 0) return m_axisY;
|
|
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)
|
|
257
|
m_seriesAxisYMap.insert(series,axis);
|
|
245
|
return m_axisX;
|
|
|
|
|
246
|
}
|
|
258
|
}
|
|
247
|
|
|
259
|
|
|
248
|
Domain* ChartDataSet::domain(QAbstractSeries *series) const
|
|
260
|
Domain* ChartDataSet::domain(QAbstractSeries *series) const
|
|
249
|
{
|
|
261
|
{
|
|
250
|
QAbstractAxis* axis = m_seriesAxisMap.value(series);
|
|
262
|
QAbstractAxis* axis = m_seriesAxisXMap.value(series);
|
|
251
|
if(axis){
|
|
263
|
if(axis){
|
|
252
|
return m_axisDomainMap.value(axis);
|
|
264
|
return m_axisDomainMap.value(axis);
|
|
253
|
}else
|
|
265
|
}else
|
|
@@
-279,7
+291,7
void ChartDataSet::scrollDomain(qreal dx,qreal dy,const QSizeF& size)
|
|
279
|
|
|
291
|
|
|
280
|
QList<QAbstractSeries*> ChartDataSet::series() const
|
|
292
|
QList<QAbstractSeries*> ChartDataSet::series() const
|
|
281
|
{
|
|
293
|
{
|
|
282
|
return m_seriesAxisMap.keys();
|
|
294
|
return m_seriesAxisXMap.keys();
|
|
283
|
}
|
|
295
|
}
|
|
284
|
|
|
296
|
|
|
285
|
void ChartDataSet::updateSeries(QAbstractSeries *series)
|
|
297
|
void ChartDataSet::updateSeries(QAbstractSeries *series)
|