@@ -145,8 +145,8 void HorizontalAxis::updateGeometry() | |||
|
145 | 145 | |
|
146 | 146 | //label overlap detection |
|
147 | 147 | if(labelItem->pos().x() < width || |
|
148 | labelItem->pos().x() < axisRect.left() || | |
|
149 |
labelItem->pos().x() + rect.width() - |
|
|
148 | labelItem->pos().x() < axisRect.left() || | |
|
149 | labelItem->pos().x() + rect.width() -1 > axisRect.right()){ | |
|
150 | 150 | labelItem->setVisible(false); |
|
151 | 151 | } else { |
|
152 | 152 | labelItem->setVisible(true); |
@@ -95,31 +95,31 QSizeF ChartValueAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c | |||
|
95 | 95 | qreal width = 0; |
|
96 | 96 | qreal height = 0; |
|
97 | 97 | |
|
98 | int count = 1; | |
|
99 | ||
|
100 | if(!ticksList.empty()) { | |
|
101 | count = qMax(ticksList.last().count(),ticksList.first().count()); | |
|
102 | } | |
|
103 | 98 | |
|
104 | 99 | switch (which) { |
|
105 | case Qt::MinimumSize:{ | |
|
106 | count = qMin(count,5); | |
|
107 | width = fn.averageCharWidth() * count; | |
|
108 | height = fn.height() + labelPadding(); | |
|
109 | width = qMax(width,base.width()); | |
|
110 | height += base.height(); | |
|
111 | sh = QSizeF(width,height); | |
|
112 | break; | |
|
113 | } | |
|
114 | case Qt::PreferredSize:{ | |
|
115 | width=fn.averageCharWidth() * count; | |
|
116 | height=fn.height()+labelPadding(); | |
|
117 | width=qMax(width,base.width()); | |
|
118 | height+=base.height(); | |
|
119 | sh = QSizeF(width,height); | |
|
120 | break; | |
|
121 | } | |
|
122 | default: | |
|
100 | case Qt::MinimumSize: { | |
|
101 | if(!ticksList.empty()) { | |
|
102 | width = qMax(fn.boundingRect(ticksList.last()).width(),fn.boundingRect(ticksList.first()).width()); | |
|
103 | } | |
|
104 | height = fn.height() + labelPadding(); | |
|
105 | width = qMax(width,base.width()); | |
|
106 | height += base.height(); | |
|
107 | sh = QSizeF(width,height); | |
|
108 | break; | |
|
109 | } | |
|
110 | case Qt::PreferredSize: { | |
|
111 | if(!ticksList.empty()) { | |
|
112 | foreach(QString label,ticksList) { | |
|
113 | width+=fn.boundingRect(label).width(); | |
|
114 | } | |
|
115 | } | |
|
116 | height=fn.height()+labelPadding(); | |
|
117 | width=qMax(width,base.width()); | |
|
118 | height+=base.height(); | |
|
119 | sh = QSizeF(width,height); | |
|
120 | break; | |
|
121 | } | |
|
122 | default: | |
|
123 | 123 | break; |
|
124 | 124 | } |
|
125 | 125 |
General Comments 0
You need to be logged in to leave comments.
Login now