##// END OF EJS Templates
Fix vanishing labels for first and last ticks....
Miikka Heikkinen -
r2443:5b27b7b1d72a RC2_1.2.1
parent child
Show More
@@ -109,13 +109,12 QSizeF ChartBarCategoryAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constra
109 QSizeF base = HorizontalAxis::sizeHint(which, constraint);
109 QSizeF base = HorizontalAxis::sizeHint(which, constraint);
110 QStringList ticksList = m_categoriesAxis->categories();
110 QStringList ticksList = m_categoriesAxis->categories();
111
111
112 qreal width=0;
112 qreal width = 0; // Width is irrelevant for X axes with interval labels
113 qreal height=0;
113 qreal height = 0;
114
114
115 switch (which) {
115 switch (which) {
116 case Qt::MinimumSize: {
116 case Qt::MinimumSize: {
117 QRectF boundingRect = labelBoundingRect(fn, "...");
117 QRectF boundingRect = labelBoundingRect(fn, "...");
118 width = qMax(boundingRect.width(), base.width());
119 height = boundingRect.height() + labelPadding();
118 height = boundingRect.height() + labelPadding();
120 height += base.height();
119 height += base.height();
121 sh = QSizeF(width, height);
120 sh = QSizeF(width, height);
@@ -126,11 +125,9 QSizeF ChartBarCategoryAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constra
126 foreach (const QString& s, ticksList) {
125 foreach (const QString& s, ticksList) {
127 QRect rect = labelBoundingRect(fn, s);
126 QRect rect = labelBoundingRect(fn, s);
128 labelHeight = qMax(rect.height(), labelHeight);
127 labelHeight = qMax(rect.height(), labelHeight);
129 width += rect.width();
130 }
128 }
131 height = labelHeight + labelPadding();
129 height = labelHeight + labelPadding();
132 height += base.height();
130 height += base.height();
133 width = qMax(width, base.width());
134 sh = QSizeF(width, height);
131 sh = QSizeF(width, height);
135 break;
132 break;
136 }
133 }
@@ -108,7 +108,7 QSizeF ChartBarCategoryAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constra
108 QSizeF base = VerticalAxis::sizeHint(which, constraint);
108 QSizeF base = VerticalAxis::sizeHint(which, constraint);
109 QStringList ticksList = m_categoriesAxis->categories();
109 QStringList ticksList = m_categoriesAxis->categories();
110 qreal width=0;
110 qreal width = 0;
111 qreal height=0;
111 qreal height = 0; // Height is irrelevant for Y axes with interval labels
112
112
113 switch (which) {
113 switch (which) {
114 case Qt::MinimumSize: {
114 case Qt::MinimumSize: {
@@ -117,7 +117,6 QSizeF ChartBarCategoryAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constra
117 width += base.width();
117 width += base.width();
118 if (base.width() > 0)
118 if (base.width() > 0)
119 width += labelPadding();
119 width += labelPadding();
120 height = qMax(boundingRect.height(), base.height());
121 sh = QSizeF(width, height);
120 sh = QSizeF(width, height);
122 break;
121 break;
123 }
122 }
@@ -126,13 +125,11 QSizeF ChartBarCategoryAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constra
126 foreach (const QString& s, ticksList) {
125 foreach (const QString& s, ticksList) {
127 QRect rect = labelBoundingRect(fn, s);
126 QRect rect = labelBoundingRect(fn, s);
128 labelWidth = qMax(rect.width(), labelWidth);
127 labelWidth = qMax(rect.width(), labelWidth);
129 height += rect.height();
130 }
128 }
131 width = labelWidth + labelPadding() + 1;
129 width = labelWidth + labelPadding() + 1;
132 width += base.width();
130 width += base.width();
133 if (base.width() > 0)
131 if (base.width() > 0)
134 width += labelPadding();
132 width += labelPadding();
135 height = qMax(height, base.height());
136 sh = QSizeF(width, height);
133 sh = QSizeF(width, height);
137 break;
134 break;
138 }
135 }
@@ -84,13 +84,12 QSizeF ChartCategoryAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint
84 QSizeF sh;
84 QSizeF sh;
85 QSizeF base = HorizontalAxis::sizeHint(which, constraint);
85 QSizeF base = HorizontalAxis::sizeHint(which, constraint);
86 QStringList ticksList = m_axis->categoriesLabels();
86 QStringList ticksList = m_axis->categoriesLabels();
87 qreal width = 0;
87 qreal width = 0; // Width is irrelevant for X axes with interval labels
88 qreal height = 0;
88 qreal height = 0;
89
89
90 switch (which) {
90 switch (which) {
91 case Qt::MinimumSize: {
91 case Qt::MinimumSize: {
92 QRectF boundingRect = labelBoundingRect(fn, "...");
92 QRectF boundingRect = labelBoundingRect(fn, "...");
93 width = qMax(boundingRect.width(), base.width());
94 height = boundingRect.height() + labelPadding();
93 height = boundingRect.height() + labelPadding();
95 height += base.height();
94 height += base.height();
96 sh = QSizeF(width, height);
95 sh = QSizeF(width, height);
@@ -101,11 +100,9 QSizeF ChartCategoryAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint
101 foreach (const QString& s, ticksList) {
100 foreach (const QString& s, ticksList) {
102 QRect rect = labelBoundingRect(fn, s);
101 QRect rect = labelBoundingRect(fn, s);
103 labelHeight = qMax(rect.height(), labelHeight);
102 labelHeight = qMax(rect.height(), labelHeight);
104 width += rect.width();
105 }
103 }
106 height = labelHeight + labelPadding();
104 height = labelHeight + labelPadding();
107 height += base.height();
105 height += base.height();
108 width = qMax(width, base.width());
109 sh = QSizeF(width, height);
106 sh = QSizeF(width, height);
110 break;
107 break;
111 }
108 }
@@ -86,14 +86,13 QSizeF ChartCategoryAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint
86 QSizeF base = VerticalAxis::sizeHint(which, constraint);
86 QSizeF base = VerticalAxis::sizeHint(which, constraint);
87 QStringList ticksList = m_axis->categoriesLabels();
87 QStringList ticksList = m_axis->categoriesLabels();
88 qreal width = 0;
88 qreal width = 0;
89 qreal height = 0;
89 qreal height = 0; // Height is irrelevant for Y axes with interval labels
90
90
91 switch (which) {
91 switch (which) {
92 case Qt::MinimumSize: {
92 case Qt::MinimumSize: {
93 QRectF boundingRect = labelBoundingRect(fn, "...");
93 QRectF boundingRect = labelBoundingRect(fn, "...");
94 width = boundingRect.width() + labelPadding();
94 width = boundingRect.width() + labelPadding();
95 width += base.width();
95 width += base.width();
96 height = qMax(boundingRect.height(), base.height());
97 sh = QSizeF(width, height);
96 sh = QSizeF(width, height);
98 break;
97 break;
99 }
98 }
@@ -102,11 +101,9 QSizeF ChartCategoryAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint
102 foreach (const QString& s, ticksList) {
101 foreach (const QString& s, ticksList) {
103 QRect rect = labelBoundingRect(fn, s);
102 QRect rect = labelBoundingRect(fn, s);
104 labelWidth = qMax(rect.width(), labelWidth);
103 labelWidth = qMax(rect.width(), labelWidth);
105 height += rect.height();
106 }
104 }
107 width = labelWidth + labelPadding() + 1;
105 width = labelWidth + labelPadding() + 1;
108 width += base.width();
106 width += base.width();
109 height = qMax(height, base.height());
110 sh = QSizeF(width, height);
107 sh = QSizeF(width, height);
111 break;
108 break;
112 }
109 }
@@ -90,17 +90,18 QSizeF ChartDateTimeAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint
90
90
91 QSizeF base = HorizontalAxis::sizeHint(which, constraint);
91 QSizeF base = HorizontalAxis::sizeHint(which, constraint);
92 QStringList ticksList = createDateTimeLabels(min(),max(),m_axis->tickCount(),m_axis->format());
92 QStringList ticksList = createDateTimeLabels(min(),max(),m_axis->tickCount(),m_axis->format());
93 // Width of horizontal axis sizeHint indicates the maximum distance labels can extend past
94 // first and last ticks. Base width is irrelevant.
93 qreal width = 0;
95 qreal width = 0;
94 qreal height = 0;
96 qreal height = 0;
95
97
96 if(ticksList.empty()){
98 if (ticksList.empty())
97 return sh;
99 return sh;
98 }
99
100
100 switch (which) {
101 switch (which) {
101 case Qt::MinimumSize:{
102 case Qt::MinimumSize:{
102 QRectF boundingRect = labelBoundingRect(fn, "...");
103 QRectF boundingRect = labelBoundingRect(fn, "...");
103 width = qMax(boundingRect.width(), base.width());
104 width = boundingRect.width() / 2.0;
104 height = boundingRect.height() + labelPadding();
105 height = boundingRect.height() + labelPadding();
105 height += base.height();
106 height += base.height();
106 sh = QSizeF(width, height);
107 sh = QSizeF(width, height);
@@ -108,14 +109,17 QSizeF ChartDateTimeAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint
108 }
109 }
109 case Qt::PreferredSize: {
110 case Qt::PreferredSize: {
110 int labelHeight = 0;
111 int labelHeight = 0;
112 int firstWidth = -1;
111 foreach (const QString& s, ticksList) {
113 foreach (const QString& s, ticksList) {
112 QRect rect = labelBoundingRect(fn, s);
114 QRect rect = labelBoundingRect(fn, s);
113 labelHeight = qMax(rect.height(), labelHeight);
115 labelHeight = qMax(rect.height(), labelHeight);
114 width += rect.width();
116 width = rect.width();
117 if (firstWidth < 0)
118 firstWidth = width;
115 }
119 }
116 height = labelHeight + labelPadding();
120 height = labelHeight + labelPadding();
117 height += base.height();
121 height += base.height();
118 width = qMax(width, base.width());
122 width = qMax(width, qreal(firstWidth)) / 2.0;
119 sh = QSizeF(width, height);
123 sh = QSizeF(width, height);
120 break;
124 break;
121 }
125 }
@@ -92,32 +92,35 QSizeF ChartDateTimeAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint
92 QSizeF base = VerticalAxis::sizeHint(which, constraint);
92 QSizeF base = VerticalAxis::sizeHint(which, constraint);
93 QStringList ticksList = createDateTimeLabels(min(),max(),m_axis->tickCount(),m_axis->format());
93 QStringList ticksList = createDateTimeLabels(min(),max(),m_axis->tickCount(),m_axis->format());
94 qreal width = 0;
94 qreal width = 0;
95 // Height of vertical axis sizeHint indicates the maximum distance labels can extend past
96 // first and last ticks. Base height is irrelevant.
95 qreal height = 0;
97 qreal height = 0;
96
98
97
99 if (ticksList.empty())
98 if(ticksList.empty()){
99 return sh;
100 return sh;
100 }
101
101
102 switch (which) {
102 switch (which) {
103 case Qt::MinimumSize: {
103 case Qt::MinimumSize: {
104 QRectF boundingRect = labelBoundingRect(fn, "...");
104 QRectF boundingRect = labelBoundingRect(fn, "...");
105 width = boundingRect.width() + labelPadding();
105 width = boundingRect.width() + labelPadding();
106 width += base.width();
106 width += base.width();
107 height = qMax(boundingRect.height(), base.height());
107 height = boundingRect.height() / 2.0;
108 sh = QSizeF(width, height);
108 sh = QSizeF(width, height);
109 break;
109 break;
110 }
110 }
111 case Qt::PreferredSize: {
111 case Qt::PreferredSize: {
112 int labelWidth = 0;
112 int labelWidth = 0;
113 int firstHeight = -1;
113 foreach (const QString& s, ticksList) {
114 foreach (const QString& s, ticksList) {
114 QRect rect = labelBoundingRect(fn, s);
115 QRect rect = labelBoundingRect(fn, s);
115 labelWidth = qMax(rect.width(), labelWidth);
116 labelWidth = qMax(rect.width(), labelWidth);
116 height += rect.height();
117 height = rect.height();
118 if (firstHeight < 0)
119 firstHeight = height;
117 }
120 }
118 width = labelWidth + labelPadding() + 2; //two pixels of tolerance
121 width = labelWidth + labelPadding() + 2; //two pixels of tolerance
119 width += base.width();
122 width += base.width();
120 height = qMax(height, base.height());
123 height = qMax(height, qreal(firstHeight)) / 2.0;
121 sh = QSizeF(width, height);
124 sh = QSizeF(width, height);
122 break;
125 break;
123 }
126 }
@@ -99,14 +99,15 QSizeF ChartLogValueAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint
99 ticksList = createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), tickCount, m_axis->labelFormat());
99 ticksList = createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), tickCount, m_axis->labelFormat());
100 else
100 else
101 ticksList.append(QString(" "));
101 ticksList.append(QString(" "));
102 // Width of horizontal axis sizeHint indicates the maximum distance labels can extend past
103 // first and last ticks. Base width is irrelevant.
102 qreal width = 0;
104 qreal width = 0;
103 qreal height = 0;
105 qreal height = 0;
104
106
105
106 switch (which) {
107 switch (which) {
107 case Qt::MinimumSize:{
108 case Qt::MinimumSize:{
108 QRectF boundingRect = labelBoundingRect(fn, "...");
109 QRectF boundingRect = labelBoundingRect(fn, "...");
109 width = qMax(boundingRect.width(), base.width());
110 width = boundingRect.width() / 2.0;
110 height = boundingRect.height() + labelPadding();
111 height = boundingRect.height() + labelPadding();
111 height += base.height();
112 height += base.height();
112 sh = QSizeF(width, height);
113 sh = QSizeF(width, height);
@@ -114,14 +115,17 QSizeF ChartLogValueAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint
114 }
115 }
115 case Qt::PreferredSize: {
116 case Qt::PreferredSize: {
116 int labelHeight = 0;
117 int labelHeight = 0;
118 int firstWidth = -1;
117 foreach (const QString& s, ticksList) {
119 foreach (const QString& s, ticksList) {
118 QRect rect = labelBoundingRect(fn, s);
120 QRect rect = labelBoundingRect(fn, s);
119 labelHeight = qMax(rect.height(), labelHeight);
121 labelHeight = qMax(rect.height(), labelHeight);
120 width += rect.width();
122 width = rect.width();
123 if (firstWidth < 0)
124 firstWidth = width;
121 }
125 }
122 height = labelHeight + labelPadding();
126 height = labelHeight + labelPadding();
123 height += base.height();
127 height += base.height();
124 width = qMax(width, base.width());
128 width = qMax(width, qreal(firstWidth)) / 2.0;
125 sh = QSizeF(width, height);
129 sh = QSizeF(width, height);
126 break;
130 break;
127 }
131 }
@@ -100,6 +100,8 QSizeF ChartLogValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint
100 else
100 else
101 ticksList.append(QString(" "));
101 ticksList.append(QString(" "));
102 qreal width = 0;
102 qreal width = 0;
103 // Height of vertical axis sizeHint indicates the maximum distance labels can extend past
104 // first and last ticks. Base height is irrelevant.
103 qreal height = 0;
105 qreal height = 0;
104
106
105 switch (which) {
107 switch (which) {
@@ -107,20 +109,23 QSizeF ChartLogValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint
107 QRectF boundingRect = labelBoundingRect(fn, "...");
109 QRectF boundingRect = labelBoundingRect(fn, "...");
108 width = boundingRect.width() + labelPadding();
110 width = boundingRect.width() + labelPadding();
109 width += base.width();
111 width += base.width();
110 height = qMax(boundingRect.height(), base.height());
112 height = boundingRect.height() / 2.0;
111 sh = QSizeF(width, height);
113 sh = QSizeF(width, height);
112 break;
114 break;
113 }
115 }
114 case Qt::PreferredSize: {
116 case Qt::PreferredSize: {
115 int labelWidth = 0;
117 int labelWidth = 0;
118 int firstHeight = -1;
116 foreach (const QString& s, ticksList) {
119 foreach (const QString& s, ticksList) {
117 QRect rect = labelBoundingRect(fn, s);
120 QRect rect = labelBoundingRect(fn, s);
118 labelWidth = qMax(rect.width(), labelWidth);
121 labelWidth = qMax(rect.width(), labelWidth);
119 height += rect.height();
122 height = rect.height();
123 if (firstHeight < 0)
124 firstHeight = height;
120 }
125 }
121 width = labelWidth + labelPadding() + 2; //two pixels of tolerance
126 width = labelWidth + labelPadding() + 2; //two pixels of tolerance
122 width += base.width();
127 width += base.width();
123 height = qMax(height, base.height());
128 height = qMax(height, qreal(firstHeight)) / 2.0;
124 sh = QSizeF(width, height);
129 sh = QSizeF(width, height);
125 break;
130 break;
126 }
131 }
@@ -92,14 +92,15 QSizeF ChartValueAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c
92
92
93 QSizeF base = HorizontalAxis::sizeHint(which, constraint);
93 QSizeF base = HorizontalAxis::sizeHint(which, constraint);
94 QStringList ticksList = createValueLabels(min(),max(),m_axis->tickCount(),m_axis->labelFormat());
94 QStringList ticksList = createValueLabels(min(),max(),m_axis->tickCount(),m_axis->labelFormat());
95 // Width of horizontal axis sizeHint indicates the maximum distance labels can extend past
96 // first and last ticks. Base width is irrelevant.
95 qreal width = 0;
97 qreal width = 0;
96 qreal height = 0;
98 qreal height = 0;
97
99
98
99 switch (which) {
100 switch (which) {
100 case Qt::MinimumSize: {
101 case Qt::MinimumSize: {
101 QRectF boundingRect = labelBoundingRect(fn, "...");
102 QRectF boundingRect = labelBoundingRect(fn, "...");
102 width = qMax(boundingRect.width(), base.width());
103 width = boundingRect.width() / 2.0;
103 height = boundingRect.height() + labelPadding();
104 height = boundingRect.height() + labelPadding();
104 height += base.height();
105 height += base.height();
105 sh = QSizeF(width, height);
106 sh = QSizeF(width, height);
@@ -107,14 +108,17 QSizeF ChartValueAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c
107 }
108 }
108 case Qt::PreferredSize: {
109 case Qt::PreferredSize: {
109 int labelHeight = 0;
110 int labelHeight = 0;
111 int firstWidth = -1;
110 foreach (const QString& s, ticksList) {
112 foreach (const QString& s, ticksList) {
111 QRect rect = labelBoundingRect(fn, s);
113 QRect rect = labelBoundingRect(fn, s);
112 labelHeight = qMax(rect.height(), labelHeight);
114 labelHeight = qMax(rect.height(), labelHeight);
113 width += rect.width();
115 width = rect.width();
116 if (firstWidth < 0)
117 firstWidth = width;
114 }
118 }
115 height = labelHeight + labelPadding();
119 height = labelHeight + labelPadding();
116 height += base.height();
120 height += base.height();
117 width = qMax(width, base.width());
121 width = qMax(width, qreal(firstWidth)) / 2.0;
118 sh = QSizeF(width, height);
122 sh = QSizeF(width, height);
119 break;
123 break;
120 }
124 }
@@ -93,6 +93,8 QSizeF ChartValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c
93 QSizeF base = VerticalAxis::sizeHint(which, constraint);
93 QSizeF base = VerticalAxis::sizeHint(which, constraint);
94 QStringList ticksList = createValueLabels(min(),max(),m_axis->tickCount(),m_axis->labelFormat());
94 QStringList ticksList = createValueLabels(min(),max(),m_axis->tickCount(),m_axis->labelFormat());
95 qreal width = 0;
95 qreal width = 0;
96 // Height of vertical axis sizeHint indicates the maximum distance labels can extend past
97 // first and last ticks. Base height is irrelevant.
96 qreal height = 0;
98 qreal height = 0;
97
99
98 switch (which) {
100 switch (which) {
@@ -100,20 +102,23 QSizeF ChartValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c
100 QRectF boundingRect = labelBoundingRect(fn, "...");
102 QRectF boundingRect = labelBoundingRect(fn, "...");
101 width = boundingRect.width() + labelPadding();
103 width = boundingRect.width() + labelPadding();
102 width += base.width();
104 width += base.width();
103 height = qMax(boundingRect.height(), base.height());
105 height = boundingRect.height() / 2.0;
104 sh = QSizeF(width, height);
106 sh = QSizeF(width, height);
105 break;
107 break;
106 }
108 }
107 case Qt::PreferredSize: {
109 case Qt::PreferredSize: {
108 int labelWidth = 0;
110 int labelWidth = 0;
111 int firstHeight = -1;
109 foreach (const QString& s, ticksList) {
112 foreach (const QString& s, ticksList) {
110 QRect rect = labelBoundingRect(fn, s);
113 QRect rect = labelBoundingRect(fn, s);
111 labelWidth = qMax(rect.width(), labelWidth);
114 labelWidth = qMax(rect.width(), labelWidth);
112 height += rect.height();
115 height = rect.height();
116 if (firstHeight < 0)
117 firstHeight = height;
113 }
118 }
114 width = labelWidth + labelPadding() + 2; //two pixels of tolerance
119 width = labelWidth + labelPadding() + 2; //two pixels of tolerance
115 width += base.width();
120 width += base.width();
116 height = qMax(height, base.height());
121 height = qMax(height, qreal(firstHeight)) / 2.0;
117 sh = QSizeF(width, height);
122 sh = QSizeF(width, height);
118 break;
123 break;
119 }
124 }
@@ -154,8 +154,8 void VerticalAxis::updateGeometry()
154
154
155 //label overlap detection
155 //label overlap detection
156 if(labelItem->pos().y() + boundingRect.height() > height ||
156 if(labelItem->pos().y() + boundingRect.height() > height ||
157 labelItem->pos().y() + boundingRect.height()/2 > gridRect.bottom() ||
157 labelItem->pos().y() + boundingRect.height()/2 > axisRect.bottom() ||
158 labelItem->pos().y() + boundingRect.height()/2 < gridRect.top()) {
158 labelItem->pos().y() + boundingRect.height()/2 < axisRect.top()) {
159 labelItem->setVisible(false);
159 labelItem->setVisible(false);
160 }
160 }
161 else {
161 else {
@@ -109,6 +109,7 QRectF ChartLayout::calculateAxisGeometry(const QRectF &geometry, const QList<Ch
109 QSizeF minBottom(0,0);
109 QSizeF minBottom(0,0);
110 QSizeF top(0,0);
110 QSizeF top(0,0);
111 QSizeF minTop(0,0);
111 QSizeF minTop(0,0);
112 QSizeF labelExtents(0,0);
112 int leftCount = 0;
113 int leftCount = 0;
113 int rightCount = 0;
114 int rightCount = 0;
114 int topCount = 0;
115 int topCount = 0;
@@ -119,7 +120,6 QRectF ChartLayout::calculateAxisGeometry(const QRectF &geometry, const QList<Ch
119 if (!axis->isVisible())
120 if (!axis->isVisible())
120 continue;
121 continue;
121
122
122
123 QSizeF size = axis->effectiveSizeHint(Qt::PreferredSize);
123 QSizeF size = axis->effectiveSizeHint(Qt::PreferredSize);
124 //this is used to get single thick font size
124 //this is used to get single thick font size
125 QSizeF minSize = axis->effectiveSizeHint(Qt::MinimumSize);
125 QSizeF minSize = axis->effectiveSizeHint(Qt::MinimumSize);
@@ -130,6 +130,7 QRectF ChartLayout::calculateAxisGeometry(const QRectF &geometry, const QList<Ch
130 left.setHeight(qMax(left.height(),size.height()));
130 left.setHeight(qMax(left.height(),size.height()));
131 minLeft.setWidth(minLeft.width()+minSize.width());
131 minLeft.setWidth(minLeft.width()+minSize.width());
132 minLeft.setHeight(qMax(minLeft.height(),minSize.height()));
132 minLeft.setHeight(qMax(minLeft.height(),minSize.height()));
133 labelExtents.setHeight(qMax(size.height(), labelExtents.height()));
133 leftCount++;
134 leftCount++;
134 break;
135 break;
135 case Qt::AlignRight:
136 case Qt::AlignRight:
@@ -137,6 +138,7 QRectF ChartLayout::calculateAxisGeometry(const QRectF &geometry, const QList<Ch
137 right.setHeight(qMax(right.height(),size.height()));
138 right.setHeight(qMax(right.height(),size.height()));
138 minRight.setWidth(minRight.width()+minSize.width());
139 minRight.setWidth(minRight.width()+minSize.width());
139 minRight.setHeight(qMax(minRight.height(),minSize.height()));
140 minRight.setHeight(qMax(minRight.height(),minSize.height()));
141 labelExtents.setHeight(qMax(size.height(), labelExtents.height()));
140 rightCount++;
142 rightCount++;
141 break;
143 break;
142 case Qt::AlignTop:
144 case Qt::AlignTop:
@@ -144,6 +146,7 QRectF ChartLayout::calculateAxisGeometry(const QRectF &geometry, const QList<Ch
144 top.setHeight(top.height()+size.height());
146 top.setHeight(top.height()+size.height());
145 minTop.setWidth(qMax(minTop.width(),minSize.width()));
147 minTop.setWidth(qMax(minTop.width(),minSize.width()));
146 minTop.setHeight(minTop.height()+minSize.height());
148 minTop.setHeight(minTop.height()+minSize.height());
149 labelExtents.setWidth(qMax(size.width(), labelExtents.width()));
147 topCount++;
150 topCount++;
148 break;
151 break;
149 case Qt::AlignBottom:
152 case Qt::AlignBottom:
@@ -151,6 +154,7 QRectF ChartLayout::calculateAxisGeometry(const QRectF &geometry, const QList<Ch
151 bottom.setHeight(bottom.height() + size.height());
154 bottom.setHeight(bottom.height() + size.height());
152 minBottom.setWidth(qMax(minBottom.width(),minSize.width()));
155 minBottom.setWidth(qMax(minBottom.width(),minSize.width()));
153 minBottom.setHeight(minBottom.height() + minSize.height());
156 minBottom.setHeight(minBottom.height() + minSize.height());
157 labelExtents.setWidth(qMax(size.width(), labelExtents.width()));
154 bottomCount++;
158 bottomCount++;
155 break;
159 break;
156 default:
160 default:
@@ -208,6 +212,12 QRectF ChartLayout::calculateAxisGeometry(const QRectF &geometry, const QList<Ch
208 qreal minHeight = qMax(minLeft.height(),minRight.height()) + 1;
212 qreal minHeight = qMax(minLeft.height(),minRight.height()) + 1;
209 qreal minWidth = qMax(minTop.width(),minBottom.width()) + 1;
213 qreal minWidth = qMax(minTop.width(),minBottom.width()) + 1;
210
214
215 // Ensure that there is enough space for first and last tick labels.
216 left.setWidth(qMax(labelExtents.width(), left.width()));
217 right.setWidth(qMax(labelExtents.width(), right.width()));
218 top.setHeight(qMax(labelExtents.height(), top.height()));
219 bottom.setHeight(qMax(labelExtents.height(), bottom.height()));
220
211 QRectF chartRect = geometry.adjusted(qMax(left.width(),minWidth/2), qMax(top.height(), minHeight/2),-qMax(right.width(),minWidth/2),-qMax(bottom.height(),minHeight/2));
221 QRectF chartRect = geometry.adjusted(qMax(left.width(),minWidth/2), qMax(top.height(), minHeight/2),-qMax(right.width(),minWidth/2),-qMax(bottom.height(),minHeight/2));
212
222
213 qreal leftOffset = 0;
223 qreal leftOffset = 0;
General Comments 0
You need to be logged in to leave comments. Login now