Project

General

Profile

Bug #4080 » 0001-Improve-WCartesianChart-vertical-Y-axis-titles.patch

Bruce Toll, 05/08/2015 02:54 PM

View differences:

src/Wt/Chart/WCartesianChart.C
chartArea_.top() - 8),
labelHFlag | AlignBottom, 0, 10);
} else {
if(axis.id() == YAxis) {
renderLabel(painter, axis.title(),
WPointF(u + (labelHFlag == AlignRight ? -40 : +40),
chartArea_.center().y() + axis.title().toUTF8().size() * titleFont.size()),
(labelHFlag == AlignRight ? AlignLeft : AlignRight) |
AlignMiddle, 90, 20);
}else {
renderLabel(painter, axis.title(),
WPointF(u + (labelHFlag == AlignRight ? -40 : +40),
chartArea_.center().y() + axis.title().toUTF8().size() * titleFont.size()),
(labelHFlag == AlignRight ? AlignRight : AlignLeft) |
AlignMiddle, 90, 20);
double textLengthEstimate = axis.title().toUTF8().size() * axis.titleFont().sizeLength().toPixels() / 2.0;
if (isAutoLayoutEnabled()) {
WTextItem t = painter.device()->measureText(axis.title());
textLengthEstimate = t.width();
}
double labelWidthEstimate = std::max(axis.label(axis.maximum()).toUTF8().size(),
axis.label(axis.minimum()).toUTF8().size()) * axis.labelFont().sizeLength().toPixels() / 1.5;
renderLabel(painter, axis.title(),
WPointF(u + (labelHFlag == AlignRight ? -1 * labelWidthEstimate - 20 : labelWidthEstimate + 20),
chartArea_.center().y() + textLengthEstimate / 2.0),
((labelHFlag == AlignRight) == (axis.id() == YAxis) ? AlignLeft : AlignRight) |
AlignMiddle, 90, 0);
}
} else {
renderLabel(painter, axis.title(),
(2-2/2)