Project

General

Profile

Feature #1139 » WPieChartAvoidRendering.patch

The patch file implementing the avoid label rendering - Stefan Ruppert, 01/18/2012 08:30 PM

View differences:

wt-3.2.0/src/Wt/Chart/WPieChart 2012-01-18 19:05:47.000000000 +0100
*/
double startAngle() const { return startAngle_; }
/*! \brief Sets the percentage value to avoid rendering of label texts
*
* The default value is 5 percent
*/
void setAvoidLabelRendering(double percent);
/*! \brief Returns the percentage to avoid label rendering.
*
* \sa setAvoidLabelRendering(double)
*/
double avoidLabelRendering() const { return avoidLabelRendering_; }
/*! \brief Configures if and how labels should be displayed
*
* The <i>options</i> must be the logical OR of a placement option
......
int dataColumn_;
double height_;
double startAngle_;
double avoidLabelRendering_;
WFlags<LabelOption> labelOptions_;
bool shadow_;
wt-3.2.0/src/Wt/Chart/WPieChart.C 2012-01-18 19:34:40.000000000 +0100
dataColumn_(-1),
height_(0.0),
startAngle_(45),
avoidLabelRendering_(0),
labelOptions_(0),
shadow_(false)
{
......
}
}
void WPieChart::setAvoidLabelRendering(double avoidLabelRendering)
{
if (avoidLabelRendering_ != avoidLabelRendering) {
avoidLabelRendering_ = avoidLabelRendering;
update();
}
}
void WPieChart::setDisplayLabels(WFlags<LabelOption> options)
{
labelOptions_ = options;
......
c = palette()->fontColor(i);
}
painter.setPen(WPen(c));
painter.drawText(WRectF(left, top, width, height),
alignment, labelText(i, v, total, labelOptions_));
if ((v / total * 100) >= avoidLabelRendering_) {
painter.setPen(WPen(c));
painter.drawText(WRectF(left, top, width, height),
alignment, labelText(i, v, total, labelOptions_));
}
currentAngle = endAngle;
}
(1-1/3)