##// END OF EJS Templates
Add defualt show axis...
Michal Klocek -
r1628:ae9ab27188c9
parent child
Show More
@@ -164,20 +164,10 Rectangle {
164 //![3]
164 //![3]
165
165
166 Component.onCompleted: {
166 Component.onCompleted: {
167 setAxisX(categoryAxis,myBarSeries)
167 createDefaultAxes();
168 setAxisX(categoryAxis,lineSeries1)
168 setAxisX(categoryAxis,myBarSeries)
169 setAxisX(categoryAxis,lineSeries2)
169 categoryAxis.min = "2007"
170 setAxisX(categoryAxis,lineSeries3)
170 categoryAxis.max = "2014"
171 setAxisX(categoryAxis,lineSeries4)
172 setAxisX(categoryAxis,lineSeries5)
173 setAxisY(yAxis,myBarSeries)
174 setAxisY(yAxis,lineSeries1)
175 setAxisY(yAxis,lineSeries2)
176 setAxisY(yAxis,lineSeries3)
177 setAxisY(yAxis,lineSeries4)
178 setAxisY(yAxis,lineSeries5)
179 categoryAxis.min = "2007"
180 categoryAxis.max = "2014"
181 }
171 }
182 }
172 }
183 }
173 }
@@ -98,8 +98,7 void ChartPresenter::handleAxisAdded(QAbstractAxis* axis,Domain* domain)
98 if(m_rect.isValid()) item->handleGeometryChanged(m_rect);
98 if(m_rect.isValid()) item->handleGeometryChanged(m_rect);
99 //reload visiblity
99 //reload visiblity
100 m_axisItems.insert(axis, item);
100 m_axisItems.insert(axis, item);
101 if(axis->isVisible()) axis->hide();
101 selectVisibleAxis();
102 axis->show();
103
102
104 }
103 }
105
104
@@ -107,6 +106,7 void ChartPresenter::handleAxisRemoved(QAbstractAxis* axis)
107 {
106 {
108 ChartAxis* item = m_axisItems.take(axis);
107 ChartAxis* item = m_axisItems.take(axis);
109 Q_ASSERT(item);
108 Q_ASSERT(item);
109 selectVisibleAxis();
110 if(m_animator) m_animator->removeAnimation(item);
110 if(m_animator) m_animator->removeAnimation(item);
111 item->deleteLater();
111 item->deleteLater();
112 }
112 }
@@ -143,6 +143,34 void ChartPresenter::handleSeriesRemoved(QAbstractSeries* series)
143 item->deleteLater();
143 item->deleteLater();
144 }
144 }
145
145
146 void ChartPresenter::selectVisibleAxis()
147 {
148 QMapIterator<QAbstractAxis*, ChartAxis*> i(m_axisItems);
149
150 while (i.hasNext()) {
151 i.next();
152 i.key()->hide();
153 }
154
155 i.toFront();
156
157 bool axisX=false;
158 bool axisY=false;
159
160 while (i.hasNext()) {
161 i.next();
162 if(i.key()->d_ptr->m_orientation==Qt::Vertical && !axisY) {
163 axisY=true;
164 i.key()->show();
165 }
166 if(i.key()->d_ptr->m_orientation==Qt::Horizontal && !axisX) {
167 axisX=true;
168 i.key()->show();
169 }
170
171 }
172 }
173
146
174
147 void ChartPresenter::handleAxisVisibleChanged(bool visible)
175 void ChartPresenter::handleAxisVisibleChanged(bool visible)
148 {
176 {
@@ -137,6 +137,7 public:
137 private:
137 private:
138 void createBackgroundItem();
138 void createBackgroundItem();
139 void createTitleItem();
139 void createTitleItem();
140 void selectVisibleAxis();
140
141
141 public Q_SLOTS:
142 public Q_SLOTS:
142 void handleSeriesAdded(QAbstractSeries* series,Domain* domain);
143 void handleSeriesAdded(QAbstractSeries* series,Domain* domain);
General Comments 0
You need to be logged in to leave comments. Login now