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