##// END OF EJS Templates
category axis initialization
sauimone -
r1662:1cbf106b76f3
parent child
Show More
@@ -143,10 +143,10 void QBarCategoriesAxis::append(const QStringList &categories)
143
143
144 Q_D(QBarCategoriesAxis);
144 Q_D(QBarCategoriesAxis);
145 if (d->m_categories.isEmpty()) {
145 if (d->m_categories.isEmpty()) {
146 d->m_categories.append(categories);
146 d->m_categories.append(categories);
147 setRange(categories.first(),categories.last());
147 setRange(categories.first(),categories.last());
148 }else{
148 }else{
149 d->m_categories.append(categories);
149 d->m_categories.append(categories);
150 }
150 }
151 emit d->updated();
151 emit d->updated();
152 emit categoriesChanged();
152 emit categoriesChanged();
@@ -157,15 +157,15 void QBarCategoriesAxis::append(const QStringList &categories)
157 */
157 */
158 void QBarCategoriesAxis::append(const QString &category)
158 void QBarCategoriesAxis::append(const QString &category)
159 {
159 {
160 Q_D(QBarCategoriesAxis);
160 Q_D(QBarCategoriesAxis);
161 if (d->m_categories.isEmpty()) {
161 if (d->m_categories.isEmpty()) {
162 d->m_categories.append(category);
162 d->m_categories.append(category);
163 setRange(category,category);
163 setRange(category,category);
164 }else{
164 }else{
165 d->m_categories.append(category);
165 d->m_categories.append(category);
166 }
166 }
167 emit d->updated();
167 emit d->updated();
168 emit categoriesChanged();
168 emit categoriesChanged();
169 }
169 }
170
170
171 /*!
171 /*!
@@ -189,8 +189,8 void QBarCategoriesAxis::insert(int index, const QString &category)
189 {
189 {
190 Q_D(QBarCategoriesAxis);
190 Q_D(QBarCategoriesAxis);
191 if (d->m_categories.isEmpty()) {
191 if (d->m_categories.isEmpty()) {
192 d->m_categories.insert(index,category);
192 d->m_categories.insert(index,category);
193 setRange(category,category);
193 setRange(category,category);
194 }else{
194 }else{
195 d->m_categories.insert(index,category);
195 d->m_categories.insert(index,category);
196 }
196 }
@@ -304,7 +304,7 void QBarCategoriesAxis::setRange(const QString& minCategory, const QString& max
304
304
305 bool changed = false;
305 bool changed = false;
306 if (!qFuzzyIsNull(d->m_min - (minIndex))||d->m_minCategory!=minCategory) {
306 if (!qFuzzyIsNull(d->m_min - (minIndex))||d->m_minCategory!=minCategory) {
307 d->m_minCategory = minCategory;
307 d->m_minCategory = minCategory;
308 d->m_min = minIndex;
308 d->m_min = minIndex;
309 emit minChanged(minCategory);
309 emit minChanged(minCategory);
310 changed = true;
310 changed = true;
@@ -368,10 +368,36 int QBarCategoriesAxisPrivate::ticksCount() const
368
368
369 void QBarCategoriesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
369 void QBarCategoriesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
370 {
370 {
371 Q_Q(QBarCategoriesAxis);
372 Q_UNUSED(count);
371 m_min = min;
373 m_min = min;
372 m_max = max;
374 m_max = max;
373 m_ticksCount = count;
375 int minIndex = qFloor(min);
374 //TODO:
376 int maxIndex = qFloor(max);
377
378 if (minIndex < 0) {
379 minIndex = 0;
380 }
381 if (maxIndex > m_categories.count()-1){
382 maxIndex = m_categories.count()-1;
383 }
384
385 bool changed = false;
386 if (m_minCategory != m_categories.at(minIndex)) {
387 m_minCategory = m_categories.at(minIndex);
388 emit q->minChanged(m_minCategory);
389 changed = true;
390 }
391
392 if (m_maxCategory != m_categories.at(maxIndex)) {
393 m_maxCategory = m_categories.at(maxIndex);
394 emit q->maxChanged(m_maxCategory);
395 changed = true;
396 }
397
398 if (changed) {
399 emit q->rangeChanged(m_minCategory, m_maxCategory);
400 }
375 }
401 }
376
402
377 ChartAxis* QBarCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter)
403 ChartAxis* QBarCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter)
@@ -386,13 +412,18 ChartAxis* QBarCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter)
386
412
387 void QBarCategoriesAxisPrivate::emitRange()
413 void QBarCategoriesAxisPrivate::emitRange()
388 {
414 {
389 emit changed(m_min -0.5, m_max +0.5, qCeil(m_max + 0.5) -qCeil(m_min - 0.5) +1, false);
415 emit changed(m_min -0.5, m_max +0.5, qCeil(m_max + 0.5) -qCeil(m_min - 0.5) +1, false);
390 }
416 }
391
417
392 void QBarCategoriesAxisPrivate::initialize(Domain* domain)
418 void QBarCategoriesAxisPrivate::initialize(Domain* domain)
393 {
419 {
394 Q_UNUSED(domain);
420 if (qFuzzyCompare(m_max, m_min)) {
395 //TODO:
421 if(m_orientation==Qt::Vertical){
422 handleAxisRangeChanged(domain->minY(),domain->maxY(),domain->tickXCount());
423 }else{
424 handleAxisRangeChanged(domain->minX(),domain->maxX(),domain->tickYCount());
425 }
426 }
396 }
427 }
397
428
398 #include "moc_qbarcategoriesaxis.cpp"
429 #include "moc_qbarcategoriesaxis.cpp"
@@ -308,7 +308,7 void QValuesAxisPrivate::emitRange()
308
308
309 void QValuesAxisPrivate::initialize(Domain* domain)
309 void QValuesAxisPrivate::initialize(Domain* domain)
310 {
310 {
311 if(m_max==m_min){
311 if(qFuzzyCompare(m_max,m_min)) {
312 if(m_orientation==Qt::Vertical){
312 if(m_orientation==Qt::Vertical){
313 handleAxisRangeChanged(domain->minY(),domain->maxY(),domain->tickXCount());
313 handleAxisRangeChanged(domain->minY(),domain->maxY(),domain->tickXCount());
314 }else{
314 }else{
General Comments 0
You need to be logged in to leave comments. Login now