##// END OF EJS Templates
Adds logic to fix overlaping axes
Michal Klocek -
r1626:7d4c8a772239
parent child
Show More
@@ -516,9 +516,12 bool QAbstractAxis::isVisible() const
516 */
516 */
517 void QAbstractAxis::setVisible(bool visible)
517 void QAbstractAxis::setVisible(bool visible)
518 {
518 {
519 if(d_ptr->m_visible!=visible){
519 d_ptr->m_visible=visible;
520 d_ptr->m_visible=visible;
521 emit visibleChanged(visible);
520 emit d_ptr->updated();
522 emit d_ptr->updated();
521 }
523 }
524 }
522
525
523
526
524 /*!
527 /*!
@@ -555,7 +558,7 void QAbstractAxis::setRange(const QVariant &min, const QVariant &max)
555
558
556 QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q):
559 QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q):
557 q_ptr(q),
560 q_ptr(q),
558 m_visible(true),
561 m_visible(false),
559 m_axisVisible(true),
562 m_axisVisible(true),
560 m_gridLineVisible(true),
563 m_gridLineVisible(true),
561 m_labelsVisible(true),
564 m_labelsVisible(true),
@@ -93,9 +93,14 void ChartPresenter::handleAxisAdded(QAbstractAxis* axis,Domain* domain)
93 }
93 }
94
94
95 QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF)));
95 QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF)));
96 QObject::connect(axis,SIGNAL(visibleChanged(bool)),this,SLOT(handleAxisVisibleChanged(bool)));
96 //initialize
97 //initialize
97 if(m_rect.isValid()) item->handleGeometryChanged(m_rect);
98 if(m_rect.isValid()) item->handleGeometryChanged(m_rect);
99 //reload visiblity
98 m_axisItems.insert(axis, item);
100 m_axisItems.insert(axis, item);
101 if(axis->isVisible()) axis->hide();
102 axis->show();
103
99 }
104 }
100
105
101 void ChartPresenter::handleAxisRemoved(QAbstractAxis* axis)
106 void ChartPresenter::handleAxisRemoved(QAbstractAxis* axis)
@@ -138,6 +143,27 void ChartPresenter::handleSeriesRemoved(QAbstractSeries* series)
138 item->deleteLater();
143 item->deleteLater();
139 }
144 }
140
145
146
147 void ChartPresenter::handleAxisVisibleChanged(bool visible)
148 {
149 QAbstractAxis* axis = static_cast<QAbstractAxis*> (sender());
150 Q_ASSERT(axis);
151 if(visible){
152
153 QMapIterator<QAbstractAxis*, ChartAxis*> i(m_axisItems);
154
155 while (i.hasNext()) {
156 i.next();
157 if(i.key()==axis) {
158 continue;
159 }
160 if(i.key()->d_ptr->m_orientation==axis->d_ptr->m_orientation) {
161 i.key()->setVisible(false);
162 }
163 }
164 }
165 }
166
141 void ChartPresenter::setTheme(QChart::ChartTheme theme,bool force)
167 void ChartPresenter::setTheme(QChart::ChartTheme theme,bool force)
142 {
168 {
143 if(m_chartTheme && m_chartTheme->id() == theme) return;
169 if(m_chartTheme && m_chartTheme->id() == theme) return;
@@ -143,6 +143,7 public Q_SLOTS:
143 void handleSeriesRemoved(QAbstractSeries* series);
143 void handleSeriesRemoved(QAbstractSeries* series);
144 void handleAxisAdded(QAbstractAxis* axis,Domain* domain);
144 void handleAxisAdded(QAbstractAxis* axis,Domain* domain);
145 void handleAxisRemoved(QAbstractAxis* axis);
145 void handleAxisRemoved(QAbstractAxis* axis);
146 void handleAxisVisibleChanged(bool visible);
146
147
147 private Q_SLOTS:
148 private Q_SLOTS:
148 void handleAnimationFinished();
149 void handleAnimationFinished();
General Comments 0
You need to be logged in to leave comments. Login now