mirror of https://github.com/qt/qtcharts.git
Hide slice label by default
This commit is contained in:
parent
c84fc5fb7b
commit
bf1f84426e
|
@ -4,6 +4,8 @@ CustomSlice::CustomSlice(qreal value, QObject* parent)
|
|||
:QPieSlice(parent)
|
||||
{
|
||||
setValue(value);
|
||||
setLabelVisible(true);
|
||||
setExploded(true);
|
||||
connect(this, SIGNAL(changed()), this, SLOT(updateLabel()));
|
||||
connect(this, SIGNAL(hoverEnter()), this, SLOT(toggleExploded()));
|
||||
connect(this, SIGNAL(hoverLeave()), this, SLOT(toggleExploded()));
|
||||
|
@ -11,7 +13,7 @@ CustomSlice::CustomSlice(qreal value, QObject* parent)
|
|||
|
||||
void CustomSlice::updateLabel()
|
||||
{
|
||||
setLabel(QString::number(this->percentage()));
|
||||
setLabel(QString::number(this->percentage()*100) + "%");
|
||||
}
|
||||
|
||||
void CustomSlice::toggleExploded()
|
||||
|
|
|
@ -248,6 +248,7 @@ void QPieSeries::highlightOn(QPieSlice* slice)
|
|||
Q_ASSERT(slice);
|
||||
QColor c = slice->brush().color().lighter();
|
||||
slice->setBrush(c);
|
||||
slice->setLabelVisible(true);
|
||||
}
|
||||
|
||||
void QPieSeries::highlightOff(QPieSlice* slice)
|
||||
|
@ -255,6 +256,7 @@ void QPieSeries::highlightOff(QPieSlice* slice)
|
|||
Q_ASSERT(slice);
|
||||
QColor c = slice->brush().color().darker(150);
|
||||
slice->setBrush(c);
|
||||
slice->setLabelVisible(false);
|
||||
}
|
||||
|
||||
void QPieSeries::updateDerivativeData()
|
||||
|
|
|
@ -10,7 +10,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE
|
|||
QPieSlice::QPieSlice(QObject *parent)
|
||||
:QObject(parent),
|
||||
m_value(0),
|
||||
m_isLabelVisible(true),
|
||||
m_isLabelVisible(false),
|
||||
m_isExploded(false),
|
||||
m_explodeDistance(DEFAULT_EXPOLODE_DISTANCE),
|
||||
m_percentage(0),
|
||||
|
|
|
@ -17,7 +17,7 @@ class QTCOMMERCIALCHART_EXPORT QPieSlice : public QObject
|
|||
|
||||
public:
|
||||
QPieSlice(QObject *parent = 0);
|
||||
QPieSlice(qreal value, QString label, bool labelVisible = true, QObject *parent = 0);
|
||||
QPieSlice(qreal value, QString label, bool labelVisible = false, QObject *parent = 0);
|
||||
virtual ~QPieSlice();
|
||||
|
||||
// data
|
||||
|
|
Loading…
Reference in New Issue