##// END OF EJS Templates
Inner pie (donut) size cannot be smaller than the outer pie size
Marek Rosa -
r1741:5e93b5bfe418
parent child
Show More
@@ -38,11 +38,11 int main(int argc, char *argv[])
38
38
39 //![2]
39 //![2]
40 QDateTime momentInTime;
40 QDateTime momentInTime;
41 for (int i = 0; i < 100; i++) {
41 for (int i = 0; i < 200; i++) {
42 momentInTime.setDate(QDate(2012, 1 , (1 + i / 9) % 28));
42 momentInTime.setDate(QDate(2012, 1 , (1 + i / 9) % 28));
43 momentInTime.setTime(QTime(9 + i % 9, 0));
43 momentInTime.setTime(QTime(9 + i % 9, 0));
44 if (i > 0)
44 if (i > 0)
45 series->append(momentInTime.toMSecsSinceEpoch(), series->points().at(i - 1).y() * (0.95 + (qrand() % 11) / 100.0));
45 series->append(momentInTime.toMSecsSinceEpoch(), series->points().at(i - 1).y() * (0.99 + (qrand() % 3) / 100.0));
46 else
46 else
47 series->append(momentInTime.toMSecsSinceEpoch(), 45);
47 series->append(momentInTime.toMSecsSinceEpoch(), 45);
48 }
48 }
@@ -54,13 +54,7 int main(int argc, char *argv[])
54 chart->addSeries(series);
54 chart->addSeries(series);
55 chart->createDefaultAxes();
55 chart->createDefaultAxes();
56 QDateTimeAxis *axisX = new QDateTimeAxis;
56 QDateTimeAxis *axisX = new QDateTimeAxis;
57 axisX->setTicksCount(20);
57 // axisX->setTicksCount(10);
58 momentInTime.setDate(QDate(2012,1,1));
59 momentInTime.setTime(QTime(6, 0));
60 axisX->setMin(momentInTime);
61 momentInTime.setDate(QDate(2012,1,7));
62 momentInTime.setTime(QTime(18, 0));
63 axisX->setMax(momentInTime);
64 chart->setAxisX(axisX, series);
58 chart->setAxisX(axisX, series);
65 chart->setTitle("Date and Time axis chart example");
59 chart->setTitle("Date and Time axis chart example");
66 //![3]
60 //![3]
@@ -132,6 +132,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
132 \o 1.0 is the maximum size that can fit the chart.
132 \o 1.0 is the maximum size that can fit the chart.
133 \endlist
133 \endlist
134
134
135 When setting this property the donutInnerSize property is adjusted if necessary, to ensure that the inner size is not greater than the outer size.
136
135 Default value is 0.7.
137 Default value is 0.7.
136 */
138 */
137
139
@@ -177,7 +179,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
177 \o 1.0 is the maximum size that can fit the chart. (donut has no width)
179 \o 1.0 is the maximum size that can fit the chart. (donut has no width)
178 \endlist
180 \endlist
179
181
180 The value is never greater then size property.
182 When setting this property the size property is adjusted if necessary, to ensure that the inner size is not greater than the outer size.
183
181 Default value is 0.5.
184 Default value is 0.5.
182 */
185 */
183
186
@@ -582,15 +585,8 bool QPieSeries::donut() const
582 void QPieSeries::setDonutInnerSize(qreal innerSize)
585 void QPieSeries::setDonutInnerSize(qreal innerSize)
583 {
586 {
584 Q_D(QPieSeries);
587 Q_D(QPieSeries);
585
588 innerSize = qBound(0.0, innerSize, 1.0);
586 if (innerSize < 0.0)
589 d->setSizes(innerSize, qMax(d->m_pieRelativeSize, innerSize));
587 innerSize = 0.0;
588 if (innerSize > d->m_pieRelativeSize)
589 innerSize = d->m_pieRelativeSize;
590
591 d->m_donutRelativeInnerSize = innerSize;
592 d->updateDerivativeData();
593 emit d->pieSizeChanged();
594 }
590 }
595
591
596 qreal QPieSeries::donutInnerSize() const
592 qreal QPieSeries::donutInnerSize() const
@@ -644,16 +640,9 qreal QPieSeries::verticalPosition() const
644 void QPieSeries::setPieSize(qreal relativeSize)
640 void QPieSeries::setPieSize(qreal relativeSize)
645 {
641 {
646 Q_D(QPieSeries);
642 Q_D(QPieSeries);
643 relativeSize = qBound(0.0, relativeSize, 1.0);
644 d->setSizes(qMin(d->m_donutRelativeInnerSize, relativeSize), relativeSize);
647
645
648 if (relativeSize < 0.0)
649 relativeSize = 0.0;
650 if (relativeSize > 1.0)
651 relativeSize = 1.0;
652
653 if (!qFuzzyIsNull(d->m_pieRelativeSize - relativeSize)) {
654 d->m_pieRelativeSize = relativeSize;
655 emit d->pieSizeChanged();
656 }
657 }
646 }
658
647
659 qreal QPieSeries::pieSize() const
648 qreal QPieSeries::pieSize() const
@@ -785,6 +774,24 void QPieSeriesPrivate::updateDerivativeData()
785 emit calculatedDataChanged();
774 emit calculatedDataChanged();
786 }
775 }
787
776
777 void QPieSeriesPrivate::setSizes(qreal innerSize, qreal outerSize)
778 {
779 bool changed = false;
780
781 if (!qFuzzyIsNull(m_donutRelativeInnerSize - innerSize)) {
782 m_donutRelativeInnerSize = innerSize;
783 changed = true;
784 }
785
786 if (!qFuzzyIsNull(m_pieRelativeSize - outerSize)) {
787 m_pieRelativeSize = outerSize;
788 changed = true;
789 }
790
791 if (changed)
792 emit pieSizeChanged();
793 }
794
788 QPieSeriesPrivate* QPieSeriesPrivate::fromSeries(QPieSeries *series)
795 QPieSeriesPrivate* QPieSeriesPrivate::fromSeries(QPieSeries *series)
789 {
796 {
790 return series->d_func();
797 return series->d_func();
@@ -51,6 +51,7 public:
51 QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const;
51 QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const;
52
52
53 void updateDerivativeData();
53 void updateDerivativeData();
54 void setSizes(qreal innerSize, qreal outerSize);
54
55
55 static QPieSeriesPrivate* fromSeries(QPieSeries *series);
56 static QPieSeriesPrivate* fromSeries(QPieSeries *series);
56
57
@@ -58,8 +58,8 public:
58 enum LabelPosition {
58 enum LabelPosition {
59 LabelOutside,
59 LabelOutside,
60 LabelInside,
60 LabelInside,
61 LabelInsideTangential,
61 LabelInsideTangential, // better name needed
62 LabelInsideNormal
62 LabelInsideNormal // better name needed
63 };
63 };
64
64
65 public:
65 public:
General Comments 0
You need to be logged in to leave comments. Login now