@@ -60,7 +60,7 int main(int argc, char *argv[]) | |||
|
60 | 60 | |
|
61 | 61 | QObject::connect(series, SIGNAL(clicked(QPieSlice*, Qt::MouseButtons)), chart, SLOT(handleSliceClicked(QPieSlice*))); |
|
62 | 62 | |
|
63 |
*yearSeries << new DrilldownSlice(series-> |
|
|
63 | *yearSeries << new DrilldownSlice(series->sum(), name, series); | |
|
64 | 64 | } |
|
65 | 65 | |
|
66 | 66 | QObject::connect(yearSeries, SIGNAL(clicked(QPieSlice*, Qt::MouseButtons)), chart, SLOT(handleSliceClicked(QPieSlice*))); |
@@ -380,10 +380,10 void QPieSeries::setLabelsVisible(bool visible) | |||
|
380 | 380 | |
|
381 | 381 | \sa QPieSlice::value(), QPieSlice::setValue() |
|
382 | 382 | */ |
|
383 |
qreal QPieSeries:: |
|
|
383 | qreal QPieSeries::sum() const | |
|
384 | 384 | { |
|
385 | 385 | Q_D(const QPieSeries); |
|
386 |
return d->m_ |
|
|
386 | return d->m_sum; | |
|
387 | 387 | } |
|
388 | 388 | |
|
389 | 389 | /*! |
@@ -520,7 +520,7 QPieSeriesPrivate::QPieSeriesPrivate(QPieSeries *parent) | |||
|
520 | 520 | m_pieRelativeSize(0.7), |
|
521 | 521 | m_pieStartAngle(0), |
|
522 | 522 | m_pieEndAngle(360), |
|
523 |
m_ |
|
|
523 | m_sum(0), | |
|
524 | 524 | m_mapValues(0), |
|
525 | 525 | m_mapLabels(0), |
|
526 | 526 | m_mapOrientation(Qt::Horizontal) |
@@ -535,18 +535,18 QPieSeriesPrivate::~QPieSeriesPrivate() | |||
|
535 | 535 | |
|
536 | 536 | void QPieSeriesPrivate::updateDerivativeData() |
|
537 | 537 | { |
|
538 |
m_ |
|
|
538 | m_sum = 0; | |
|
539 | 539 | |
|
540 | 540 | // nothing to do? |
|
541 | 541 | if (m_slices.count() == 0) |
|
542 | 542 | return; |
|
543 | 543 | |
|
544 |
// calculate |
|
|
544 | // calculate sum of all slices | |
|
545 | 545 | foreach (QPieSlice* s, m_slices) |
|
546 |
m_ |
|
|
546 | m_sum += s->value(); | |
|
547 | 547 | |
|
548 | 548 | // nothing to show.. |
|
549 |
if (qFuzzyIsNull(m_ |
|
|
549 | if (qFuzzyIsNull(m_sum)) | |
|
550 | 550 | return; |
|
551 | 551 | |
|
552 | 552 | // update slice attributes |
@@ -556,7 +556,7 void QPieSeriesPrivate::updateDerivativeData() | |||
|
556 | 556 | foreach (QPieSlice* s, m_slices) { |
|
557 | 557 | |
|
558 | 558 | PieSliceData data = PieSliceData::data(s); |
|
559 |
data.m_percentage = s->value() / m_ |
|
|
559 | data.m_percentage = s->value() / m_sum; | |
|
560 | 560 | data.m_angleSpan = pieSpan * data.m_percentage; |
|
561 | 561 | data.m_startAngle = sliceAngle; |
|
562 | 562 | sliceAngle += data.m_angleSpan; |
General Comments 0
You need to be logged in to leave comments.
Login now