@@ -56,6 +56,10 void CartesianChartAxis::createItems(int count) | |||||
56 | QGraphicsLineItem *item = new QGraphicsLineItem(this); |
|
56 | QGraphicsLineItem *item = new QGraphicsLineItem(this); | |
57 | item->setPen(axis()->gridLinePen()); |
|
57 | item->setPen(axis()->gridLinePen()); | |
58 | gridGroup()->addToGroup(item); |
|
58 | gridGroup()->addToGroup(item); | |
|
59 | QGraphicsRectItem *shades = new QGraphicsRectItem(this); | |||
|
60 | shades->setPen(axis()->shadesPen()); | |||
|
61 | shades->setBrush(axis()->shadesBrush()); | |||
|
62 | shadeGroup()->addToGroup(shades); | |||
59 | } |
|
63 | } | |
60 | } |
|
64 | } | |
61 |
|
65 | |||
@@ -78,14 +82,13 void CartesianChartAxis::createItems(int count) | |||||
78 | gridGroup()->addToGroup(grid); |
|
82 | gridGroup()->addToGroup(grid); | |
79 | labelGroup()->addToGroup(label); |
|
83 | labelGroup()->addToGroup(label); | |
80 |
|
84 | |||
81 |
if ((gridItems().size()) % 2 && gridItems().size() > |
|
85 | if (gridItems().size() == 1 || (((gridItems().size() + 1) % 2) && gridItems().size() > 0)) { | |
82 |
QGraphicsRectItem* |
|
86 | QGraphicsRectItem *shades = new QGraphicsRectItem(this); | |
83 | shades->setPen(axis()->shadesPen()); |
|
87 | shades->setPen(axis()->shadesPen()); | |
84 | shades->setBrush(axis()->shadesBrush()); |
|
88 | shades->setBrush(axis()->shadesBrush()); | |
85 | shadeGroup()->addToGroup(shades); |
|
89 | shadeGroup()->addToGroup(shades); | |
86 | } |
|
90 | } | |
87 | } |
|
91 | } | |
88 |
|
||||
89 | } |
|
92 | } | |
90 |
|
93 | |||
91 | void CartesianChartAxis::deleteItems(int count) |
|
94 | void CartesianChartAxis::deleteItems(int count) | |
@@ -96,7 +99,7 void CartesianChartAxis::deleteItems(int count) | |||||
96 | QList<QGraphicsItem *> axis = arrowItems(); |
|
99 | QList<QGraphicsItem *> axis = arrowItems(); | |
97 |
|
100 | |||
98 | for (int i = 0; i < count; ++i) { |
|
101 | for (int i = 0; i < count; ++i) { | |
99 |
if (lines.size() % 2 && lines.size() > |
|
102 | if (lines.size() == 1 || (((lines.size() + 1) % 2) && lines.size() > 0)) | |
100 | delete(shades.takeLast()); |
|
103 | delete(shades.takeLast()); | |
101 | delete(lines.takeLast()); |
|
104 | delete(lines.takeLast()); | |
102 | delete(labels.takeLast()); |
|
105 | delete(labels.takeLast()); |
@@ -161,15 +161,30 void HorizontalAxis::updateGeometry() | |||||
161 | } |
|
161 | } | |
162 |
|
162 | |||
163 | //shades |
|
163 | //shades | |
164 | if ((i + 1) % 2 && i > 1) { |
|
164 | QGraphicsRectItem *shadeItem = 0; | |
165 | QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem *>(shades.at(i / 2 - 1)); |
|
165 | if (i == 0) | |
166 | qreal leftBound = qMax(layout[i - 1], gridRect.left()); |
|
166 | shadeItem = static_cast<QGraphicsRectItem *>(shades.at(0)); | |
167 | qreal rightBound = qMin(layout[i], gridRect.right()); |
|
167 | else if (i % 2) | |
168 | rectItem->setRect(leftBound, gridRect.top(), rightBound - leftBound, gridRect.height()); |
|
168 | shadeItem = static_cast<QGraphicsRectItem *>(shades.at((i / 2) + 1)); | |
169 | if (rectItem->rect().width() <= 0.0) |
|
169 | if (shadeItem) { | |
170 | rectItem->setVisible(false); |
|
170 | qreal leftBound; | |
|
171 | qreal rightBound; | |||
|
172 | if (i == 0) { | |||
|
173 | leftBound = gridRect.left(); | |||
|
174 | rightBound = layout[0]; | |||
|
175 | } else { | |||
|
176 | leftBound = layout[i]; | |||
|
177 | if (i == layout.size() - 1) | |||
|
178 | rightBound = gridRect.right(); | |||
|
179 | else | |||
|
180 | rightBound = qMin(layout[i + 1], gridRect.right()); | |||
|
181 | } | |||
|
182 | shadeItem->setRect(leftBound, gridRect.top(), rightBound - leftBound, | |||
|
183 | gridRect.height()); | |||
|
184 | if (shadeItem->rect().width() <= 0.0) | |||
|
185 | shadeItem->setVisible(false); | |||
171 | else |
|
186 | else | |
172 |
|
|
187 | shadeItem->setVisible(true); | |
173 | } |
|
188 | } | |
174 |
|
189 | |||
175 | // check if the grid line and the axis tick should be shown |
|
190 | // check if the grid line and the axis tick should be shown |
@@ -165,15 +165,31 void VerticalAxis::updateGeometry() | |||||
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | //shades |
|
167 | //shades | |
168 | if ((i + 1) % 2 && i > 1) { |
|
168 | QGraphicsRectItem *shadeItem = 0; | |
169 | QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem *>(shades.at(i / 2 - 1)); |
|
169 | if (i == 0) | |
170 | qreal lowerBound = qMin(layout[i - 1], gridRect.bottom()); |
|
170 | shadeItem = static_cast<QGraphicsRectItem *>(shades.at(0)); | |
171 | qreal upperBound = qMax(layout[i], gridRect.top()); |
|
171 | else if (i % 2) | |
172 | rectItem->setRect(gridRect.left(), upperBound, gridRect.width(), lowerBound - upperBound); |
|
172 | shadeItem = static_cast<QGraphicsRectItem *>(shades.at((i / 2) + 1)); | |
173 | if (rectItem->rect().height() <= 0.0) |
|
173 | if (shadeItem) { | |
174 | rectItem->setVisible(false); |
|
174 | qreal lowerBound; | |
|
175 | qreal upperBound; | |||
|
176 | if (i == 0) { | |||
|
177 | lowerBound = gridRect.bottom(); | |||
|
178 | upperBound = layout[0]; | |||
|
179 | } else { | |||
|
180 | lowerBound = layout[i]; | |||
|
181 | if (i == layout.size() - 1) | |||
|
182 | upperBound = gridRect.top(); | |||
|
183 | else | |||
|
184 | upperBound = qMax(layout[i + 1], gridRect.top()); | |||
|
185 | ||||
|
186 | } | |||
|
187 | shadeItem->setRect(gridRect.left(), upperBound, gridRect.width(), | |||
|
188 | lowerBound - upperBound); | |||
|
189 | if (shadeItem->rect().height() <= 0.0) | |||
|
190 | shadeItem->setVisible(false); | |||
175 | else |
|
191 | else | |
176 |
|
|
192 | shadeItem->setVisible(true); | |
177 | } |
|
193 | } | |
178 |
|
194 | |||
179 | // check if the grid line and the axis tick should be shown |
|
195 | // check if the grid line and the axis tick should be shown |
General Comments 0
You need to be logged in to leave comments.
Login now