@@ -81,11 +81,11 void ChartCategoriesAxisX::updateGeometry() | |||
|
81 | 81 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(axis.at(0)); |
|
82 | 82 | lineItem->setLine(m_rect.left(), m_rect.bottom(), m_rect.right(), m_rect.bottom()); |
|
83 | 83 | |
|
84 |
for (int i = |
|
|
84 | for (int i = 0; i < layout.size(); ++i) { | |
|
85 | 85 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i)); |
|
86 | 86 | lineItem->setLine(layout[i], m_rect.top(), layout[i], m_rect.bottom()); |
|
87 |
QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i |
|
|
88 | ||
|
87 | QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i)); | |
|
88 | if (i>=1) { | |
|
89 | 89 | labelItem->setText(ticksList.at(i-1)); |
|
90 | 90 | const QRectF& rect = labelItem->boundingRect(); |
|
91 | 91 | QPointF center = rect.center(); |
@@ -93,6 +93,9 void ChartCategoriesAxisX::updateGeometry() | |||
|
93 | 93 | labelItem->setPos(layout[i] - (layout[i] - layout[i-1])/2 - center.x(), m_rect.bottom() + label_padding); |
|
94 | 94 | m_minWidth+=rect.width(); |
|
95 | 95 | m_minHeight=qMax(rect.height()+label_padding,m_minHeight); |
|
96 | }else{ | |
|
97 | labelItem->setVisible(false); | |
|
98 | } | |
|
96 | 99 | |
|
97 | 100 | if ((i+1)%2 && i>1) { |
|
98 | 101 | QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2-1)); |
@@ -79,18 +79,22 void ChartCategoriesAxisY::updateGeometry() | |||
|
79 | 79 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(axis.at(0)); |
|
80 | 80 | lineItem->setLine(m_rect.left(), m_rect.bottom(), m_rect.right(), m_rect.bottom()); |
|
81 | 81 | |
|
82 |
for (int i = |
|
|
82 | for (int i = 0; i < layout.size(); ++i) { | |
|
83 | 83 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i)); |
|
84 | 84 | lineItem->setLine(layout[i], m_rect.top(), layout[i], m_rect.bottom()); |
|
85 | 85 | QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i)); |
|
86 | ||
|
87 | labelItem->setText(ticksList.at(i)); | |
|
86 | if(i>=1){ | |
|
87 | labelItem->setText(ticksList.at(i-1)); | |
|
88 | 88 | const QRectF& rect = labelItem->boundingRect(); |
|
89 | 89 | QPointF center = rect.center(); |
|
90 | 90 | labelItem->setTransformOriginPoint(center.x(), center.y()); |
|
91 | 91 | labelItem->setPos(layout[i] - (layout[i] - layout[i-1])/2 - center.x(), m_rect.bottom() + label_padding); |
|
92 | 92 | m_minWidth+=rect.width(); |
|
93 | 93 | m_minHeight=qMax(rect.height()+label_padding,m_minHeight); |
|
94 | }else{ | |
|
95 | labelItem->setVisible(false); | |
|
96 | } | |
|
97 | ||
|
94 | 98 | |
|
95 | 99 | if ((i+1)%2 && i>1) { |
|
96 | 100 | QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2-1)); |
@@ -124,6 +124,8 QBarCategoriesAxis::QBarCategoriesAxis(QBarCategoriesAxisPrivate &d,QObject *par | |||
|
124 | 124 | */ |
|
125 | 125 | void QBarCategoriesAxis::append(const QStringList &categories) |
|
126 | 126 | { |
|
127 | if(categories.isEmpty()) return; | |
|
128 | ||
|
127 | 129 | Q_D(QBarCategoriesAxis); |
|
128 | 130 | if (d->m_categories.isEmpty()) { |
|
129 | 131 | d->m_categories.append(categories); |
@@ -173,7 +175,7 void QBarCategoriesAxis::insert(int index, const QString &category) | |||
|
173 | 175 | d->m_categories.insert(index,category); |
|
174 | 176 | setRange(category,category); |
|
175 | 177 | }else{ |
|
176 | ||
|
178 | d->m_categories.insert(index,category); | |
|
177 | 179 | } |
|
178 | 180 | emit categoriesChanged(); |
|
179 | 181 | } |
@@ -295,7 +297,7 void QBarCategoriesAxis::setRange(const QString& minCategory, const QString& max | |||
|
295 | 297 | changed = true; |
|
296 | 298 | } |
|
297 | 299 | |
|
298 |
if ( |
|
|
300 | if (changed) { | |
|
299 | 301 | d->emitRange(); |
|
300 | 302 | emit categoriesChanged(); |
|
301 | 303 | } |
General Comments 0
You need to be logged in to leave comments.
Login now