@@ -1,284 +1,306 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #include <private/areachartitem_p.h> |
|
20 | 20 | #include <QtCharts/QAreaSeries> |
|
21 | 21 | #include <private/qareaseries_p.h> |
|
22 | 22 | #include <QtCharts/QLineSeries> |
|
23 | 23 | #include <private/chartpresenter_p.h> |
|
24 | 24 | #include <private/abstractdomain_p.h> |
|
25 | 25 | #include <QtGui/QPainter> |
|
26 | 26 | #include <QtWidgets/QGraphicsSceneMouseEvent> |
|
27 | 27 | #include <QtCore/QDebug> |
|
28 | 28 | |
|
29 | 29 | |
|
30 | 30 | QT_CHARTS_BEGIN_NAMESPACE |
|
31 | 31 | |
|
32 | 32 | AreaChartItem::AreaChartItem(QAreaSeries *areaSeries, QGraphicsItem* item) |
|
33 | 33 | : ChartItem(areaSeries->d_func(),item), |
|
34 | 34 | m_series(areaSeries), |
|
35 | 35 | m_upper(0), |
|
36 | 36 | m_lower(0), |
|
37 | 37 | m_pointsVisible(false), |
|
38 | 38 | m_pointLabelsVisible(false), |
|
39 | 39 | m_pointLabelsFormat(areaSeries->pointLabelsFormat()), |
|
40 | 40 | m_pointLabelsFont(areaSeries->pointLabelsFont()), |
|
41 | 41 | m_pointLabelsColor(areaSeries->pointLabelsColor()), |
|
42 | 42 | m_mousePressed(false) |
|
43 | 43 | { |
|
44 | 44 | setAcceptHoverEvents(true); |
|
45 | 45 | setFlag(QGraphicsItem::ItemIsSelectable, true); |
|
46 | 46 | setZValue(ChartPresenter::LineChartZValue); |
|
47 | 47 | if (m_series->upperSeries()) |
|
48 | 48 | m_upper = new AreaBoundItem(this, m_series->upperSeries()); |
|
49 | 49 | if (m_series->lowerSeries()) |
|
50 | 50 | m_lower = new AreaBoundItem(this, m_series->lowerSeries()); |
|
51 | 51 | |
|
52 | 52 | QObject::connect(m_series->d_func(), SIGNAL(updated()), this, SLOT(handleUpdated())); |
|
53 | 53 | QObject::connect(m_series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated())); |
|
54 | 54 | QObject::connect(m_series, SIGNAL(opacityChanged()), this, SLOT(handleUpdated())); |
|
55 | 55 | QObject::connect(this, SIGNAL(clicked(QPointF)), areaSeries, SIGNAL(clicked(QPointF))); |
|
56 | 56 | QObject::connect(this, SIGNAL(hovered(QPointF,bool)), areaSeries, SIGNAL(hovered(QPointF,bool))); |
|
57 | 57 | QObject::connect(this, SIGNAL(pressed(QPointF)), areaSeries, SIGNAL(pressed(QPointF))); |
|
58 | 58 | QObject::connect(this, SIGNAL(released(QPointF)), areaSeries, SIGNAL(released(QPointF))); |
|
59 | 59 | QObject::connect(this, SIGNAL(doubleClicked(QPointF)), |
|
60 | 60 | areaSeries, SIGNAL(doubleClicked(QPointF))); |
|
61 | 61 | QObject::connect(areaSeries, SIGNAL(pointLabelsFormatChanged(QString)), |
|
62 | 62 | this, SLOT(handleUpdated())); |
|
63 | 63 | QObject::connect(areaSeries, SIGNAL(pointLabelsVisibilityChanged(bool)), |
|
64 | 64 | this, SLOT(handleUpdated())); |
|
65 | 65 | QObject::connect(areaSeries, SIGNAL(pointLabelsFontChanged(QFont)), |
|
66 | 66 | this, SLOT(handleUpdated())); |
|
67 | 67 | QObject::connect(areaSeries, SIGNAL(pointLabelsColorChanged(QColor)), |
|
68 | 68 | this, SLOT(handleUpdated())); |
|
69 | 69 | |
|
70 | 70 | handleUpdated(); |
|
71 | 71 | } |
|
72 | 72 | |
|
73 | 73 | AreaChartItem::~AreaChartItem() |
|
74 | 74 | { |
|
75 | 75 | delete m_upper; |
|
76 | 76 | delete m_lower; |
|
77 | 77 | } |
|
78 | 78 | |
|
79 | 79 | void AreaChartItem::setPresenter(ChartPresenter *presenter) |
|
80 | 80 | { |
|
81 | 81 | if (m_upper) |
|
82 | 82 | m_upper->setPresenter(presenter); |
|
83 | 83 | if (m_lower) { |
|
84 | 84 | m_lower->setPresenter(presenter); |
|
85 | 85 | } |
|
86 | 86 | ChartItem::setPresenter(presenter); |
|
87 | 87 | } |
|
88 | 88 | |
|
89 | 89 | QRectF AreaChartItem::boundingRect() const |
|
90 | 90 | { |
|
91 | 91 | return m_rect; |
|
92 | 92 | } |
|
93 | 93 | |
|
94 | 94 | QPainterPath AreaChartItem::shape() const |
|
95 | 95 | { |
|
96 | 96 | return m_path; |
|
97 | 97 | } |
|
98 | 98 | |
|
99 | 99 | void AreaChartItem::updatePath() |
|
100 | 100 | { |
|
101 | 101 | QPainterPath path; |
|
102 | 102 | QRectF rect(QPointF(0,0),domain()->size()); |
|
103 | 103 | |
|
104 | 104 | path = m_upper->path(); |
|
105 | 105 | |
|
106 | 106 | if (m_lower) { |
|
107 | 107 | // Note: Polarcharts always draw area correctly only when both series have equal width or are |
|
108 | 108 | // fully displayed. If one series is partally off-chart, the connecting line between |
|
109 | 109 | // the series does not attach to the end of the partially hidden series but to the point |
|
110 | 110 | // where it intersects the axis line. The problem is especially noticeable when one of the series |
|
111 | 111 | // is entirely off-chart, in which case the connecting line connects two ends of the |
|
112 | 112 | // visible series. |
|
113 | 113 | // This happens because we get the paths from linechart, which omits off-chart segments. |
|
114 | 114 | // To properly fix, linechart would need to provide true full path, in right, left, and the rest |
|
115 | 115 | // portions to enable proper clipping. However, combining those to single visually unified area |
|
116 | 116 | // would be a nightmare, since they would have to be painted separately. |
|
117 | 117 | path.connectPath(m_lower->path().toReversed()); |
|
118 | 118 | } else { |
|
119 | 119 | QPointF first = path.pointAtPercent(0); |
|
120 | 120 | QPointF last = path.pointAtPercent(1); |
|
121 | 121 | if (presenter()->chartType() == QChart::ChartTypeCartesian) { |
|
122 | 122 | path.lineTo(last.x(), rect.bottom()); |
|
123 | 123 | path.lineTo(first.x(), rect.bottom()); |
|
124 | 124 | } else { // polar |
|
125 | 125 | path.lineTo(rect.center()); |
|
126 | 126 | } |
|
127 | 127 | } |
|
128 | 128 | path.closeSubpath(); |
|
129 | 129 | |
|
130 | 130 | // Only zoom in if the bounding rect of the path fits inside int limits. QWidget::update() uses |
|
131 | 131 | // a region that has to be compatible with QRect. |
|
132 | 132 | if (path.boundingRect().height() <= INT_MAX |
|
133 | 133 | && path.boundingRect().width() <= INT_MAX) { |
|
134 | 134 | prepareGeometryChange(); |
|
135 | 135 | m_path = path; |
|
136 | 136 | m_rect = path.boundingRect(); |
|
137 | 137 | update(); |
|
138 | 138 | } |
|
139 | 139 | } |
|
140 | 140 | |
|
141 | 141 | void AreaChartItem::handleUpdated() |
|
142 | 142 | { |
|
143 | 143 | setVisible(m_series->isVisible()); |
|
144 | 144 | m_pointsVisible = m_series->pointsVisible(); |
|
145 | 145 | m_linePen = m_series->pen(); |
|
146 | 146 | m_brush = m_series->brush(); |
|
147 | 147 | m_pointPen = m_series->pen(); |
|
148 | 148 | m_pointPen.setWidthF(2 * m_pointPen.width()); |
|
149 | 149 | setOpacity(m_series->opacity()); |
|
150 | 150 | m_pointLabelsFormat = m_series->pointLabelsFormat(); |
|
151 | 151 | m_pointLabelsVisible = m_series->pointLabelsVisible(); |
|
152 | 152 | m_pointLabelsFont = m_series->pointLabelsFont(); |
|
153 | 153 | m_pointLabelsColor = m_series->pointLabelsColor(); |
|
154 | 154 | update(); |
|
155 | 155 | } |
|
156 | 156 | |
|
157 | 157 | void AreaChartItem::handleDomainUpdated() |
|
158 | 158 | { |
|
159 | 159 | if (m_upper) { |
|
160 | 160 | AbstractDomain* d = m_upper->domain(); |
|
161 | 161 | d->setSize(domain()->size()); |
|
162 | 162 | d->setRange(domain()->minX(),domain()->maxX(),domain()->minY(),domain()->maxY()); |
|
163 | 163 | m_upper->handleDomainUpdated(); |
|
164 | 164 | } |
|
165 | 165 | |
|
166 | 166 | if (m_lower) { |
|
167 | 167 | AbstractDomain* d = m_lower->domain(); |
|
168 | 168 | d->setSize(domain()->size()); |
|
169 | 169 | d->setRange(domain()->minX(),domain()->maxX(),domain()->minY(),domain()->maxY()); |
|
170 | 170 | m_lower->handleDomainUpdated(); |
|
171 | 171 | } |
|
172 | 172 | } |
|
173 | 173 | |
|
174 | 174 | void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
175 | 175 | { |
|
176 | 176 | Q_UNUSED(widget) |
|
177 | 177 | Q_UNUSED(option) |
|
178 | 178 | painter->save(); |
|
179 | 179 | painter->setPen(m_linePen); |
|
180 | 180 | painter->setBrush(m_brush); |
|
181 | 181 | QRectF clipRect = QRectF(QPointF(0, 0), domain()->size()); |
|
182 | 182 | if (presenter()->chartType() == QChart::ChartTypePolar) |
|
183 | 183 | painter->setClipRegion(QRegion(clipRect.toRect(), QRegion::Ellipse)); |
|
184 | 184 | else |
|
185 | 185 | painter->setClipRect(clipRect); |
|
186 | ||
|
187 | reversePainter(painter, clipRect); | |
|
188 | ||
|
186 | 189 | painter->drawPath(m_path); |
|
187 | 190 | if (m_pointsVisible) { |
|
188 | 191 | painter->setPen(m_pointPen); |
|
189 | 192 | painter->drawPoints(m_upper->geometryPoints()); |
|
190 | 193 | if (m_lower) |
|
191 | 194 | painter->drawPoints(m_lower->geometryPoints()); |
|
192 | 195 | } |
|
193 | 196 | |
|
197 | reversePainter(painter, clipRect); | |
|
198 | ||
|
194 | 199 | // Draw series point label |
|
195 | 200 | if (m_pointLabelsVisible) { |
|
196 | 201 | static const QString xPointTag(QLatin1String("@xPoint")); |
|
197 | 202 | static const QString yPointTag(QLatin1String("@yPoint")); |
|
198 | 203 | const int labelOffset = 2; |
|
199 | 204 | |
|
200 | 205 | painter->setFont(m_pointLabelsFont); |
|
201 | 206 | painter->setPen(QPen(m_pointLabelsColor)); |
|
202 | 207 | QFontMetrics fm(painter->font()); |
|
203 | 208 | |
|
204 | 209 | QString pointLabel; |
|
205 | 210 | |
|
206 | 211 | if (m_series->upperSeries()) { |
|
207 | 212 | for (int i(0); i < m_series->upperSeries()->count(); i++) { |
|
208 | 213 | pointLabel = m_pointLabelsFormat; |
|
209 | 214 | pointLabel.replace(xPointTag, |
|
210 | 215 | presenter()->numberToString(m_series->upperSeries()->at(i).x())); |
|
211 | 216 | pointLabel.replace(yPointTag, |
|
212 | 217 | presenter()->numberToString(m_series->upperSeries()->at(i).y())); |
|
213 | 218 | |
|
214 | 219 | // Position text in relation to the point |
|
215 | 220 | int pointLabelWidth = fm.width(pointLabel); |
|
216 | 221 | QPointF position(m_upper->geometryPoints().at(i)); |
|
217 | position.setX(position.x() - pointLabelWidth / 2); | |
|
218 |
position.set |
|
|
219 | ||
|
222 | if (!seriesPrivate()->reverseXAxis()) | |
|
223 | position.setX(position.x() - pointLabelWidth / 2); | |
|
224 | else | |
|
225 | position.setX(domain()->size().width() - position.x() - pointLabelWidth / 2); | |
|
226 | if (!seriesPrivate()->reverseYAxis()) { | |
|
227 | position.setY(position.y() - m_series->upperSeries()->pen().width() / 2 | |
|
228 | - labelOffset); | |
|
229 | } else { | |
|
230 | position.setY(domain()->size().height() - position.y() | |
|
231 | - m_series->upperSeries()->pen().width() / 2 - labelOffset); | |
|
232 | } | |
|
220 | 233 | painter->drawText(position, pointLabel); |
|
221 | 234 | } |
|
222 | 235 | } |
|
223 | 236 | |
|
224 | 237 | if (m_series->lowerSeries()) { |
|
225 | 238 | for (int i(0); i < m_series->lowerSeries()->count(); i++) { |
|
226 | 239 | pointLabel = m_pointLabelsFormat; |
|
227 | 240 | pointLabel.replace(xPointTag, |
|
228 | 241 | presenter()->numberToString(m_series->lowerSeries()->at(i).x())); |
|
229 | 242 | pointLabel.replace(yPointTag, |
|
230 | 243 | presenter()->numberToString(m_series->lowerSeries()->at(i).y())); |
|
231 | 244 | |
|
232 | 245 | // Position text in relation to the point |
|
233 | 246 | int pointLabelWidth = fm.width(pointLabel); |
|
234 | 247 | QPointF position(m_lower->geometryPoints().at(i)); |
|
235 | position.setX(position.x() - pointLabelWidth / 2); | |
|
236 |
position.set |
|
|
248 | if (!seriesPrivate()->reverseXAxis()) | |
|
249 | position.setX(position.x() - pointLabelWidth / 2); | |
|
250 | else | |
|
251 | position.setX(domain()->size().width() - position.x() - pointLabelWidth / 2); | |
|
252 | if (!seriesPrivate()->reverseYAxis()) { | |
|
253 | position.setY(position.y() - m_series->lowerSeries()->pen().width() / 2 | |
|
254 | - labelOffset); | |
|
255 | } else { | |
|
256 | position.setY(domain()->size().height() - position.y() | |
|
257 | - m_series->lowerSeries()->pen().width() / 2 - labelOffset); | |
|
258 | } | |
|
237 | 259 | painter->drawText(position, pointLabel); |
|
238 | 260 | } |
|
239 | 261 | } |
|
240 | 262 | } |
|
241 | 263 | |
|
242 | 264 | painter->restore(); |
|
243 | 265 | } |
|
244 | 266 | |
|
245 | 267 | void AreaChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
246 | 268 | { |
|
247 | 269 | emit pressed(m_upper->domain()->calculateDomainPoint(event->pos())); |
|
248 | 270 | m_lastMousePos = event->pos(); |
|
249 | 271 | m_mousePressed = true; |
|
250 | 272 | ChartItem::mousePressEvent(event); |
|
251 | 273 | } |
|
252 | 274 | |
|
253 | 275 | void AreaChartItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
|
254 | 276 | { |
|
255 | 277 | emit hovered(domain()->calculateDomainPoint(event->pos()), true); |
|
256 | 278 | event->accept(); |
|
257 | 279 | // QGraphicsItem::hoverEnterEvent(event); |
|
258 | 280 | } |
|
259 | 281 | |
|
260 | 282 | void AreaChartItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) |
|
261 | 283 | { |
|
262 | 284 | emit hovered(domain()->calculateDomainPoint(event->pos()), false); |
|
263 | 285 | event->accept(); |
|
264 | 286 | // QGraphicsItem::hoverEnterEvent(event); |
|
265 | 287 | } |
|
266 | 288 | |
|
267 | 289 | void AreaChartItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
268 | 290 | { |
|
269 | 291 | emit released(m_upper->domain()->calculateDomainPoint(m_lastMousePos)); |
|
270 | 292 | if (m_mousePressed) |
|
271 | 293 | emit clicked(m_upper->domain()->calculateDomainPoint(m_lastMousePos)); |
|
272 | 294 | m_mousePressed = false; |
|
273 | 295 | ChartItem::mouseReleaseEvent(event); |
|
274 | 296 | } |
|
275 | 297 | |
|
276 | 298 | void AreaChartItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) |
|
277 | 299 | { |
|
278 | 300 | emit doubleClicked(m_upper->domain()->calculateDomainPoint(m_lastMousePos)); |
|
279 | 301 | ChartItem::mouseDoubleClickEvent(event); |
|
280 | 302 | } |
|
281 | 303 | |
|
282 | 304 | #include "moc_areachartitem_p.cpp" |
|
283 | 305 | |
|
284 | 306 | QT_CHARTS_END_NAMESPACE |
@@ -1,391 +1,400 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #include <private/chartaxiselement_p.h> |
|
20 | 20 | #include <private/qabstractaxis_p.h> |
|
21 | 21 | #include <private/chartpresenter_p.h> |
|
22 | 22 | #include <private/abstractchartlayout_p.h> |
|
23 | 23 | #include <QtCore/QtMath> |
|
24 | 24 | #include <QtCore/QDateTime> |
|
25 | 25 | #include <QtGui/QTextDocument> |
|
26 | 26 | #include <cmath> |
|
27 | 27 | |
|
28 | 28 | QT_CHARTS_BEGIN_NAMESPACE |
|
29 | 29 | |
|
30 | 30 | static const char *labelFormatMatchString = "%[\\-\\+#\\s\\d\\.\\'lhjztL]*([dicuoxfegXFEG])"; |
|
31 | 31 | static const char *labelFormatMatchLocalizedString = "^([^%]*)%\\.(\\d+)([defgiEG])(.*)$"; |
|
32 | 32 | static QRegExp *labelFormatMatcher = 0; |
|
33 | 33 | static QRegExp *labelFormatMatcherLocalized = 0; |
|
34 | 34 | class StaticLabelFormatMatcherDeleter |
|
35 | 35 | { |
|
36 | 36 | public: |
|
37 | 37 | StaticLabelFormatMatcherDeleter() {} |
|
38 | 38 | ~StaticLabelFormatMatcherDeleter() { |
|
39 | 39 | delete labelFormatMatcher; |
|
40 | 40 | delete labelFormatMatcherLocalized; |
|
41 | 41 | } |
|
42 | 42 | }; |
|
43 | 43 | static StaticLabelFormatMatcherDeleter staticLabelFormatMatcherDeleter; |
|
44 | 44 | |
|
45 | 45 | ChartAxisElement::ChartAxisElement(QAbstractAxis *axis, QGraphicsItem *item, bool intervalAxis) |
|
46 | 46 | : ChartElement(item), |
|
47 | 47 | m_axis(axis), |
|
48 | 48 | m_animation(0), |
|
49 | 49 | m_grid(new QGraphicsItemGroup(item)), |
|
50 | 50 | m_arrow(new QGraphicsItemGroup(item)), |
|
51 | 51 | m_shades(new QGraphicsItemGroup(item)), |
|
52 | 52 | m_labels(new QGraphicsItemGroup(item)), |
|
53 | 53 | m_title(new QGraphicsTextItem(item)), |
|
54 | 54 | m_intervalAxis(intervalAxis) |
|
55 | 55 | |
|
56 | 56 | { |
|
57 | 57 | //initial initialization |
|
58 | 58 | m_arrow->setHandlesChildEvents(false); |
|
59 | 59 | m_arrow->setZValue(ChartPresenter::AxisZValue); |
|
60 | 60 | m_labels->setZValue(ChartPresenter::AxisZValue); |
|
61 | 61 | m_shades->setZValue(ChartPresenter::ShadesZValue); |
|
62 | 62 | m_grid->setZValue(ChartPresenter::GridZValue); |
|
63 | 63 | m_title->setZValue(ChartPresenter::GridZValue); |
|
64 | 64 | m_title->document()->setDocumentMargin(ChartPresenter::textMargin()); |
|
65 | 65 | handleVisibleChanged(axis->isVisible()); |
|
66 | 66 | connectSlots(); |
|
67 | 67 | |
|
68 | 68 | setFlag(QGraphicsItem::ItemHasNoContents, true); |
|
69 | 69 | } |
|
70 | 70 | |
|
71 | 71 | ChartAxisElement::~ChartAxisElement() |
|
72 | 72 | { |
|
73 | 73 | } |
|
74 | 74 | |
|
75 | 75 | void ChartAxisElement::connectSlots() |
|
76 | 76 | { |
|
77 | 77 | QObject::connect(axis(), SIGNAL(visibleChanged(bool)), this, SLOT(handleVisibleChanged(bool))); |
|
78 | 78 | QObject::connect(axis(), SIGNAL(lineVisibleChanged(bool)), this, SLOT(handleArrowVisibleChanged(bool))); |
|
79 | 79 | QObject::connect(axis(), SIGNAL(gridVisibleChanged(bool)), this, SLOT(handleGridVisibleChanged(bool))); |
|
80 | 80 | QObject::connect(axis(), SIGNAL(labelsVisibleChanged(bool)), this, SLOT(handleLabelsVisibleChanged(bool))); |
|
81 | 81 | QObject::connect(axis(), SIGNAL(shadesVisibleChanged(bool)), this, SLOT(handleShadesVisibleChanged(bool))); |
|
82 | 82 | QObject::connect(axis(), SIGNAL(labelsAngleChanged(int)), this, SLOT(handleLabelsAngleChanged(int))); |
|
83 | 83 | QObject::connect(axis(), SIGNAL(linePenChanged(const QPen&)), this, SLOT(handleArrowPenChanged(const QPen&))); |
|
84 | 84 | QObject::connect(axis(), SIGNAL(labelsBrushChanged(const QBrush&)), this, SLOT(handleLabelsBrushChanged(const QBrush&))); |
|
85 | 85 | QObject::connect(axis(), SIGNAL(labelsFontChanged(const QFont&)), this, SLOT(handleLabelsFontChanged(const QFont&))); |
|
86 | 86 | QObject::connect(axis(), SIGNAL(gridLinePenChanged(const QPen&)), this, SLOT(handleGridPenChanged(const QPen&))); |
|
87 | 87 | QObject::connect(axis(), SIGNAL(shadesPenChanged(const QPen&)), this, SLOT(handleShadesPenChanged(const QPen&))); |
|
88 | 88 | QObject::connect(axis(), SIGNAL(shadesBrushChanged(const QBrush&)), this, SLOT(handleShadesBrushChanged(const QBrush&))); |
|
89 | 89 | QObject::connect(axis(), SIGNAL(titleTextChanged(const QString&)), this, SLOT(handleTitleTextChanged(const QString&))); |
|
90 | 90 | QObject::connect(axis(), SIGNAL(titleFontChanged(const QFont&)), this, SLOT(handleTitleFontChanged(const QFont&))); |
|
91 | 91 | QObject::connect(axis(), SIGNAL(titleBrushChanged(const QBrush&)), this, SLOT(handleTitleBrushChanged(const QBrush&))); |
|
92 | 92 | QObject::connect(axis(), SIGNAL(titleVisibleChanged(bool)), this, SLOT(handleTitleVisibleChanged(bool))); |
|
93 | 93 | QObject::connect(axis()->d_ptr.data(), SIGNAL(rangeChanged(qreal, qreal)), this, SLOT(handleRangeChanged(qreal, qreal))); |
|
94 | QObject::connect(axis(), SIGNAL(reverseChanged(bool)), this, SLOT(handleReverseChanged(bool))); | |
|
94 | 95 | } |
|
95 | 96 | |
|
96 | 97 | void ChartAxisElement::handleArrowVisibleChanged(bool visible) |
|
97 | 98 | { |
|
98 | 99 | m_arrow->setVisible(visible); |
|
99 | 100 | } |
|
100 | 101 | |
|
101 | 102 | void ChartAxisElement::handleGridVisibleChanged(bool visible) |
|
102 | 103 | { |
|
103 | 104 | m_grid->setVisible(visible); |
|
104 | 105 | } |
|
105 | 106 | |
|
106 | 107 | void ChartAxisElement::handleLabelsVisibleChanged(bool visible) |
|
107 | 108 | { |
|
108 | 109 | QGraphicsLayoutItem::updateGeometry(); |
|
109 | 110 | presenter()->layout()->invalidate(); |
|
110 | 111 | m_labels->setVisible(visible); |
|
111 | 112 | } |
|
112 | 113 | |
|
113 | 114 | void ChartAxisElement::handleShadesVisibleChanged(bool visible) |
|
114 | 115 | { |
|
115 | 116 | m_shades->setVisible(visible); |
|
116 | 117 | } |
|
117 | 118 | |
|
118 | 119 | void ChartAxisElement::handleTitleVisibleChanged(bool visible) |
|
119 | 120 | { |
|
120 | 121 | QGraphicsLayoutItem::updateGeometry(); |
|
121 | 122 | presenter()->layout()->invalidate(); |
|
122 | 123 | m_title->setVisible(visible); |
|
123 | 124 | } |
|
124 | 125 | |
|
125 | 126 | void ChartAxisElement::handleLabelsAngleChanged(int angle) |
|
126 | 127 | { |
|
127 | 128 | foreach (QGraphicsItem *item, m_labels->childItems()) |
|
128 | 129 | item->setRotation(angle); |
|
129 | 130 | |
|
130 | 131 | QGraphicsLayoutItem::updateGeometry(); |
|
131 | 132 | presenter()->layout()->invalidate(); |
|
132 | 133 | } |
|
133 | 134 | |
|
134 | 135 | void ChartAxisElement::handleLabelsBrushChanged(const QBrush &brush) |
|
135 | 136 | { |
|
136 | 137 | foreach (QGraphicsItem *item, m_labels->childItems()) |
|
137 | 138 | static_cast<QGraphicsTextItem *>(item)->setDefaultTextColor(brush.color()); |
|
138 | 139 | } |
|
139 | 140 | |
|
140 | 141 | void ChartAxisElement::handleLabelsFontChanged(const QFont &font) |
|
141 | 142 | { |
|
142 | 143 | foreach (QGraphicsItem *item, m_labels->childItems()) |
|
143 | 144 | static_cast<QGraphicsTextItem *>(item)->setFont(font); |
|
144 | 145 | QGraphicsLayoutItem::updateGeometry(); |
|
145 | 146 | presenter()->layout()->invalidate(); |
|
146 | 147 | } |
|
147 | 148 | |
|
148 | 149 | void ChartAxisElement::handleTitleTextChanged(const QString &title) |
|
149 | 150 | { |
|
150 | 151 | QGraphicsLayoutItem::updateGeometry(); |
|
151 | 152 | presenter()->layout()->invalidate(); |
|
152 | 153 | if (title.isEmpty() || !m_title->isVisible()) |
|
153 | 154 | m_title->setHtml(title); |
|
154 | 155 | } |
|
155 | 156 | |
|
156 | 157 | void ChartAxisElement::handleTitleBrushChanged(const QBrush &brush) |
|
157 | 158 | { |
|
158 | 159 | m_title->setDefaultTextColor(brush.color()); |
|
159 | 160 | } |
|
160 | 161 | |
|
161 | 162 | void ChartAxisElement::handleTitleFontChanged(const QFont &font) |
|
162 | 163 | { |
|
163 | 164 | if (m_title->font() != font) { |
|
164 | 165 | m_title->setFont(font); |
|
165 | 166 | QGraphicsLayoutItem::updateGeometry(); |
|
166 | 167 | presenter()->layout()->invalidate(); |
|
167 | 168 | } |
|
168 | 169 | } |
|
169 | 170 | |
|
170 | 171 | void ChartAxisElement::handleVisibleChanged(bool visible) |
|
171 | 172 | { |
|
172 | 173 | setVisible(visible); |
|
173 | 174 | if (!visible) { |
|
174 | 175 | m_grid->setVisible(visible); |
|
175 | 176 | m_arrow->setVisible(visible); |
|
176 | 177 | m_shades->setVisible(visible); |
|
177 | 178 | m_labels->setVisible(visible); |
|
178 | 179 | m_title->setVisible(visible); |
|
179 | 180 | } else { |
|
180 | 181 | m_grid->setVisible(axis()->isGridLineVisible()); |
|
181 | 182 | m_arrow->setVisible(axis()->isLineVisible()); |
|
182 | 183 | m_shades->setVisible(axis()->shadesVisible()); |
|
183 | 184 | m_labels->setVisible(axis()->labelsVisible()); |
|
184 | 185 | m_title->setVisible(axis()->isTitleVisible()); |
|
185 | 186 | } |
|
186 | 187 | |
|
187 | 188 | if (presenter()) presenter()->layout()->invalidate(); |
|
188 | 189 | } |
|
189 | 190 | |
|
190 | 191 | void ChartAxisElement::handleRangeChanged(qreal min, qreal max) |
|
191 | 192 | { |
|
192 | 193 | Q_UNUSED(min); |
|
193 | 194 | Q_UNUSED(max); |
|
194 | 195 | |
|
195 | 196 | if (!isEmpty()) { |
|
196 | 197 | QVector<qreal> layout = calculateLayout(); |
|
197 | 198 | updateLayout(layout); |
|
198 | 199 | QSizeF before = effectiveSizeHint(Qt::PreferredSize); |
|
199 | 200 | QSizeF after = sizeHint(Qt::PreferredSize); |
|
200 | 201 | |
|
201 | 202 | if (before != after) { |
|
202 | 203 | QGraphicsLayoutItem::updateGeometry(); |
|
203 | 204 | // We don't want to call invalidate on layout, since it will change minimum size of |
|
204 | 205 | // component, which we would like to avoid since it causes nasty flips when scrolling |
|
205 | 206 | // or zooming, instead recalculate layout and use plotArea for extra space. |
|
206 | 207 | presenter()->layout()->setGeometry(presenter()->layout()->geometry()); |
|
207 | 208 | } |
|
208 | 209 | } |
|
209 | 210 | } |
|
210 | 211 | |
|
212 | void ChartAxisElement::handleReverseChanged(bool reverse) | |
|
213 | { | |
|
214 | Q_UNUSED(reverse); | |
|
215 | ||
|
216 | QGraphicsLayoutItem::updateGeometry(); | |
|
217 | presenter()->layout()->invalidate(); | |
|
218 | } | |
|
219 | ||
|
211 | 220 | bool ChartAxisElement::isEmpty() |
|
212 | 221 | { |
|
213 | 222 | return axisGeometry().isEmpty() |
|
214 | 223 | || gridGeometry().isEmpty() |
|
215 | 224 | || qFuzzyCompare(min(), max()); |
|
216 | 225 | } |
|
217 | 226 | |
|
218 | 227 | qreal ChartAxisElement::min() const |
|
219 | 228 | { |
|
220 | 229 | return m_axis->d_ptr->min(); |
|
221 | 230 | } |
|
222 | 231 | |
|
223 | 232 | qreal ChartAxisElement::max() const |
|
224 | 233 | { |
|
225 | 234 | return m_axis->d_ptr->max(); |
|
226 | 235 | } |
|
227 | 236 | |
|
228 | 237 | QString ChartAxisElement::formatLabel(const QString &formatSpec, const QByteArray &array, |
|
229 | 238 | qreal value, int precision, const QString &preStr, |
|
230 | 239 | const QString &postStr) const |
|
231 | 240 | { |
|
232 | 241 | QString retVal; |
|
233 | 242 | if (!formatSpec.isEmpty()) { |
|
234 | 243 | if (formatSpec.at(0) == QLatin1Char('d') |
|
235 | 244 | || formatSpec.at(0) == QLatin1Char('i') |
|
236 | 245 | || formatSpec.at(0) == QLatin1Char('c')) { |
|
237 | 246 | if (presenter()->localizeNumbers()) |
|
238 | 247 | retVal = preStr + presenter()->locale().toString(qint64(value)) + postStr; |
|
239 | 248 | else |
|
240 | 249 | retVal = QString().sprintf(array, qint64(value)); |
|
241 | 250 | } else if (formatSpec.at(0) == QLatin1Char('u') |
|
242 | 251 | || formatSpec.at(0) == QLatin1Char('o') |
|
243 | 252 | || formatSpec.at(0) == QLatin1Char('x') |
|
244 | 253 | || formatSpec.at(0) == QLatin1Char('X')) { |
|
245 | 254 | // These formats are not supported by localized numbers |
|
246 | 255 | retVal = QString().sprintf(array, quint64(value)); |
|
247 | 256 | } else if (formatSpec.at(0) == QLatin1Char('f') |
|
248 | 257 | || formatSpec.at(0) == QLatin1Char('F') |
|
249 | 258 | || formatSpec.at(0) == QLatin1Char('e') |
|
250 | 259 | || formatSpec.at(0) == QLatin1Char('E') |
|
251 | 260 | || formatSpec.at(0) == QLatin1Char('g') |
|
252 | 261 | || formatSpec.at(0) == QLatin1Char('G')) { |
|
253 | 262 | if (presenter()->localizeNumbers()) { |
|
254 | 263 | retVal = preStr |
|
255 | 264 | + presenter()->locale().toString(value, formatSpec.at(0).toLatin1(), |
|
256 | 265 | precision) |
|
257 | 266 | + postStr; |
|
258 | 267 | } else { |
|
259 | 268 | retVal = QString().sprintf(array, value); |
|
260 | 269 | } |
|
261 | 270 | } |
|
262 | 271 | } |
|
263 | 272 | return retVal; |
|
264 | 273 | } |
|
265 | 274 | |
|
266 | 275 | QStringList ChartAxisElement::createValueLabels(qreal min, qreal max, int ticks, |
|
267 | 276 | const QString &format) const |
|
268 | 277 | { |
|
269 | 278 | QStringList labels; |
|
270 | 279 | |
|
271 | 280 | if (max <= min || ticks < 1) |
|
272 | 281 | return labels; |
|
273 | 282 | |
|
274 | 283 | if (format.isNull()) { |
|
275 | 284 | int n = qMax(int(-qFloor(std::log10((max - min) / (ticks - 1)))), 0) + 1; |
|
276 | 285 | for (int i = 0; i < ticks; i++) { |
|
277 | 286 | qreal value = min + (i * (max - min) / (ticks - 1)); |
|
278 | 287 | labels << presenter()->numberToString(value, 'f', n); |
|
279 | 288 | } |
|
280 | 289 | } else { |
|
281 | 290 | QByteArray array = format.toLatin1(); |
|
282 | 291 | QString formatSpec; |
|
283 | 292 | QString preStr; |
|
284 | 293 | QString postStr; |
|
285 | 294 | int precision = 6; // Six is the default precision in Qt API |
|
286 | 295 | if (presenter()->localizeNumbers()) { |
|
287 | 296 | if (!labelFormatMatcherLocalized) |
|
288 | 297 | labelFormatMatcherLocalized |
|
289 | 298 | = new QRegExp(QString::fromLatin1(labelFormatMatchLocalizedString)); |
|
290 | 299 | if (labelFormatMatcherLocalized->indexIn(format, 0) != -1) { |
|
291 | 300 | preStr = labelFormatMatcherLocalized->cap(1); |
|
292 | 301 | if (!labelFormatMatcherLocalized->cap(2).isEmpty()) |
|
293 | 302 | precision = labelFormatMatcherLocalized->cap(2).toInt(); |
|
294 | 303 | formatSpec = labelFormatMatcherLocalized->cap(3); |
|
295 | 304 | postStr = labelFormatMatcherLocalized->cap(4); |
|
296 | 305 | } |
|
297 | 306 | } else { |
|
298 | 307 | if (!labelFormatMatcher) |
|
299 | 308 | labelFormatMatcher = new QRegExp(QString::fromLatin1(labelFormatMatchString)); |
|
300 | 309 | if (labelFormatMatcher->indexIn(format, 0) != -1) |
|
301 | 310 | formatSpec = labelFormatMatcher->cap(1); |
|
302 | 311 | } |
|
303 | 312 | for (int i = 0; i < ticks; i++) { |
|
304 | 313 | qreal value = min + (i * (max - min) / (ticks - 1)); |
|
305 | 314 | labels << formatLabel(formatSpec, array, value, precision, preStr, postStr); |
|
306 | 315 | } |
|
307 | 316 | } |
|
308 | 317 | |
|
309 | 318 | return labels; |
|
310 | 319 | } |
|
311 | 320 | |
|
312 | 321 | QStringList ChartAxisElement::createLogValueLabels(qreal min, qreal max, qreal base, int ticks, |
|
313 | 322 | const QString &format) const |
|
314 | 323 | { |
|
315 | 324 | QStringList labels; |
|
316 | 325 | |
|
317 | 326 | if (max <= min || ticks < 1) |
|
318 | 327 | return labels; |
|
319 | 328 | |
|
320 | 329 | int firstTick; |
|
321 | 330 | if (base > 1) |
|
322 | 331 | firstTick = qCeil(std::log10(min) / std::log10(base)); |
|
323 | 332 | else |
|
324 | 333 | firstTick = qCeil(std::log10(max) / std::log10(base)); |
|
325 | 334 | |
|
326 | 335 | if (format.isNull()) { |
|
327 | 336 | int n = 0; |
|
328 | 337 | if (ticks > 1) |
|
329 | 338 | n = qMax(int(-qFloor(std::log10((max - min) / (ticks - 1)))), 0); |
|
330 | 339 | n++; |
|
331 | 340 | for (int i = firstTick; i < ticks + firstTick; i++) { |
|
332 | 341 | qreal value = qPow(base, i); |
|
333 | 342 | labels << presenter()->numberToString(value, 'f', n); |
|
334 | 343 | } |
|
335 | 344 | } else { |
|
336 | 345 | QByteArray array = format.toLatin1(); |
|
337 | 346 | QString formatSpec; |
|
338 | 347 | QString preStr; |
|
339 | 348 | QString postStr; |
|
340 | 349 | int precision = 6; // Six is the default precision in Qt API |
|
341 | 350 | if (presenter()->localizeNumbers()) { |
|
342 | 351 | if (!labelFormatMatcherLocalized) |
|
343 | 352 | labelFormatMatcherLocalized = |
|
344 | 353 | new QRegExp(QString::fromLatin1(labelFormatMatchLocalizedString)); |
|
345 | 354 | if (labelFormatMatcherLocalized->indexIn(format, 0) != -1) { |
|
346 | 355 | preStr = labelFormatMatcherLocalized->cap(1); |
|
347 | 356 | if (!labelFormatMatcherLocalized->cap(2).isEmpty()) |
|
348 | 357 | precision = labelFormatMatcherLocalized->cap(2).toInt(); |
|
349 | 358 | formatSpec = labelFormatMatcherLocalized->cap(3); |
|
350 | 359 | postStr = labelFormatMatcherLocalized->cap(4); |
|
351 | 360 | } |
|
352 | 361 | } else { |
|
353 | 362 | if (!labelFormatMatcher) |
|
354 | 363 | labelFormatMatcher = new QRegExp(QString::fromLatin1(labelFormatMatchString)); |
|
355 | 364 | if (labelFormatMatcher->indexIn(format, 0) != -1) |
|
356 | 365 | formatSpec = labelFormatMatcher->cap(1); |
|
357 | 366 | } |
|
358 | 367 | for (int i = firstTick; i < ticks + firstTick; i++) { |
|
359 | 368 | qreal value = qPow(base, i); |
|
360 | 369 | labels << formatLabel(formatSpec, array, value, precision, preStr, postStr); |
|
361 | 370 | } |
|
362 | 371 | } |
|
363 | 372 | |
|
364 | 373 | return labels; |
|
365 | 374 | } |
|
366 | 375 | |
|
367 | 376 | QStringList ChartAxisElement::createDateTimeLabels(qreal min, qreal max,int ticks, |
|
368 | 377 | const QString &format) const |
|
369 | 378 | { |
|
370 | 379 | QStringList labels; |
|
371 | 380 | |
|
372 | 381 | if (max <= min || ticks < 1) |
|
373 | 382 | return labels; |
|
374 | 383 | |
|
375 | 384 | int n = qMax(int(-qFloor(std::log10((max - min) / (ticks - 1)))), 0); |
|
376 | 385 | n++; |
|
377 | 386 | for (int i = 0; i < ticks; i++) { |
|
378 | 387 | qreal value = min + (i * (max - min) / (ticks - 1)); |
|
379 | 388 | labels << presenter()->locale().toString(QDateTime::fromMSecsSinceEpoch(value), format); |
|
380 | 389 | } |
|
381 | 390 | return labels; |
|
382 | 391 | } |
|
383 | 392 | |
|
384 | 393 | void ChartAxisElement::axisSelected() |
|
385 | 394 | { |
|
386 | 395 | emit clicked(); |
|
387 | 396 | } |
|
388 | 397 | |
|
389 | 398 | #include "moc_chartaxiselement_p.cpp" |
|
390 | 399 | |
|
391 | 400 | QT_CHARTS_END_NAMESPACE |
@@ -1,151 +1,152 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | // W A R N I N G |
|
20 | 20 | // ------------- |
|
21 | 21 | // |
|
22 | 22 | // This file is not part of the Qt Enterprise Chart API. It exists purely as an |
|
23 | 23 | // implementation detail. This header file may change from version to |
|
24 | 24 | // version without notice, or even be removed. |
|
25 | 25 | // |
|
26 | 26 | // We mean it. |
|
27 | 27 | |
|
28 | 28 | #ifndef CHARTAXISELEMENT_H |
|
29 | 29 | #define CHARTAXISELEMENT_H |
|
30 | 30 | |
|
31 | 31 | #include <QtCharts/QChartGlobal> |
|
32 | 32 | #include <private/chartelement_p.h> |
|
33 | 33 | #include <private/axisanimation_p.h> |
|
34 | 34 | #include <QtWidgets/QGraphicsItem> |
|
35 | 35 | #include <QtWidgets/QGraphicsLayoutItem> |
|
36 | 36 | #include <QtGui/QFont> |
|
37 | 37 | |
|
38 | 38 | QT_CHARTS_BEGIN_NAMESPACE |
|
39 | 39 | |
|
40 | 40 | class ChartPresenter; |
|
41 | 41 | class QAbstractAxis; |
|
42 | 42 | |
|
43 | 43 | class ChartAxisElement : public ChartElement, public QGraphicsLayoutItem |
|
44 | 44 | { |
|
45 | 45 | Q_OBJECT |
|
46 | 46 | |
|
47 | 47 | using QGraphicsLayoutItem::setGeometry; |
|
48 | 48 | public: |
|
49 | 49 | ChartAxisElement(QAbstractAxis *axis, QGraphicsItem *item, bool intervalAxis = false); |
|
50 | 50 | ~ChartAxisElement(); |
|
51 | 51 | |
|
52 | 52 | virtual QRectF gridGeometry() const = 0; |
|
53 | 53 | virtual void setGeometry(const QRectF &axis, const QRectF &grid) = 0; |
|
54 | 54 | virtual bool isEmpty() = 0; |
|
55 | 55 | |
|
56 | 56 | void setAnimation(AxisAnimation *animation) { m_animation = animation; } |
|
57 | 57 | AxisAnimation *animation() const { return m_animation; } |
|
58 | 58 | |
|
59 | 59 | QAbstractAxis *axis() const { return m_axis; } |
|
60 | 60 | void setLayout(QVector<qreal> &layout) { m_layout = layout; } |
|
61 | 61 | QVector<qreal> &layout() { return m_layout; } // Modifiable reference |
|
62 | 62 | inline qreal labelPadding() const { return qreal(4.0); } |
|
63 | 63 | inline qreal titlePadding() const { return qreal(2.0); } |
|
64 | 64 | void setLabels(const QStringList &labels) { m_labelsList = labels; } |
|
65 | 65 | QStringList labels() const { return m_labelsList; } |
|
66 | 66 | |
|
67 | 67 | qreal min() const; |
|
68 | 68 | qreal max() const; |
|
69 | 69 | |
|
70 | 70 | QRectF axisGeometry() const { return m_axisRect; } |
|
71 | 71 | void setAxisGeometry(const QRectF &axisGeometry) { m_axisRect = axisGeometry; } |
|
72 | 72 | |
|
73 | 73 | void axisSelected(); |
|
74 | 74 | |
|
75 | 75 | //this flag indicates that axis is used to show intervals it means labels are in between ticks |
|
76 | 76 | bool intervalAxis() const { return m_intervalAxis; } |
|
77 | 77 | |
|
78 | 78 | QStringList createValueLabels(qreal max, qreal min, int ticks, const QString &format) const; |
|
79 | 79 | QStringList createLogValueLabels(qreal min, qreal max, qreal base, int ticks, |
|
80 | 80 | const QString &format) const; |
|
81 | 81 | QStringList createDateTimeLabels(qreal max, qreal min, int ticks, const QString &format) const; |
|
82 | 82 | |
|
83 | 83 | // from QGraphicsLayoutItem |
|
84 | 84 | QRectF boundingRect() const |
|
85 | 85 | { |
|
86 | 86 | return QRectF(); |
|
87 | 87 | } |
|
88 | 88 | |
|
89 | 89 | // from QGraphicsLayoutItem |
|
90 | 90 | void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) |
|
91 | 91 | { |
|
92 | 92 | } |
|
93 | 93 | |
|
94 | 94 | protected: |
|
95 | 95 | virtual QVector<qreal> calculateLayout() const = 0; |
|
96 | 96 | virtual void updateLayout(QVector<qreal> &layout) = 0; |
|
97 | 97 | |
|
98 | 98 | QList<QGraphicsItem *> gridItems() { return m_grid->childItems(); } |
|
99 | 99 | QList<QGraphicsItem *> labelItems() { return m_labels->childItems(); } |
|
100 | 100 | QList<QGraphicsItem *> shadeItems() { return m_shades->childItems(); } |
|
101 | 101 | QList<QGraphicsItem *> arrowItems() { return m_arrow->childItems(); } |
|
102 | 102 | QGraphicsTextItem *titleItem() const { return m_title.data(); } |
|
103 | 103 | QGraphicsItemGroup *gridGroup() { return m_grid.data(); } |
|
104 | 104 | QGraphicsItemGroup *labelGroup() { return m_labels.data(); } |
|
105 | 105 | QGraphicsItemGroup *shadeGroup() { return m_shades.data(); } |
|
106 | 106 | QGraphicsItemGroup *arrowGroup() { return m_arrow.data(); } |
|
107 | 107 | |
|
108 | 108 | public Q_SLOTS: |
|
109 | 109 | void handleVisibleChanged(bool visible); |
|
110 | 110 | void handleArrowVisibleChanged(bool visible); |
|
111 | 111 | void handleGridVisibleChanged(bool visible); |
|
112 | 112 | void handleLabelsVisibleChanged(bool visible); |
|
113 | 113 | void handleShadesVisibleChanged(bool visible); |
|
114 | 114 | void handleLabelsAngleChanged(int angle); |
|
115 | 115 | virtual void handleShadesBrushChanged(const QBrush &brush) = 0; |
|
116 | 116 | virtual void handleShadesPenChanged(const QPen &pen) = 0; |
|
117 | 117 | virtual void handleArrowPenChanged(const QPen &pen) = 0; |
|
118 | 118 | virtual void handleGridPenChanged(const QPen &pen) = 0; |
|
119 | 119 | void handleLabelsBrushChanged(const QBrush &brush); |
|
120 | 120 | void handleLabelsFontChanged(const QFont &font); |
|
121 | 121 | void handleTitleBrushChanged(const QBrush &brush); |
|
122 | 122 | void handleTitleFontChanged(const QFont &font); |
|
123 | 123 | void handleTitleTextChanged(const QString &title); |
|
124 | 124 | void handleTitleVisibleChanged(bool visible); |
|
125 | 125 | void handleRangeChanged(qreal min, qreal max); |
|
126 | void handleReverseChanged(bool reverse); | |
|
126 | 127 | |
|
127 | 128 | Q_SIGNALS: |
|
128 | 129 | void clicked(); |
|
129 | 130 | |
|
130 | 131 | private: |
|
131 | 132 | void connectSlots(); |
|
132 | 133 | QString formatLabel(const QString &formatSpec, const QByteArray &array, |
|
133 | 134 | qreal value, int precision, const QString &preStr, |
|
134 | 135 | const QString &postStr) const; |
|
135 | 136 | |
|
136 | 137 | QAbstractAxis *m_axis; |
|
137 | 138 | AxisAnimation *m_animation; |
|
138 | 139 | QVector<qreal> m_layout; |
|
139 | 140 | QStringList m_labelsList; |
|
140 | 141 | QRectF m_axisRect; |
|
141 | 142 | QScopedPointer<QGraphicsItemGroup> m_grid; |
|
142 | 143 | QScopedPointer<QGraphicsItemGroup> m_arrow; |
|
143 | 144 | QScopedPointer<QGraphicsItemGroup> m_shades; |
|
144 | 145 | QScopedPointer<QGraphicsItemGroup> m_labels; |
|
145 | 146 | QScopedPointer<QGraphicsTextItem> m_title; |
|
146 | 147 | bool m_intervalAxis; |
|
147 | 148 | }; |
|
148 | 149 | |
|
149 | 150 | QT_CHARTS_END_NAMESPACE |
|
150 | 151 | |
|
151 | 152 | #endif /* CHARTAXISELEMENT_H */ |
@@ -1,264 +1,324 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #include <private/horizontalaxis_p.h> |
|
20 | 20 | #include <private/qabstractaxis_p.h> |
|
21 | 21 | #include <private/chartpresenter_p.h> |
|
22 | 22 | #include <QtCharts/QCategoryAxis> |
|
23 | 23 | #include <QtCore/QtMath> |
|
24 | 24 | #include <QtCore/QDebug> |
|
25 | 25 | |
|
26 | 26 | QT_CHARTS_BEGIN_NAMESPACE |
|
27 | 27 | |
|
28 | 28 | HorizontalAxis::HorizontalAxis(QAbstractAxis *axis, QGraphicsItem *item, bool intervalAxis) |
|
29 | 29 | : CartesianChartAxis(axis, item, intervalAxis) |
|
30 | 30 | { |
|
31 | 31 | } |
|
32 | 32 | |
|
33 | 33 | HorizontalAxis::~HorizontalAxis() |
|
34 | 34 | { |
|
35 | 35 | } |
|
36 | 36 | |
|
37 | 37 | void HorizontalAxis::updateGeometry() |
|
38 | 38 | { |
|
39 | 39 | const QVector<qreal> &layout = ChartAxisElement::layout(); |
|
40 | 40 | |
|
41 | 41 | if (layout.isEmpty() && axis()->type() != QAbstractAxis::AxisTypeLogValue) |
|
42 | 42 | return; |
|
43 | 43 | |
|
44 | 44 | QStringList labelList = labels(); |
|
45 | 45 | |
|
46 | 46 | QList<QGraphicsItem *> labels = labelItems(); |
|
47 | 47 | QList<QGraphicsItem *> arrow = arrowItems(); |
|
48 | 48 | QGraphicsTextItem *title = titleItem(); |
|
49 | 49 | |
|
50 | 50 | Q_ASSERT(labels.size() == labelList.size()); |
|
51 | 51 | Q_ASSERT(layout.size() == labelList.size()); |
|
52 | 52 | |
|
53 | 53 | const QRectF &axisRect = axisGeometry(); |
|
54 | 54 | const QRectF &gridRect = gridGeometry(); |
|
55 | 55 | |
|
56 | 56 | //arrow |
|
57 | 57 | QGraphicsLineItem *arrowItem = static_cast<QGraphicsLineItem *>(arrow.at(0)); |
|
58 | 58 | |
|
59 | 59 | if (axis()->alignment() == Qt::AlignTop) |
|
60 | 60 | arrowItem->setLine(gridRect.left(), axisRect.bottom(), gridRect.right(), axisRect.bottom()); |
|
61 | 61 | else if (axis()->alignment() == Qt::AlignBottom) |
|
62 | 62 | arrowItem->setLine(gridRect.left(), axisRect.top(), gridRect.right(), axisRect.top()); |
|
63 | 63 | |
|
64 | 64 | qreal width = 0; |
|
65 | 65 | const QLatin1String ellipsis("..."); |
|
66 | 66 | |
|
67 | 67 | //title |
|
68 | 68 | QRectF titleBoundingRect; |
|
69 | 69 | QString titleText = axis()->titleText(); |
|
70 | 70 | qreal availableSpace = axisRect.height() - labelPadding(); |
|
71 | 71 | if (!titleText.isEmpty() && titleItem()->isVisible()) { |
|
72 | 72 | availableSpace -= titlePadding() * 2.0; |
|
73 | 73 | qreal minimumLabelHeight = ChartPresenter::textBoundingRect(axis()->labelsFont(), |
|
74 | 74 | QStringLiteral("...")).height(); |
|
75 | 75 | qreal titleSpace = availableSpace - minimumLabelHeight; |
|
76 | 76 | title->setHtml(ChartPresenter::truncatedText(axis()->titleFont(), titleText, qreal(0.0), |
|
77 | 77 | gridRect.width(), titleSpace, |
|
78 | 78 | titleBoundingRect)); |
|
79 | 79 | title->setTextWidth(titleBoundingRect.width()); |
|
80 | 80 | |
|
81 | 81 | titleBoundingRect = title->boundingRect(); |
|
82 | 82 | |
|
83 | 83 | QPointF center = gridRect.center() - titleBoundingRect.center(); |
|
84 | 84 | if (axis()->alignment() == Qt::AlignTop) |
|
85 | 85 | title->setPos(center.x(), axisRect.top() + titlePadding()); |
|
86 | 86 | else if (axis()->alignment() == Qt::AlignBottom) |
|
87 | 87 | title->setPos(center.x(), axisRect.bottom() - titleBoundingRect.height() - titlePadding()); |
|
88 | 88 | |
|
89 | 89 | availableSpace -= titleBoundingRect.height(); |
|
90 | 90 | } |
|
91 | 91 | |
|
92 | 92 | if (layout.isEmpty() && axis()->type() == QAbstractAxis::AxisTypeLogValue) |
|
93 | 93 | return; |
|
94 | 94 | |
|
95 | 95 | QList<QGraphicsItem *> lines = gridItems(); |
|
96 | 96 | QList<QGraphicsItem *> shades = shadeItems(); |
|
97 | 97 | |
|
98 | 98 | for (int i = 0; i < layout.size(); ++i) { |
|
99 | 99 | //items |
|
100 | 100 | QGraphicsLineItem *gridItem = static_cast<QGraphicsLineItem*>(lines.at(i)); |
|
101 | 101 | QGraphicsLineItem *tickItem = static_cast<QGraphicsLineItem*>(arrow.at(i + 1)); |
|
102 | 102 | QGraphicsTextItem *labelItem = static_cast<QGraphicsTextItem *>(labels.at(i)); |
|
103 | 103 | |
|
104 | 104 | //grid line |
|
105 | gridItem->setLine(layout[i], gridRect.top(), layout[i], gridRect.bottom()); | |
|
105 | if (axis()->isReverse()) { | |
|
106 | gridItem->setLine(gridRect.right() - layout[i] + gridRect.left(), gridRect.top(), | |
|
107 | gridRect.right() - layout[i] + gridRect.left(), gridRect.bottom()); | |
|
108 | } else { | |
|
109 | gridItem->setLine(layout[i], gridRect.top(), layout[i], gridRect.bottom()); | |
|
110 | } | |
|
106 | 111 | |
|
107 | 112 | //label text wrapping |
|
108 |
QString text |
|
|
113 | QString text; | |
|
114 | if (axis()->isReverse() && axis()->type() != QAbstractAxis::AxisTypeCategory) | |
|
115 | text = labelList.at(labelList.count() - i - 1); | |
|
116 | else | |
|
117 | text = labelList.at(i); | |
|
118 | ||
|
109 | 119 | QRectF boundingRect; |
|
110 | 120 | // don't truncate empty labels |
|
111 | 121 | if (text.isEmpty()) { |
|
112 | 122 | labelItem->setHtml(text); |
|
113 | 123 | } else { |
|
114 | 124 | qreal labelWidth = axisRect.width() / layout.count() - (2 * labelPadding()); |
|
115 | 125 | QString truncatedText = ChartPresenter::truncatedText(axis()->labelsFont(), text, |
|
116 | 126 | axis()->labelsAngle(), |
|
117 | 127 | labelWidth, |
|
118 | 128 | availableSpace, boundingRect); |
|
119 | 129 | labelItem->setTextWidth(ChartPresenter::textBoundingRect(axis()->labelsFont(), |
|
120 | 130 | truncatedText).width()); |
|
121 | 131 | labelItem->setHtml(truncatedText); |
|
122 | 132 | } |
|
123 | 133 | |
|
124 | 134 | //label transformation origin point |
|
125 | 135 | const QRectF& rect = labelItem->boundingRect(); |
|
126 | 136 | QPointF center = rect.center(); |
|
127 | 137 | labelItem->setTransformOriginPoint(center.x(), center.y()); |
|
128 | 138 | qreal heightDiff = rect.height() - boundingRect.height(); |
|
129 | 139 | qreal widthDiff = rect.width() - boundingRect.width(); |
|
130 | 140 | |
|
131 | 141 | //ticks and label position |
|
132 | 142 | if (axis()->alignment() == Qt::AlignTop) { |
|
133 | labelItem->setPos(layout[i] - center.x(), axisRect.bottom() - rect.height() + (heightDiff / 2.0) - labelPadding()); | |
|
134 | tickItem->setLine(layout[i], axisRect.bottom(), layout[i], axisRect.bottom() - labelPadding()); | |
|
143 | if (axis()->isReverse()) { | |
|
144 | labelItem->setPos(gridRect.right() - layout[layout.size() - i - 1] | |
|
145 | + gridRect.left() - center.x(), | |
|
146 | axisRect.bottom() - rect.height() | |
|
147 | + (heightDiff / 2.0) - labelPadding()); | |
|
148 | tickItem->setLine(gridRect.right() + gridRect.left() - layout[i], | |
|
149 | axisRect.bottom(), | |
|
150 | gridRect.right() + gridRect.left() - layout[i], | |
|
151 | axisRect.bottom() - labelPadding()); | |
|
152 | } else { | |
|
153 | labelItem->setPos(layout[i] - center.x(), axisRect.bottom() - rect.height() | |
|
154 | + (heightDiff / 2.0) - labelPadding()); | |
|
155 | tickItem->setLine(layout[i], axisRect.bottom(), | |
|
156 | layout[i], axisRect.bottom() - labelPadding()); | |
|
157 | } | |
|
135 | 158 | } else if (axis()->alignment() == Qt::AlignBottom) { |
|
136 | labelItem->setPos(layout[i] - center.x(), axisRect.top() - (heightDiff / 2.0) + labelPadding()); | |
|
137 | tickItem->setLine(layout[i], axisRect.top(), layout[i], axisRect.top() + labelPadding()); | |
|
159 | if (axis()->isReverse()) { | |
|
160 | labelItem->setPos(gridRect.right() - layout[layout.size() - i - 1] | |
|
161 | + gridRect.left() - center.x(), | |
|
162 | axisRect.top() - (heightDiff / 2.0) + labelPadding()); | |
|
163 | tickItem->setLine(gridRect.right() + gridRect.left() - layout[i], axisRect.top(), | |
|
164 | gridRect.right() + gridRect.left() - layout[i], | |
|
165 | axisRect.top() + labelPadding()); | |
|
166 | } else { | |
|
167 | labelItem->setPos(layout[i] - center.x(), axisRect.top() - (heightDiff / 2.0) | |
|
168 | + labelPadding()); | |
|
169 | tickItem->setLine(layout[i], axisRect.top(), | |
|
170 | layout[i], axisRect.top() + labelPadding()); | |
|
171 | } | |
|
138 | 172 | } |
|
139 | 173 | |
|
140 | 174 | //label in between |
|
141 | 175 | bool forceHide = false; |
|
142 | 176 | if (intervalAxis() && (i + 1) != layout.size()) { |
|
143 |
qreal leftBound |
|
|
144 | qreal rightBound = qMin(layout[i + 1], gridRect.right()); | |
|
177 | qreal leftBound; | |
|
178 | qreal rightBound; | |
|
179 | if (axis()->isReverse()) { | |
|
180 | leftBound = qMax(gridRect.right() + gridRect.left() - layout[i + 1], | |
|
181 | gridRect.left()); | |
|
182 | rightBound = qMin(gridRect.right() + gridRect.left() - layout[i], gridRect.right()); | |
|
183 | } else { | |
|
184 | leftBound = qMax(layout[i], gridRect.left()); | |
|
185 | rightBound = qMin(layout[i + 1], gridRect.right()); | |
|
186 | } | |
|
145 | 187 | const qreal delta = rightBound - leftBound; |
|
146 | 188 | if (axis()->type() != QAbstractAxis::AxisTypeCategory) { |
|
147 | 189 | // Hide label in case visible part of the category at the grid edge is too narrow |
|
148 | 190 | if (delta < boundingRect.width() |
|
149 | 191 | && (leftBound == gridRect.left() || rightBound == gridRect.right())) { |
|
150 | 192 | forceHide = true; |
|
151 | 193 | } else { |
|
152 | 194 | labelItem->setPos(leftBound + (delta / 2.0) - center.x(), labelItem->pos().y()); |
|
153 | 195 | } |
|
154 | 196 | } else { |
|
155 | 197 | QCategoryAxis *categoryAxis = static_cast<QCategoryAxis *>(axis()); |
|
156 | 198 | if (categoryAxis->labelsPosition() == QCategoryAxis::AxisLabelsPositionCenter) { |
|
157 | 199 | if (delta < boundingRect.width() |
|
158 | 200 | && (leftBound == gridRect.left() || rightBound == gridRect.right())) { |
|
159 | 201 | forceHide = true; |
|
160 | 202 | } else { |
|
161 | 203 | labelItem->setPos(leftBound + (delta / 2.0) - center.x(), |
|
162 | 204 | labelItem->pos().y()); |
|
163 | 205 | } |
|
164 | 206 | } else if (categoryAxis->labelsPosition() |
|
165 | 207 | == QCategoryAxis::AxisLabelsPositionOnValue) { |
|
166 | labelItem->setPos(rightBound - center.x(), labelItem->pos().y()); | |
|
208 | if (axis()->isReverse()) | |
|
209 | labelItem->setPos(leftBound - center.x(), labelItem->pos().y()); | |
|
210 | else | |
|
211 | labelItem->setPos(rightBound - center.x(), labelItem->pos().y()); | |
|
167 | 212 | } |
|
168 | 213 | } |
|
169 | 214 | } |
|
170 | 215 | |
|
171 | 216 | //label overlap detection - compensate one pixel for rounding errors |
|
172 | 217 | if ((labelItem->pos().x() < width && labelItem->toPlainText() == ellipsis) || forceHide || |
|
173 | 218 | (labelItem->pos().x() + (widthDiff / 2.0)) < (axisRect.left() - 1.0) || |
|
174 | 219 | (labelItem->pos().x() + (widthDiff / 2.0) - 1.0) > axisRect.right()) { |
|
175 | 220 | labelItem->setVisible(false); |
|
176 | 221 | } else { |
|
177 | 222 | labelItem->setVisible(true); |
|
178 | 223 | width = boundingRect.width() + labelItem->pos().x(); |
|
179 | 224 | } |
|
180 | 225 | |
|
181 | 226 | //shades |
|
182 | 227 | QGraphicsRectItem *shadeItem = 0; |
|
183 | 228 | if (i == 0) |
|
184 | 229 | shadeItem = static_cast<QGraphicsRectItem *>(shades.at(0)); |
|
185 | 230 | else if (i % 2) |
|
186 | 231 | shadeItem = static_cast<QGraphicsRectItem *>(shades.at((i / 2) + 1)); |
|
187 | 232 | if (shadeItem) { |
|
188 | 233 | qreal leftBound; |
|
189 | 234 | qreal rightBound; |
|
190 | 235 | if (i == 0) { |
|
191 | leftBound = gridRect.left(); | |
|
192 | rightBound = layout[0]; | |
|
193 | } else { | |
|
194 | leftBound = layout[i]; | |
|
195 | if (i == layout.size() - 1) | |
|
236 | if (axis()->isReverse()) { | |
|
237 | leftBound = gridRect.right() + gridRect.left() - layout[i]; | |
|
196 | 238 | rightBound = gridRect.right(); |
|
197 | else | |
|
198 |
|
|
|
239 | } else { | |
|
240 | leftBound = gridRect.left(); | |
|
241 | rightBound = layout[0]; | |
|
242 | } | |
|
243 | } else { | |
|
244 | if (axis()->isReverse()) { | |
|
245 | rightBound = gridRect.right() + gridRect.left() - layout[i]; | |
|
246 | if (i == layout.size() - 1) { | |
|
247 | leftBound = gridRect.left(); | |
|
248 | } else { | |
|
249 | leftBound = qMax(gridRect.right() + gridRect.left() - layout[i + 1], | |
|
250 | gridRect.left()); | |
|
251 | } | |
|
252 | } else { | |
|
253 | leftBound = layout[i]; | |
|
254 | if (i == layout.size() - 1) | |
|
255 | rightBound = gridRect.right(); | |
|
256 | else | |
|
257 | rightBound = qMin(layout[i + 1], gridRect.right()); | |
|
258 | } | |
|
199 | 259 | } |
|
200 | 260 | if (leftBound < gridRect.left()) |
|
201 | 261 | leftBound = gridRect.left(); |
|
202 | 262 | if (rightBound > gridRect.right()) |
|
203 | 263 | rightBound = gridRect.right(); |
|
204 | 264 | shadeItem->setRect(leftBound, gridRect.top(), rightBound - leftBound, |
|
205 | 265 | gridRect.height()); |
|
206 | 266 | if (shadeItem->rect().width() <= 0.0) |
|
207 | 267 | shadeItem->setVisible(false); |
|
208 | 268 | else |
|
209 | 269 | shadeItem->setVisible(true); |
|
210 | 270 | } |
|
211 | 271 | |
|
212 | 272 | // check if the grid line and the axis tick should be shown |
|
213 | 273 | qreal x = gridItem->line().p1().x(); |
|
214 | 274 | if (x < gridRect.left() || x > gridRect.right()) { |
|
215 | 275 | gridItem->setVisible(false); |
|
216 | 276 | tickItem->setVisible(false); |
|
217 | 277 | } else { |
|
218 | 278 | gridItem->setVisible(true); |
|
219 | 279 | tickItem->setVisible(true); |
|
220 | 280 | } |
|
221 | 281 | |
|
222 | 282 | } |
|
223 | 283 | |
|
224 | 284 | //begin/end grid line in case labels between |
|
225 | 285 | if (intervalAxis()) { |
|
226 | 286 | QGraphicsLineItem *gridLine; |
|
227 | 287 | gridLine = static_cast<QGraphicsLineItem *>(lines.at(layout.size())); |
|
228 | 288 | gridLine->setLine(gridRect.right(), gridRect.top(), gridRect.right(), gridRect.bottom()); |
|
229 | 289 | gridLine->setVisible(true); |
|
230 | 290 | gridLine = static_cast<QGraphicsLineItem*>(lines.at(layout.size()+1)); |
|
231 | 291 | gridLine->setLine(gridRect.left(), gridRect.top(), gridRect.left(), gridRect.bottom()); |
|
232 | 292 | gridLine->setVisible(true); |
|
233 | 293 | } |
|
234 | 294 | } |
|
235 | 295 | |
|
236 | 296 | QSizeF HorizontalAxis::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
|
237 | 297 | { |
|
238 | 298 | Q_UNUSED(constraint); |
|
239 | 299 | QSizeF sh(0,0); |
|
240 | 300 | |
|
241 | 301 | if (axis()->titleText().isEmpty() || !titleItem()->isVisible()) |
|
242 | 302 | return sh; |
|
243 | 303 | |
|
244 | 304 | switch (which) { |
|
245 | 305 | case Qt::MinimumSize: { |
|
246 | 306 | QRectF titleRect = ChartPresenter::textBoundingRect(axis()->titleFont(), |
|
247 | 307 | QStringLiteral("...")); |
|
248 | 308 | sh = QSizeF(titleRect.width(), titleRect.height() + (titlePadding() * 2.0)); |
|
249 | 309 | break; |
|
250 | 310 | } |
|
251 | 311 | case Qt::MaximumSize: |
|
252 | 312 | case Qt::PreferredSize: { |
|
253 | 313 | QRectF titleRect = ChartPresenter::textBoundingRect(axis()->titleFont(), axis()->titleText()); |
|
254 | 314 | sh = QSizeF(titleRect.width(), titleRect.height() + (titlePadding() * 2.0)); |
|
255 | 315 | break; |
|
256 | 316 | } |
|
257 | 317 | default: |
|
258 | 318 | break; |
|
259 | 319 | } |
|
260 | 320 | |
|
261 | 321 | return sh; |
|
262 | 322 | } |
|
263 | 323 | |
|
264 | 324 | QT_CHARTS_END_NAMESPACE |
@@ -1,948 +1,979 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #include <QtCharts/QAbstractAxis> |
|
20 | 20 | #include <private/qabstractaxis_p.h> |
|
21 | 21 | #include <private/chartdataset_p.h> |
|
22 | 22 | #include <private/charttheme_p.h> |
|
23 | 23 | #include <private/qchart_p.h> |
|
24 | 24 | |
|
25 | 25 | QT_CHARTS_BEGIN_NAMESPACE |
|
26 | 26 | |
|
27 | 27 | /*! |
|
28 | 28 | \class QAbstractAxis |
|
29 | 29 | \inmodule Qt Charts |
|
30 | 30 | \brief The QAbstractAxis class is used for manipulating chart's axis. |
|
31 | 31 | \mainclass |
|
32 | 32 | |
|
33 | 33 | Each series can be bound to one or more horizontal and vertical axes, but mixing axis types |
|
34 | 34 | that would result in different domains is not supported, such as specifying |
|
35 | 35 | QValueAxis and QLogValueAxis on the same orientation. |
|
36 | 36 | |
|
37 | 37 | Properties and visibility of various axis elements such as axis line, title, labels, grid lines, |
|
38 | 38 | and shades can be individually controlled. |
|
39 | 39 | */ |
|
40 | 40 | /*! |
|
41 | 41 | \qmltype AbstractAxis |
|
42 | 42 | \instantiates QAbstractAxis |
|
43 | 43 | \inqmlmodule QtCharts |
|
44 | 44 | |
|
45 | 45 | \brief The AbstractAxis is a base element used for specialized axis elements. |
|
46 | 46 | |
|
47 | 47 | Each series can be bound to only one horizontal and vertical axis. |
|
48 | 48 | |
|
49 | 49 | Properties and visibility of various axis elements such as axis line, title, labels, grid lines, |
|
50 | 50 | and shades can be individually controlled. |
|
51 | 51 | */ |
|
52 | 52 | |
|
53 | 53 | /*! |
|
54 | 54 | \enum QAbstractAxis::AxisType |
|
55 | 55 | |
|
56 | 56 | The type of the axis object. |
|
57 | 57 | |
|
58 | 58 | \value AxisTypeNoAxis |
|
59 | 59 | \value AxisTypeValue |
|
60 | 60 | \value AxisTypeBarCategory |
|
61 | 61 | \value AxisTypeCategory |
|
62 | 62 | \value AxisTypeDateTime |
|
63 | 63 | \value AxisTypeLogValue |
|
64 | 64 | */ |
|
65 | 65 | |
|
66 | 66 | /*! |
|
67 | 67 | *\fn void QAbstractAxis::type() const |
|
68 | 68 | Returns the type of the axis |
|
69 | 69 | */ |
|
70 | 70 | |
|
71 | 71 | /*! |
|
72 | 72 | \property QAbstractAxis::lineVisible |
|
73 | 73 | The visibility of the axis line |
|
74 | 74 | */ |
|
75 | 75 | /*! |
|
76 | 76 | \qmlproperty bool AbstractAxis::lineVisible |
|
77 | 77 | The visibility of the axis line |
|
78 | 78 | */ |
|
79 | 79 | |
|
80 | 80 | /*! |
|
81 | 81 | \property QAbstractAxis::linePen |
|
82 | 82 | The pen of the line. |
|
83 | 83 | */ |
|
84 | 84 | |
|
85 | 85 | /*! |
|
86 | 86 | \property QAbstractAxis::labelsVisible |
|
87 | 87 | Defines if axis labels are visible. |
|
88 | 88 | */ |
|
89 | 89 | /*! |
|
90 | 90 | \qmlproperty bool AbstractAxis::labelsVisible |
|
91 | 91 | Defines if axis labels are visible. |
|
92 | 92 | */ |
|
93 | 93 | |
|
94 | 94 | /*! |
|
95 | 95 | \property QAbstractAxis::labelsBrush |
|
96 | 96 | The brush of the labels. Only the color of the brush is relevant. |
|
97 | 97 | */ |
|
98 | 98 | |
|
99 | 99 | /*! |
|
100 | 100 | \property QAbstractAxis::visible |
|
101 | 101 | The visibility of the axis. |
|
102 | 102 | */ |
|
103 | 103 | /*! |
|
104 | 104 | \qmlproperty bool AbstractAxis::visible |
|
105 | 105 | The visibility of the axis. |
|
106 | 106 | */ |
|
107 | 107 | |
|
108 | 108 | /*! |
|
109 | 109 | \property QAbstractAxis::gridVisible |
|
110 | 110 | The visibility of the grid lines. |
|
111 | 111 | */ |
|
112 | 112 | /*! |
|
113 | 113 | \qmlproperty bool AbstractAxis::gridVisible |
|
114 | 114 | The visibility of the grid lines. |
|
115 | 115 | */ |
|
116 | 116 | |
|
117 | 117 | /*! |
|
118 | 118 | \property QAbstractAxis::color |
|
119 | 119 | The color of the axis and ticks. |
|
120 | 120 | */ |
|
121 | 121 | /*! |
|
122 | 122 | \qmlproperty color AbstractAxis::color |
|
123 | 123 | The color of the axis and ticks. |
|
124 | 124 | */ |
|
125 | 125 | |
|
126 | 126 | /*! |
|
127 | 127 | \property QAbstractAxis::gridLinePen |
|
128 | 128 | The pen of the grid line. |
|
129 | 129 | */ |
|
130 | 130 | |
|
131 | 131 | /*! |
|
132 | 132 | \property QAbstractAxis::labelsFont |
|
133 | 133 | The font of the axis labels. |
|
134 | 134 | */ |
|
135 | 135 | |
|
136 | 136 | /*! |
|
137 | 137 | \qmlproperty Font AbstractAxis::labelsFont |
|
138 | 138 | The font of the axis labels. |
|
139 | 139 | |
|
140 | 140 | See the Qt documentation for more details of Font. |
|
141 | 141 | */ |
|
142 | 142 | |
|
143 | 143 | /*! |
|
144 | 144 | \property QAbstractAxis::labelsColor |
|
145 | 145 | The color of the axis labels. |
|
146 | 146 | */ |
|
147 | 147 | /*! |
|
148 | 148 | \qmlproperty color AbstractAxis::labelsColor |
|
149 | 149 | The color of the axis labels. |
|
150 | 150 | */ |
|
151 | 151 | |
|
152 | 152 | /*! |
|
153 | 153 | \property QAbstractAxis::labelsAngle |
|
154 | 154 | The angle of the axis labels in degrees. |
|
155 | 155 | */ |
|
156 | 156 | /*! |
|
157 | 157 | \qmlproperty int AbstractAxis::labelsAngle |
|
158 | 158 | The angle of the axis labels in degrees. |
|
159 | 159 | */ |
|
160 | 160 | |
|
161 | 161 | /*! |
|
162 | 162 | \property QAbstractAxis::shadesVisible |
|
163 | 163 | The visibility of the axis shades. |
|
164 | 164 | */ |
|
165 | 165 | /*! |
|
166 | 166 | \qmlproperty bool AbstractAxis::shadesVisible |
|
167 | 167 | The visibility of the axis shades. |
|
168 | 168 | */ |
|
169 | 169 | |
|
170 | 170 | /*! |
|
171 | 171 | \property QAbstractAxis::shadesColor |
|
172 | 172 | The fill (brush) color of the axis shades. |
|
173 | 173 | */ |
|
174 | 174 | /*! |
|
175 | 175 | \qmlproperty color AbstractAxis::shadesColor |
|
176 | 176 | The fill (brush) color of the axis shades. |
|
177 | 177 | */ |
|
178 | 178 | |
|
179 | 179 | /*! |
|
180 | 180 | \property QAbstractAxis::shadesBorderColor |
|
181 | 181 | The border (pen) color of the axis shades. |
|
182 | 182 | */ |
|
183 | 183 | /*! |
|
184 | 184 | \qmlproperty color AbstractAxis::shadesBorderColor |
|
185 | 185 | The border (pen) color of the axis shades. |
|
186 | 186 | */ |
|
187 | 187 | |
|
188 | 188 | /*! |
|
189 | 189 | \property QAbstractAxis::shadesPen |
|
190 | 190 | The pen of the axis shades (area between grid lines). |
|
191 | 191 | */ |
|
192 | 192 | |
|
193 | 193 | /*! |
|
194 | 194 | \property QAbstractAxis::shadesBrush |
|
195 | 195 | The brush of the axis shades (area between grid lines). |
|
196 | 196 | */ |
|
197 | 197 | |
|
198 | 198 | /*! |
|
199 | 199 | \property QAbstractAxis::titleVisible |
|
200 | 200 | The visibility of the axis title. By default the value is true. |
|
201 | 201 | */ |
|
202 | 202 | /*! |
|
203 | 203 | \qmlproperty bool AbstractAxis::titleVisible |
|
204 | 204 | The visibility of the axis title. By default the value is true. |
|
205 | 205 | */ |
|
206 | 206 | |
|
207 | 207 | /*! |
|
208 | 208 | \property QAbstractAxis::titleText |
|
209 | 209 | The title of the axis. Empty by default. Axis titles support html formatting. |
|
210 | 210 | */ |
|
211 | 211 | /*! |
|
212 | 212 | \qmlproperty String AbstractAxis::titleText |
|
213 | 213 | The title of the axis. Empty by default. Axis titles support html formatting. |
|
214 | 214 | */ |
|
215 | 215 | |
|
216 | 216 | /*! |
|
217 | 217 | \property QAbstractAxis::titleBrush |
|
218 | 218 | The brush of the title text. Only the color of the brush is relevant. |
|
219 | 219 | */ |
|
220 | 220 | |
|
221 | 221 | /*! |
|
222 | 222 | \property QAbstractAxis::titleFont |
|
223 | 223 | The font of the title of the axis. |
|
224 | 224 | */ |
|
225 | 225 | /*! |
|
226 | 226 | \qmlproperty Font AbstractAxis::titleFont |
|
227 | 227 | The font of the title of the axis. |
|
228 | 228 | */ |
|
229 | 229 | |
|
230 | 230 | /*! |
|
231 | 231 | \property QAbstractAxis::orientation |
|
232 | 232 | The orientation of the axis. Fixed to either Qt::Horizontal or Qt::Vertical when you add the axis to a chart. |
|
233 | 233 | */ |
|
234 | 234 | /*! |
|
235 | 235 | \qmlproperty Qt.Orientation AbstractAxis::orientation |
|
236 | 236 | The orientation of the axis. Fixed to either Qt.Horizontal or Qt.Vertical when the axis is set to a series. |
|
237 | 237 | */ |
|
238 | 238 | |
|
239 | 239 | /*! |
|
240 | 240 | \property QAbstractAxis::alignment |
|
241 | 241 | The alignment of the axis. Can be Qt::AlignLeft, Qt::AlignRight, Qt::AlignBottom, or Qt::AlignTop. |
|
242 | 242 | */ |
|
243 | 243 | /*! |
|
244 | 244 | \qmlproperty alignment AbstractAxis::alignment |
|
245 | 245 | The alignment of the axis. Can be Qt.AlignLeft, Qt.AlignRight, Qt.AlignBottom, or Qt.AlignTop. |
|
246 | 246 | */ |
|
247 | 247 | |
|
248 | 248 | /*! |
|
249 | \property QAbstractAxis::reverse | |
|
250 | The reverse property defines if reverse axis is used. By default the value is false. | |
|
251 | ||
|
252 | Reverse axis is supported with line, spline, scatter and area series with cartesian chart. | |
|
253 | All axes of the same orientation attached to same series must be reversed if one is reversed or | |
|
254 | the behavior is undefined. | |
|
255 | */ | |
|
256 | /*! | |
|
257 | \qmlproperty alignment AbstractAxis::reverse | |
|
258 | The reverse property defines if reverse axis is used. By default the value is false. | |
|
259 | ||
|
260 | Reverse axis is supported with line, spline, scatter and area series with cartesian chart. | |
|
261 | All axes of the same orientation attached to same series must be reversed if one is reversed or | |
|
262 | the behavior is undefined. | |
|
263 | */ | |
|
264 | ||
|
265 | /*! | |
|
249 | 266 | \fn void QAbstractAxis::visibleChanged(bool visible) |
|
250 | 267 | Visibility of the axis has changed to \a visible. |
|
251 | 268 | */ |
|
252 | 269 | /*! |
|
253 | 270 | \qmlsignal AbstractAxis::onVisibleChanged(bool visible) |
|
254 | 271 | Visibility of the axis has changed to \a visible. |
|
255 | 272 | */ |
|
256 | 273 | |
|
257 | 274 | /*! |
|
258 | 275 | \fn void QAbstractAxis::linePenChanged(const QPen& pen) |
|
259 | 276 | The pen of the line of the axis has changed to \a pen. |
|
260 | 277 | */ |
|
261 | 278 | |
|
262 | 279 | /*! |
|
263 | 280 | \fn void QAbstractAxis::lineVisibleChanged(bool visible) |
|
264 | 281 | Visibility of the axis line has changed to \a visible. |
|
265 | 282 | */ |
|
266 | 283 | /*! |
|
267 | 284 | \qmlsignal AbstractAxis::onLineVisibleChanged(bool visible) |
|
268 | 285 | Visibility of the axis line has changed to \a visible. |
|
269 | 286 | */ |
|
270 | 287 | |
|
271 | 288 | /*! |
|
272 | 289 | \fn void QAbstractAxis::labelsVisibleChanged(bool visible) |
|
273 | 290 | Visibility of the labels of the axis has changed to \a visible. |
|
274 | 291 | */ |
|
275 | 292 | /*! |
|
276 | 293 | \qmlsignal AbstractAxis::onLabelsVisibleChanged(bool visible) |
|
277 | 294 | Visibility of the labels of the axis has changed to \a visible. |
|
278 | 295 | */ |
|
279 | 296 | |
|
280 | 297 | /*! |
|
281 | 298 | \fn void QAbstractAxis::labelsFontChanged(const QFont& font) |
|
282 | 299 | The font of the axis labels has changed to \a font. |
|
283 | 300 | */ |
|
284 | 301 | /*! |
|
285 | 302 | \qmlsignal AbstractAxis::onLabelsFontChanged(Font font) |
|
286 | 303 | The font of the axis labels has changed to \a font. |
|
287 | 304 | */ |
|
288 | 305 | |
|
289 | 306 | /*! |
|
290 | 307 | \fn void QAbstractAxis::labelsBrushChanged(const QBrush& brush) |
|
291 | 308 | The brush of the axis labels has changed to \a brush. |
|
292 | 309 | */ |
|
293 | 310 | |
|
294 | 311 | /*! |
|
295 | 312 | \fn void QAbstractAxis::labelsAngleChanged(int angle) |
|
296 | 313 | The angle of the axis labels has changed to \a angle. |
|
297 | 314 | */ |
|
298 | 315 | /*! |
|
299 | 316 | \qmlsignal AbstractAxis::onLabelsAngleChanged(int angle) |
|
300 | 317 | The angle of the axis labels has changed to \a angle. |
|
301 | 318 | */ |
|
302 | 319 | |
|
303 | 320 | /*! |
|
304 | 321 | \fn void QAbstractAxis::gridVisibleChanged(bool visible) |
|
305 | 322 | Visibility of the grid lines of the axis has changed to \a visible. |
|
306 | 323 | */ |
|
307 | 324 | /*! |
|
308 | 325 | \qmlsignal AbstractAxis::onGridVisibleChanged(bool visible) |
|
309 | 326 | Visibility of the grid lines of the axis has changed to \a visible. |
|
310 | 327 | */ |
|
311 | 328 | |
|
312 | 329 | /*! |
|
313 | 330 | \fn void QAbstractAxis::gridLinePenChanged(const QPen& pen) |
|
314 | 331 | The pen of the grid line has changed to \a pen. |
|
315 | 332 | */ |
|
316 | 333 | |
|
317 | 334 | /*! |
|
318 | 335 | \fn void QAbstractAxis::colorChanged(QColor color) |
|
319 | 336 | Emitted if the \a color of the axis is changed. |
|
320 | 337 | */ |
|
321 | 338 | /*! |
|
322 | 339 | \qmlsignal AbstractAxis::onColorChanged(QColor color) |
|
323 | 340 | Emitted if the \a color of the axis is changed. |
|
324 | 341 | */ |
|
325 | 342 | |
|
326 | 343 | /*! |
|
327 | 344 | \fn void QAbstractAxis::labelsColorChanged(QColor color) |
|
328 | 345 | Emitted if the \a color of the axis labels is changed. |
|
329 | 346 | */ |
|
330 | 347 | /*! |
|
331 | 348 | \qmlsignal AbstractAxis::onLabelsColorChanged(QColor color) |
|
332 | 349 | Emitted if the \a color of the axis labels is changed. |
|
333 | 350 | */ |
|
334 | 351 | |
|
335 | 352 | /*! |
|
336 | 353 | \fn void QAbstractAxis::titleVisibleChanged(bool visible) |
|
337 | 354 | Visibility of the title text of the axis has changed to \a visible. |
|
338 | 355 | */ |
|
339 | 356 | /*! |
|
340 | 357 | \qmlsignal AbstractAxis::onTitleVisibleChanged(bool visible) |
|
341 | 358 | Visibility of the title text of the axis has changed to \a visible. |
|
342 | 359 | */ |
|
343 | 360 | |
|
344 | 361 | /*! |
|
345 | 362 | \fn void QAbstractAxis::titleTextChanged(const QString& text) |
|
346 | 363 | The text of the axis title has changed to \a text. |
|
347 | 364 | */ |
|
348 | 365 | /*! |
|
349 | 366 | \qmlsignal AbstractAxis::onTitleTextChanged(String text) |
|
350 | 367 | The text of the axis title has changed to \a text. |
|
351 | 368 | */ |
|
352 | 369 | |
|
353 | 370 | /*! |
|
354 | 371 | \fn void QAbstractAxis::titleBrushChanged(const QBrush& brush) |
|
355 | 372 | The brush of the axis title has changed to \a brush. |
|
356 | 373 | */ |
|
357 | 374 | |
|
358 | 375 | /*! |
|
359 | 376 | \fn void QAbstractAxis::titleFontChanged(const QFont& font) |
|
360 | 377 | The font of the axis title has changed to \a font. |
|
361 | 378 | */ |
|
362 | 379 | /*! |
|
363 | 380 | \qmlsignal AbstractAxis::onTitleFontChanged(Font font) |
|
364 | 381 | The font of the axis title has changed to \a font. |
|
365 | 382 | */ |
|
366 | 383 | |
|
367 | 384 | /*! |
|
368 | 385 | \fn void QAbstractAxis::shadesVisibleChanged(bool) |
|
369 | 386 | Emitted if the visibility of the axis shades is changed to \a visible. |
|
370 | 387 | */ |
|
371 | 388 | /*! |
|
372 | 389 | \qmlsignal AbstractAxis::onShadesVisibleChanged(bool visible) |
|
373 | 390 | Emitted if the visibility of the axis shades is changed to \a visible. |
|
374 | 391 | */ |
|
375 | 392 | |
|
376 | 393 | /*! |
|
377 | 394 | \fn void QAbstractAxis::shadesColorChanged(QColor color) |
|
378 | 395 | Emitted if the \a color of the axis shades is changed. |
|
379 | 396 | */ |
|
380 | 397 | /*! |
|
381 | 398 | \qmlsignal AbstractAxis::onShadesColorChanged(QColor color) |
|
382 | 399 | Emitted if the \a color of the axis shades is changed. |
|
383 | 400 | */ |
|
384 | 401 | |
|
385 | 402 | /*! |
|
386 | 403 | \fn void QAbstractAxis::shadesBorderColorChanged(QColor) |
|
387 | 404 | Emitted if the border \a color of the axis shades is changed. |
|
388 | 405 | */ |
|
389 | 406 | /*! |
|
390 | 407 | \qmlsignal AbstractAxis::onBorderColorChanged(QColor color) |
|
391 | 408 | Emitted if the border \a color of the axis shades is changed. |
|
392 | 409 | */ |
|
393 | 410 | |
|
394 | 411 | /*! |
|
395 | 412 | \fn void QAbstractAxis::shadesBrushChanged(const QBrush& brush) |
|
396 | 413 | The brush of the axis shades has changed to \a brush. |
|
397 | 414 | */ |
|
398 | 415 | |
|
399 | 416 | /*! |
|
400 | 417 | \fn void QAbstractAxis::shadesPenChanged(const QPen& pen) |
|
401 | 418 | The pen of the axis shades has changed to \a pen. |
|
402 | 419 | */ |
|
403 | 420 | |
|
404 | 421 | /*! |
|
405 | 422 | \internal |
|
406 | 423 | Constructs new axis object which is a child of \a parent. Ownership is taken by |
|
407 | 424 | QChart when axis added. |
|
408 | 425 | */ |
|
409 | 426 | |
|
410 | 427 | QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) |
|
411 | 428 | : QObject(parent), |
|
412 | 429 | d_ptr(&d) |
|
413 | 430 | { |
|
414 | 431 | } |
|
415 | 432 | |
|
416 | 433 | /*! |
|
417 | 434 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. |
|
418 | 435 | */ |
|
419 | 436 | |
|
420 | 437 | QAbstractAxis::~QAbstractAxis() |
|
421 | 438 | { |
|
422 | 439 | if (d_ptr->m_chart) |
|
423 | 440 | qFatal("Still binded axis detected !"); |
|
424 | 441 | } |
|
425 | 442 | |
|
426 | 443 | /*! |
|
427 | 444 | Sets \a pen used to draw axis line and ticks. |
|
428 | 445 | */ |
|
429 | 446 | void QAbstractAxis::setLinePen(const QPen &pen) |
|
430 | 447 | { |
|
431 | 448 | if (d_ptr->m_axisPen != pen) { |
|
432 | 449 | d_ptr->m_axisPen = pen; |
|
433 | 450 | emit linePenChanged(pen); |
|
434 | 451 | } |
|
435 | 452 | } |
|
436 | 453 | |
|
437 | 454 | /*! |
|
438 | 455 | Returns pen used to draw axis and ticks. |
|
439 | 456 | */ |
|
440 | 457 | QPen QAbstractAxis::linePen() const |
|
441 | 458 | { |
|
442 | 459 | if (d_ptr->m_axisPen == QChartPrivate::defaultPen()) |
|
443 | 460 | return QPen(); |
|
444 | 461 | else |
|
445 | 462 | return d_ptr->m_axisPen; |
|
446 | 463 | } |
|
447 | 464 | |
|
448 | 465 | void QAbstractAxis::setLinePenColor(QColor color) |
|
449 | 466 | { |
|
450 | 467 | QPen p = d_ptr->m_axisPen; |
|
451 | 468 | if (p.color() != color) { |
|
452 | 469 | p.setColor(color); |
|
453 | 470 | setLinePen(p); |
|
454 | 471 | emit colorChanged(color); |
|
455 | 472 | } |
|
456 | 473 | } |
|
457 | 474 | |
|
458 | 475 | QColor QAbstractAxis::linePenColor() const |
|
459 | 476 | { |
|
460 | 477 | return linePen().color(); |
|
461 | 478 | } |
|
462 | 479 | |
|
463 | 480 | /*! |
|
464 | 481 | Sets if axis and ticks are \a visible. |
|
465 | 482 | */ |
|
466 | 483 | void QAbstractAxis::setLineVisible(bool visible) |
|
467 | 484 | { |
|
468 | 485 | if (d_ptr->m_arrowVisible != visible) { |
|
469 | 486 | d_ptr->m_arrowVisible = visible; |
|
470 | 487 | emit lineVisibleChanged(visible); |
|
471 | 488 | } |
|
472 | 489 | } |
|
473 | 490 | |
|
474 | 491 | bool QAbstractAxis::isLineVisible() const |
|
475 | 492 | { |
|
476 | 493 | return d_ptr->m_arrowVisible; |
|
477 | 494 | } |
|
478 | 495 | |
|
479 | 496 | void QAbstractAxis::setGridLineVisible(bool visible) |
|
480 | 497 | { |
|
481 | 498 | if (d_ptr->m_gridLineVisible != visible) { |
|
482 | 499 | d_ptr->m_gridLineVisible = visible; |
|
483 | 500 | emit gridVisibleChanged(visible); |
|
484 | 501 | } |
|
485 | 502 | } |
|
486 | 503 | |
|
487 | 504 | bool QAbstractAxis::isGridLineVisible() const |
|
488 | 505 | { |
|
489 | 506 | return d_ptr->m_gridLineVisible; |
|
490 | 507 | } |
|
491 | 508 | |
|
492 | 509 | /*! |
|
493 | 510 | Sets \a pen used to draw grid line. |
|
494 | 511 | */ |
|
495 | 512 | void QAbstractAxis::setGridLinePen(const QPen &pen) |
|
496 | 513 | { |
|
497 | 514 | if (d_ptr->m_gridLinePen != pen) { |
|
498 | 515 | d_ptr->m_gridLinePen = pen; |
|
499 | 516 | emit gridLinePenChanged(pen); |
|
500 | 517 | } |
|
501 | 518 | } |
|
502 | 519 | |
|
503 | 520 | /*! |
|
504 | 521 | Returns pen used to draw grid. |
|
505 | 522 | */ |
|
506 | 523 | QPen QAbstractAxis::gridLinePen() const |
|
507 | 524 | { |
|
508 | 525 | if (d_ptr->m_gridLinePen == QChartPrivate::defaultPen()) |
|
509 | 526 | return QPen(); |
|
510 | 527 | else |
|
511 | 528 | return d_ptr->m_gridLinePen; |
|
512 | 529 | } |
|
513 | 530 | |
|
514 | 531 | void QAbstractAxis::setLabelsVisible(bool visible) |
|
515 | 532 | { |
|
516 | 533 | if (d_ptr->m_labelsVisible != visible) { |
|
517 | 534 | d_ptr->m_labelsVisible = visible; |
|
518 | 535 | emit labelsVisibleChanged(visible); |
|
519 | 536 | } |
|
520 | 537 | } |
|
521 | 538 | |
|
522 | 539 | bool QAbstractAxis::labelsVisible() const |
|
523 | 540 | { |
|
524 | 541 | return d_ptr->m_labelsVisible; |
|
525 | 542 | } |
|
526 | 543 | |
|
527 | 544 | /*! |
|
528 | 545 | Sets \a brush used to draw labels. |
|
529 | 546 | */ |
|
530 | 547 | void QAbstractAxis::setLabelsBrush(const QBrush &brush) |
|
531 | 548 | { |
|
532 | 549 | if (d_ptr->m_labelsBrush != brush) { |
|
533 | 550 | d_ptr->m_labelsBrush = brush; |
|
534 | 551 | emit labelsBrushChanged(brush); |
|
535 | 552 | } |
|
536 | 553 | } |
|
537 | 554 | |
|
538 | 555 | /*! |
|
539 | 556 | Returns brush used to draw labels. |
|
540 | 557 | */ |
|
541 | 558 | QBrush QAbstractAxis::labelsBrush() const |
|
542 | 559 | { |
|
543 | 560 | if (d_ptr->m_labelsBrush == QChartPrivate::defaultBrush()) |
|
544 | 561 | return QBrush(); |
|
545 | 562 | else |
|
546 | 563 | return d_ptr->m_labelsBrush; |
|
547 | 564 | } |
|
548 | 565 | |
|
549 | 566 | /*! |
|
550 | 567 | Sets \a font used to draw labels. |
|
551 | 568 | */ |
|
552 | 569 | void QAbstractAxis::setLabelsFont(const QFont &font) |
|
553 | 570 | { |
|
554 | 571 | if (d_ptr->m_labelsFont != font) { |
|
555 | 572 | d_ptr->m_labelsFont = font; |
|
556 | 573 | emit labelsFontChanged(font); |
|
557 | 574 | } |
|
558 | 575 | } |
|
559 | 576 | |
|
560 | 577 | /*! |
|
561 | 578 | Returns font used to draw labels. |
|
562 | 579 | */ |
|
563 | 580 | QFont QAbstractAxis::labelsFont() const |
|
564 | 581 | { |
|
565 | 582 | if (d_ptr->m_labelsFont == QChartPrivate::defaultFont()) |
|
566 | 583 | return QFont(); |
|
567 | 584 | else |
|
568 | 585 | return d_ptr->m_labelsFont; |
|
569 | 586 | } |
|
570 | 587 | |
|
571 | 588 | void QAbstractAxis::setLabelsAngle(int angle) |
|
572 | 589 | { |
|
573 | 590 | if (d_ptr->m_labelsAngle != angle) { |
|
574 | 591 | d_ptr->m_labelsAngle = angle; |
|
575 | 592 | emit labelsAngleChanged(angle); |
|
576 | 593 | } |
|
577 | 594 | } |
|
578 | 595 | |
|
579 | 596 | int QAbstractAxis::labelsAngle() const |
|
580 | 597 | { |
|
581 | 598 | return d_ptr->m_labelsAngle; |
|
582 | 599 | } |
|
583 | 600 | void QAbstractAxis::setLabelsColor(QColor color) |
|
584 | 601 | { |
|
585 | 602 | QBrush b = d_ptr->m_labelsBrush; |
|
586 | 603 | if (b.color() != color) { |
|
587 | 604 | b.setColor(color); |
|
588 | 605 | setLabelsBrush(b); |
|
589 | 606 | emit labelsColorChanged(color); |
|
590 | 607 | } |
|
591 | 608 | } |
|
592 | 609 | |
|
593 | 610 | QColor QAbstractAxis::labelsColor() const |
|
594 | 611 | { |
|
595 | 612 | return labelsBrush().color(); |
|
596 | 613 | } |
|
597 | 614 | |
|
598 | 615 | void QAbstractAxis::setTitleVisible(bool visible) |
|
599 | 616 | { |
|
600 | 617 | if (d_ptr->m_titleVisible != visible) { |
|
601 | 618 | d_ptr->m_titleVisible = visible; |
|
602 | 619 | emit titleVisibleChanged(visible); |
|
603 | 620 | } |
|
604 | 621 | } |
|
605 | 622 | |
|
606 | 623 | bool QAbstractAxis::isTitleVisible() const |
|
607 | 624 | { |
|
608 | 625 | return d_ptr->m_titleVisible; |
|
609 | 626 | } |
|
610 | 627 | |
|
611 | 628 | /*! |
|
612 | 629 | Sets \a brush used to draw title. |
|
613 | 630 | */ |
|
614 | 631 | void QAbstractAxis::setTitleBrush(const QBrush &brush) |
|
615 | 632 | { |
|
616 | 633 | if (d_ptr->m_titleBrush != brush) { |
|
617 | 634 | d_ptr->m_titleBrush = brush; |
|
618 | 635 | emit titleBrushChanged(brush); |
|
619 | 636 | } |
|
620 | 637 | } |
|
621 | 638 | |
|
622 | 639 | /*! |
|
623 | 640 | Returns brush used to draw title. |
|
624 | 641 | */ |
|
625 | 642 | QBrush QAbstractAxis::titleBrush() const |
|
626 | 643 | { |
|
627 | 644 | if (d_ptr->m_titleBrush == QChartPrivate::defaultBrush()) |
|
628 | 645 | return QBrush(); |
|
629 | 646 | else |
|
630 | 647 | return d_ptr->m_titleBrush; |
|
631 | 648 | } |
|
632 | 649 | |
|
633 | 650 | /*! |
|
634 | 651 | Sets \a font used to draw title. |
|
635 | 652 | */ |
|
636 | 653 | void QAbstractAxis::setTitleFont(const QFont &font) |
|
637 | 654 | { |
|
638 | 655 | if (d_ptr->m_titleFont != font) { |
|
639 | 656 | d_ptr->m_titleFont = font; |
|
640 | 657 | emit titleFontChanged(font); |
|
641 | 658 | } |
|
642 | 659 | } |
|
643 | 660 | |
|
644 | 661 | /*! |
|
645 | 662 | Returns font used to draw title. |
|
646 | 663 | */ |
|
647 | 664 | QFont QAbstractAxis::titleFont() const |
|
648 | 665 | { |
|
649 | 666 | if (d_ptr->m_titleFont == QChartPrivate::defaultFont()) |
|
650 | 667 | return QFont(); |
|
651 | 668 | else |
|
652 | 669 | return d_ptr->m_titleFont; |
|
653 | 670 | } |
|
654 | 671 | |
|
655 | 672 | void QAbstractAxis::setTitleText(const QString &title) |
|
656 | 673 | { |
|
657 | 674 | if (d_ptr->m_title != title) { |
|
658 | 675 | d_ptr->m_title = title; |
|
659 | 676 | emit titleTextChanged(title); |
|
660 | 677 | } |
|
661 | 678 | } |
|
662 | 679 | |
|
663 | 680 | QString QAbstractAxis::titleText() const |
|
664 | 681 | { |
|
665 | 682 | return d_ptr->m_title; |
|
666 | 683 | } |
|
667 | 684 | |
|
668 | 685 | |
|
669 | 686 | void QAbstractAxis::setShadesVisible(bool visible) |
|
670 | 687 | { |
|
671 | 688 | if (d_ptr->m_shadesVisible != visible) { |
|
672 | 689 | d_ptr->m_shadesVisible = visible; |
|
673 | 690 | emit shadesVisibleChanged(visible); |
|
674 | 691 | } |
|
675 | 692 | } |
|
676 | 693 | |
|
677 | 694 | bool QAbstractAxis::shadesVisible() const |
|
678 | 695 | { |
|
679 | 696 | return d_ptr->m_shadesVisible; |
|
680 | 697 | } |
|
681 | 698 | |
|
682 | 699 | /*! |
|
683 | 700 | Sets \a pen used to draw shades. |
|
684 | 701 | */ |
|
685 | 702 | void QAbstractAxis::setShadesPen(const QPen &pen) |
|
686 | 703 | { |
|
687 | 704 | if (d_ptr->m_shadesPen != pen) { |
|
688 | 705 | d_ptr->m_shadesPen = pen; |
|
689 | 706 | emit shadesPenChanged(pen); |
|
690 | 707 | } |
|
691 | 708 | } |
|
692 | 709 | |
|
693 | 710 | /*! |
|
694 | 711 | Returns pen used to draw shades. |
|
695 | 712 | */ |
|
696 | 713 | QPen QAbstractAxis::shadesPen() const |
|
697 | 714 | { |
|
698 | 715 | if (d_ptr->m_shadesPen == QChartPrivate::defaultPen()) |
|
699 | 716 | return QPen(); |
|
700 | 717 | else |
|
701 | 718 | return d_ptr->m_shadesPen; |
|
702 | 719 | } |
|
703 | 720 | |
|
704 | 721 | /*! |
|
705 | 722 | Sets \a brush used to draw shades. |
|
706 | 723 | */ |
|
707 | 724 | void QAbstractAxis::setShadesBrush(const QBrush &brush) |
|
708 | 725 | { |
|
709 | 726 | if (d_ptr->m_shadesBrush != brush) { |
|
710 | 727 | d_ptr->m_shadesBrush = brush; |
|
711 | 728 | emit shadesBrushChanged(brush); |
|
712 | 729 | } |
|
713 | 730 | } |
|
714 | 731 | |
|
715 | 732 | /*! |
|
716 | 733 | Returns brush used to draw shades. |
|
717 | 734 | */ |
|
718 | 735 | QBrush QAbstractAxis::shadesBrush() const |
|
719 | 736 | { |
|
720 | 737 | if (d_ptr->m_shadesBrush == QChartPrivate::defaultBrush()) |
|
721 | 738 | return QBrush(Qt::SolidPattern); |
|
722 | 739 | else |
|
723 | 740 | return d_ptr->m_shadesBrush; |
|
724 | 741 | } |
|
725 | 742 | |
|
726 | 743 | void QAbstractAxis::setShadesColor(QColor color) |
|
727 | 744 | { |
|
728 | 745 | QBrush b = d_ptr->m_shadesBrush; |
|
729 | 746 | if (b.color() != color) { |
|
730 | 747 | b.setColor(color); |
|
731 | 748 | setShadesBrush(b); |
|
732 | 749 | emit shadesColorChanged(color); |
|
733 | 750 | } |
|
734 | 751 | } |
|
735 | 752 | |
|
736 | 753 | QColor QAbstractAxis::shadesColor() const |
|
737 | 754 | { |
|
738 | 755 | return shadesBrush().color(); |
|
739 | 756 | } |
|
740 | 757 | |
|
741 | 758 | void QAbstractAxis::setShadesBorderColor(QColor color) |
|
742 | 759 | { |
|
743 | 760 | QPen p = d_ptr->m_shadesPen; |
|
744 | 761 | if (p.color() != color) { |
|
745 | 762 | p.setColor(color); |
|
746 | 763 | setShadesPen(p); |
|
747 | 764 | emit shadesColorChanged(color); |
|
748 | 765 | } |
|
749 | 766 | } |
|
750 | 767 | |
|
751 | 768 | QColor QAbstractAxis::shadesBorderColor() const |
|
752 | 769 | { |
|
753 | 770 | return shadesPen().color(); |
|
754 | 771 | } |
|
755 | 772 | |
|
756 | 773 | |
|
757 | 774 | bool QAbstractAxis::isVisible() const |
|
758 | 775 | { |
|
759 | 776 | return d_ptr->m_visible; |
|
760 | 777 | } |
|
761 | 778 | |
|
762 | 779 | /*! |
|
763 | 780 | Sets axis, shades, labels and grid lines to be visible. |
|
764 | 781 | */ |
|
765 | 782 | void QAbstractAxis::setVisible(bool visible) |
|
766 | 783 | { |
|
767 | 784 | if (d_ptr->m_visible != visible) { |
|
768 | 785 | d_ptr->m_visible = visible; |
|
769 | 786 | emit visibleChanged(visible); |
|
770 | 787 | } |
|
771 | 788 | } |
|
772 | 789 | |
|
773 | 790 | |
|
774 | 791 | /*! |
|
775 | 792 | Sets axis, shades, labels and grid lines to be visible. |
|
776 | 793 | */ |
|
777 | 794 | void QAbstractAxis::show() |
|
778 | 795 | { |
|
779 | 796 | setVisible(true); |
|
780 | 797 | } |
|
781 | 798 | |
|
782 | 799 | /*! |
|
783 | 800 | Sets axis, shades, labels and grid lines to not be visible. |
|
784 | 801 | */ |
|
785 | 802 | void QAbstractAxis::hide() |
|
786 | 803 | { |
|
787 | 804 | setVisible(false); |
|
788 | 805 | } |
|
789 | 806 | |
|
790 | 807 | /*! |
|
791 | 808 | Sets the minimum value shown on the axis. |
|
792 | 809 | Depending on the actual axis type the \a min parameter is converted to appropriate type. |
|
793 | 810 | If the conversion is impossible then the function call does nothing |
|
794 | 811 | */ |
|
795 | 812 | void QAbstractAxis::setMin(const QVariant &min) |
|
796 | 813 | { |
|
797 | 814 | d_ptr->setMin(min); |
|
798 | 815 | } |
|
799 | 816 | |
|
800 | 817 | /*! |
|
801 | 818 | Sets the maximum value shown on the axis. |
|
802 | 819 | Depending on the actual axis type the \a max parameter is converted to appropriate type. |
|
803 | 820 | If the conversion is impossible then the function call does nothing |
|
804 | 821 | */ |
|
805 | 822 | void QAbstractAxis::setMax(const QVariant &max) |
|
806 | 823 | { |
|
807 | 824 | d_ptr->setMax(max); |
|
808 | 825 | } |
|
809 | 826 | |
|
810 | 827 | /*! |
|
811 | 828 | Sets the range shown on the axis. |
|
812 | 829 | Depending on the actual axis type the \a min and \a max parameters are converted to appropriate types. |
|
813 | 830 | If the conversion is impossible then the function call does nothing. |
|
814 | 831 | */ |
|
815 | 832 | void QAbstractAxis::setRange(const QVariant &min, const QVariant &max) |
|
816 | 833 | { |
|
817 | 834 | d_ptr->setRange(min, max); |
|
818 | 835 | } |
|
819 | 836 | |
|
820 | 837 | |
|
821 | 838 | /*! |
|
822 | 839 | Returns the orientation in which the axis is being used (Vertical or Horizontal) |
|
823 | 840 | */ |
|
824 | 841 | Qt::Orientation QAbstractAxis::orientation() const |
|
825 | 842 | { |
|
826 | 843 | return d_ptr->orientation(); |
|
827 | 844 | } |
|
828 | 845 | |
|
829 | 846 | Qt::Alignment QAbstractAxis::alignment() const |
|
830 | 847 | { |
|
831 | 848 | return d_ptr->alignment(); |
|
832 | 849 | } |
|
833 | 850 | |
|
851 | bool QAbstractAxis::isReverse() const | |
|
852 | { | |
|
853 | return d_ptr->m_reverse; | |
|
854 | } | |
|
855 | ||
|
856 | void QAbstractAxis::setReverse(bool reverse) | |
|
857 | { | |
|
858 | if (d_ptr->m_reverse != reverse && type() != QAbstractAxis::AxisTypeBarCategory) { | |
|
859 | d_ptr->m_reverse = reverse; | |
|
860 | emit reverseChanged(reverse); | |
|
861 | } | |
|
862 | } | |
|
863 | ||
|
834 | 864 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
835 | 865 | |
|
836 | 866 | QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis *q) |
|
837 | 867 | : q_ptr(q), |
|
838 | 868 | m_chart(0), |
|
839 | 869 | m_alignment(0), |
|
840 | 870 | m_orientation(Qt::Orientation(0)), |
|
841 | 871 | m_visible(true), |
|
842 | 872 | m_arrowVisible(true), |
|
843 | 873 | m_axisPen(QChartPrivate::defaultPen()), |
|
844 | 874 | m_axisBrush(QChartPrivate::defaultBrush()), |
|
845 | 875 | m_gridLineVisible(true), |
|
846 | 876 | m_gridLinePen(QChartPrivate::defaultPen()), |
|
847 | 877 | m_labelsVisible(true), |
|
848 | 878 | m_labelsBrush(QChartPrivate::defaultBrush()), |
|
849 | 879 | m_labelsFont(QChartPrivate::defaultFont()), |
|
850 | 880 | m_labelsAngle(0), |
|
851 | 881 | m_titleVisible(true), |
|
852 | 882 | m_titleBrush(QChartPrivate::defaultBrush()), |
|
853 | 883 | m_titleFont(QChartPrivate::defaultFont()), |
|
854 | 884 | m_shadesVisible(false), |
|
855 | 885 | m_shadesPen(QChartPrivate::defaultPen()), |
|
856 | 886 | m_shadesBrush(QChartPrivate::defaultBrush()), |
|
857 | 887 | m_shadesOpacity(1.0), |
|
858 | m_dirty(false) | |
|
888 | m_dirty(false), | |
|
889 | m_reverse(false) | |
|
859 | 890 | { |
|
860 | 891 | } |
|
861 | 892 | |
|
862 | 893 | QAbstractAxisPrivate::~QAbstractAxisPrivate() |
|
863 | 894 | { |
|
864 | 895 | } |
|
865 | 896 | |
|
866 | 897 | void QAbstractAxisPrivate::setAlignment( Qt::Alignment alignment) |
|
867 | 898 | { |
|
868 | 899 | switch(alignment) { |
|
869 | 900 | case Qt::AlignTop: |
|
870 | 901 | case Qt::AlignBottom: |
|
871 | 902 | m_orientation = Qt::Horizontal; |
|
872 | 903 | break; |
|
873 | 904 | case Qt::AlignLeft: |
|
874 | 905 | case Qt::AlignRight: |
|
875 | 906 | m_orientation = Qt::Vertical; |
|
876 | 907 | break; |
|
877 | 908 | default: |
|
878 | 909 | qWarning()<<"No alignment specified !"; |
|
879 | 910 | break; |
|
880 | 911 | }; |
|
881 | 912 | m_alignment=alignment; |
|
882 | 913 | } |
|
883 | 914 | |
|
884 | 915 | void QAbstractAxisPrivate::initializeTheme(ChartTheme* theme, bool forced) |
|
885 | 916 | { |
|
886 | 917 | if (forced || QChartPrivate::defaultPen() == m_axisPen) |
|
887 | 918 | q_ptr->setLinePen(theme->axisLinePen()); |
|
888 | 919 | |
|
889 | 920 | if (forced || QChartPrivate::defaultPen() == m_gridLinePen) |
|
890 | 921 | q_ptr->setGridLinePen(theme->girdLinePen()); |
|
891 | 922 | |
|
892 | 923 | if (forced || QChartPrivate::defaultBrush() == m_labelsBrush) |
|
893 | 924 | q_ptr->setLabelsBrush(theme->labelBrush()); |
|
894 | 925 | if (forced || QChartPrivate::defaultFont() == m_labelsFont) |
|
895 | 926 | q_ptr->setLabelsFont(theme->labelFont()); |
|
896 | 927 | |
|
897 | 928 | if (forced || QChartPrivate::defaultBrush() == m_titleBrush) |
|
898 | 929 | q_ptr->setTitleBrush(theme->labelBrush()); |
|
899 | 930 | if (forced || QChartPrivate::defaultFont() == m_titleFont) { |
|
900 | 931 | QFont font(m_labelsFont); |
|
901 | 932 | font.setBold(true); |
|
902 | 933 | q_ptr->setTitleFont(font); |
|
903 | 934 | } |
|
904 | 935 | |
|
905 | 936 | if (forced || QChartPrivate::defaultBrush() == m_shadesBrush) |
|
906 | 937 | q_ptr->setShadesBrush(theme->backgroundShadesBrush()); |
|
907 | 938 | if (forced || QChartPrivate::defaultPen() == m_shadesPen) |
|
908 | 939 | q_ptr->setShadesPen(theme->backgroundShadesPen()); |
|
909 | 940 | |
|
910 | 941 | bool axisX = m_orientation == Qt::Horizontal; |
|
911 | 942 | if (forced && (theme->backgroundShades() == ChartTheme::BackgroundShadesBoth |
|
912 | 943 | || (theme->backgroundShades() == ChartTheme::BackgroundShadesVertical && axisX) |
|
913 | 944 | || (theme->backgroundShades() == ChartTheme::BackgroundShadesHorizontal && !axisX))) { |
|
914 | 945 | q_ptr->setShadesVisible(true); |
|
915 | 946 | } else if (forced) { |
|
916 | 947 | q_ptr->setShadesVisible(false); |
|
917 | 948 | } |
|
918 | 949 | } |
|
919 | 950 | |
|
920 | 951 | void QAbstractAxisPrivate::handleRangeChanged(qreal min, qreal max) |
|
921 | 952 | { |
|
922 | 953 | setRange(min,max); |
|
923 | 954 | } |
|
924 | 955 | |
|
925 | 956 | void QAbstractAxisPrivate::initializeGraphics(QGraphicsItem* parent) |
|
926 | 957 | { |
|
927 | 958 | Q_UNUSED(parent); |
|
928 | 959 | } |
|
929 | 960 | |
|
930 | 961 | void QAbstractAxisPrivate::initializeAnimations(QChart::AnimationOptions options) |
|
931 | 962 | { |
|
932 | 963 | ChartAxisElement *axis = m_item.data(); |
|
933 | 964 | Q_ASSERT(axis); |
|
934 | 965 | if (axis->animation()) |
|
935 | 966 | axis->animation()->stopAndDestroyLater(); |
|
936 | 967 | |
|
937 | 968 | if (options.testFlag(QChart::GridAxisAnimations)) |
|
938 | 969 | axis->setAnimation(new AxisAnimation(axis)); |
|
939 | 970 | else |
|
940 | 971 | axis->setAnimation(0); |
|
941 | 972 | } |
|
942 | 973 | |
|
943 | 974 | |
|
944 | 975 | |
|
945 | 976 | #include "moc_qabstractaxis.cpp" |
|
946 | 977 | #include "moc_qabstractaxis_p.cpp" |
|
947 | 978 | |
|
948 | 979 | QT_CHARTS_END_NAMESPACE |
@@ -1,185 +1,191 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #ifndef QABSTRACTAXIS_H |
|
20 | 20 | #define QABSTRACTAXIS_H |
|
21 | 21 | |
|
22 | 22 | #include <QtCharts/QChartGlobal> |
|
23 | 23 | #include <QtGui/QPen> |
|
24 | 24 | #include <QtGui/QFont> |
|
25 | 25 | #include <QtCore/QVariant> |
|
26 | 26 | |
|
27 | 27 | QT_CHARTS_BEGIN_NAMESPACE |
|
28 | 28 | |
|
29 | 29 | class QAbstractAxisPrivate; |
|
30 | 30 | |
|
31 | 31 | class QT_CHARTS_EXPORT QAbstractAxis : public QObject |
|
32 | 32 | { |
|
33 | 33 | Q_OBJECT |
|
34 | 34 | //visibility |
|
35 | 35 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) |
|
36 | 36 | //arrow |
|
37 | 37 | Q_PROPERTY(bool lineVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged) |
|
38 | 38 | Q_PROPERTY(QPen linePen READ linePen WRITE setLinePen NOTIFY linePenChanged) |
|
39 | 39 | Q_PROPERTY(QColor color READ linePenColor WRITE setLinePenColor NOTIFY colorChanged) |
|
40 | 40 | //labels |
|
41 | 41 | Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) |
|
42 | 42 | Q_PROPERTY(QBrush labelsBrush READ labelsBrush WRITE setLabelsBrush NOTIFY labelsBrushChanged) |
|
43 | 43 | Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged) |
|
44 | 44 | Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont NOTIFY labelsFontChanged) |
|
45 | 45 | Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged) |
|
46 | 46 | //grid |
|
47 | 47 | Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged) |
|
48 | 48 | Q_PROPERTY(QPen gridLinePen READ gridLinePen WRITE setGridLinePen NOTIFY gridLinePenChanged) |
|
49 | 49 | //shades |
|
50 | 50 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) |
|
51 | 51 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) |
|
52 | 52 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) |
|
53 | 53 | Q_PROPERTY(QPen shadesPen READ shadesPen WRITE setShadesPen NOTIFY shadesPenChanged) |
|
54 | 54 | Q_PROPERTY(QBrush shadesBrush READ shadesBrush WRITE setShadesBrush NOTIFY shadesBrushChanged) |
|
55 | 55 | //title |
|
56 | 56 | Q_PROPERTY(QString titleText READ titleText WRITE setTitleText NOTIFY titleTextChanged) |
|
57 | 57 | Q_PROPERTY(QBrush titleBrush READ titleBrush WRITE setTitleBrush NOTIFY titleBrushChanged) |
|
58 | 58 | Q_PROPERTY(bool titleVisible READ isTitleVisible WRITE setTitleVisible NOTIFY titleVisibleChanged) |
|
59 | 59 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont NOTIFY titleFontChanged) |
|
60 | 60 | //orientation |
|
61 | 61 | Q_PROPERTY(Qt::Orientation orientation READ orientation) |
|
62 | 62 | //aligment |
|
63 | 63 | Q_PROPERTY(Qt::Alignment alignment READ alignment) |
|
64 | Q_PROPERTY(bool reverse READ isReverse WRITE setReverse NOTIFY reverseChanged) | |
|
64 | 65 | |
|
65 | 66 | public: |
|
66 | 67 | |
|
67 | 68 | enum AxisType { |
|
68 | 69 | AxisTypeNoAxis = 0x0, |
|
69 | 70 | AxisTypeValue = 0x1, |
|
70 | 71 | AxisTypeBarCategory = 0x2, |
|
71 | 72 | AxisTypeCategory = 0x4, |
|
72 | 73 | AxisTypeDateTime = 0x8, |
|
73 | 74 | AxisTypeLogValue = 0x10 |
|
74 | 75 | }; |
|
75 | 76 | |
|
76 | 77 | Q_DECLARE_FLAGS(AxisTypes, AxisType) |
|
77 | 78 | |
|
78 | 79 | protected: |
|
79 | 80 | explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = 0); |
|
80 | 81 | |
|
81 | 82 | public: |
|
82 | 83 | ~QAbstractAxis(); |
|
83 | 84 | |
|
84 | 85 | virtual AxisType type() const = 0; |
|
85 | 86 | |
|
86 | 87 | //visibility handling |
|
87 | 88 | bool isVisible() const; |
|
88 | 89 | void setVisible(bool visible = true); |
|
89 | 90 | void show(); |
|
90 | 91 | void hide(); |
|
91 | 92 | |
|
92 | 93 | //arrow handling |
|
93 | 94 | bool isLineVisible() const; |
|
94 | 95 | void setLineVisible(bool visible = true); |
|
95 | 96 | void setLinePen(const QPen &pen); |
|
96 | 97 | QPen linePen() const; |
|
97 | 98 | void setLinePenColor(QColor color); |
|
98 | 99 | QColor linePenColor() const; |
|
99 | 100 | |
|
100 | 101 | //grid handling |
|
101 | 102 | bool isGridLineVisible() const; |
|
102 | 103 | void setGridLineVisible(bool visible = true); |
|
103 | 104 | void setGridLinePen(const QPen &pen); |
|
104 | 105 | QPen gridLinePen() const; |
|
105 | 106 | |
|
106 | 107 | //labels handling |
|
107 | 108 | bool labelsVisible() const; |
|
108 | 109 | void setLabelsVisible(bool visible = true); |
|
109 | 110 | void setLabelsBrush(const QBrush &brush); |
|
110 | 111 | QBrush labelsBrush() const; |
|
111 | 112 | void setLabelsFont(const QFont &font); |
|
112 | 113 | QFont labelsFont() const; |
|
113 | 114 | void setLabelsAngle(int angle); |
|
114 | 115 | int labelsAngle() const; |
|
115 | 116 | void setLabelsColor(QColor color); |
|
116 | 117 | QColor labelsColor() const; |
|
117 | 118 | |
|
118 | 119 | //title handling |
|
119 | 120 | bool isTitleVisible() const; |
|
120 | 121 | void setTitleVisible(bool visible = true); |
|
121 | 122 | void setTitleBrush(const QBrush &brush); |
|
122 | 123 | QBrush titleBrush() const; |
|
123 | 124 | void setTitleFont(const QFont &font); |
|
124 | 125 | QFont titleFont() const; |
|
125 | 126 | void setTitleText(const QString &title); |
|
126 | 127 | QString titleText() const; |
|
127 | 128 | |
|
128 | 129 | //shades handling |
|
129 | 130 | bool shadesVisible() const; |
|
130 | 131 | void setShadesVisible(bool visible = true); |
|
131 | 132 | void setShadesPen(const QPen &pen); |
|
132 | 133 | QPen shadesPen() const; |
|
133 | 134 | void setShadesBrush(const QBrush &brush); |
|
134 | 135 | QBrush shadesBrush() const; |
|
135 | 136 | void setShadesColor(QColor color); |
|
136 | 137 | QColor shadesColor() const; |
|
137 | 138 | void setShadesBorderColor(QColor color); |
|
138 | 139 | QColor shadesBorderColor() const; |
|
139 | 140 | |
|
140 | 141 | Qt::Orientation orientation() const; |
|
141 | 142 | Qt::Alignment alignment() const; |
|
142 | 143 | |
|
143 | 144 | //range handling |
|
144 | 145 | void setMin(const QVariant &min); |
|
145 | 146 | void setMax(const QVariant &max); |
|
146 | 147 | void setRange(const QVariant &min, const QVariant &max); |
|
147 | 148 | |
|
149 | //reverse handling | |
|
150 | void setReverse(bool reverse = true); | |
|
151 | bool isReverse() const; | |
|
152 | ||
|
148 | 153 | Q_SIGNALS: |
|
149 | 154 | void visibleChanged(bool visible); |
|
150 | 155 | void linePenChanged(const QPen &pen); |
|
151 | 156 | void lineVisibleChanged(bool visible); |
|
152 | 157 | void labelsVisibleChanged(bool visible); |
|
153 | 158 | void labelsBrushChanged(const QBrush &brush); |
|
154 | 159 | void labelsFontChanged(const QFont &pen); |
|
155 | 160 | void labelsAngleChanged(int angle); |
|
156 | 161 | void gridLinePenChanged(const QPen &pen); |
|
157 | 162 | void gridVisibleChanged(bool visible); |
|
158 | 163 | void colorChanged(QColor color); |
|
159 | 164 | void labelsColorChanged(QColor color); |
|
160 | 165 | void titleTextChanged(const QString &title); |
|
161 | 166 | void titleBrushChanged(const QBrush &brush); |
|
162 | 167 | void titleVisibleChanged(bool visible); |
|
163 | 168 | void titleFontChanged(const QFont &font); |
|
164 | 169 | void shadesVisibleChanged(bool visible); |
|
165 | 170 | void shadesColorChanged(QColor color); |
|
166 | 171 | void shadesBorderColorChanged(QColor color); |
|
167 | 172 | void shadesPenChanged(const QPen &pen); |
|
168 | 173 | void shadesBrushChanged(const QBrush &brush); |
|
174 | void reverseChanged(bool reverse); | |
|
169 | 175 | |
|
170 | 176 | protected: |
|
171 | 177 | QScopedPointer<QAbstractAxisPrivate> d_ptr; |
|
172 | 178 | friend class ChartDataSet; |
|
173 | 179 | friend class ChartPresenter; |
|
174 | 180 | friend class ChartThemeManager; |
|
175 | 181 | friend class AbstractDomain; |
|
176 | 182 | friend class ChartAxisElement; |
|
177 | 183 | friend class XYChart; |
|
178 | 184 | |
|
179 | 185 | private: |
|
180 | 186 | Q_DISABLE_COPY(QAbstractAxis) |
|
181 | 187 | }; |
|
182 | 188 | |
|
183 | 189 | QT_CHARTS_END_NAMESPACE |
|
184 | 190 | |
|
185 | 191 | #endif // QABSTRACTAXIS_H |
@@ -1,128 +1,130 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | // W A R N I N G |
|
20 | 20 | // ------------- |
|
21 | 21 | // |
|
22 | 22 | // This file is not part of the Qt Enterprise Chart API. It exists purely as an |
|
23 | 23 | // implementation detail. This header file may change from version to |
|
24 | 24 | // version without notice, or even be removed. |
|
25 | 25 | // |
|
26 | 26 | // We mean it. |
|
27 | 27 | |
|
28 | 28 | #ifndef QABSTRACTAXIS_P_H |
|
29 | 29 | #define QABSTRACTAXIS_P_H |
|
30 | 30 | |
|
31 | 31 | #include <QtCharts/QAbstractAxis> |
|
32 | 32 | #include <private/chartaxiselement_p.h> |
|
33 | 33 | #include <QtCharts/QChart> |
|
34 | 34 | #include <QtCore/QDebug> |
|
35 | 35 | |
|
36 | 36 | QT_BEGIN_NAMESPACE |
|
37 | 37 | class QGraphicsItem; |
|
38 | 38 | QT_END_NAMESPACE |
|
39 | 39 | |
|
40 | 40 | QT_CHARTS_BEGIN_NAMESPACE |
|
41 | 41 | |
|
42 | 42 | class ChartPresenter; |
|
43 | 43 | class AbstractDomain; |
|
44 | 44 | class QChart; |
|
45 | 45 | class QAbstractSeries; |
|
46 | 46 | class ChartTheme; |
|
47 | 47 | class ChartElement; |
|
48 | 48 | |
|
49 | 49 | class QT_CHARTS_AUTOTEST_EXPORT QAbstractAxisPrivate : public QObject |
|
50 | 50 | { |
|
51 | 51 | Q_OBJECT |
|
52 | 52 | public: |
|
53 | 53 | QAbstractAxisPrivate(QAbstractAxis *q); |
|
54 | 54 | ~QAbstractAxisPrivate(); |
|
55 | 55 | |
|
56 | 56 | public: |
|
57 | 57 | Qt::Alignment alignment() const { return m_alignment; } |
|
58 | 58 | Qt::Orientation orientation() const { return m_orientation; } |
|
59 | 59 | void setAlignment( Qt::Alignment alignment); |
|
60 | 60 | |
|
61 | 61 | virtual void initializeDomain(AbstractDomain *domain) = 0; |
|
62 | 62 | virtual void initializeGraphics(QGraphicsItem *parent) = 0; |
|
63 | 63 | virtual void initializeTheme(ChartTheme* theme, bool forced = false); |
|
64 | 64 | virtual void initializeAnimations(QChart::AnimationOptions options); |
|
65 | 65 | |
|
66 | 66 | //interface for manipulating range form base class |
|
67 | 67 | virtual void setMin(const QVariant &min) = 0; |
|
68 | 68 | virtual void setMax(const QVariant &max) = 0; |
|
69 | 69 | virtual void setRange(const QVariant &min, const QVariant &max) = 0; |
|
70 | 70 | |
|
71 | 71 | //interface manipulating range form domain |
|
72 | 72 | virtual void setRange(qreal min, qreal max) = 0; |
|
73 | 73 | virtual qreal min() = 0; |
|
74 | 74 | virtual qreal max() = 0; |
|
75 | 75 | |
|
76 | 76 | ChartAxisElement *axisItem() { return m_item.data(); } |
|
77 | 77 | |
|
78 | 78 | public Q_SLOTS: |
|
79 | 79 | void handleRangeChanged(qreal min, qreal max); |
|
80 | 80 | |
|
81 | 81 | Q_SIGNALS: |
|
82 | 82 | void rangeChanged(qreal min, qreal max); |
|
83 | 83 | |
|
84 | 84 | protected: |
|
85 | 85 | QAbstractAxis *q_ptr; |
|
86 | 86 | QChart *m_chart; |
|
87 | 87 | QScopedPointer<ChartAxisElement> m_item; |
|
88 | 88 | |
|
89 | 89 | private: |
|
90 | 90 | QList<QAbstractSeries*> m_series; |
|
91 | 91 | |
|
92 | 92 | Qt::Alignment m_alignment; |
|
93 | 93 | Qt::Orientation m_orientation; |
|
94 | 94 | |
|
95 | 95 | bool m_visible; |
|
96 | 96 | |
|
97 | 97 | bool m_arrowVisible; |
|
98 | 98 | QPen m_axisPen; |
|
99 | 99 | QBrush m_axisBrush; |
|
100 | 100 | |
|
101 | 101 | bool m_gridLineVisible; |
|
102 | 102 | QPen m_gridLinePen; |
|
103 | 103 | |
|
104 | 104 | bool m_labelsVisible; |
|
105 | 105 | QBrush m_labelsBrush; |
|
106 | 106 | QFont m_labelsFont; |
|
107 | 107 | int m_labelsAngle; |
|
108 | 108 | |
|
109 | 109 | bool m_titleVisible; |
|
110 | 110 | QBrush m_titleBrush; |
|
111 | 111 | QFont m_titleFont; |
|
112 | 112 | QString m_title; |
|
113 | 113 | |
|
114 | 114 | bool m_shadesVisible; |
|
115 | 115 | QPen m_shadesPen; |
|
116 | 116 | QBrush m_shadesBrush; |
|
117 | 117 | qreal m_shadesOpacity; |
|
118 | 118 | |
|
119 | 119 | bool m_dirty; |
|
120 | 120 | |
|
121 | bool m_reverse; | |
|
122 | ||
|
121 | 123 | friend class QAbstractAxis; |
|
122 | 124 | friend class ChartDataSet; |
|
123 | 125 | friend class ChartPresenter; |
|
124 | 126 | }; |
|
125 | 127 | |
|
126 | 128 | QT_CHARTS_END_NAMESPACE |
|
127 | 129 | |
|
128 | 130 | #endif |
@@ -1,272 +1,340 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #include <private/verticalaxis_p.h> |
|
20 | 20 | #include <QtCharts/QAbstractAxis> |
|
21 | 21 | #include <private/chartpresenter_p.h> |
|
22 | 22 | #include <QtCharts/QCategoryAxis> |
|
23 | 23 | #include <QtCore/QDebug> |
|
24 | 24 | |
|
25 | 25 | QT_CHARTS_BEGIN_NAMESPACE |
|
26 | 26 | |
|
27 | 27 | VerticalAxis::VerticalAxis(QAbstractAxis *axis, QGraphicsItem *item, bool intervalAxis) |
|
28 | 28 | : CartesianChartAxis(axis, item, intervalAxis) |
|
29 | 29 | { |
|
30 | 30 | } |
|
31 | 31 | |
|
32 | 32 | VerticalAxis::~VerticalAxis() |
|
33 | 33 | { |
|
34 | 34 | } |
|
35 | 35 | |
|
36 | 36 | void VerticalAxis::updateGeometry() |
|
37 | 37 | { |
|
38 | 38 | const QVector<qreal> &layout = ChartAxisElement::layout(); |
|
39 | 39 | |
|
40 | 40 | if (layout.isEmpty() && axis()->type() != QAbstractAxis::AxisTypeLogValue) |
|
41 | 41 | return; |
|
42 | 42 | |
|
43 | 43 | QStringList labelList = labels(); |
|
44 | 44 | |
|
45 | 45 | QList<QGraphicsItem *> labels = labelItems(); |
|
46 | 46 | QList<QGraphicsItem *> arrow = arrowItems(); |
|
47 | 47 | QGraphicsTextItem *title = titleItem(); |
|
48 | 48 | |
|
49 | 49 | Q_ASSERT(labels.size() == labelList.size()); |
|
50 | 50 | Q_ASSERT(layout.size() == labelList.size()); |
|
51 | 51 | |
|
52 | 52 | const QRectF &axisRect = axisGeometry(); |
|
53 | 53 | const QRectF &gridRect = gridGeometry(); |
|
54 | 54 | |
|
55 | 55 | qreal height = axisRect.bottom(); |
|
56 | 56 | |
|
57 | 57 | //arrow |
|
58 | 58 | QGraphicsLineItem *arrowItem = static_cast<QGraphicsLineItem*>(arrow.at(0)); |
|
59 | 59 | |
|
60 | 60 | //arrow position |
|
61 | 61 | if (axis()->alignment() == Qt::AlignLeft) |
|
62 | 62 | arrowItem->setLine(axisRect.right(), gridRect.top(), axisRect.right(), gridRect.bottom()); |
|
63 | 63 | else if (axis()->alignment() == Qt::AlignRight) |
|
64 | 64 | arrowItem->setLine(axisRect.left(), gridRect.top(), axisRect.left(), gridRect.bottom()); |
|
65 | 65 | |
|
66 | 66 | //title |
|
67 | 67 | QRectF titleBoundingRect; |
|
68 | 68 | QString titleText = axis()->titleText(); |
|
69 | 69 | qreal availableSpace = axisRect.width() - labelPadding(); |
|
70 | 70 | if (!titleText.isEmpty() && titleItem()->isVisible()) { |
|
71 | 71 | availableSpace -= titlePadding() * 2.0; |
|
72 | 72 | qreal minimumLabelWidth = ChartPresenter::textBoundingRect(axis()->labelsFont(), |
|
73 | 73 | QStringLiteral("...")).width(); |
|
74 | 74 | qreal titleSpace = availableSpace - minimumLabelWidth; |
|
75 | 75 | title->setHtml(ChartPresenter::truncatedText(axis()->titleFont(), titleText, qreal(90.0), |
|
76 | 76 | titleSpace, gridRect.height(), |
|
77 | 77 | titleBoundingRect)); |
|
78 | 78 | title->setTextWidth(titleBoundingRect.height()); |
|
79 | 79 | |
|
80 | 80 | titleBoundingRect = title->boundingRect(); |
|
81 | 81 | |
|
82 | 82 | QPointF center = gridRect.center() - titleBoundingRect.center(); |
|
83 | 83 | if (axis()->alignment() == Qt::AlignLeft) |
|
84 | 84 | title->setPos(axisRect.left() - titleBoundingRect.width() / 2.0 + titleBoundingRect.height() / 2.0 + titlePadding(), center.y()); |
|
85 | 85 | else if (axis()->alignment() == Qt::AlignRight) |
|
86 | 86 | title->setPos(axisRect.right() - titleBoundingRect.width() / 2.0 - titleBoundingRect.height() / 2.0 - titlePadding(), center.y()); |
|
87 | 87 | |
|
88 | 88 | title->setTransformOriginPoint(titleBoundingRect.center()); |
|
89 | 89 | title->setRotation(270); |
|
90 | 90 | |
|
91 | 91 | availableSpace -= titleBoundingRect.height(); |
|
92 | 92 | } |
|
93 | 93 | |
|
94 | 94 | if (layout.isEmpty() && axis()->type() == QAbstractAxis::AxisTypeLogValue) |
|
95 | 95 | return; |
|
96 | 96 | |
|
97 | 97 | QList<QGraphicsItem *> lines = gridItems(); |
|
98 | 98 | QList<QGraphicsItem *> shades = shadeItems(); |
|
99 | 99 | |
|
100 | 100 | for (int i = 0; i < layout.size(); ++i) { |
|
101 | 101 | //items |
|
102 | 102 | QGraphicsLineItem *gridItem = static_cast<QGraphicsLineItem *>(lines.at(i)); |
|
103 | 103 | QGraphicsLineItem *tickItem = static_cast<QGraphicsLineItem *>(arrow.at(i + 1)); |
|
104 | 104 | QGraphicsTextItem *labelItem = static_cast<QGraphicsTextItem *>(labels.at(i)); |
|
105 | 105 | |
|
106 | 106 | //grid line |
|
107 | gridItem->setLine(gridRect.left(), layout[i], gridRect.right(), layout[i]); | |
|
107 | if (axis()->isReverse()) { | |
|
108 | gridItem->setLine(gridRect.left(), gridRect.top() + gridRect.bottom() - layout[i], | |
|
109 | gridRect.right(), gridRect.top() + gridRect.bottom() - layout[i]); | |
|
110 | } else { | |
|
111 | gridItem->setLine(gridRect.left(), layout[i], gridRect.right(), layout[i]); | |
|
112 | } | |
|
108 | 113 | |
|
109 | 114 | //label text wrapping |
|
110 |
QString text |
|
|
115 | QString text; | |
|
116 | if (axis()->isReverse() && axis()->type() != QAbstractAxis::AxisTypeCategory) | |
|
117 | text = labelList.at(labelList.count() - i - 1); | |
|
118 | else | |
|
119 | text = labelList.at(i); | |
|
120 | ||
|
111 | 121 | QRectF boundingRect; |
|
112 | 122 | // don't truncate empty labels |
|
113 | 123 | if (text.isEmpty()) { |
|
114 | 124 | labelItem->setHtml(text); |
|
115 | 125 | } else { |
|
116 | 126 | qreal labelHeight = (axisRect.height() / layout.count()) - (2 * labelPadding()); |
|
117 | 127 | QString truncatedText = ChartPresenter::truncatedText(axis()->labelsFont(), text, |
|
118 | 128 | axis()->labelsAngle(), |
|
119 | 129 | availableSpace, |
|
120 | 130 | labelHeight, boundingRect); |
|
121 | 131 | labelItem->setTextWidth(ChartPresenter::textBoundingRect(axis()->labelsFont(), |
|
122 | 132 | truncatedText).width()); |
|
123 | 133 | labelItem->setHtml(truncatedText); |
|
124 | 134 | } |
|
125 | 135 | |
|
126 | 136 | //label transformation origin point |
|
127 | 137 | const QRectF &rect = labelItem->boundingRect(); |
|
128 | 138 | QPointF center = rect.center(); |
|
129 | 139 | labelItem->setTransformOriginPoint(center.x(), center.y()); |
|
130 | 140 | qreal widthDiff = rect.width() - boundingRect.width(); |
|
131 | 141 | qreal heightDiff = rect.height() - boundingRect.height(); |
|
132 | 142 | |
|
133 | 143 | //ticks and label position |
|
134 | 144 | if (axis()->alignment() == Qt::AlignLeft) { |
|
135 | labelItem->setPos(axisRect.right() - rect.width() + (widthDiff / 2.0) - labelPadding(), layout[i] - center.y()); | |
|
136 | tickItem->setLine(axisRect.right() - labelPadding(), layout[i], axisRect.right(), layout[i]); | |
|
145 | if (axis()->isReverse()) { | |
|
146 | labelItem->setPos(axisRect.right() - rect.width() + (widthDiff / 2.0) | |
|
147 | - labelPadding(), | |
|
148 | gridRect.top() + gridRect.bottom() | |
|
149 | - layout[layout.size() - i - 1] - center.y()); | |
|
150 | tickItem->setLine(axisRect.right() - labelPadding(), | |
|
151 | gridRect.top() + gridRect.bottom() - layout[i], | |
|
152 | axisRect.right(), | |
|
153 | gridRect.top() + gridRect.bottom() - layout[i]); | |
|
154 | } else { | |
|
155 | labelItem->setPos(axisRect.right() - rect.width() + (widthDiff / 2.0) | |
|
156 | - labelPadding(), | |
|
157 | layout[i] - center.y()); | |
|
158 | tickItem->setLine(axisRect.right() - labelPadding(), layout[i], | |
|
159 | axisRect.right(), layout[i]); | |
|
160 | } | |
|
137 | 161 | } else if (axis()->alignment() == Qt::AlignRight) { |
|
138 | labelItem->setPos(axisRect.left() + labelPadding() - (widthDiff / 2.0), layout[i] - center.y()); | |
|
139 |
tickItem->setLine(axisRect.left(), |
|
|
162 | if (axis()->isReverse()) { | |
|
163 | tickItem->setLine(axisRect.left(), | |
|
164 | gridRect.top() + gridRect.bottom() - layout[i], | |
|
165 | axisRect.left() + labelPadding(), | |
|
166 | gridRect.top() + gridRect.bottom() - layout[i]); | |
|
167 | labelItem->setPos(axisRect.left() + labelPadding() - (widthDiff / 2.0), | |
|
168 | gridRect.top() + gridRect.bottom() | |
|
169 | - layout[layout.size() - i - 1] - center.y()); | |
|
170 | } else { | |
|
171 | labelItem->setPos(axisRect.left() + labelPadding() - (widthDiff / 2.0), | |
|
172 | layout[i] - center.y()); | |
|
173 | tickItem->setLine(axisRect.left(), layout[i], | |
|
174 | axisRect.left() + labelPadding(), layout[i]); | |
|
175 | } | |
|
140 | 176 | } |
|
141 | 177 | |
|
142 | 178 | //label in between |
|
143 | 179 | bool forceHide = false; |
|
144 | 180 | bool labelOnValue = false; |
|
145 | 181 | if (intervalAxis() && (i + 1) != layout.size()) { |
|
146 |
qreal lowerBound |
|
|
147 |
qreal upperBound |
|
|
182 | qreal lowerBound; | |
|
183 | qreal upperBound; | |
|
184 | if (axis()->isReverse()) { | |
|
185 | lowerBound = qMax(gridRect.top() + gridRect.bottom() - layout[i + 1], | |
|
186 | gridRect.top()); | |
|
187 | upperBound = qMin(gridRect.top() + gridRect.bottom() - layout[i], | |
|
188 | gridRect.bottom()); | |
|
189 | } else { | |
|
190 | lowerBound = qMin(layout[i], gridRect.bottom()); | |
|
191 | upperBound = qMax(layout[i + 1], gridRect.top()); | |
|
192 | } | |
|
148 | 193 | const qreal delta = lowerBound - upperBound; |
|
149 | 194 | if (axis()->type() != QAbstractAxis::AxisTypeCategory) { |
|
150 | 195 | // Hide label in case visible part of the category at the grid edge is too narrow |
|
151 | 196 | if (delta < boundingRect.height() |
|
152 | 197 | && (lowerBound == gridRect.bottom() || upperBound == gridRect.top())) { |
|
153 | 198 | forceHide = true; |
|
154 | 199 | } else { |
|
155 | 200 | labelItem->setPos(labelItem->pos().x(), |
|
156 | 201 | lowerBound - (delta / 2.0) - center.y()); |
|
157 | 202 | } |
|
158 | 203 | } else { |
|
159 | 204 | QCategoryAxis *categoryAxis = static_cast<QCategoryAxis *>(axis()); |
|
160 | 205 | if (categoryAxis->labelsPosition() == QCategoryAxis::AxisLabelsPositionCenter) { |
|
161 | 206 | if (delta < boundingRect.height() |
|
162 | 207 | && (lowerBound == gridRect.bottom() || upperBound == gridRect.top())) { |
|
163 | 208 | forceHide = true; |
|
164 | 209 | } else { |
|
165 | 210 | labelItem->setPos(labelItem->pos().x(), |
|
166 | 211 | lowerBound - (delta / 2.0) - center.y()); |
|
167 | 212 | } |
|
168 | 213 | } else if (categoryAxis->labelsPosition() |
|
169 | 214 | == QCategoryAxis::AxisLabelsPositionOnValue) { |
|
170 | 215 | labelOnValue = true; |
|
171 | labelItem->setPos(labelItem->pos().x(), upperBound - center.y()); | |
|
216 | if (axis()->isReverse()) { | |
|
217 | labelItem->setPos(labelItem->pos().x(), gridRect.top() + gridRect.bottom() | |
|
218 | - layout[i + 1] - center.y()); | |
|
219 | } else { | |
|
220 | labelItem->setPos(labelItem->pos().x(), upperBound - center.y()); | |
|
221 | } | |
|
172 | 222 | } |
|
173 | 223 | } |
|
174 | 224 | } |
|
175 | 225 | |
|
176 | 226 | //label overlap detection - compensate one pixel for rounding errors |
|
177 | if (labelItem->pos().y() + boundingRect.height() > height || forceHide || | |
|
227 | if (axis()->isReverse()) { | |
|
228 | if (forceHide) | |
|
229 | labelItem->setVisible(false); | |
|
230 | } else if (labelItem->pos().y() + boundingRect.height() > height || forceHide || | |
|
178 | 231 | ((labelItem->pos().y() + (heightDiff / 2.0) - 1.0) > axisRect.bottom() |
|
179 | 232 | && !labelOnValue) || |
|
180 | 233 | (labelItem->pos().y() + (heightDiff / 2.0) < (axisRect.top() - 1.0) && !labelOnValue)) { |
|
181 | 234 | labelItem->setVisible(false); |
|
182 | 235 | } |
|
183 | 236 | else { |
|
184 | 237 | labelItem->setVisible(true); |
|
185 | 238 | height=labelItem->pos().y(); |
|
186 | 239 | } |
|
187 | 240 | |
|
188 | 241 | //shades |
|
189 | 242 | QGraphicsRectItem *shadeItem = 0; |
|
190 | 243 | if (i == 0) |
|
191 | 244 | shadeItem = static_cast<QGraphicsRectItem *>(shades.at(0)); |
|
192 | 245 | else if (i % 2) |
|
193 | 246 | shadeItem = static_cast<QGraphicsRectItem *>(shades.at((i / 2) + 1)); |
|
194 | 247 | if (shadeItem) { |
|
195 | 248 | qreal lowerBound; |
|
196 | 249 | qreal upperBound; |
|
197 | 250 | if (i == 0) { |
|
198 | lowerBound = gridRect.bottom(); | |
|
199 | upperBound = layout[0]; | |
|
200 | } else { | |
|
201 | lowerBound = layout[i]; | |
|
202 | if (i == layout.size() - 1) | |
|
251 | if (axis()->isReverse()) { | |
|
203 | 252 | upperBound = gridRect.top(); |
|
204 | else | |
|
205 | upperBound = qMax(layout[i + 1], gridRect.top()); | |
|
253 | lowerBound = gridRect.top() + gridRect.bottom() - layout[i]; | |
|
254 | } else { | |
|
255 | lowerBound = gridRect.bottom(); | |
|
256 | upperBound = layout[0]; | |
|
257 | } | |
|
258 | } else { | |
|
259 | if (axis()->isReverse()) { | |
|
260 | upperBound = gridRect.top() + gridRect.bottom() - layout[i]; | |
|
261 | if (i == layout.size() - 1) { | |
|
262 | lowerBound = gridRect.bottom(); | |
|
263 | } else { | |
|
264 | lowerBound = qMax(gridRect.top() + gridRect.bottom() - layout[i + 1], | |
|
265 | gridRect.top()); | |
|
266 | } | |
|
267 | } else { | |
|
268 | lowerBound = layout[i]; | |
|
269 | if (i == layout.size() - 1) | |
|
270 | upperBound = gridRect.top(); | |
|
271 | else | |
|
272 | upperBound = qMax(layout[i + 1], gridRect.top()); | |
|
273 | } | |
|
206 | 274 | |
|
207 | 275 | } |
|
208 | 276 | if (lowerBound > gridRect.bottom()) |
|
209 | 277 | lowerBound = gridRect.bottom(); |
|
210 | 278 | if (upperBound < gridRect.top()) |
|
211 | 279 | upperBound = gridRect.top(); |
|
212 | 280 | shadeItem->setRect(gridRect.left(), upperBound, gridRect.width(), |
|
213 | 281 | lowerBound - upperBound); |
|
214 | 282 | if (shadeItem->rect().height() <= 0.0) |
|
215 | 283 | shadeItem->setVisible(false); |
|
216 | 284 | else |
|
217 | 285 | shadeItem->setVisible(true); |
|
218 | 286 | } |
|
219 | 287 | |
|
220 | 288 | // check if the grid line and the axis tick should be shown |
|
221 | 289 | qreal y = gridItem->line().p1().y(); |
|
222 | 290 | if ((y < gridRect.top() || y > gridRect.bottom())) |
|
223 | 291 | { |
|
224 | 292 | gridItem->setVisible(false); |
|
225 | 293 | tickItem->setVisible(false); |
|
226 | 294 | }else{ |
|
227 | 295 | gridItem->setVisible(true); |
|
228 | 296 | tickItem->setVisible(true); |
|
229 | 297 | } |
|
230 | 298 | |
|
231 | 299 | } |
|
232 | 300 | //begin/end grid line in case labels between |
|
233 | 301 | if (intervalAxis()) { |
|
234 | 302 | QGraphicsLineItem *gridLine; |
|
235 | 303 | gridLine = static_cast<QGraphicsLineItem *>(lines.at(layout.size())); |
|
236 | 304 | gridLine->setLine(gridRect.left(), gridRect.top(), gridRect.right(), gridRect.top()); |
|
237 | 305 | gridLine->setVisible(true); |
|
238 | 306 | gridLine = static_cast<QGraphicsLineItem*>(lines.at(layout.size() + 1)); |
|
239 | 307 | gridLine->setLine(gridRect.left(), gridRect.bottom(), gridRect.right(), gridRect.bottom()); |
|
240 | 308 | gridLine->setVisible(true); |
|
241 | 309 | } |
|
242 | 310 | } |
|
243 | 311 | |
|
244 | 312 | QSizeF VerticalAxis::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
|
245 | 313 | { |
|
246 | 314 | Q_UNUSED(constraint); |
|
247 | 315 | QSizeF sh(0, 0); |
|
248 | 316 | |
|
249 | 317 | if (axis()->titleText().isEmpty() || !titleItem()->isVisible()) |
|
250 | 318 | return sh; |
|
251 | 319 | |
|
252 | 320 | switch (which) { |
|
253 | 321 | case Qt::MinimumSize: { |
|
254 | 322 | QRectF titleRect = ChartPresenter::textBoundingRect(axis()->titleFont(), |
|
255 | 323 | QStringLiteral("...")); |
|
256 | 324 | sh = QSizeF(titleRect.height() + (titlePadding() * 2.0), titleRect.width()); |
|
257 | 325 | break; |
|
258 | 326 | } |
|
259 | 327 | case Qt::MaximumSize: |
|
260 | 328 | case Qt::PreferredSize: { |
|
261 | 329 | QRectF titleRect = ChartPresenter::textBoundingRect(axis()->titleFont(), axis()->titleText()); |
|
262 | 330 | sh = QSizeF(titleRect.height() + (titlePadding() * 2.0), titleRect.width()); |
|
263 | 331 | break; |
|
264 | 332 | } |
|
265 | 333 | default: |
|
266 | 334 | break; |
|
267 | 335 | } |
|
268 | 336 | |
|
269 | 337 | return sh; |
|
270 | 338 | } |
|
271 | 339 | |
|
272 | 340 | QT_CHARTS_END_NAMESPACE |
@@ -1,45 +1,58 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #include <private/chartitem_p.h> |
|
20 | 20 | #include <private/qabstractseries_p.h> |
|
21 | 21 | #include <private/abstractdomain_p.h> |
|
22 | 22 | |
|
23 | 23 | QT_CHARTS_BEGIN_NAMESPACE |
|
24 | 24 | |
|
25 | 25 | ChartItem::ChartItem(QAbstractSeriesPrivate *series,QGraphicsItem* item): |
|
26 | 26 | ChartElement(item), |
|
27 | 27 | m_validData(true), |
|
28 | 28 | m_series(series) |
|
29 | 29 | { |
|
30 | 30 | |
|
31 | 31 | } |
|
32 | 32 | |
|
33 | 33 | AbstractDomain* ChartItem::domain() const |
|
34 | 34 | { |
|
35 | 35 | return m_series->domain(); |
|
36 | 36 | } |
|
37 | 37 | |
|
38 | 38 | void ChartItem::handleDomainUpdated() |
|
39 | 39 | { |
|
40 | 40 | qWarning() << __FUNCTION__<< "Slot not implemented"; |
|
41 | 41 | } |
|
42 | 42 | |
|
43 | void ChartItem::reversePainter(QPainter *painter, const QRectF &clipRect) | |
|
44 | { | |
|
45 | if (m_series->reverseXAxis()) { | |
|
46 | painter->translate(clipRect.width(), 0); | |
|
47 | painter->scale(-1, 1); | |
|
48 | } | |
|
49 | ||
|
50 | if (m_series->reverseYAxis()) { | |
|
51 | painter->translate(0, clipRect.height()); | |
|
52 | painter->scale(1, -1); | |
|
53 | } | |
|
54 | } | |
|
55 | ||
|
43 | 56 | #include "moc_chartitem_p.cpp" |
|
44 | 57 | |
|
45 | 58 | QT_CHARTS_END_NAMESPACE |
@@ -1,55 +1,58 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | // W A R N I N G |
|
20 | 20 | // ------------- |
|
21 | 21 | // |
|
22 | 22 | // This file is not part of the Qt Enterprise Chart API. It exists purely as an |
|
23 | 23 | // implementation detail. This header file may change from version to |
|
24 | 24 | // version without notice, or even be removed. |
|
25 | 25 | // |
|
26 | 26 | // We mean it. |
|
27 | 27 | |
|
28 | 28 | #ifndef CHARTITEM_H |
|
29 | 29 | #define CHARTITEM_H |
|
30 | 30 | |
|
31 | 31 | #include <private/chartelement_p.h> |
|
32 | 32 | #include <private/chartpresenter_p.h> |
|
33 | 33 | #include <QtWidgets/QGraphicsItem> |
|
34 | 34 | |
|
35 | 35 | QT_CHARTS_BEGIN_NAMESPACE |
|
36 | 36 | |
|
37 | 37 | class ChartItem : public ChartElement |
|
38 | 38 | { |
|
39 | 39 | Q_OBJECT |
|
40 | 40 | enum ChartItemTypes { AXIS_ITEM = UserType + 1, XYLINE_ITEM }; |
|
41 | 41 | public: |
|
42 | 42 | ChartItem(QAbstractSeriesPrivate *series,QGraphicsItem* item); |
|
43 | 43 | AbstractDomain* domain() const; |
|
44 | 44 | public Q_SLOTS: |
|
45 | 45 | virtual void handleDomainUpdated(); |
|
46 | 46 | |
|
47 | void reversePainter(QPainter *painter, const QRectF &clipRect); | |
|
48 | QAbstractSeriesPrivate* seriesPrivate() const {return m_series;} | |
|
49 | ||
|
47 | 50 | protected: |
|
48 | 51 | bool m_validData; |
|
49 | 52 | private: |
|
50 | 53 | QAbstractSeriesPrivate* m_series; |
|
51 | 54 | }; |
|
52 | 55 | |
|
53 | 56 | QT_CHARTS_END_NAMESPACE |
|
54 | 57 | |
|
55 | 58 | #endif /* CHARTITEM_H */ |
@@ -1,427 +1,431 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #include <private/linechartitem_p.h> |
|
20 | 20 | #include <QtCharts/QLineSeries> |
|
21 | 21 | #include <private/qlineseries_p.h> |
|
22 | 22 | #include <private/chartpresenter_p.h> |
|
23 | 23 | #include <private/polardomain_p.h> |
|
24 | 24 | #include <private/chartthememanager_p.h> |
|
25 | 25 | #include <private/charttheme_p.h> |
|
26 | 26 | #include <QtGui/QPainter> |
|
27 | 27 | #include <QtWidgets/QGraphicsSceneMouseEvent> |
|
28 | 28 | |
|
29 | 29 | QT_CHARTS_BEGIN_NAMESPACE |
|
30 | 30 | |
|
31 | 31 | const qreal mouseEventMinWidth(12); |
|
32 | 32 | |
|
33 | 33 | LineChartItem::LineChartItem(QLineSeries *series, QGraphicsItem *item) |
|
34 | 34 | : XYChart(series,item), |
|
35 | 35 | m_series(series), |
|
36 | 36 | m_pointsVisible(false), |
|
37 | 37 | m_chartType(QChart::ChartTypeUndefined), |
|
38 | 38 | m_pointLabelsVisible(false), |
|
39 | 39 | m_pointLabelsFormat(series->pointLabelsFormat()), |
|
40 | 40 | m_pointLabelsFont(series->pointLabelsFont()), |
|
41 | 41 | m_pointLabelsColor(series->pointLabelsColor()), |
|
42 | 42 | m_mousePressed(false) |
|
43 | 43 | { |
|
44 | 44 | setAcceptHoverEvents(true); |
|
45 | 45 | setFlag(QGraphicsItem::ItemIsSelectable); |
|
46 | 46 | setZValue(ChartPresenter::LineChartZValue); |
|
47 | 47 | QObject::connect(series->d_func(), SIGNAL(updated()), this, SLOT(handleUpdated())); |
|
48 | 48 | QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated())); |
|
49 | 49 | QObject::connect(series, SIGNAL(opacityChanged()), this, SLOT(handleUpdated())); |
|
50 | 50 | QObject::connect(series, SIGNAL(pointLabelsFormatChanged(QString)), |
|
51 | 51 | this, SLOT(handleUpdated())); |
|
52 | 52 | QObject::connect(series, SIGNAL(pointLabelsVisibilityChanged(bool)), |
|
53 | 53 | this, SLOT(handleUpdated())); |
|
54 | 54 | QObject::connect(series, SIGNAL(pointLabelsFontChanged(QFont)), this, SLOT(handleUpdated())); |
|
55 | 55 | QObject::connect(series, SIGNAL(pointLabelsColorChanged(QColor)), this, SLOT(handleUpdated())); |
|
56 | 56 | handleUpdated(); |
|
57 | 57 | } |
|
58 | 58 | |
|
59 | 59 | QRectF LineChartItem::boundingRect() const |
|
60 | 60 | { |
|
61 | 61 | return m_rect; |
|
62 | 62 | } |
|
63 | 63 | |
|
64 | 64 | QPainterPath LineChartItem::shape() const |
|
65 | 65 | { |
|
66 | 66 | return m_shapePath; |
|
67 | 67 | } |
|
68 | 68 | |
|
69 | 69 | void LineChartItem::updateGeometry() |
|
70 | 70 | { |
|
71 | 71 | m_points = geometryPoints(); |
|
72 | 72 | const QVector<QPointF> &points = m_points; |
|
73 | 73 | |
|
74 | 74 | if (points.size() == 0) { |
|
75 | 75 | prepareGeometryChange(); |
|
76 | 76 | m_fullPath = QPainterPath(); |
|
77 | 77 | m_linePath = QPainterPath(); |
|
78 | 78 | m_rect = QRect(); |
|
79 | 79 | return; |
|
80 | 80 | } |
|
81 | 81 | |
|
82 | 82 | QPainterPath linePath; |
|
83 | 83 | QPainterPath fullPath; |
|
84 | 84 | // Use worst case scenario to determine required margin. |
|
85 | 85 | qreal margin = m_linePen.width() * 1.42; |
|
86 | 86 | |
|
87 | 87 | // Area series use component line series that aren't necessarily added to the chart themselves, |
|
88 | 88 | // so check if chart type is forced before trying to obtain it from the chart. |
|
89 | 89 | QChart::ChartType chartType = m_chartType; |
|
90 | 90 | if (chartType == QChart::ChartTypeUndefined) |
|
91 | 91 | chartType = m_series->chart()->chartType(); |
|
92 | 92 | |
|
93 | 93 | // For polar charts, we need special handling for angular (horizontal) |
|
94 | 94 | // points that are off-grid. |
|
95 | 95 | if (chartType == QChart::ChartTypePolar) { |
|
96 | 96 | QPainterPath linePathLeft; |
|
97 | 97 | QPainterPath linePathRight; |
|
98 | 98 | QPainterPath *currentSegmentPath = 0; |
|
99 | 99 | QPainterPath *previousSegmentPath = 0; |
|
100 | 100 | qreal minX = domain()->minX(); |
|
101 | 101 | qreal maxX = domain()->maxX(); |
|
102 | 102 | qreal minY = domain()->minY(); |
|
103 | 103 | QPointF currentSeriesPoint = m_series->at(0); |
|
104 | 104 | QPointF currentGeometryPoint = points.at(0); |
|
105 | 105 | QPointF previousGeometryPoint = points.at(0); |
|
106 | 106 | int size = m_linePen.width(); |
|
107 | 107 | bool pointOffGrid = false; |
|
108 | 108 | bool previousPointWasOffGrid = (currentSeriesPoint.x() < minX || currentSeriesPoint.x() > maxX); |
|
109 | 109 | |
|
110 | 110 | qreal domainRadius = domain()->size().height() / 2.0; |
|
111 | 111 | const QPointF centerPoint(domainRadius, domainRadius); |
|
112 | 112 | |
|
113 | 113 | if (!previousPointWasOffGrid) { |
|
114 | 114 | fullPath.moveTo(points.at(0)); |
|
115 | 115 | if (m_pointsVisible && currentSeriesPoint.y() >= minY) { |
|
116 | 116 | // Do not draw ellipses for points below minimum Y. |
|
117 | 117 | linePath.addEllipse(points.at(0), size, size); |
|
118 | 118 | fullPath.addEllipse(points.at(0), size, size); |
|
119 | 119 | linePath.moveTo(points.at(0)); |
|
120 | 120 | fullPath.moveTo(points.at(0)); |
|
121 | 121 | } |
|
122 | 122 | } |
|
123 | 123 | |
|
124 | 124 | qreal leftMarginLine = centerPoint.x() - margin; |
|
125 | 125 | qreal rightMarginLine = centerPoint.x() + margin; |
|
126 | 126 | qreal horizontal = centerPoint.y(); |
|
127 | 127 | |
|
128 | 128 | // See ScatterChartItem::updateGeometry() for explanation why seriesLastIndex is needed |
|
129 | 129 | const int seriesLastIndex = m_series->count() - 1; |
|
130 | 130 | |
|
131 | 131 | for (int i = 1; i < points.size(); i++) { |
|
132 | 132 | // Interpolating line fragments would be ugly when thick pen is used, |
|
133 | 133 | // so we work around it by utilizing three separate |
|
134 | 134 | // paths for line segments and clip those with custom regions at paint time. |
|
135 | 135 | // "Right" path contains segments that cross the axis line with visible point on the |
|
136 | 136 | // right side of the axis line, as well as segments that have one point within the margin |
|
137 | 137 | // on the right side of the axis line and another point on the right side of the chart. |
|
138 | 138 | // "Left" path contains points with similarly on the left side. |
|
139 | 139 | // "Full" path contains rest of the points. |
|
140 | 140 | // This doesn't yield perfect results always. E.g. when segment covers more than 90 |
|
141 | 141 | // degrees and both of the points are within the margin, one in the top half and one in the |
|
142 | 142 | // bottom half of the chart, the bottom one gets clipped incorrectly. |
|
143 | 143 | // However, this should be rare occurrence in any sensible chart. |
|
144 | 144 | currentSeriesPoint = m_series->at(qMin(seriesLastIndex, i)); |
|
145 | 145 | currentGeometryPoint = points.at(i); |
|
146 | 146 | pointOffGrid = (currentSeriesPoint.x() < minX || currentSeriesPoint.x() > maxX); |
|
147 | 147 | |
|
148 | 148 | // Draw something unless both off-grid |
|
149 | 149 | if (!pointOffGrid || !previousPointWasOffGrid) { |
|
150 | 150 | QPointF intersectionPoint; |
|
151 | 151 | qreal y; |
|
152 | 152 | if (pointOffGrid != previousPointWasOffGrid) { |
|
153 | 153 | if (currentGeometryPoint.x() == previousGeometryPoint.x()) { |
|
154 | 154 | y = currentGeometryPoint.y() + (currentGeometryPoint.y() - previousGeometryPoint.y()) / 2.0; |
|
155 | 155 | } else { |
|
156 | 156 | qreal ratio = (centerPoint.x() - currentGeometryPoint.x()) / (currentGeometryPoint.x() - previousGeometryPoint.x()); |
|
157 | 157 | y = currentGeometryPoint.y() + (currentGeometryPoint.y() - previousGeometryPoint.y()) * ratio; |
|
158 | 158 | } |
|
159 | 159 | intersectionPoint = QPointF(centerPoint.x(), y); |
|
160 | 160 | } |
|
161 | 161 | |
|
162 | 162 | bool dummyOk; // We know points are ok, but this is needed |
|
163 | 163 | qreal currentAngle = 0; |
|
164 | 164 | qreal previousAngle = 0; |
|
165 | 165 | if (const PolarDomain *pd = qobject_cast<const PolarDomain *>(domain())) { |
|
166 | 166 | currentAngle = pd->toAngularCoordinate(currentSeriesPoint.x(), dummyOk); |
|
167 | 167 | previousAngle = pd->toAngularCoordinate(m_series->at(i - 1).x(), dummyOk); |
|
168 | 168 | } else { |
|
169 | 169 | qWarning() << Q_FUNC_INFO << "Unexpected domain: " << domain(); |
|
170 | 170 | } |
|
171 | 171 | if ((qAbs(currentAngle - previousAngle) > 180.0)) { |
|
172 | 172 | // If the angle between two points is over 180 degrees (half X range), |
|
173 | 173 | // any direct segment between them becomes meaningless. |
|
174 | 174 | // In this case two line segments are drawn instead, from previous |
|
175 | 175 | // point to the center and from center to current point. |
|
176 | 176 | if ((previousAngle < 0.0 || (previousAngle <= 180.0 && previousGeometryPoint.x() < rightMarginLine)) |
|
177 | 177 | && previousGeometryPoint.y() < horizontal) { |
|
178 | 178 | currentSegmentPath = &linePathRight; |
|
179 | 179 | } else if ((previousAngle > 360.0 || (previousAngle > 180.0 && previousGeometryPoint.x() > leftMarginLine)) |
|
180 | 180 | && previousGeometryPoint.y() < horizontal) { |
|
181 | 181 | currentSegmentPath = &linePathLeft; |
|
182 | 182 | } else if (previousAngle > 0.0 && previousAngle < 360.0) { |
|
183 | 183 | currentSegmentPath = &linePath; |
|
184 | 184 | } else { |
|
185 | 185 | currentSegmentPath = 0; |
|
186 | 186 | } |
|
187 | 187 | |
|
188 | 188 | if (currentSegmentPath) { |
|
189 | 189 | if (previousSegmentPath != currentSegmentPath) |
|
190 | 190 | currentSegmentPath->moveTo(previousGeometryPoint); |
|
191 | 191 | if (previousPointWasOffGrid) |
|
192 | 192 | fullPath.moveTo(intersectionPoint); |
|
193 | 193 | |
|
194 | 194 | currentSegmentPath->lineTo(centerPoint); |
|
195 | 195 | fullPath.lineTo(centerPoint); |
|
196 | 196 | } |
|
197 | 197 | |
|
198 | 198 | previousSegmentPath = currentSegmentPath; |
|
199 | 199 | |
|
200 | 200 | if ((currentAngle < 0.0 || (currentAngle <= 180.0 && currentGeometryPoint.x() < rightMarginLine)) |
|
201 | 201 | && currentGeometryPoint.y() < horizontal) { |
|
202 | 202 | currentSegmentPath = &linePathRight; |
|
203 | 203 | } else if ((currentAngle > 360.0 || (currentAngle > 180.0 &¤tGeometryPoint.x() > leftMarginLine)) |
|
204 | 204 | && currentGeometryPoint.y() < horizontal) { |
|
205 | 205 | currentSegmentPath = &linePathLeft; |
|
206 | 206 | } else if (currentAngle > 0.0 && currentAngle < 360.0) { |
|
207 | 207 | currentSegmentPath = &linePath; |
|
208 | 208 | } else { |
|
209 | 209 | currentSegmentPath = 0; |
|
210 | 210 | } |
|
211 | 211 | |
|
212 | 212 | if (currentSegmentPath) { |
|
213 | 213 | if (previousSegmentPath != currentSegmentPath) |
|
214 | 214 | currentSegmentPath->moveTo(centerPoint); |
|
215 | 215 | if (!previousSegmentPath) |
|
216 | 216 | fullPath.moveTo(centerPoint); |
|
217 | 217 | |
|
218 | 218 | currentSegmentPath->lineTo(currentGeometryPoint); |
|
219 | 219 | if (pointOffGrid) |
|
220 | 220 | fullPath.lineTo(intersectionPoint); |
|
221 | 221 | else |
|
222 | 222 | fullPath.lineTo(currentGeometryPoint); |
|
223 | 223 | } |
|
224 | 224 | } else { |
|
225 | 225 | if (previousAngle < 0.0 || currentAngle < 0.0 |
|
226 | 226 | || ((previousAngle <= 180.0 && currentAngle <= 180.0) |
|
227 | 227 | && ((previousGeometryPoint.x() < rightMarginLine && previousGeometryPoint.y() < horizontal) |
|
228 | 228 | || (currentGeometryPoint.x() < rightMarginLine && currentGeometryPoint.y() < horizontal)))) { |
|
229 | 229 | currentSegmentPath = &linePathRight; |
|
230 | 230 | } else if (previousAngle > 360.0 || currentAngle > 360.0 |
|
231 | 231 | || ((previousAngle > 180.0 && currentAngle > 180.0) |
|
232 | 232 | && ((previousGeometryPoint.x() > leftMarginLine && previousGeometryPoint.y() < horizontal) |
|
233 | 233 | || (currentGeometryPoint.x() > leftMarginLine && currentGeometryPoint.y() < horizontal)))) { |
|
234 | 234 | currentSegmentPath = &linePathLeft; |
|
235 | 235 | } else { |
|
236 | 236 | currentSegmentPath = &linePath; |
|
237 | 237 | } |
|
238 | 238 | |
|
239 | 239 | if (currentSegmentPath != previousSegmentPath) |
|
240 | 240 | currentSegmentPath->moveTo(previousGeometryPoint); |
|
241 | 241 | if (previousPointWasOffGrid) |
|
242 | 242 | fullPath.moveTo(intersectionPoint); |
|
243 | 243 | |
|
244 | 244 | if (pointOffGrid) |
|
245 | 245 | fullPath.lineTo(intersectionPoint); |
|
246 | 246 | else |
|
247 | 247 | fullPath.lineTo(currentGeometryPoint); |
|
248 | 248 | currentSegmentPath->lineTo(currentGeometryPoint); |
|
249 | 249 | } |
|
250 | 250 | } else { |
|
251 | 251 | currentSegmentPath = 0; |
|
252 | 252 | } |
|
253 | 253 | |
|
254 | 254 | previousPointWasOffGrid = pointOffGrid; |
|
255 | 255 | if (m_pointsVisible && !pointOffGrid && currentSeriesPoint.y() >= minY) { |
|
256 | 256 | linePath.addEllipse(points.at(i), size, size); |
|
257 | 257 | fullPath.addEllipse(points.at(i), size, size); |
|
258 | 258 | linePath.moveTo(points.at(i)); |
|
259 | 259 | fullPath.moveTo(points.at(i)); |
|
260 | 260 | } |
|
261 | 261 | previousSegmentPath = currentSegmentPath; |
|
262 | 262 | previousGeometryPoint = currentGeometryPoint; |
|
263 | 263 | } |
|
264 | 264 | m_linePathPolarRight = linePathRight; |
|
265 | 265 | m_linePathPolarLeft = linePathLeft; |
|
266 | 266 | // Note: This construction of m_fullpath is not perfect. The partial segments that are |
|
267 | 267 | // outside left/right clip regions at axis boundary still generate hover/click events, |
|
268 | 268 | // because shape doesn't get clipped. It doesn't seem possible to do sensibly. |
|
269 | 269 | } else { // not polar |
|
270 | 270 | linePath.moveTo(points.at(0)); |
|
271 | 271 | if (m_pointsVisible) { |
|
272 | 272 | int size = m_linePen.width(); |
|
273 | 273 | linePath.addEllipse(points.at(0), size, size); |
|
274 | 274 | linePath.moveTo(points.at(0)); |
|
275 | 275 | for (int i = 1; i < points.size(); i++) { |
|
276 | 276 | linePath.lineTo(points.at(i)); |
|
277 | 277 | linePath.addEllipse(points.at(i), size, size); |
|
278 | 278 | linePath.moveTo(points.at(i)); |
|
279 | 279 | } |
|
280 | 280 | } else { |
|
281 | 281 | for (int i = 1; i < points.size(); i++) |
|
282 | 282 | linePath.lineTo(points.at(i)); |
|
283 | 283 | } |
|
284 | 284 | fullPath = linePath; |
|
285 | 285 | } |
|
286 | 286 | |
|
287 | 287 | QPainterPathStroker stroker; |
|
288 | 288 | // QPainter::drawLine does not respect join styles, for example BevelJoin becomes MiterJoin. |
|
289 | 289 | // This is why we are prepared for the "worst case" scenario, i.e. use always MiterJoin and |
|
290 | 290 | // multiply line width with square root of two when defining shape and bounding rectangle. |
|
291 | 291 | stroker.setWidth(margin); |
|
292 | 292 | stroker.setJoinStyle(Qt::MiterJoin); |
|
293 | 293 | stroker.setCapStyle(Qt::SquareCap); |
|
294 | 294 | stroker.setMiterLimit(m_linePen.miterLimit()); |
|
295 | 295 | |
|
296 | 296 | QPainterPath checkShapePath = stroker.createStroke(fullPath); |
|
297 | 297 | |
|
298 | 298 | // Only zoom in if the bounding rects of the paths fit inside int limits. QWidget::update() uses |
|
299 | 299 | // a region that has to be compatible with QRect. |
|
300 | 300 | if (checkShapePath.boundingRect().height() <= INT_MAX |
|
301 | 301 | && checkShapePath.boundingRect().width() <= INT_MAX |
|
302 | 302 | && linePath.boundingRect().height() <= INT_MAX |
|
303 | 303 | && linePath.boundingRect().width() <= INT_MAX |
|
304 | 304 | && fullPath.boundingRect().height() <= INT_MAX |
|
305 | 305 | && fullPath.boundingRect().width() <= INT_MAX) { |
|
306 | 306 | prepareGeometryChange(); |
|
307 | 307 | |
|
308 | 308 | m_linePath = linePath; |
|
309 | 309 | m_fullPath = fullPath; |
|
310 | 310 | m_shapePath = checkShapePath; |
|
311 | 311 | |
|
312 | 312 | m_rect = m_shapePath.boundingRect(); |
|
313 | 313 | } else { |
|
314 | 314 | update(); |
|
315 | 315 | } |
|
316 | 316 | } |
|
317 | 317 | |
|
318 | 318 | void LineChartItem::handleUpdated() |
|
319 | 319 | { |
|
320 | 320 | // If points visibility has changed, a geometry update is needed. |
|
321 | 321 | // Also, if pen changes when points are visible, geometry update is needed. |
|
322 | 322 | bool doGeometryUpdate = |
|
323 | 323 | (m_pointsVisible != m_series->pointsVisible()) |
|
324 | 324 | || (m_series->pointsVisible() && (m_linePen != m_series->pen())); |
|
325 | 325 | setVisible(m_series->isVisible()); |
|
326 | 326 | setOpacity(m_series->opacity()); |
|
327 | 327 | m_pointsVisible = m_series->pointsVisible(); |
|
328 | 328 | m_linePen = m_series->pen(); |
|
329 | 329 | m_pointLabelsFormat = m_series->pointLabelsFormat(); |
|
330 | 330 | m_pointLabelsVisible = m_series->pointLabelsVisible(); |
|
331 | 331 | m_pointLabelsFont = m_series->pointLabelsFont(); |
|
332 | 332 | m_pointLabelsColor = m_series->pointLabelsColor(); |
|
333 | 333 | if (doGeometryUpdate) |
|
334 | 334 | updateGeometry(); |
|
335 | 335 | update(); |
|
336 | 336 | } |
|
337 | 337 | |
|
338 | 338 | void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
339 | 339 | { |
|
340 | 340 | Q_UNUSED(widget) |
|
341 | 341 | Q_UNUSED(option) |
|
342 | 342 | |
|
343 | 343 | QRectF clipRect = QRectF(QPointF(0, 0), domain()->size()); |
|
344 | 344 | |
|
345 | 345 | painter->save(); |
|
346 | 346 | painter->setPen(m_linePen); |
|
347 | 347 | bool alwaysUsePath = false; |
|
348 | 348 | |
|
349 | 349 | if (m_series->chart()->chartType() == QChart::ChartTypePolar) { |
|
350 | 350 | qreal halfWidth = domain()->size().width() / 2.0; |
|
351 | 351 | QRectF clipRectLeft = QRectF(0, 0, halfWidth, domain()->size().height()); |
|
352 | 352 | QRectF clipRectRight = QRectF(halfWidth, 0, halfWidth, domain()->size().height()); |
|
353 | 353 | QRegion fullPolarClipRegion(clipRect.toRect(), QRegion::Ellipse); |
|
354 | 354 | QRegion clipRegionLeft(fullPolarClipRegion.intersected(clipRectLeft.toRect())); |
|
355 | 355 | QRegion clipRegionRight(fullPolarClipRegion.intersected(clipRectRight.toRect())); |
|
356 | 356 | painter->setClipRegion(clipRegionLeft); |
|
357 | 357 | painter->drawPath(m_linePathPolarLeft); |
|
358 | 358 | painter->setClipRegion(clipRegionRight); |
|
359 | 359 | painter->drawPath(m_linePathPolarRight); |
|
360 | 360 | painter->setClipRegion(fullPolarClipRegion); |
|
361 | 361 | alwaysUsePath = true; // required for proper clipping |
|
362 | 362 | } else { |
|
363 | 363 | painter->setClipRect(clipRect); |
|
364 | 364 | } |
|
365 | 365 | |
|
366 | reversePainter(painter, clipRect); | |
|
367 | ||
|
366 | 368 | if (m_pointsVisible) { |
|
367 | 369 | painter->setBrush(m_linePen.color()); |
|
368 | 370 | painter->drawPath(m_linePath); |
|
369 | 371 | } else { |
|
370 | 372 | painter->setBrush(QBrush(Qt::NoBrush)); |
|
371 | 373 | if (m_linePen.style() != Qt::SolidLine || alwaysUsePath) { |
|
372 | 374 | // If pen style is not solid line, always fall back to path painting |
|
373 | 375 | // to ensure proper continuity of the pattern |
|
374 | 376 | painter->drawPath(m_linePath); |
|
375 | 377 | } else { |
|
376 | 378 | for (int i(1); i < m_points.size(); i++) |
|
377 | 379 | painter->drawLine(m_points.at(i - 1), m_points.at(i)); |
|
378 | 380 | } |
|
379 | 381 | } |
|
380 | 382 | |
|
383 | reversePainter(painter, clipRect); | |
|
384 | ||
|
381 | 385 | if (m_pointLabelsVisible) |
|
382 | 386 | m_series->d_func()->drawSeriesPointLabels(painter, m_points, m_linePen.width() / 2); |
|
383 | 387 | |
|
384 | 388 | painter->restore(); |
|
385 | 389 | |
|
386 | 390 | } |
|
387 | 391 | |
|
388 | 392 | void LineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
389 | 393 | { |
|
390 | 394 | emit XYChart::pressed(domain()->calculateDomainPoint(event->pos())); |
|
391 | 395 | m_lastMousePos = event->pos(); |
|
392 | 396 | m_mousePressed = true; |
|
393 | 397 | QGraphicsItem::mousePressEvent(event); |
|
394 | 398 | } |
|
395 | 399 | |
|
396 | 400 | void LineChartItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
|
397 | 401 | { |
|
398 | 402 | emit XYChart::hovered(domain()->calculateDomainPoint(event->pos()), true); |
|
399 | 403 | // event->accept(); |
|
400 | 404 | QGraphicsItem::hoverEnterEvent(event); |
|
401 | 405 | } |
|
402 | 406 | |
|
403 | 407 | void LineChartItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) |
|
404 | 408 | { |
|
405 | 409 | emit XYChart::hovered(domain()->calculateDomainPoint(event->pos()), false); |
|
406 | 410 | // event->accept(); |
|
407 | 411 | QGraphicsItem::hoverEnterEvent(event); |
|
408 | 412 | } |
|
409 | 413 | |
|
410 | 414 | void LineChartItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
411 | 415 | { |
|
412 | 416 | emit XYChart::released(domain()->calculateDomainPoint(m_lastMousePos)); |
|
413 | 417 | if (m_mousePressed) |
|
414 | 418 | emit XYChart::clicked(domain()->calculateDomainPoint(m_lastMousePos)); |
|
415 | 419 | m_mousePressed = false; |
|
416 | 420 | QGraphicsItem::mouseReleaseEvent(event); |
|
417 | 421 | } |
|
418 | 422 | |
|
419 | 423 | void LineChartItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) |
|
420 | 424 | { |
|
421 | 425 | emit XYChart::doubleClicked(domain()->calculateDomainPoint(m_lastMousePos)); |
|
422 | 426 | QGraphicsItem::mouseDoubleClickEvent(event); |
|
423 | 427 | } |
|
424 | 428 | |
|
425 | 429 | #include "moc_linechartitem_p.cpp" |
|
426 | 430 | |
|
427 | 431 | QT_CHARTS_END_NAMESPACE |
@@ -1,326 +1,360 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #include <QtCharts/QAbstractSeries> |
|
20 | 20 | #include <private/qabstractseries_p.h> |
|
21 | 21 | #include <private/chartdataset_p.h> |
|
22 | 22 | #include <QtCharts/QChart> |
|
23 | 23 | #include <private/qchart_p.h> |
|
24 | 24 | #include <private/chartitem_p.h> |
|
25 | 25 | #include <private/xydomain_p.h> |
|
26 | 26 | #include <private/xlogydomain_p.h> |
|
27 | 27 | #include <private/logxydomain_p.h> |
|
28 | 28 | #include <private/logxlogydomain_p.h> |
|
29 | 29 | |
|
30 | 30 | QT_CHARTS_BEGIN_NAMESPACE |
|
31 | 31 | |
|
32 | 32 | /*! |
|
33 | 33 | \class QAbstractSeries |
|
34 | 34 | \inmodule Qt Charts |
|
35 | 35 | \brief Base class for all Qt Chart series. |
|
36 | 36 | \mainclass |
|
37 | 37 | |
|
38 | 38 | Usually you use the series type specific inherited classes instead of the base class. |
|
39 | 39 | \sa QXYSeries, QLineSeries, QSplineSeries, QScatterSeries, QAreaSeries, QAbstractBarSeries, QStackedBarSeries, |
|
40 | 40 | QPercentBarSeries, QPieSeries |
|
41 | 41 | */ |
|
42 | 42 | /*! |
|
43 | 43 | \qmltype AbstractSeries |
|
44 | 44 | \instantiates QAbstractSeries |
|
45 | 45 | \inqmlmodule QtCharts |
|
46 | 46 | |
|
47 | 47 | \brief Base class for all Qt Chart series. |
|
48 | 48 | |
|
49 | 49 | AbstractSeries is the base class for all series. |
|
50 | 50 | The class cannot be instantiated by the user. |
|
51 | 51 | */ |
|
52 | 52 | |
|
53 | 53 | /*! |
|
54 | 54 | \enum QAbstractSeries::SeriesType |
|
55 | 55 | |
|
56 | 56 | The type of the series object. |
|
57 | 57 | |
|
58 | 58 | \value SeriesTypeLine |
|
59 | 59 | \value SeriesTypeArea |
|
60 | 60 | \value SeriesTypeBar |
|
61 | 61 | \value SeriesTypeStackedBar |
|
62 | 62 | \value SeriesTypePercentBar |
|
63 | 63 | \value SeriesTypePie |
|
64 | 64 | \value SeriesTypeScatter |
|
65 | 65 | \value SeriesTypeSpline |
|
66 | 66 | \value SeriesTypeHorizontalBar |
|
67 | 67 | \value SeriesTypeHorizontalStackedBar |
|
68 | 68 | \value SeriesTypeHorizontalPercentBar |
|
69 | 69 | \value SeriesTypeBoxPlot |
|
70 | 70 | */ |
|
71 | 71 | |
|
72 | 72 | /*! |
|
73 | 73 | \property QAbstractSeries::type |
|
74 | 74 | The type of the series. |
|
75 | 75 | */ |
|
76 | 76 | /*! |
|
77 | 77 | \qmlproperty ChartView.SeriesType AbstractSeries::type |
|
78 | 78 | The type of the series. |
|
79 | 79 | */ |
|
80 | 80 | |
|
81 | 81 | /*! |
|
82 | 82 | \property QAbstractSeries::name |
|
83 | 83 | \brief name of the series property. The name is shown in legend for series and supports html formatting. |
|
84 | 84 | */ |
|
85 | 85 | /*! |
|
86 | 86 | \qmlproperty string AbstractSeries::name |
|
87 | 87 | Name of the series. The name is shown in legend for series and supports html formatting. |
|
88 | 88 | */ |
|
89 | 89 | |
|
90 | 90 | /*! |
|
91 | 91 | \fn void QAbstractSeries::nameChanged() |
|
92 | 92 | This signal is emitted when the series name changes. |
|
93 | 93 | */ |
|
94 | 94 | /*! |
|
95 | 95 | \qmlsignal AbstractSeries::onNameChanged() |
|
96 | 96 | This signal is emitted when the series name changes. |
|
97 | 97 | */ |
|
98 | 98 | |
|
99 | 99 | /*! |
|
100 | 100 | \property QAbstractSeries::visible |
|
101 | 101 | \brief whether the series is visible or not; true by default. |
|
102 | 102 | */ |
|
103 | 103 | /*! |
|
104 | 104 | \qmlproperty bool AbstractSeries::visible |
|
105 | 105 | Visibility of the series. True by default. |
|
106 | 106 | */ |
|
107 | 107 | |
|
108 | 108 | /*! |
|
109 | 109 | \fn void QAbstractSeries::visibleChanged() |
|
110 | 110 | Emitted when the series visibility changes. |
|
111 | 111 | */ |
|
112 | 112 | /*! |
|
113 | 113 | \qmlsignal AbstractSeries::onVisibleChanged() |
|
114 | 114 | Emitted when the series visibility changes. |
|
115 | 115 | */ |
|
116 | 116 | |
|
117 | 117 | /*! |
|
118 | 118 | \property QAbstractSeries::opacity |
|
119 | 119 | \brief The opacity of the series. |
|
120 | 120 | |
|
121 | 121 | By default the opacity is 1.0. The valid values range from 0.0 (transparent) to 1.0 (opaque). |
|
122 | 122 | */ |
|
123 | 123 | /*! |
|
124 | 124 | \qmlproperty real AbstractSeries::opacity |
|
125 | 125 | The opacity of the series. By default the opacity is 1.0. |
|
126 | 126 | The valid values range from 0.0 (transparent) to 1.0 (opaque). |
|
127 | 127 | */ |
|
128 | 128 | |
|
129 | 129 | /*! |
|
130 | 130 | \fn void QAbstractSeries::opacityChanged() |
|
131 | 131 | Emitted when the opacity of the series changes. |
|
132 | 132 | */ |
|
133 | 133 | /*! |
|
134 | 134 | \qmlsignal AbstractSeries::onOpacityChanged() |
|
135 | 135 | Emitted when the opacity of the series changes. |
|
136 | 136 | */ |
|
137 | 137 | |
|
138 | 138 | /*! |
|
139 | 139 | \internal |
|
140 | 140 | \brief Constructs QAbstractSeries object with \a parent. |
|
141 | 141 | */ |
|
142 | 142 | QAbstractSeries::QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent) : |
|
143 | 143 | QObject(parent), |
|
144 | 144 | d_ptr(&d) |
|
145 | 145 | { |
|
146 | 146 | } |
|
147 | 147 | |
|
148 | 148 | /*! |
|
149 | 149 | \brief Virtual destructor for the chart series. |
|
150 | 150 | */ |
|
151 | 151 | QAbstractSeries::~QAbstractSeries() |
|
152 | 152 | { |
|
153 | 153 | if (d_ptr->m_chart) |
|
154 | 154 | qFatal("Series still bound to a chart when destroyed!"); |
|
155 | 155 | } |
|
156 | 156 | |
|
157 | 157 | void QAbstractSeries::setName(const QString &name) |
|
158 | 158 | { |
|
159 | 159 | if (name != d_ptr->m_name) { |
|
160 | 160 | d_ptr->m_name = name; |
|
161 | 161 | emit nameChanged(); |
|
162 | 162 | } |
|
163 | 163 | } |
|
164 | 164 | |
|
165 | 165 | QString QAbstractSeries::name() const |
|
166 | 166 | { |
|
167 | 167 | return d_ptr->m_name; |
|
168 | 168 | } |
|
169 | 169 | |
|
170 | 170 | void QAbstractSeries::setVisible(bool visible) |
|
171 | 171 | { |
|
172 | 172 | if (visible != d_ptr->m_visible) { |
|
173 | 173 | d_ptr->m_visible = visible; |
|
174 | 174 | emit visibleChanged(); |
|
175 | 175 | } |
|
176 | 176 | } |
|
177 | 177 | |
|
178 | 178 | bool QAbstractSeries::isVisible() const |
|
179 | 179 | { |
|
180 | 180 | return d_ptr->m_visible; |
|
181 | 181 | } |
|
182 | 182 | |
|
183 | 183 | qreal QAbstractSeries::opacity() const |
|
184 | 184 | { |
|
185 | 185 | return d_ptr->m_opacity; |
|
186 | 186 | } |
|
187 | 187 | |
|
188 | 188 | void QAbstractSeries::setOpacity(qreal opacity) |
|
189 | 189 | { |
|
190 | 190 | if (opacity != d_ptr->m_opacity) { |
|
191 | 191 | d_ptr->m_opacity = opacity; |
|
192 | 192 | emit opacityChanged(); |
|
193 | 193 | } |
|
194 | 194 | } |
|
195 | 195 | |
|
196 | 196 | /*! |
|
197 | 197 | \brief Returns the chart where series belongs to. |
|
198 | 198 | |
|
199 | 199 | Set automatically when the series is added to the chart |
|
200 | 200 | and unset when the series is removed from the chart. |
|
201 | 201 | */ |
|
202 | 202 | QChart *QAbstractSeries::chart() const |
|
203 | 203 | { |
|
204 | 204 | return d_ptr->m_chart; |
|
205 | 205 | } |
|
206 | 206 | |
|
207 | 207 | /*! |
|
208 | 208 | \brief Sets the visibility of the series to true. |
|
209 | 209 | |
|
210 | 210 | \sa setVisible(), isVisible() |
|
211 | 211 | */ |
|
212 | 212 | void QAbstractSeries::show() |
|
213 | 213 | { |
|
214 | 214 | setVisible(true); |
|
215 | 215 | } |
|
216 | 216 | |
|
217 | 217 | /*! |
|
218 | 218 | \brief Sets the visibility of the series to false. |
|
219 | 219 | |
|
220 | 220 | \sa setVisible(), isVisible() |
|
221 | 221 | */ |
|
222 | 222 | void QAbstractSeries::hide() |
|
223 | 223 | { |
|
224 | 224 | setVisible(false); |
|
225 | 225 | } |
|
226 | 226 | |
|
227 | 227 | /*! |
|
228 | 228 | Attach \a axis to the series. |
|
229 | 229 | \return true if the axis was attached successfully, false otherwise. |
|
230 | 230 | \note If multiple axes of same orientation are attached to same series, |
|
231 | 231 | they will have same min/max ranges. |
|
232 | 232 | \sa QChart::addAxis(), QChart::createDefaultAxes() |
|
233 | 233 | */ |
|
234 | 234 | bool QAbstractSeries::attachAxis(QAbstractAxis* axis) |
|
235 | 235 | { |
|
236 | 236 | if(d_ptr->m_chart) { |
|
237 | 237 | return d_ptr->m_chart->d_ptr->m_dataset->attachAxis(this, axis); |
|
238 | 238 | } else { |
|
239 | 239 | qWarning()<<"Series not in the chart. Please addSeries to chart first."; |
|
240 | 240 | return false; |
|
241 | 241 | } |
|
242 | 242 | } |
|
243 | 243 | |
|
244 | 244 | /*! |
|
245 | 245 | Detach \a axis from the series. |
|
246 | 246 | \return true if the axis was detached successfully, false otherwise. |
|
247 | 247 | \sa QChart::removeAxis() |
|
248 | 248 | */ |
|
249 | 249 | bool QAbstractSeries::detachAxis(QAbstractAxis* axis) |
|
250 | 250 | { |
|
251 | 251 | if(d_ptr->m_chart) { |
|
252 | 252 | return d_ptr->m_chart->d_ptr->m_dataset->detachAxis(this, axis); |
|
253 | 253 | } |
|
254 | 254 | else { |
|
255 | 255 | qWarning()<<"Series not in the chart. Please addSeries to chart first."; |
|
256 | 256 | return false; |
|
257 | 257 | } |
|
258 | 258 | } |
|
259 | 259 | |
|
260 | 260 | /*! |
|
261 | 261 | Returns the list of axes attached to the series. Usually there is an x-axis and a y-axis attached to a series, except |
|
262 | 262 | in case of a QPieSeries, which does not have any axes attached. |
|
263 | 263 | \sa attachAxis(), detachAxis() |
|
264 | 264 | */ |
|
265 | 265 | QList<QAbstractAxis*> QAbstractSeries::attachedAxes() |
|
266 | 266 | { |
|
267 | 267 | return d_ptr->m_axes; |
|
268 | 268 | } |
|
269 | 269 | |
|
270 | 270 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
|
271 | 271 | |
|
272 | 272 | QAbstractSeriesPrivate::QAbstractSeriesPrivate(QAbstractSeries *q) |
|
273 | 273 | : q_ptr(q), |
|
274 | 274 | m_chart(0), |
|
275 | 275 | m_item(0), |
|
276 | 276 | m_domain(new XYDomain()), |
|
277 | 277 | m_visible(true), |
|
278 | 278 | m_opacity(1.0) |
|
279 | 279 | { |
|
280 | 280 | } |
|
281 | 281 | |
|
282 | 282 | QAbstractSeriesPrivate::~QAbstractSeriesPrivate() |
|
283 | 283 | { |
|
284 | 284 | } |
|
285 | 285 | |
|
286 | 286 | void QAbstractSeriesPrivate::setDomain(AbstractDomain* domain) |
|
287 | 287 | { |
|
288 | 288 | Q_ASSERT(domain); |
|
289 | 289 | if(m_domain.data()!=domain) { |
|
290 | 290 | if(!m_item.isNull()) QObject::disconnect(m_domain.data(), SIGNAL(updated()), m_item.data(), SLOT(handleDomainUpdated())); |
|
291 | 291 | m_domain.reset(domain); |
|
292 | 292 | if(!m_item.isNull()) { |
|
293 | 293 | QObject::connect(m_domain.data(), SIGNAL(updated()),m_item.data(), SLOT(handleDomainUpdated())); |
|
294 | 294 | m_item->handleDomainUpdated(); |
|
295 | 295 | } |
|
296 | 296 | } |
|
297 | 297 | } |
|
298 | 298 | |
|
299 | 299 | void QAbstractSeriesPrivate::setPresenter(ChartPresenter *presenter) |
|
300 | 300 | { |
|
301 | 301 | m_presenter = presenter; |
|
302 | 302 | } |
|
303 | 303 | |
|
304 | 304 | ChartPresenter *QAbstractSeriesPrivate::presenter() const |
|
305 | 305 | { |
|
306 | 306 | return m_presenter; |
|
307 | 307 | } |
|
308 | 308 | |
|
309 | 309 | void QAbstractSeriesPrivate::initializeGraphics(QGraphicsItem* parent) |
|
310 | 310 | { |
|
311 | 311 | Q_ASSERT(!m_item.isNull()); |
|
312 | 312 | Q_UNUSED(parent); |
|
313 | 313 | QObject::connect(m_domain.data(), SIGNAL(updated()),m_item.data(), SLOT(handleDomainUpdated())); |
|
314 | 314 | } |
|
315 | 315 | |
|
316 | 316 | void QAbstractSeriesPrivate::initializeAnimations(QChart::AnimationOptions options) |
|
317 | 317 | { |
|
318 | 318 | Q_UNUSED(options); |
|
319 | 319 | } |
|
320 | 320 | |
|
321 | bool QAbstractSeriesPrivate::reverseXAxis() | |
|
322 | { | |
|
323 | bool reverseXAxis = false; | |
|
324 | if (m_axes.size() != 0 && !(m_chart->chartType() == QChart::ChartTypePolar)) { | |
|
325 | int i = 0; | |
|
326 | while (i < m_axes.size()) { | |
|
327 | if (m_axes.at(i)->orientation() == Qt::Horizontal && m_axes.at(i)->isReverse()) { | |
|
328 | reverseXAxis = true; | |
|
329 | break; | |
|
330 | } | |
|
331 | i++; | |
|
332 | } | |
|
333 | } | |
|
334 | ||
|
335 | return reverseXAxis; | |
|
336 | } | |
|
337 | ||
|
338 | bool QAbstractSeriesPrivate::reverseYAxis() | |
|
339 | { | |
|
340 | bool reverseYAxis = false; | |
|
341 | if (m_axes.size() != 0 && !(m_chart->chartType() == QChart::ChartTypePolar)) { | |
|
342 | int i = 0; | |
|
343 | while (i < m_axes.size()) { | |
|
344 | if (m_axes.at(i)->orientation() == Qt::Vertical && m_axes.at(i)->isReverse()) { | |
|
345 | reverseYAxis = true; | |
|
346 | break; | |
|
347 | } | |
|
348 | i++; | |
|
349 | } | |
|
350 | } | |
|
351 | ||
|
352 | return reverseYAxis; | |
|
353 | } | |
|
354 | ||
|
321 | 355 | #include "moc_qabstractseries.cpp" |
|
322 | 356 | #include "moc_qabstractseries_p.cpp" |
|
323 | 357 | |
|
324 | 358 | QT_CHARTS_END_NAMESPACE |
|
325 | 359 | |
|
326 | 360 |
@@ -1,105 +1,108 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | // W A R N I N G |
|
20 | 20 | // ------------- |
|
21 | 21 | // |
|
22 | 22 | // This file is not part of the Qt Enterprise Chart API. It exists purely as an |
|
23 | 23 | // implementation detail. This header file may change from version to |
|
24 | 24 | // version without notice, or even be removed. |
|
25 | 25 | // |
|
26 | 26 | // We mean it. |
|
27 | 27 | |
|
28 | 28 | #ifndef QABSTRACTSERIES_P_H |
|
29 | 29 | #define QABSTRACTSERIES_P_H |
|
30 | 30 | |
|
31 | 31 | #include <QtCharts/QAbstractSeries> |
|
32 | 32 | #include <QtCharts/QChart> |
|
33 | 33 | #include <private/abstractdomain_p.h> |
|
34 | 34 | |
|
35 | 35 | QT_BEGIN_NAMESPACE |
|
36 | 36 | class QGraphicsItem; |
|
37 | 37 | QT_END_NAMESPACE |
|
38 | 38 | |
|
39 | 39 | QT_CHARTS_BEGIN_NAMESPACE |
|
40 | 40 | |
|
41 | 41 | class ChartPresenter; |
|
42 | 42 | class ChartElement; |
|
43 | 43 | class LegendMarker; |
|
44 | 44 | class QLegend; |
|
45 | 45 | class ChartDataSet; |
|
46 | 46 | class QAbstractAxis; |
|
47 | 47 | class QLegendMarker; |
|
48 | 48 | class ChartTheme; |
|
49 | 49 | class ChartAnimation; |
|
50 | 50 | class ChartItem; |
|
51 | 51 | class BoxPlotChartItem; |
|
52 | 52 | |
|
53 | 53 | class QAbstractSeriesPrivate : public QObject |
|
54 | 54 | { |
|
55 | 55 | Q_OBJECT |
|
56 | 56 | public: |
|
57 | 57 | QAbstractSeriesPrivate(QAbstractSeries *q); |
|
58 | 58 | ~QAbstractSeriesPrivate(); |
|
59 | 59 | |
|
60 | 60 | virtual void initializeDomain() = 0; |
|
61 | 61 | virtual void initializeAxes() = 0; |
|
62 | 62 | virtual void initializeTheme(int index, ChartTheme* theme, bool forced = false) = 0; |
|
63 | 63 | virtual void initializeGraphics(QGraphicsItem* parent) = 0; |
|
64 | 64 | virtual void initializeAnimations(QChart::AnimationOptions options) = 0; |
|
65 | 65 | |
|
66 | 66 | virtual QList<QLegendMarker*> createLegendMarkers(QLegend* legend) = 0; |
|
67 | 67 | |
|
68 | 68 | virtual QAbstractAxis::AxisType defaultAxisType(Qt::Orientation) const = 0; |
|
69 | 69 | virtual QAbstractAxis* createDefaultAxis(Qt::Orientation) const = 0; |
|
70 | 70 | |
|
71 | 71 | ChartItem* chartItem() { return m_item.data(); } |
|
72 | 72 | |
|
73 | 73 | virtual void setDomain(AbstractDomain* domain); |
|
74 | 74 | AbstractDomain* domain() { return m_domain.data(); } |
|
75 | 75 | |
|
76 | 76 | virtual void setPresenter(ChartPresenter *presenter); |
|
77 | 77 | ChartPresenter *presenter() const; |
|
78 | 78 | |
|
79 | 79 | QChart* chart() { return m_chart; } |
|
80 | bool reverseXAxis(); | |
|
81 | bool reverseYAxis(); | |
|
80 | 82 | |
|
81 | 83 | Q_SIGNALS: |
|
82 | 84 | void countChanged(); |
|
83 | 85 | |
|
84 | 86 | protected: |
|
85 | 87 | QAbstractSeries *q_ptr; |
|
86 | 88 | QChart *m_chart; |
|
87 | 89 | QScopedPointer<ChartItem> m_item; |
|
88 | 90 | QList<QAbstractAxis*> m_axes; |
|
91 | ||
|
89 | 92 | private: |
|
90 | 93 | QScopedPointer<AbstractDomain> m_domain; |
|
91 | 94 | QString m_name; |
|
92 | 95 | bool m_visible; |
|
93 | 96 | qreal m_opacity; |
|
94 | 97 | ChartPresenter *m_presenter; |
|
95 | 98 | |
|
96 | 99 | friend class QAbstractSeries; |
|
97 | 100 | friend class ChartDataSet; |
|
98 | 101 | friend class ChartPresenter; |
|
99 | 102 | friend class QLegendPrivate; |
|
100 | 103 | friend class BoxPlotChartItem; |
|
101 | 104 | }; |
|
102 | 105 | |
|
103 | 106 | QT_CHARTS_END_NAMESPACE |
|
104 | 107 | |
|
105 | 108 | #endif |
@@ -1,251 +1,261 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #include <private/scatterchartitem_p.h> |
|
20 | 20 | #include <QtCharts/QScatterSeries> |
|
21 | 21 | #include <private/qscatterseries_p.h> |
|
22 | 22 | #include <private/chartpresenter_p.h> |
|
23 | 23 | #include <private/abstractdomain_p.h> |
|
24 | 24 | #include <QtCharts/QChart> |
|
25 | 25 | #include <QtGui/QPainter> |
|
26 | 26 | #include <QtWidgets/QGraphicsScene> |
|
27 | 27 | #include <QtCore/QDebug> |
|
28 | 28 | #include <QtWidgets/QGraphicsSceneMouseEvent> |
|
29 | 29 | |
|
30 | 30 | QT_CHARTS_BEGIN_NAMESPACE |
|
31 | 31 | |
|
32 | 32 | ScatterChartItem::ScatterChartItem(QScatterSeries *series, QGraphicsItem *item) |
|
33 | 33 | : XYChart(series,item), |
|
34 | 34 | m_series(series), |
|
35 | 35 | m_items(this), |
|
36 | 36 | m_visible(true), |
|
37 | 37 | m_shape(QScatterSeries::MarkerShapeRectangle), |
|
38 | 38 | m_size(15), |
|
39 | 39 | m_pointLabelsVisible(false), |
|
40 | 40 | m_pointLabelsFormat(series->pointLabelsFormat()), |
|
41 | 41 | m_pointLabelsFont(series->pointLabelsFont()), |
|
42 | 42 | m_pointLabelsColor(series->pointLabelsColor()), |
|
43 | 43 | m_mousePressed(false) |
|
44 | 44 | { |
|
45 | 45 | QObject::connect(m_series->d_func(), SIGNAL(updated()), this, SLOT(handleUpdated())); |
|
46 | 46 | QObject::connect(m_series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated())); |
|
47 | 47 | QObject::connect(m_series, SIGNAL(opacityChanged()), this, SLOT(handleUpdated())); |
|
48 | 48 | QObject::connect(series, SIGNAL(pointLabelsFormatChanged(QString)), |
|
49 | 49 | this, SLOT(handleUpdated())); |
|
50 | 50 | QObject::connect(series, SIGNAL(pointLabelsVisibilityChanged(bool)), |
|
51 | 51 | this, SLOT(handleUpdated())); |
|
52 | 52 | QObject::connect(series, SIGNAL(pointLabelsFontChanged(QFont)), this, SLOT(handleUpdated())); |
|
53 | 53 | QObject::connect(series, SIGNAL(pointLabelsColorChanged(QColor)), this, SLOT(handleUpdated())); |
|
54 | 54 | |
|
55 | 55 | setZValue(ChartPresenter::ScatterSeriesZValue); |
|
56 | 56 | setFlags(QGraphicsItem::ItemClipsChildrenToShape); |
|
57 | 57 | |
|
58 | 58 | handleUpdated(); |
|
59 | 59 | |
|
60 | 60 | m_items.setHandlesChildEvents(false); |
|
61 | 61 | } |
|
62 | 62 | |
|
63 | 63 | QRectF ScatterChartItem::boundingRect() const |
|
64 | 64 | { |
|
65 | 65 | return m_rect; |
|
66 | 66 | } |
|
67 | 67 | |
|
68 | 68 | void ScatterChartItem::createPoints(int count) |
|
69 | 69 | { |
|
70 | 70 | for (int i = 0; i < count; ++i) { |
|
71 | 71 | |
|
72 | 72 | QGraphicsItem *item = 0; |
|
73 | 73 | |
|
74 | 74 | switch (m_shape) { |
|
75 | 75 | case QScatterSeries::MarkerShapeCircle: { |
|
76 | 76 | item = new CircleMarker(0, 0, m_size, m_size, this); |
|
77 | 77 | const QRectF &rect = item->boundingRect(); |
|
78 | 78 | item->setPos(-rect.width() / 2, -rect.height() / 2); |
|
79 | 79 | break; |
|
80 | 80 | } |
|
81 | 81 | case QScatterSeries::MarkerShapeRectangle: |
|
82 | 82 | item = new RectangleMarker(0, 0, m_size, m_size, this); |
|
83 | 83 | item->setPos(-m_size / 2, -m_size / 2); |
|
84 | 84 | break; |
|
85 | 85 | default: |
|
86 | 86 | qWarning() << "Unsupported marker type"; |
|
87 | 87 | break; |
|
88 | 88 | } |
|
89 | 89 | m_items.addToGroup(item); |
|
90 | 90 | } |
|
91 | 91 | } |
|
92 | 92 | |
|
93 | 93 | void ScatterChartItem::deletePoints(int count) |
|
94 | 94 | { |
|
95 | 95 | QList<QGraphicsItem *> items = m_items.childItems(); |
|
96 | 96 | |
|
97 | 97 | for (int i = 0; i < count; ++i) { |
|
98 | 98 | QGraphicsItem *item = items.takeLast(); |
|
99 | 99 | m_markerMap.remove(item); |
|
100 | 100 | delete(item); |
|
101 | 101 | } |
|
102 | 102 | } |
|
103 | 103 | |
|
104 | 104 | void ScatterChartItem::markerSelected(QGraphicsItem *marker) |
|
105 | 105 | { |
|
106 | 106 | emit XYChart::clicked(m_markerMap[marker]); |
|
107 | 107 | } |
|
108 | 108 | |
|
109 | 109 | void ScatterChartItem::markerHovered(QGraphicsItem *marker, bool state) |
|
110 | 110 | { |
|
111 | 111 | emit XYChart::hovered(m_markerMap[marker], state); |
|
112 | 112 | } |
|
113 | 113 | |
|
114 | 114 | void ScatterChartItem::markerPressed(QGraphicsItem *marker) |
|
115 | 115 | { |
|
116 | 116 | emit XYChart::pressed(m_markerMap[marker]); |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | void ScatterChartItem::markerReleased(QGraphicsItem *marker) |
|
120 | 120 | { |
|
121 | 121 | emit XYChart::released(m_markerMap[marker]); |
|
122 | 122 | } |
|
123 | 123 | |
|
124 | 124 | void ScatterChartItem::markerDoubleClicked(QGraphicsItem *marker) |
|
125 | 125 | { |
|
126 | 126 | emit XYChart::doubleClicked(m_markerMap[marker]); |
|
127 | 127 | } |
|
128 | 128 | |
|
129 | 129 | void ScatterChartItem::updateGeometry() |
|
130 | 130 | { |
|
131 | 131 | |
|
132 | 132 | const QVector<QPointF>& points = geometryPoints(); |
|
133 | 133 | |
|
134 | 134 | if (points.size() == 0) { |
|
135 | 135 | deletePoints(m_items.childItems().count()); |
|
136 | 136 | return; |
|
137 | 137 | } |
|
138 | 138 | |
|
139 | 139 | int diff = m_items.childItems().size() - points.size(); |
|
140 | 140 | |
|
141 | 141 | if (diff > 0) |
|
142 | 142 | deletePoints(diff); |
|
143 | 143 | else if (diff < 0) |
|
144 | 144 | createPoints(-diff); |
|
145 | 145 | |
|
146 | 146 | if (diff != 0) |
|
147 | 147 | handleUpdated(); |
|
148 | 148 | |
|
149 | 149 | QList<QGraphicsItem *> items = m_items.childItems(); |
|
150 | 150 | |
|
151 | 151 | QRectF clipRect(QPointF(0,0),domain()->size()); |
|
152 | 152 | |
|
153 | 153 | // Only zoom in if the clipRect fits inside int limits. QWidget::update() uses |
|
154 | 154 | // a region that has to be compatible with QRect. |
|
155 | 155 | if (clipRect.height() <= INT_MAX |
|
156 | 156 | && clipRect.width() <= INT_MAX) { |
|
157 | 157 | QVector<bool> offGridStatus = offGridStatusVector(); |
|
158 | 158 | const int seriesLastIndex = m_series->count() - 1; |
|
159 | 159 | |
|
160 | 160 | for (int i = 0; i < points.size(); i++) { |
|
161 | 161 | QGraphicsItem *item = items.at(i); |
|
162 | 162 | const QPointF &point = points.at(i); |
|
163 | 163 | const QRectF &rect = item->boundingRect(); |
|
164 | 164 | // During remove animation series may have different number of points, |
|
165 | 165 | // so ensure we don't go over the index. Animation handling itself ensures that |
|
166 | 166 | // if there is actually no points in the series, then it won't generate a fake point, |
|
167 | 167 | // so we can be assured there is always at least one point in m_series here. |
|
168 | 168 | // Note that marker map values can be technically incorrect during the animation, |
|
169 | 169 | // if it was caused by an insert, but this shouldn't be a problem as the points are |
|
170 | 170 | // fake anyway. After remove animation stops, geometry is updated to correct one. |
|
171 | 171 | m_markerMap[item] = m_series->at(qMin(seriesLastIndex, i)); |
|
172 | item->setPos(point.x() - rect.width() / 2, point.y() - rect.height() / 2); | |
|
172 | QPointF position; | |
|
173 | if (seriesPrivate()->reverseXAxis()) | |
|
174 | position.setX(domain()->size().width() - point.x() - rect.width() / 2); | |
|
175 | else | |
|
176 | position.setX(point.x() - rect.width() / 2); | |
|
177 | if (seriesPrivate()->reverseYAxis()) | |
|
178 | position.setY(domain()->size().height() - point.y() - rect.height() / 2); | |
|
179 | else | |
|
180 | position.setY(point.y() - rect.height() / 2); | |
|
181 | item->setPos(position); | |
|
182 | ||
|
173 | 183 | |
|
174 | 184 | if (!m_visible || offGridStatus.at(i)) |
|
175 | 185 | item->setVisible(false); |
|
176 | 186 | else |
|
177 | 187 | item->setVisible(true); |
|
178 | 188 | } |
|
179 | 189 | |
|
180 | 190 | prepareGeometryChange(); |
|
181 | 191 | m_rect = clipRect; |
|
182 | 192 | } |
|
183 | 193 | } |
|
184 | 194 | |
|
185 | 195 | void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
186 | 196 | { |
|
187 | 197 | Q_UNUSED(option) |
|
188 | 198 | Q_UNUSED(widget) |
|
189 | 199 | |
|
190 | 200 | QRectF clipRect = QRectF(QPointF(0, 0), domain()->size()); |
|
191 | 201 | |
|
192 | 202 | painter->save(); |
|
193 | 203 | painter->setClipRect(clipRect); |
|
194 | 204 | |
|
195 | 205 | if (m_pointLabelsVisible) { |
|
196 | 206 | m_series->d_func()->drawSeriesPointLabels(painter, m_points, |
|
197 | 207 | m_series->markerSize() / 2 |
|
198 | 208 | + m_series->pen().width()); |
|
199 | 209 | } |
|
200 | 210 | |
|
201 | 211 | painter->restore(); |
|
202 | 212 | } |
|
203 | 213 | |
|
204 | 214 | void ScatterChartItem::setPen(const QPen &pen) |
|
205 | 215 | { |
|
206 | 216 | foreach (QGraphicsItem *item , m_items.childItems()) |
|
207 | 217 | static_cast<QAbstractGraphicsShapeItem*>(item)->setPen(pen); |
|
208 | 218 | } |
|
209 | 219 | |
|
210 | 220 | void ScatterChartItem::setBrush(const QBrush &brush) |
|
211 | 221 | { |
|
212 | 222 | foreach (QGraphicsItem *item , m_items.childItems()) |
|
213 | 223 | static_cast<QAbstractGraphicsShapeItem*>(item)->setBrush(brush); |
|
214 | 224 | } |
|
215 | 225 | |
|
216 | 226 | void ScatterChartItem::handleUpdated() |
|
217 | 227 | { |
|
218 | 228 | int count = m_items.childItems().count(); |
|
219 | 229 | |
|
220 | 230 | if (count == 0) |
|
221 | 231 | return; |
|
222 | 232 | |
|
223 | 233 | bool recreate = m_visible != m_series->isVisible() |
|
224 | 234 | || m_size != m_series->markerSize() |
|
225 | 235 | || m_shape != m_series->markerShape(); |
|
226 | 236 | |
|
227 | 237 | m_visible = m_series->isVisible(); |
|
228 | 238 | m_size = m_series->markerSize(); |
|
229 | 239 | m_shape = m_series->markerShape(); |
|
230 | 240 | setOpacity(m_series->opacity()); |
|
231 | 241 | m_pointLabelsFormat = m_series->pointLabelsFormat(); |
|
232 | 242 | m_pointLabelsVisible = m_series->pointLabelsVisible(); |
|
233 | 243 | m_pointLabelsFont = m_series->pointLabelsFont(); |
|
234 | 244 | m_pointLabelsColor = m_series->pointLabelsColor(); |
|
235 | 245 | |
|
236 | 246 | if (recreate) { |
|
237 | 247 | deletePoints(count); |
|
238 | 248 | createPoints(count); |
|
239 | 249 | |
|
240 | 250 | // Updating geometry is now safe, because it won't call handleUpdated unless it creates/deletes points |
|
241 | 251 | updateGeometry(); |
|
242 | 252 | } |
|
243 | 253 | |
|
244 | 254 | setPen(m_series->pen()); |
|
245 | 255 | setBrush(m_series->brush()); |
|
246 | 256 | update(); |
|
247 | 257 | } |
|
248 | 258 | |
|
249 | 259 | #include "moc_scatterchartitem_p.cpp" |
|
250 | 260 | |
|
251 | 261 | QT_CHARTS_END_NAMESPACE |
@@ -1,502 +1,506 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #include <private/splinechartitem_p.h> |
|
20 | 20 | #include <private/qsplineseries_p.h> |
|
21 | 21 | #include <private/chartpresenter_p.h> |
|
22 | 22 | #include <private/splineanimation_p.h> |
|
23 | 23 | #include <private/polardomain_p.h> |
|
24 | 24 | #include <QtGui/QPainter> |
|
25 | 25 | #include <QtWidgets/QGraphicsSceneMouseEvent> |
|
26 | 26 | |
|
27 | 27 | QT_CHARTS_BEGIN_NAMESPACE |
|
28 | 28 | |
|
29 | 29 | SplineChartItem::SplineChartItem(QSplineSeries *series, QGraphicsItem *item) |
|
30 | 30 | : XYChart(series,item), |
|
31 | 31 | m_series(series), |
|
32 | 32 | m_pointsVisible(false), |
|
33 | 33 | m_animation(0), |
|
34 | 34 | m_pointLabelsVisible(false), |
|
35 | 35 | m_pointLabelsFormat(series->pointLabelsFormat()), |
|
36 | 36 | m_pointLabelsFont(series->pointLabelsFont()), |
|
37 | 37 | m_pointLabelsColor(series->pointLabelsColor()), |
|
38 | 38 | m_mousePressed(false) |
|
39 | 39 | { |
|
40 | 40 | setAcceptHoverEvents(true); |
|
41 | 41 | setFlag(QGraphicsItem::ItemIsSelectable); |
|
42 | 42 | setZValue(ChartPresenter::SplineChartZValue); |
|
43 | 43 | QObject::connect(m_series->d_func(), SIGNAL(updated()), this, SLOT(handleUpdated())); |
|
44 | 44 | QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated())); |
|
45 | 45 | QObject::connect(series, SIGNAL(opacityChanged()), this, SLOT(handleUpdated())); |
|
46 | 46 | QObject::connect(series, SIGNAL(pointLabelsFormatChanged(QString)), |
|
47 | 47 | this, SLOT(handleUpdated())); |
|
48 | 48 | QObject::connect(series, SIGNAL(pointLabelsVisibilityChanged(bool)), |
|
49 | 49 | this, SLOT(handleUpdated())); |
|
50 | 50 | QObject::connect(series, SIGNAL(pointLabelsFontChanged(QFont)), this, SLOT(handleUpdated())); |
|
51 | 51 | QObject::connect(series, SIGNAL(pointLabelsColorChanged(QColor)), this, SLOT(handleUpdated())); |
|
52 | 52 | handleUpdated(); |
|
53 | 53 | } |
|
54 | 54 | |
|
55 | 55 | QRectF SplineChartItem::boundingRect() const |
|
56 | 56 | { |
|
57 | 57 | return m_rect; |
|
58 | 58 | } |
|
59 | 59 | |
|
60 | 60 | QPainterPath SplineChartItem::shape() const |
|
61 | 61 | { |
|
62 | 62 | return m_fullPath; |
|
63 | 63 | } |
|
64 | 64 | |
|
65 | 65 | void SplineChartItem::setAnimation(SplineAnimation *animation) |
|
66 | 66 | { |
|
67 | 67 | m_animation = animation; |
|
68 | 68 | XYChart::setAnimation(animation); |
|
69 | 69 | } |
|
70 | 70 | |
|
71 | 71 | ChartAnimation *SplineChartItem::animation() const |
|
72 | 72 | { |
|
73 | 73 | return m_animation; |
|
74 | 74 | } |
|
75 | 75 | |
|
76 | 76 | void SplineChartItem::setControlGeometryPoints(QVector<QPointF>& points) |
|
77 | 77 | { |
|
78 | 78 | m_controlPoints = points; |
|
79 | 79 | } |
|
80 | 80 | |
|
81 | 81 | QVector<QPointF> SplineChartItem::controlGeometryPoints() const |
|
82 | 82 | { |
|
83 | 83 | return m_controlPoints; |
|
84 | 84 | } |
|
85 | 85 | |
|
86 | 86 | void SplineChartItem::updateChart(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints, int index) |
|
87 | 87 | { |
|
88 | 88 | QVector<QPointF> controlPoints; |
|
89 | 89 | if (newPoints.count() >= 2) |
|
90 | 90 | controlPoints = calculateControlPoints(newPoints); |
|
91 | 91 | |
|
92 | 92 | if (m_animation) |
|
93 | 93 | m_animation->setup(oldPoints, newPoints, m_controlPoints, controlPoints, index); |
|
94 | 94 | |
|
95 | 95 | m_points = newPoints; |
|
96 | 96 | m_controlPoints = controlPoints; |
|
97 | 97 | setDirty(false); |
|
98 | 98 | |
|
99 | 99 | if (m_animation) |
|
100 | 100 | presenter()->startAnimation(m_animation); |
|
101 | 101 | else |
|
102 | 102 | updateGeometry(); |
|
103 | 103 | } |
|
104 | 104 | |
|
105 | 105 | void SplineChartItem::updateGeometry() |
|
106 | 106 | { |
|
107 | 107 | const QVector<QPointF> &points = m_points; |
|
108 | 108 | const QVector<QPointF> &controlPoints = m_controlPoints; |
|
109 | 109 | |
|
110 | 110 | if ((points.size() < 2) || (controlPoints.size() < 2)) { |
|
111 | 111 | prepareGeometryChange(); |
|
112 | 112 | m_path = QPainterPath(); |
|
113 | 113 | m_rect = QRect(); |
|
114 | 114 | return; |
|
115 | 115 | } |
|
116 | 116 | |
|
117 | 117 | Q_ASSERT(points.count() * 2 - 2 == controlPoints.count()); |
|
118 | 118 | |
|
119 | 119 | QPainterPath splinePath; |
|
120 | 120 | QPainterPath fullPath; |
|
121 | 121 | // Use worst case scenario to determine required margin. |
|
122 | 122 | qreal margin = m_linePen.width() * 1.42; |
|
123 | 123 | |
|
124 | 124 | if (m_series->chart()->chartType() == QChart::ChartTypePolar) { |
|
125 | 125 | QPainterPath splinePathLeft; |
|
126 | 126 | QPainterPath splinePathRight; |
|
127 | 127 | QPainterPath *currentSegmentPath = 0; |
|
128 | 128 | QPainterPath *previousSegmentPath = 0; |
|
129 | 129 | qreal minX = domain()->minX(); |
|
130 | 130 | qreal maxX = domain()->maxX(); |
|
131 | 131 | qreal minY = domain()->minY(); |
|
132 | 132 | QPointF currentSeriesPoint = m_series->at(0); |
|
133 | 133 | QPointF currentGeometryPoint = points.at(0); |
|
134 | 134 | QPointF previousGeometryPoint = points.at(0); |
|
135 | 135 | bool pointOffGrid = false; |
|
136 | 136 | bool previousPointWasOffGrid = (currentSeriesPoint.x() < minX || currentSeriesPoint.x() > maxX); |
|
137 | 137 | m_visiblePoints.clear(); |
|
138 | 138 | m_visiblePoints.reserve(points.size()); |
|
139 | 139 | |
|
140 | 140 | qreal domainRadius = domain()->size().height() / 2.0; |
|
141 | 141 | const QPointF centerPoint(domainRadius, domainRadius); |
|
142 | 142 | |
|
143 | 143 | if (!previousPointWasOffGrid) { |
|
144 | 144 | fullPath.moveTo(points.at(0)); |
|
145 | 145 | // Do not draw points for points below minimum Y. |
|
146 | 146 | if (m_pointsVisible && currentSeriesPoint.y() >= minY) |
|
147 | 147 | m_visiblePoints.append(currentGeometryPoint); |
|
148 | 148 | } |
|
149 | 149 | |
|
150 | 150 | qreal leftMarginLine = centerPoint.x() - margin; |
|
151 | 151 | qreal rightMarginLine = centerPoint.x() + margin; |
|
152 | 152 | qreal horizontal = centerPoint.y(); |
|
153 | 153 | |
|
154 | 154 | // See ScatterChartItem::updateGeometry() for explanation why seriesLastIndex is needed |
|
155 | 155 | const int seriesLastIndex = m_series->count() - 1; |
|
156 | 156 | |
|
157 | 157 | for (int i = 1; i < points.size(); i++) { |
|
158 | 158 | // Interpolating spline fragments accurately is not trivial, and would anyway be ugly |
|
159 | 159 | // when thick pen is used, so we work around it by utilizing three separate |
|
160 | 160 | // paths for spline segments and clip those with custom regions at paint time. |
|
161 | 161 | // "Right" path contains segments that cross the axis line with visible point on the |
|
162 | 162 | // right side of the axis line, as well as segments that have one point within the margin |
|
163 | 163 | // on the right side of the axis line and another point on the right side of the chart. |
|
164 | 164 | // "Left" path contains points with similarly on the left side. |
|
165 | 165 | // "Full" path contains rest of the points. |
|
166 | 166 | // This doesn't yield perfect results always. E.g. when segment covers more than 90 |
|
167 | 167 | // degrees and both of the points are within the margin, one in the top half and one in the |
|
168 | 168 | // bottom half of the chart, the bottom one gets clipped incorrectly. |
|
169 | 169 | // However, this should be rare occurrence in any sensible chart. |
|
170 | 170 | currentSeriesPoint = m_series->at(qMin(seriesLastIndex, i)); |
|
171 | 171 | currentGeometryPoint = points.at(i); |
|
172 | 172 | pointOffGrid = (currentSeriesPoint.x() < minX || currentSeriesPoint.x() > maxX); |
|
173 | 173 | |
|
174 | 174 | // Draw something unless both off-grid |
|
175 | 175 | if (!pointOffGrid || !previousPointWasOffGrid) { |
|
176 | 176 | bool dummyOk; // We know points are ok, but this is needed |
|
177 | 177 | qreal currentAngle = static_cast<PolarDomain *>(domain())->toAngularCoordinate(currentSeriesPoint.x(), dummyOk); |
|
178 | 178 | qreal previousAngle = static_cast<PolarDomain *>(domain())->toAngularCoordinate(m_series->at(i - 1).x(), dummyOk); |
|
179 | 179 | |
|
180 | 180 | if ((qAbs(currentAngle - previousAngle) > 180.0)) { |
|
181 | 181 | // If the angle between two points is over 180 degrees (half X range), |
|
182 | 182 | // any direct segment between them becomes meaningless. |
|
183 | 183 | // In this case two line segments are drawn instead, from previous |
|
184 | 184 | // point to the center and from center to current point. |
|
185 | 185 | if ((previousAngle < 0.0 || (previousAngle <= 180.0 && previousGeometryPoint.x() < rightMarginLine)) |
|
186 | 186 | && previousGeometryPoint.y() < horizontal) { |
|
187 | 187 | currentSegmentPath = &splinePathRight; |
|
188 | 188 | } else if ((previousAngle > 360.0 || (previousAngle > 180.0 && previousGeometryPoint.x() > leftMarginLine)) |
|
189 | 189 | && previousGeometryPoint.y() < horizontal) { |
|
190 | 190 | currentSegmentPath = &splinePathLeft; |
|
191 | 191 | } else if (previousAngle > 0.0 && previousAngle < 360.0) { |
|
192 | 192 | currentSegmentPath = &splinePath; |
|
193 | 193 | } else { |
|
194 | 194 | currentSegmentPath = 0; |
|
195 | 195 | } |
|
196 | 196 | |
|
197 | 197 | if (currentSegmentPath) { |
|
198 | 198 | if (previousSegmentPath != currentSegmentPath) |
|
199 | 199 | currentSegmentPath->moveTo(previousGeometryPoint); |
|
200 | 200 | if (!previousSegmentPath) |
|
201 | 201 | fullPath.moveTo(previousGeometryPoint); |
|
202 | 202 | |
|
203 | 203 | currentSegmentPath->lineTo(centerPoint); |
|
204 | 204 | fullPath.lineTo(centerPoint); |
|
205 | 205 | } |
|
206 | 206 | |
|
207 | 207 | previousSegmentPath = currentSegmentPath; |
|
208 | 208 | |
|
209 | 209 | if ((currentAngle < 0.0 || (currentAngle <= 180.0 && currentGeometryPoint.x() < rightMarginLine)) |
|
210 | 210 | && currentGeometryPoint.y() < horizontal) { |
|
211 | 211 | currentSegmentPath = &splinePathRight; |
|
212 | 212 | } else if ((currentAngle > 360.0 || (currentAngle > 180.0 &¤tGeometryPoint.x() > leftMarginLine)) |
|
213 | 213 | && currentGeometryPoint.y() < horizontal) { |
|
214 | 214 | currentSegmentPath = &splinePathLeft; |
|
215 | 215 | } else if (currentAngle > 0.0 && currentAngle < 360.0) { |
|
216 | 216 | currentSegmentPath = &splinePath; |
|
217 | 217 | } else { |
|
218 | 218 | currentSegmentPath = 0; |
|
219 | 219 | } |
|
220 | 220 | |
|
221 | 221 | if (currentSegmentPath) { |
|
222 | 222 | if (previousSegmentPath != currentSegmentPath) |
|
223 | 223 | currentSegmentPath->moveTo(centerPoint); |
|
224 | 224 | if (!previousSegmentPath) |
|
225 | 225 | fullPath.moveTo(centerPoint); |
|
226 | 226 | |
|
227 | 227 | currentSegmentPath->lineTo(currentGeometryPoint); |
|
228 | 228 | fullPath.lineTo(currentGeometryPoint); |
|
229 | 229 | } |
|
230 | 230 | } else { |
|
231 | 231 | QPointF cp1 = controlPoints[2 * (i - 1)]; |
|
232 | 232 | QPointF cp2 = controlPoints[(2 * i) - 1]; |
|
233 | 233 | |
|
234 | 234 | if (previousAngle < 0.0 || currentAngle < 0.0 |
|
235 | 235 | || ((previousAngle <= 180.0 && currentAngle <= 180.0) |
|
236 | 236 | && ((previousGeometryPoint.x() < rightMarginLine && previousGeometryPoint.y() < horizontal) |
|
237 | 237 | || (currentGeometryPoint.x() < rightMarginLine && currentGeometryPoint.y() < horizontal)))) { |
|
238 | 238 | currentSegmentPath = &splinePathRight; |
|
239 | 239 | } else if (previousAngle > 360.0 || currentAngle > 360.0 |
|
240 | 240 | || ((previousAngle > 180.0 && currentAngle > 180.0) |
|
241 | 241 | && ((previousGeometryPoint.x() > leftMarginLine && previousGeometryPoint.y() < horizontal) |
|
242 | 242 | || (currentGeometryPoint.x() > leftMarginLine && currentGeometryPoint.y() < horizontal)))) { |
|
243 | 243 | currentSegmentPath = &splinePathLeft; |
|
244 | 244 | } else { |
|
245 | 245 | currentSegmentPath = &splinePath; |
|
246 | 246 | } |
|
247 | 247 | |
|
248 | 248 | if (currentSegmentPath != previousSegmentPath) |
|
249 | 249 | currentSegmentPath->moveTo(previousGeometryPoint); |
|
250 | 250 | if (!previousSegmentPath) |
|
251 | 251 | fullPath.moveTo(previousGeometryPoint); |
|
252 | 252 | |
|
253 | 253 | fullPath.cubicTo(cp1, cp2, currentGeometryPoint); |
|
254 | 254 | currentSegmentPath->cubicTo(cp1, cp2, currentGeometryPoint); |
|
255 | 255 | } |
|
256 | 256 | } else { |
|
257 | 257 | currentSegmentPath = 0; |
|
258 | 258 | } |
|
259 | 259 | |
|
260 | 260 | previousPointWasOffGrid = pointOffGrid; |
|
261 | 261 | if (!pointOffGrid && m_pointsVisible && currentSeriesPoint.y() >= minY) |
|
262 | 262 | m_visiblePoints.append(currentGeometryPoint); |
|
263 | 263 | previousSegmentPath = currentSegmentPath; |
|
264 | 264 | previousGeometryPoint = currentGeometryPoint; |
|
265 | 265 | } |
|
266 | 266 | |
|
267 | 267 | m_pathPolarRight = splinePathRight; |
|
268 | 268 | m_pathPolarLeft = splinePathLeft; |
|
269 | 269 | // Note: This construction of m_fullpath is not perfect. The partial segments that are |
|
270 | 270 | // outside left/right clip regions at axis boundary still generate hover/click events, |
|
271 | 271 | // because shape doesn't get clipped. It doesn't seem possible to do sensibly. |
|
272 | 272 | } else { // not polar |
|
273 | 273 | splinePath.moveTo(points.at(0)); |
|
274 | 274 | for (int i = 0; i < points.size() - 1; i++) { |
|
275 | 275 | const QPointF &point = points.at(i + 1); |
|
276 | 276 | splinePath.cubicTo(controlPoints[2 * i], controlPoints[2 * i + 1], point); |
|
277 | 277 | } |
|
278 | 278 | fullPath = splinePath; |
|
279 | 279 | } |
|
280 | 280 | |
|
281 | 281 | QPainterPathStroker stroker; |
|
282 | 282 | // The full path is comprised of three separate paths. |
|
283 | 283 | // This is why we are prepared for the "worst case" scenario, i.e. use always MiterJoin and |
|
284 | 284 | // multiply line width with square root of two when defining shape and bounding rectangle. |
|
285 | 285 | stroker.setWidth(margin); |
|
286 | 286 | stroker.setJoinStyle(Qt::MiterJoin); |
|
287 | 287 | stroker.setCapStyle(Qt::SquareCap); |
|
288 | 288 | stroker.setMiterLimit(m_linePen.miterLimit()); |
|
289 | 289 | |
|
290 | 290 | // Only zoom in if the bounding rects of the path fit inside int limits. QWidget::update() uses |
|
291 | 291 | // a region that has to be compatible with QRect. |
|
292 | 292 | QPainterPath checkShapePath = stroker.createStroke(fullPath); |
|
293 | 293 | if (checkShapePath.boundingRect().height() <= INT_MAX |
|
294 | 294 | && checkShapePath.boundingRect().width() <= INT_MAX |
|
295 | 295 | && splinePath.boundingRect().height() <= INT_MAX |
|
296 | 296 | && splinePath.boundingRect().width() <= INT_MAX) { |
|
297 | 297 | m_path = splinePath; |
|
298 | 298 | |
|
299 | 299 | prepareGeometryChange(); |
|
300 | 300 | |
|
301 | 301 | m_fullPath = checkShapePath; |
|
302 | 302 | m_rect = m_fullPath.boundingRect(); |
|
303 | 303 | } |
|
304 | 304 | } |
|
305 | 305 | |
|
306 | 306 | /*! |
|
307 | 307 | Calculates control points which are needed by QPainterPath.cubicTo function to draw the cubic Bezier cureve between two points. |
|
308 | 308 | */ |
|
309 | 309 | QVector<QPointF> SplineChartItem::calculateControlPoints(const QVector<QPointF> &points) |
|
310 | 310 | { |
|
311 | 311 | QVector<QPointF> controlPoints; |
|
312 | 312 | controlPoints.resize(points.count() * 2 - 2); |
|
313 | 313 | |
|
314 | 314 | int n = points.count() - 1; |
|
315 | 315 | |
|
316 | 316 | if (n == 1) { |
|
317 | 317 | //for n==1 |
|
318 | 318 | controlPoints[0].setX((2 * points[0].x() + points[1].x()) / 3); |
|
319 | 319 | controlPoints[0].setY((2 * points[0].y() + points[1].y()) / 3); |
|
320 | 320 | controlPoints[1].setX(2 * controlPoints[0].x() - points[0].x()); |
|
321 | 321 | controlPoints[1].setY(2 * controlPoints[0].y() - points[0].y()); |
|
322 | 322 | return controlPoints; |
|
323 | 323 | } |
|
324 | 324 | |
|
325 | 325 | // Calculate first Bezier control points |
|
326 | 326 | // Set of equations for P0 to Pn points. |
|
327 | 327 | // |
|
328 | 328 | // | 2 1 0 0 ... 0 0 0 ... 0 0 0 | | P1_1 | | P0 + 2 * P1 | |
|
329 | 329 | // | 1 4 1 0 ... 0 0 0 ... 0 0 0 | | P1_2 | | 4 * P1 + 2 * P2 | |
|
330 | 330 | // | 0 1 4 1 ... 0 0 0 ... 0 0 0 | | P1_3 | | 4 * P2 + 2 * P3 | |
|
331 | 331 | // | . . . . . . . . . . . . | | ... | | ... | |
|
332 | 332 | // | 0 0 0 0 ... 1 4 1 ... 0 0 0 | * | P1_i | = | 4 * P(i-1) + 2 * Pi | |
|
333 | 333 | // | . . . . . . . . . . . . | | ... | | ... | |
|
334 | 334 | // | 0 0 0 0 0 0 0 0 ... 1 4 1 | | P1_(n-1)| | 4 * P(n-2) + 2 * P(n-1) | |
|
335 | 335 | // | 0 0 0 0 0 0 0 0 ... 0 2 7 | | P1_n | | 8 * P(n-1) + Pn | |
|
336 | 336 | // |
|
337 | 337 | QVector<qreal> vector; |
|
338 | 338 | vector.resize(n); |
|
339 | 339 | |
|
340 | 340 | vector[0] = points[0].x() + 2 * points[1].x(); |
|
341 | 341 | |
|
342 | 342 | |
|
343 | 343 | for (int i = 1; i < n - 1; ++i) |
|
344 | 344 | vector[i] = 4 * points[i].x() + 2 * points[i + 1].x(); |
|
345 | 345 | |
|
346 | 346 | vector[n - 1] = (8 * points[n - 1].x() + points[n].x()) / 2.0; |
|
347 | 347 | |
|
348 | 348 | QVector<qreal> xControl = firstControlPoints(vector); |
|
349 | 349 | |
|
350 | 350 | vector[0] = points[0].y() + 2 * points[1].y(); |
|
351 | 351 | |
|
352 | 352 | for (int i = 1; i < n - 1; ++i) |
|
353 | 353 | vector[i] = 4 * points[i].y() + 2 * points[i + 1].y(); |
|
354 | 354 | |
|
355 | 355 | vector[n - 1] = (8 * points[n - 1].y() + points[n].y()) / 2.0; |
|
356 | 356 | |
|
357 | 357 | QVector<qreal> yControl = firstControlPoints(vector); |
|
358 | 358 | |
|
359 | 359 | for (int i = 0, j = 0; i < n; ++i, ++j) { |
|
360 | 360 | |
|
361 | 361 | controlPoints[j].setX(xControl[i]); |
|
362 | 362 | controlPoints[j].setY(yControl[i]); |
|
363 | 363 | |
|
364 | 364 | j++; |
|
365 | 365 | |
|
366 | 366 | if (i < n - 1) { |
|
367 | 367 | controlPoints[j].setX(2 * points[i + 1].x() - xControl[i + 1]); |
|
368 | 368 | controlPoints[j].setY(2 * points[i + 1].y() - yControl[i + 1]); |
|
369 | 369 | } else { |
|
370 | 370 | controlPoints[j].setX((points[n].x() + xControl[n - 1]) / 2); |
|
371 | 371 | controlPoints[j].setY((points[n].y() + yControl[n - 1]) / 2); |
|
372 | 372 | } |
|
373 | 373 | } |
|
374 | 374 | return controlPoints; |
|
375 | 375 | } |
|
376 | 376 | |
|
377 | 377 | QVector<qreal> SplineChartItem::firstControlPoints(const QVector<qreal>& vector) |
|
378 | 378 | { |
|
379 | 379 | QVector<qreal> result; |
|
380 | 380 | |
|
381 | 381 | int count = vector.count(); |
|
382 | 382 | result.resize(count); |
|
383 | 383 | result[0] = vector[0] / 2.0; |
|
384 | 384 | |
|
385 | 385 | QVector<qreal> temp; |
|
386 | 386 | temp.resize(count); |
|
387 | 387 | temp[0] = 0; |
|
388 | 388 | |
|
389 | 389 | qreal b = 2.0; |
|
390 | 390 | |
|
391 | 391 | for (int i = 1; i < count; i++) { |
|
392 | 392 | temp[i] = 1 / b; |
|
393 | 393 | b = (i < count - 1 ? 4.0 : 3.5) - temp[i]; |
|
394 | 394 | result[i] = (vector[i] - result[i - 1]) / b; |
|
395 | 395 | } |
|
396 | 396 | |
|
397 | 397 | for (int i = 1; i < count; i++) |
|
398 | 398 | result[count - i - 1] -= temp[count - i] * result[count - i]; |
|
399 | 399 | |
|
400 | 400 | return result; |
|
401 | 401 | } |
|
402 | 402 | |
|
403 | 403 | //handlers |
|
404 | 404 | |
|
405 | 405 | void SplineChartItem::handleUpdated() |
|
406 | 406 | { |
|
407 | 407 | setVisible(m_series->isVisible()); |
|
408 | 408 | setOpacity(m_series->opacity()); |
|
409 | 409 | m_pointsVisible = m_series->pointsVisible(); |
|
410 | 410 | m_linePen = m_series->pen(); |
|
411 | 411 | m_pointPen = m_series->pen(); |
|
412 | 412 | m_pointPen.setWidthF(2 * m_pointPen.width()); |
|
413 | 413 | m_pointLabelsFormat = m_series->pointLabelsFormat(); |
|
414 | 414 | m_pointLabelsVisible = m_series->pointLabelsVisible(); |
|
415 | 415 | m_pointLabelsFont = m_series->pointLabelsFont(); |
|
416 | 416 | m_pointLabelsColor = m_series->pointLabelsColor(); |
|
417 | 417 | update(); |
|
418 | 418 | } |
|
419 | 419 | |
|
420 | 420 | //painter |
|
421 | 421 | |
|
422 | 422 | void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
423 | 423 | { |
|
424 | 424 | Q_UNUSED(widget) |
|
425 | 425 | Q_UNUSED(option) |
|
426 | 426 | |
|
427 | 427 | QRectF clipRect = QRectF(QPointF(0, 0), domain()->size()); |
|
428 | 428 | |
|
429 | 429 | painter->save(); |
|
430 | 430 | painter->setPen(m_linePen); |
|
431 | 431 | painter->setBrush(Qt::NoBrush); |
|
432 | 432 | |
|
433 | 433 | if (m_series->chart()->chartType() == QChart::ChartTypePolar) { |
|
434 | 434 | qreal halfWidth = domain()->size().width() / 2.0; |
|
435 | 435 | QRectF clipRectLeft = QRectF(0, 0, halfWidth, domain()->size().height()); |
|
436 | 436 | QRectF clipRectRight = QRectF(halfWidth, 0, halfWidth, domain()->size().height()); |
|
437 | 437 | QRegion fullPolarClipRegion(clipRect.toRect(), QRegion::Ellipse); |
|
438 | 438 | QRegion clipRegionLeft(fullPolarClipRegion.intersected(clipRectLeft.toRect())); |
|
439 | 439 | QRegion clipRegionRight(fullPolarClipRegion.intersected(clipRectRight.toRect())); |
|
440 | 440 | painter->setClipRegion(clipRegionLeft); |
|
441 | 441 | painter->drawPath(m_pathPolarLeft); |
|
442 | 442 | painter->setClipRegion(clipRegionRight); |
|
443 | 443 | painter->drawPath(m_pathPolarRight); |
|
444 | 444 | painter->setClipRegion(fullPolarClipRegion); |
|
445 | 445 | } else { |
|
446 | 446 | painter->setClipRect(clipRect); |
|
447 | 447 | } |
|
448 | 448 | |
|
449 | reversePainter(painter, clipRect); | |
|
450 | ||
|
449 | 451 | painter->drawPath(m_path); |
|
450 | 452 | |
|
451 | 453 | if (m_pointsVisible) { |
|
452 | 454 | painter->setPen(m_pointPen); |
|
453 | 455 | if (m_series->chart()->chartType() == QChart::ChartTypePolar) |
|
454 | 456 | painter->drawPoints(m_visiblePoints); |
|
455 | 457 | else |
|
456 | 458 | painter->drawPoints(geometryPoints()); |
|
457 | 459 | } |
|
458 | 460 | |
|
461 | reversePainter(painter, clipRect); | |
|
462 | ||
|
459 | 463 | if (m_pointLabelsVisible) |
|
460 | 464 | m_series->d_func()->drawSeriesPointLabels(painter, m_points, m_linePen.width() / 2); |
|
461 | 465 | |
|
462 | 466 | painter->restore(); |
|
463 | 467 | } |
|
464 | 468 | |
|
465 | 469 | void SplineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
466 | 470 | { |
|
467 | 471 | emit XYChart::pressed(domain()->calculateDomainPoint(event->pos())); |
|
468 | 472 | m_lastMousePos = event->pos(); |
|
469 | 473 | m_mousePressed = true; |
|
470 | 474 | QGraphicsItem::mousePressEvent(event); |
|
471 | 475 | } |
|
472 | 476 | |
|
473 | 477 | void SplineChartItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
|
474 | 478 | { |
|
475 | 479 | emit XYChart::hovered(domain()->calculateDomainPoint(event->pos()), true); |
|
476 | 480 | QGraphicsItem::hoverEnterEvent(event); |
|
477 | 481 | } |
|
478 | 482 | |
|
479 | 483 | void SplineChartItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) |
|
480 | 484 | { |
|
481 | 485 | emit XYChart::hovered(domain()->calculateDomainPoint(event->pos()), false); |
|
482 | 486 | QGraphicsItem::hoverLeaveEvent(event); |
|
483 | 487 | } |
|
484 | 488 | |
|
485 | 489 | void SplineChartItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
486 | 490 | { |
|
487 | 491 | emit XYChart::released(domain()->calculateDomainPoint(m_lastMousePos)); |
|
488 | 492 | if (m_mousePressed) |
|
489 | 493 | emit XYChart::clicked(domain()->calculateDomainPoint(m_lastMousePos)); |
|
490 | 494 | m_mousePressed = false; |
|
491 | 495 | QGraphicsItem::mouseReleaseEvent(event); |
|
492 | 496 | } |
|
493 | 497 | |
|
494 | 498 | void SplineChartItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) |
|
495 | 499 | { |
|
496 | 500 | emit XYChart::doubleClicked(domain()->calculateDomainPoint(m_lastMousePos)); |
|
497 | 501 | QGraphicsItem::mouseDoubleClickEvent(event); |
|
498 | 502 | } |
|
499 | 503 | |
|
500 | 504 | #include "moc_splinechartitem_p.cpp" |
|
501 | 505 | |
|
502 | 506 | QT_CHARTS_END_NAMESPACE |
@@ -1,864 +1,870 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #include <QtCharts/QXYSeries> |
|
20 | 20 | #include <private/qxyseries_p.h> |
|
21 | 21 | #include <private/abstractdomain_p.h> |
|
22 | 22 | #include <QtCharts/QValueAxis> |
|
23 | 23 | #include <private/xychart_p.h> |
|
24 | 24 | #include <QtCharts/QXYLegendMarker> |
|
25 | 25 | #include <private/charthelpers_p.h> |
|
26 | 26 | #include <private/qchart_p.h> |
|
27 | 27 | #include <QtGui/QPainter> |
|
28 | 28 | |
|
29 | 29 | QT_CHARTS_BEGIN_NAMESPACE |
|
30 | 30 | |
|
31 | 31 | /*! |
|
32 | 32 | \class QXYSeries |
|
33 | 33 | \inmodule Qt Charts |
|
34 | 34 | \brief The QXYSeries class is a base class for line, spline and scatter series. |
|
35 | 35 | */ |
|
36 | 36 | /*! |
|
37 | 37 | \qmltype XYSeries |
|
38 | 38 | \instantiates QXYSeries |
|
39 | 39 | \inqmlmodule QtCharts |
|
40 | 40 | |
|
41 | 41 | \inherits AbstractSeries |
|
42 | 42 | |
|
43 | 43 | \brief The XYSeries type is a base type for line, spline and scatter series. |
|
44 | 44 | |
|
45 | 45 | The XYSeries class is a base class for line, spline and scatter series. |
|
46 | 46 | The class cannot be instantiated directly. |
|
47 | 47 | */ |
|
48 | 48 | |
|
49 | 49 | /*! |
|
50 | 50 | \qmlproperty AbstractAxis XYSeries::axisX |
|
51 | 51 | The x axis used for the series. If you leave both axisX and axisXTop undefined, a ValueAxis is created for |
|
52 | 52 | the series. |
|
53 | 53 | \sa axisXTop |
|
54 | 54 | */ |
|
55 | 55 | |
|
56 | 56 | /*! |
|
57 | 57 | \qmlproperty AbstractAxis XYSeries::axisY |
|
58 | 58 | The y axis used for the series. If you leave both axisY and axisYRight undefined, a ValueAxis is created for |
|
59 | 59 | the series. |
|
60 | 60 | \sa axisYRight |
|
61 | 61 | */ |
|
62 | 62 | |
|
63 | 63 | /*! |
|
64 | 64 | \qmlproperty AbstractAxis XYSeries::axisXTop |
|
65 | 65 | The x axis used for the series, drawn on top of the chart view. Note that you can only provide either axisX or |
|
66 | 66 | axisXTop, but not both. |
|
67 | 67 | \sa axisX |
|
68 | 68 | */ |
|
69 | 69 | |
|
70 | 70 | /*! |
|
71 | 71 | \qmlproperty AbstractAxis XYSeries::axisYRight |
|
72 | 72 | The y axis used for the series, drawn to the right on the chart view. Note that you can only provide either axisY |
|
73 | 73 | or axisYRight, but not both. |
|
74 | 74 | \sa axisY |
|
75 | 75 | */ |
|
76 | 76 | |
|
77 | 77 | /*! |
|
78 | 78 | \qmlproperty AbstractAxis XYSeries::axisAngular |
|
79 | 79 | The angular axis used for the series, drawn around the polar chart view. |
|
80 | 80 | \sa axisX |
|
81 | 81 | */ |
|
82 | 82 | |
|
83 | 83 | /*! |
|
84 | 84 | \qmlproperty AbstractAxis XYSeries::axisRadial |
|
85 | 85 | The radial axis used for the series, drawn inside the polar chart view. |
|
86 | 86 | \sa axisY |
|
87 | 87 | */ |
|
88 | 88 | |
|
89 | 89 | /*! |
|
90 | 90 | \property QXYSeries::pointsVisible |
|
91 | 91 | Controls if the data points are visible and should be drawn. |
|
92 | 92 | */ |
|
93 | 93 | /*! |
|
94 | 94 | \qmlproperty bool XYSeries::pointsVisible |
|
95 | 95 | Controls if the data points are visible and should be drawn. |
|
96 | 96 | */ |
|
97 | 97 | |
|
98 | 98 | /*! |
|
99 | 99 | \fn QPen QXYSeries::pen() const |
|
100 | 100 | \brief Returns pen used to draw points for series. |
|
101 | 101 | \sa setPen() |
|
102 | 102 | */ |
|
103 | 103 | |
|
104 | 104 | /*! |
|
105 | 105 | \fn QBrush QXYSeries::brush() const |
|
106 | 106 | \brief Returns brush used to draw points for series. |
|
107 | 107 | \sa setBrush() |
|
108 | 108 | */ |
|
109 | 109 | |
|
110 | 110 | /*! |
|
111 | 111 | \property QXYSeries::color |
|
112 | 112 | The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and |
|
113 | 113 | fill (brush) color in case of QScatterSeries or QAreaSeries. |
|
114 | 114 | \sa QXYSeries::pen(), QXYSeries::brush() |
|
115 | 115 | */ |
|
116 | 116 | /*! |
|
117 | 117 | \qmlproperty color XYSeries::color |
|
118 | 118 | The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and |
|
119 | 119 | fill (brush) color in case of ScatterSeries or AreaSeries. |
|
120 | 120 | */ |
|
121 | 121 | |
|
122 | 122 | /*! |
|
123 | 123 | \property QXYSeries::pointLabelsFormat |
|
124 | 124 | The \a format used for showing labels with series points. |
|
125 | 125 | |
|
126 | 126 | QXYSeries supports the following format tags: |
|
127 | 127 | \table |
|
128 | 128 | \row |
|
129 | 129 | \li @xPoint \li The x value of the data point |
|
130 | 130 | \row |
|
131 | 131 | \li @yPoint \li The y value of the data point |
|
132 | 132 | \endtable |
|
133 | 133 | |
|
134 | 134 | For example, the following usage of the format tags would produce labels that have the data |
|
135 | 135 | point (x, y) shown inside brackets separated by a comma: |
|
136 | 136 | \code |
|
137 | 137 | series->setPointLabelsFormat("(@xPoint, @yPoint)"); |
|
138 | 138 | \endcode |
|
139 | 139 | |
|
140 | 140 | By default, the labels format is set to '@xPoint, @yPoint'. The labels are shown on the plot |
|
141 | 141 | area, labels on the edge of the plot area are cut. If the points are close to each other the |
|
142 | 142 | labels may overlap. |
|
143 | 143 | |
|
144 | 144 | \sa QXYSeries::pointLabelsVisible, QXYSeries::pointLabelsFont, QXYSeries::pointLabelsColor |
|
145 | 145 | */ |
|
146 | 146 | /*! |
|
147 | 147 | \qmlproperty string XYSeries::pointLabelsFormat |
|
148 | 148 | The \a format used for showing labels with series points. |
|
149 | 149 | |
|
150 | 150 | \sa QXYSeries::pointLabelsFormat, pointLabelsVisible, pointLabelsFont, pointLabelsColor |
|
151 | 151 | */ |
|
152 | 152 | /*! |
|
153 | 153 | \fn void QXYSeries::pointLabelsFormatChanged(const QString &format) |
|
154 | 154 | Signal is emitted when the \a format of data point labels is changed. |
|
155 | 155 | */ |
|
156 | 156 | /*! |
|
157 | 157 | \qmlsignal XYSeries::onPointLabelsFormatChanged(string format) |
|
158 | 158 | Signal is emitted when the \a format of data point labels is changed. |
|
159 | 159 | */ |
|
160 | 160 | |
|
161 | 161 | /*! |
|
162 | 162 | \property QXYSeries::pointLabelsVisible |
|
163 | 163 | Defines the visibility for data point labels. False by default. |
|
164 | 164 | |
|
165 | 165 | \sa QXYSeries::pointLabelsFormat |
|
166 | 166 | */ |
|
167 | 167 | /*! |
|
168 | 168 | \qmlproperty bool XYSeries::pointLabelsVisible |
|
169 | 169 | Defines the visibility for data point labels. |
|
170 | 170 | |
|
171 | 171 | \sa pointLabelsFormat |
|
172 | 172 | */ |
|
173 | 173 | /*! |
|
174 | 174 | \fn void QXYSeries::pointLabelsVisibilityChanged(bool visible) |
|
175 | 175 | The visibility of the data point labels is changed to \a visible. |
|
176 | 176 | */ |
|
177 | 177 | /*! |
|
178 | 178 | \qmlsignal XYSeries::onPointLabelsVisibilityChanged(bool visible) |
|
179 | 179 | The visibility of the data point labels is changed to \a visible. |
|
180 | 180 | */ |
|
181 | 181 | |
|
182 | 182 | /*! |
|
183 | 183 | \property QXYSeries::pointLabelsFont |
|
184 | 184 | Defines the font used for data point labels. |
|
185 | 185 | |
|
186 | 186 | \sa QXYSeries::pointLabelsFormat |
|
187 | 187 | */ |
|
188 | 188 | /*! |
|
189 | 189 | \qmlproperty font XYSeries::pointLabelsFont |
|
190 | 190 | Defines the font used for data point labels. |
|
191 | 191 | |
|
192 | 192 | \sa pointLabelsFormat |
|
193 | 193 | */ |
|
194 | 194 | /*! |
|
195 | 195 | \fn void QXYSeries::pointLabelsFontChanged(const QFont &font); |
|
196 | 196 | The font used for data point labels is changed to \a font. |
|
197 | 197 | */ |
|
198 | 198 | /*! |
|
199 | 199 | \qmlsignal XYSeries::onPointLabelsFontChanged(Font font) |
|
200 | 200 | The font used for data point labels is changed to \a font. |
|
201 | 201 | */ |
|
202 | 202 | |
|
203 | 203 | /*! |
|
204 | 204 | \property QXYSeries::pointLabelsColor |
|
205 | 205 | Defines the color used for data point labels. By default, the color is the color of the brush |
|
206 | 206 | defined in theme for labels. |
|
207 | 207 | |
|
208 | 208 | \sa QXYSeries::pointLabelsFormat |
|
209 | 209 | */ |
|
210 | 210 | /*! |
|
211 | 211 | \qmlproperty font XYSeries::pointLabelsColor |
|
212 | 212 | Defines the color used for data point labels. By default, the color is the color of the brush |
|
213 | 213 | defined in theme for labels. |
|
214 | 214 | |
|
215 | 215 | \sa pointLabelsFormat |
|
216 | 216 | */ |
|
217 | 217 | /*! |
|
218 | 218 | \fn void QXYSeries::pointLabelsColorChanged(const QColor &color); |
|
219 | 219 | The color used for data point labels is changed to \a color. |
|
220 | 220 | */ |
|
221 | 221 | /*! |
|
222 | 222 | \qmlsignal XYSeries::onPointLabelsColorChanged(Color color) |
|
223 | 223 | The color used for data point labels is changed to \a color. |
|
224 | 224 | */ |
|
225 | 225 | |
|
226 | 226 | /*! |
|
227 | 227 | \fn void QXYSeries::clicked(const QPointF& point) |
|
228 | 228 | \brief Signal is emitted when user clicks the \a point on chart. The \a point is the point |
|
229 | 229 | where the press was triggered. |
|
230 | 230 | \sa pressed, released, doubleClicked |
|
231 | 231 | */ |
|
232 | 232 | /*! |
|
233 | 233 | \qmlsignal XYSeries::onClicked(QPointF point) |
|
234 | 234 | Signal is emitted when user clicks the \a point on chart. The \a point is the point where the |
|
235 | 235 | press was triggered. For example: |
|
236 | 236 | \code |
|
237 | 237 | LineSeries { |
|
238 | 238 | XYPoint { x: 0; y: 0 } |
|
239 | 239 | XYPoint { x: 1.1; y: 2.1 } |
|
240 | 240 | onClicked: console.log("onClicked: " + point.x + ", " + point.y); |
|
241 | 241 | } |
|
242 | 242 | \endcode |
|
243 | 243 | \sa onPressed, onReleased, onDoubleClicked |
|
244 | 244 | */ |
|
245 | 245 | |
|
246 | 246 | /*! |
|
247 | 247 | \fn void QXYSeries::hovered(const QPointF &point, bool state) |
|
248 | 248 | This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate) |
|
249 | 249 | of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from |
|
250 | 250 | the series. |
|
251 | 251 | */ |
|
252 | 252 | /*! |
|
253 | 253 | \qmlsignal XYSeries::onHovered(point point, bool state) |
|
254 | 254 | This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate) |
|
255 | 255 | of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from |
|
256 | 256 | the series. |
|
257 | 257 | */ |
|
258 | 258 | |
|
259 | 259 | /*! |
|
260 | 260 | \fn void QXYSeries::pressed(const QPointF& point) |
|
261 | 261 | \brief Signal is emitted when user presses the \a point on chart. |
|
262 | 262 | \sa clicked, released, doubleClicked |
|
263 | 263 | */ |
|
264 | 264 | /*! |
|
265 | 265 | \qmlsignal XYSeries::onPressed(QPointF point) |
|
266 | 266 | Signal is emitted when user presses the \a point on chart. For example: |
|
267 | 267 | \code |
|
268 | 268 | LineSeries { |
|
269 | 269 | XYPoint { x: 0; y: 0 } |
|
270 | 270 | XYPoint { x: 1.1; y: 2.1 } |
|
271 | 271 | onPressed: console.log("onPressed: " + point.x + ", " + point.y); |
|
272 | 272 | } |
|
273 | 273 | \endcode |
|
274 | 274 | \sa onClicked, onReleased, onDoubleClicked |
|
275 | 275 | */ |
|
276 | 276 | |
|
277 | 277 | /*! |
|
278 | 278 | \fn void QXYSeries::released(const QPointF& point) |
|
279 | 279 | \brief Signal is emitted when user releases a press that was triggered on a \a point on chart. |
|
280 | 280 | \sa pressed, clicked, doubleClicked |
|
281 | 281 | */ |
|
282 | 282 | /*! |
|
283 | 283 | \qmlsignal XYSeries::onReleased(QPointF point) |
|
284 | 284 | Signal is emitted when user releases a press that was triggered on a \a point on chart. |
|
285 | 285 | For example: |
|
286 | 286 | \code |
|
287 | 287 | LineSeries { |
|
288 | 288 | XYPoint { x: 0; y: 0 } |
|
289 | 289 | XYPoint { x: 1.1; y: 2.1 } |
|
290 | 290 | onReleased: console.log("onReleased: " + point.x + ", " + point.y); |
|
291 | 291 | } |
|
292 | 292 | \endcode |
|
293 | 293 | \sa onPressed, onClicked, onDoubleClicked |
|
294 | 294 | */ |
|
295 | 295 | |
|
296 | 296 | /*! |
|
297 | 297 | \fn void QXYSeries::doubleClicked(const QPointF& point) |
|
298 | 298 | \brief Signal is emitted when user doubleclicks the \a point on chart. The \a point is the |
|
299 | 299 | point where the first press was triggered. |
|
300 | 300 | \sa pressed, released, clicked |
|
301 | 301 | */ |
|
302 | 302 | /*! |
|
303 | 303 | \qmlsignal XYSeries::onDoubleClicked(QPointF point) |
|
304 | 304 | Signal is emitted when user doubleclicks the \a point on chart. The \a point is the point where |
|
305 | 305 | the first press was triggered. For example: |
|
306 | 306 | \code |
|
307 | 307 | LineSeries { |
|
308 | 308 | XYPoint { x: 0; y: 0 } |
|
309 | 309 | XYPoint { x: 1.1; y: 2.1 } |
|
310 | 310 | onDoubleClicked: console.log("onDoubleClicked: " + point.x + ", " + point.y); |
|
311 | 311 | } |
|
312 | 312 | \endcode |
|
313 | 313 | \sa onPressed, onReleased, onClicked |
|
314 | 314 | */ |
|
315 | 315 | |
|
316 | 316 | /*! |
|
317 | 317 | \fn void QXYSeries::pointReplaced(int index) |
|
318 | 318 | Signal is emitted when a point has been replaced at \a index. |
|
319 | 319 | \sa replace() |
|
320 | 320 | */ |
|
321 | 321 | /*! |
|
322 | 322 | \qmlsignal XYSeries::onPointReplaced(int index) |
|
323 | 323 | Signal is emitted when a point has been replaced at \a index. |
|
324 | 324 | */ |
|
325 | 325 | |
|
326 | 326 | /*! |
|
327 | 327 | \fn void QXYSeries::pointsReplaced() |
|
328 | 328 | Signal is emitted when all points have been replaced with other points. |
|
329 | 329 | \sa replace() |
|
330 | 330 | */ |
|
331 | 331 | /*! |
|
332 | 332 | \qmlsignal XYSeries::onPointsReplaced() |
|
333 | 333 | Signal is emitted when all points have been replaced with other points. |
|
334 | 334 | */ |
|
335 | 335 | |
|
336 | 336 | /*! |
|
337 | 337 | \fn void QXYSeries::pointAdded(int index) |
|
338 | 338 | Signal is emitted when a point has been added at \a index. |
|
339 | 339 | \sa append(), insert() |
|
340 | 340 | */ |
|
341 | 341 | /*! |
|
342 | 342 | \qmlsignal XYSeries::onPointAdded(int index) |
|
343 | 343 | Signal is emitted when a point has been added at \a index. |
|
344 | 344 | */ |
|
345 | 345 | |
|
346 | 346 | /*! |
|
347 | 347 | \fn void QXYSeries::pointRemoved(int index) |
|
348 | 348 | Signal is emitted when a point has been removed from \a index. |
|
349 | 349 | \sa remove() |
|
350 | 350 | */ |
|
351 | 351 | |
|
352 | 352 | /*! |
|
353 | 353 | \qmlsignal XYSeries::onPointRemoved(int index) |
|
354 | 354 | Signal is emitted when a point has been removed from \a index. |
|
355 | 355 | */ |
|
356 | 356 | |
|
357 | 357 | /*! |
|
358 | 358 | \fn void QXYSeries::colorChanged(QColor color) |
|
359 | 359 | \brief Signal is emitted when the line (pen) color has changed to \a color. |
|
360 | 360 | */ |
|
361 | 361 | /*! |
|
362 | 362 | \qmlsignal XYSeries::onColorChanged(color color) |
|
363 | 363 | Signal is emitted when the line (pen) color has changed to \a color. |
|
364 | 364 | */ |
|
365 | 365 | |
|
366 | 366 | /*! |
|
367 | 367 | \fn void QXYSeriesPrivate::updated() |
|
368 | 368 | \brief \internal |
|
369 | 369 | */ |
|
370 | 370 | |
|
371 | 371 | /*! |
|
372 | 372 | \qmlmethod XYSeries::append(real x, real y) |
|
373 | 373 | Append point (\a x, \a y) to the series |
|
374 | 374 | */ |
|
375 | 375 | |
|
376 | 376 | /*! |
|
377 | 377 | \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY) |
|
378 | 378 | Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not |
|
379 | 379 | exist. |
|
380 | 380 | */ |
|
381 | 381 | |
|
382 | 382 | /*! |
|
383 | 383 | \qmlmethod XYSeries::remove(real x, real y) |
|
384 | 384 | Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist. |
|
385 | 385 | */ |
|
386 | 386 | |
|
387 | 387 | /*! |
|
388 | 388 | \qmlmethod XYSeries::insert(int index, real x, real y) |
|
389 | 389 | Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of |
|
390 | 390 | points. If index is the same as or bigger than count, the point is appended to the list of points. |
|
391 | 391 | */ |
|
392 | 392 | |
|
393 | 393 | /*! |
|
394 | 394 | \qmlmethod QPointF XYSeries::at(int index) |
|
395 | 395 | Returns point at \a index. Returns (0, 0) if the index is not valid. |
|
396 | 396 | */ |
|
397 | 397 | |
|
398 | 398 | /*! |
|
399 | 399 | \internal |
|
400 | 400 | |
|
401 | 401 | Constructs empty series object which is a child of \a parent. |
|
402 | 402 | When series object is added to QChart instance ownerships is transferred. |
|
403 | 403 | */ |
|
404 | 404 | QXYSeries::QXYSeries(QXYSeriesPrivate &d, QObject *parent) |
|
405 | 405 | : QAbstractSeries(d, parent) |
|
406 | 406 | { |
|
407 | 407 | } |
|
408 | 408 | |
|
409 | 409 | /*! |
|
410 | 410 | Destroys the object. Series added to QChart instances are owned by those, |
|
411 | 411 | and are destroyed when QChart instances are destroyed. |
|
412 | 412 | */ |
|
413 | 413 | QXYSeries::~QXYSeries() |
|
414 | 414 | { |
|
415 | 415 | } |
|
416 | 416 | |
|
417 | 417 | /*! |
|
418 | 418 | Adds data point (\a x, \a y) to the series. |
|
419 | 419 | */ |
|
420 | 420 | void QXYSeries::append(qreal x, qreal y) |
|
421 | 421 | { |
|
422 | 422 | append(QPointF(x, y)); |
|
423 | 423 | } |
|
424 | 424 | |
|
425 | 425 | /*! |
|
426 | 426 | This is an overloaded function. |
|
427 | 427 | Adds data \a point to the series. |
|
428 | 428 | */ |
|
429 | 429 | void QXYSeries::append(const QPointF &point) |
|
430 | 430 | { |
|
431 | 431 | Q_D(QXYSeries); |
|
432 | 432 | |
|
433 | 433 | if (isValidValue(point)) { |
|
434 | 434 | d->m_points << point; |
|
435 | 435 | emit pointAdded(d->m_points.count() - 1); |
|
436 | 436 | } |
|
437 | 437 | } |
|
438 | 438 | |
|
439 | 439 | /*! |
|
440 | 440 | This is an overloaded function. |
|
441 | 441 | Adds list of data \a points to the series. |
|
442 | 442 | */ |
|
443 | 443 | void QXYSeries::append(const QList<QPointF> &points) |
|
444 | 444 | { |
|
445 | 445 | foreach (const QPointF &point , points) |
|
446 | 446 | append(point); |
|
447 | 447 | } |
|
448 | 448 | |
|
449 | 449 | /*! |
|
450 | 450 | Replaces data point (\a oldX, \a oldY) with data point (\a newX, \a newY). |
|
451 | 451 | \sa QXYSeries::pointReplaced() |
|
452 | 452 | */ |
|
453 | 453 | void QXYSeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY) |
|
454 | 454 | { |
|
455 | 455 | replace(QPointF(oldX, oldY), QPointF(newX, newY)); |
|
456 | 456 | } |
|
457 | 457 | |
|
458 | 458 | /*! |
|
459 | 459 | Replaces \a oldPoint with \a newPoint. |
|
460 | 460 | \sa QXYSeries::pointReplaced() |
|
461 | 461 | */ |
|
462 | 462 | void QXYSeries::replace(const QPointF &oldPoint, const QPointF &newPoint) |
|
463 | 463 | { |
|
464 | 464 | Q_D(QXYSeries); |
|
465 | 465 | int index = d->m_points.indexOf(oldPoint); |
|
466 | 466 | if (index == -1) |
|
467 | 467 | return; |
|
468 | 468 | replace(index, newPoint); |
|
469 | 469 | } |
|
470 | 470 | |
|
471 | 471 | /*! |
|
472 | 472 | Replaces the point at \a index with data point (\a newX, \a newY). |
|
473 | 473 | \sa QXYSeries::pointReplaced() |
|
474 | 474 | */ |
|
475 | 475 | void QXYSeries::replace(int index, qreal newX, qreal newY) |
|
476 | 476 | { |
|
477 | 477 | replace(index, QPointF(newX, newY)); |
|
478 | 478 | } |
|
479 | 479 | |
|
480 | 480 | /*! |
|
481 | 481 | Replaces the point at \a index with \a newPoint. |
|
482 | 482 | \sa QXYSeries::pointReplaced() |
|
483 | 483 | */ |
|
484 | 484 | void QXYSeries::replace(int index, const QPointF &newPoint) |
|
485 | 485 | { |
|
486 | 486 | Q_D(QXYSeries); |
|
487 | 487 | if (isValidValue(newPoint)) { |
|
488 | 488 | d->m_points[index] = newPoint; |
|
489 | 489 | emit pointReplaced(index); |
|
490 | 490 | } |
|
491 | 491 | } |
|
492 | 492 | |
|
493 | 493 | /*! |
|
494 | 494 | Replaces the current points with \a points. |
|
495 | 495 | \note This is much faster than replacing data points one by one, |
|
496 | 496 | or first clearing all data, and then appending the new data. Emits QXYSeries::pointsReplaced() |
|
497 | 497 | when the points have been replaced. |
|
498 | 498 | \sa QXYSeries::pointsReplaced() |
|
499 | 499 | */ |
|
500 | 500 | void QXYSeries::replace(QList<QPointF> points) |
|
501 | 501 | { |
|
502 | 502 | Q_D(QXYSeries); |
|
503 | 503 | d->m_points = points.toVector(); |
|
504 | 504 | emit pointsReplaced(); |
|
505 | 505 | } |
|
506 | 506 | |
|
507 | 507 | /*! |
|
508 | 508 | Removes the point (\a x, \a y) from the series. |
|
509 | 509 | */ |
|
510 | 510 | void QXYSeries::remove(qreal x, qreal y) |
|
511 | 511 | { |
|
512 | 512 | remove(QPointF(x, y)); |
|
513 | 513 | } |
|
514 | 514 | |
|
515 | 515 | /*! |
|
516 | 516 | Removes the \a point from the series. |
|
517 | 517 | */ |
|
518 | 518 | void QXYSeries::remove(const QPointF &point) |
|
519 | 519 | { |
|
520 | 520 | Q_D(QXYSeries); |
|
521 | 521 | int index = d->m_points.indexOf(point); |
|
522 | 522 | if (index == -1) |
|
523 | 523 | return; |
|
524 | 524 | remove(index); |
|
525 | 525 | } |
|
526 | 526 | |
|
527 | 527 | /*! |
|
528 | 528 | Removes the point at \a index from the series. |
|
529 | 529 | */ |
|
530 | 530 | void QXYSeries::remove(int index) |
|
531 | 531 | { |
|
532 | 532 | Q_D(QXYSeries); |
|
533 | 533 | d->m_points.remove(index); |
|
534 | 534 | emit pointRemoved(index); |
|
535 | 535 | } |
|
536 | 536 | |
|
537 | 537 | /*! |
|
538 | 538 | Inserts a \a point in the series at \a index position. |
|
539 | 539 | */ |
|
540 | 540 | void QXYSeries::insert(int index, const QPointF &point) |
|
541 | 541 | { |
|
542 | 542 | Q_D(QXYSeries); |
|
543 | 543 | if (isValidValue(point)) { |
|
544 | 544 | index = qMax(0, qMin(index, d->m_points.size())); |
|
545 | 545 | d->m_points.insert(index, point); |
|
546 | 546 | emit pointAdded(index); |
|
547 | 547 | } |
|
548 | 548 | } |
|
549 | 549 | |
|
550 | 550 | /*! |
|
551 | 551 | Removes all points from the series. |
|
552 | 552 | */ |
|
553 | 553 | void QXYSeries::clear() |
|
554 | 554 | { |
|
555 | 555 | Q_D(QXYSeries); |
|
556 | 556 | for (int i = d->m_points.size() - 1; i >= 0; i--) |
|
557 | 557 | remove(d->m_points.at(i)); |
|
558 | 558 | } |
|
559 | 559 | |
|
560 | 560 | /*! |
|
561 | 561 | Returns list of points in the series. |
|
562 | 562 | */ |
|
563 | 563 | QList<QPointF> QXYSeries::points() const |
|
564 | 564 | { |
|
565 | 565 | Q_D(const QXYSeries); |
|
566 | 566 | return d->m_points.toList(); |
|
567 | 567 | } |
|
568 | 568 | |
|
569 | 569 | /*! |
|
570 | 570 | Returns point at \a index in internal points vector. |
|
571 | 571 | */ |
|
572 | 572 | const QPointF &QXYSeries::at(int index) const |
|
573 | 573 | { |
|
574 | 574 | Q_D(const QXYSeries); |
|
575 | 575 | return d->m_points.at(index); |
|
576 | 576 | } |
|
577 | 577 | |
|
578 | 578 | /*! |
|
579 | 579 | Returns number of data points within series. |
|
580 | 580 | */ |
|
581 | 581 | int QXYSeries::count() const |
|
582 | 582 | { |
|
583 | 583 | Q_D(const QXYSeries); |
|
584 | 584 | return d->m_points.count(); |
|
585 | 585 | } |
|
586 | 586 | |
|
587 | 587 | |
|
588 | 588 | /*! |
|
589 | 589 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the |
|
590 | 590 | pen from chart theme is used. |
|
591 | 591 | \sa QChart::setTheme() |
|
592 | 592 | */ |
|
593 | 593 | void QXYSeries::setPen(const QPen &pen) |
|
594 | 594 | { |
|
595 | 595 | Q_D(QXYSeries); |
|
596 | 596 | if (d->m_pen != pen) { |
|
597 | 597 | bool emitColorChanged = d->m_pen.color() != pen.color(); |
|
598 | 598 | d->m_pen = pen; |
|
599 | 599 | emit d->updated(); |
|
600 | 600 | if (emitColorChanged) |
|
601 | 601 | emit colorChanged(pen.color()); |
|
602 | 602 | } |
|
603 | 603 | } |
|
604 | 604 | |
|
605 | 605 | QPen QXYSeries::pen() const |
|
606 | 606 | { |
|
607 | 607 | Q_D(const QXYSeries); |
|
608 | 608 | if (d->m_pen == QChartPrivate::defaultPen()) |
|
609 | 609 | return QPen(); |
|
610 | 610 | else |
|
611 | 611 | return d->m_pen; |
|
612 | 612 | } |
|
613 | 613 | |
|
614 | 614 | /*! |
|
615 | 615 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush |
|
616 | 616 | from chart theme setting is used. |
|
617 | 617 | \sa QChart::setTheme() |
|
618 | 618 | */ |
|
619 | 619 | void QXYSeries::setBrush(const QBrush &brush) |
|
620 | 620 | { |
|
621 | 621 | Q_D(QXYSeries); |
|
622 | 622 | if (d->m_brush != brush) { |
|
623 | 623 | d->m_brush = brush; |
|
624 | 624 | emit d->updated(); |
|
625 | 625 | } |
|
626 | 626 | } |
|
627 | 627 | |
|
628 | 628 | QBrush QXYSeries::brush() const |
|
629 | 629 | { |
|
630 | 630 | Q_D(const QXYSeries); |
|
631 | 631 | if (d->m_brush == QChartPrivate::defaultBrush()) |
|
632 | 632 | return QBrush(); |
|
633 | 633 | else |
|
634 | 634 | return d->m_brush; |
|
635 | 635 | } |
|
636 | 636 | |
|
637 | 637 | void QXYSeries::setColor(const QColor &color) |
|
638 | 638 | { |
|
639 | 639 | QPen p = pen(); |
|
640 | 640 | if (p.color() != color) { |
|
641 | 641 | p.setColor(color); |
|
642 | 642 | setPen(p); |
|
643 | 643 | } |
|
644 | 644 | } |
|
645 | 645 | |
|
646 | 646 | QColor QXYSeries::color() const |
|
647 | 647 | { |
|
648 | 648 | return pen().color(); |
|
649 | 649 | } |
|
650 | 650 | |
|
651 | 651 | void QXYSeries::setPointsVisible(bool visible) |
|
652 | 652 | { |
|
653 | 653 | Q_D(QXYSeries); |
|
654 | 654 | if (d->m_pointsVisible != visible) { |
|
655 | 655 | d->m_pointsVisible = visible; |
|
656 | 656 | emit d->updated(); |
|
657 | 657 | } |
|
658 | 658 | } |
|
659 | 659 | |
|
660 | 660 | bool QXYSeries::pointsVisible() const |
|
661 | 661 | { |
|
662 | 662 | Q_D(const QXYSeries); |
|
663 | 663 | return d->m_pointsVisible; |
|
664 | 664 | } |
|
665 | 665 | |
|
666 | 666 | void QXYSeries::setPointLabelsFormat(const QString &format) |
|
667 | 667 | { |
|
668 | 668 | Q_D(QXYSeries); |
|
669 | 669 | if (d->m_pointLabelsFormat != format) { |
|
670 | 670 | d->m_pointLabelsFormat = format; |
|
671 | 671 | emit pointLabelsFormatChanged(format); |
|
672 | 672 | } |
|
673 | 673 | } |
|
674 | 674 | |
|
675 | 675 | QString QXYSeries::pointLabelsFormat() const |
|
676 | 676 | { |
|
677 | 677 | Q_D(const QXYSeries); |
|
678 | 678 | return d->m_pointLabelsFormat; |
|
679 | 679 | } |
|
680 | 680 | |
|
681 | 681 | void QXYSeries::setPointLabelsVisible(bool visible) |
|
682 | 682 | { |
|
683 | 683 | Q_D(QXYSeries); |
|
684 | 684 | if (d->m_pointLabelsVisible != visible) { |
|
685 | 685 | d->m_pointLabelsVisible = visible; |
|
686 | 686 | emit pointLabelsVisibilityChanged(visible); |
|
687 | 687 | } |
|
688 | 688 | } |
|
689 | 689 | |
|
690 | 690 | bool QXYSeries::pointLabelsVisible() const |
|
691 | 691 | { |
|
692 | 692 | Q_D(const QXYSeries); |
|
693 | 693 | return d->m_pointLabelsVisible; |
|
694 | 694 | } |
|
695 | 695 | |
|
696 | 696 | void QXYSeries::setPointLabelsFont(const QFont &font) |
|
697 | 697 | { |
|
698 | 698 | Q_D(QXYSeries); |
|
699 | 699 | if (d->m_pointLabelsFont != font) { |
|
700 | 700 | d->m_pointLabelsFont = font; |
|
701 | 701 | emit pointLabelsFontChanged(font); |
|
702 | 702 | } |
|
703 | 703 | } |
|
704 | 704 | |
|
705 | 705 | QFont QXYSeries::pointLabelsFont() const |
|
706 | 706 | { |
|
707 | 707 | Q_D(const QXYSeries); |
|
708 | 708 | return d->m_pointLabelsFont; |
|
709 | 709 | } |
|
710 | 710 | |
|
711 | 711 | void QXYSeries::setPointLabelsColor(const QColor &color) |
|
712 | 712 | { |
|
713 | 713 | Q_D(QXYSeries); |
|
714 | 714 | if (d->m_pointLabelsColor != color) { |
|
715 | 715 | d->m_pointLabelsColor = color; |
|
716 | 716 | emit pointLabelsColorChanged(color); |
|
717 | 717 | } |
|
718 | 718 | } |
|
719 | 719 | |
|
720 | 720 | QColor QXYSeries::pointLabelsColor() const |
|
721 | 721 | { |
|
722 | 722 | Q_D(const QXYSeries); |
|
723 | 723 | if (d->m_pointLabelsColor == QChartPrivate::defaultPen().color()) |
|
724 | 724 | return QPen().color(); |
|
725 | 725 | else |
|
726 | 726 | return d->m_pointLabelsColor; |
|
727 | 727 | } |
|
728 | 728 | |
|
729 | 729 | /*! |
|
730 | 730 | Stream operator for adding a data \a point to the series. |
|
731 | 731 | \sa append() |
|
732 | 732 | */ |
|
733 | 733 | QXYSeries &QXYSeries::operator<< (const QPointF &point) |
|
734 | 734 | { |
|
735 | 735 | append(point); |
|
736 | 736 | return *this; |
|
737 | 737 | } |
|
738 | 738 | |
|
739 | 739 | |
|
740 | 740 | /*! |
|
741 | 741 | Stream operator for adding a list of \a points to the series. |
|
742 | 742 | \sa append() |
|
743 | 743 | */ |
|
744 | 744 | |
|
745 | 745 | QXYSeries &QXYSeries::operator<< (const QList<QPointF>& points) |
|
746 | 746 | { |
|
747 | 747 | append(points); |
|
748 | 748 | return *this; |
|
749 | 749 | } |
|
750 | 750 | |
|
751 | 751 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
752 | 752 | |
|
753 | 753 | |
|
754 | 754 | QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) |
|
755 | 755 | : QAbstractSeriesPrivate(q), |
|
756 | 756 | m_pen(QChartPrivate::defaultPen()), |
|
757 | 757 | m_brush(QChartPrivate::defaultBrush()), |
|
758 | 758 | m_pointsVisible(false), |
|
759 | 759 | m_pointLabelsFormat(QLatin1String("@xPoint, @yPoint")), |
|
760 | 760 | m_pointLabelsVisible(false), |
|
761 | 761 | m_pointLabelsFont(QChartPrivate::defaultFont()), |
|
762 | 762 | m_pointLabelsColor(QChartPrivate::defaultPen().color()) |
|
763 | 763 | { |
|
764 | 764 | } |
|
765 | 765 | |
|
766 | 766 | void QXYSeriesPrivate::initializeDomain() |
|
767 | 767 | { |
|
768 | 768 | qreal minX(0); |
|
769 | 769 | qreal minY(0); |
|
770 | 770 | qreal maxX(1); |
|
771 | 771 | qreal maxY(1); |
|
772 | 772 | |
|
773 | 773 | Q_Q(QXYSeries); |
|
774 | 774 | |
|
775 | 775 | const QList<QPointF>& points = q->points(); |
|
776 | 776 | |
|
777 | 777 | if (!points.isEmpty()) { |
|
778 | 778 | minX = points[0].x(); |
|
779 | 779 | minY = points[0].y(); |
|
780 | 780 | maxX = minX; |
|
781 | 781 | maxY = minY; |
|
782 | 782 | |
|
783 | 783 | for (int i = 0; i < points.count(); i++) { |
|
784 | 784 | qreal x = points[i].x(); |
|
785 | 785 | qreal y = points[i].y(); |
|
786 | 786 | minX = qMin(minX, x); |
|
787 | 787 | minY = qMin(minY, y); |
|
788 | 788 | maxX = qMax(maxX, x); |
|
789 | 789 | maxY = qMax(maxY, y); |
|
790 | 790 | } |
|
791 | 791 | } |
|
792 | 792 | |
|
793 | 793 | domain()->setRange(minX, maxX, minY, maxY); |
|
794 | 794 | } |
|
795 | 795 | |
|
796 | 796 | QList<QLegendMarker*> QXYSeriesPrivate::createLegendMarkers(QLegend* legend) |
|
797 | 797 | { |
|
798 | 798 | Q_Q(QXYSeries); |
|
799 | 799 | QList<QLegendMarker*> list; |
|
800 | 800 | return list << new QXYLegendMarker(q,legend); |
|
801 | 801 | } |
|
802 | 802 | |
|
803 | 803 | void QXYSeriesPrivate::initializeAxes() |
|
804 | 804 | { |
|
805 | 805 | |
|
806 | 806 | } |
|
807 | 807 | |
|
808 | 808 | QAbstractAxis::AxisType QXYSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const |
|
809 | 809 | { |
|
810 | 810 | Q_UNUSED(orientation); |
|
811 | 811 | return QAbstractAxis::AxisTypeValue; |
|
812 | 812 | } |
|
813 | 813 | |
|
814 | 814 | QAbstractAxis* QXYSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const |
|
815 | 815 | { |
|
816 | 816 | Q_UNUSED(orientation); |
|
817 | 817 | return new QValueAxis; |
|
818 | 818 | } |
|
819 | 819 | |
|
820 | 820 | void QXYSeriesPrivate::initializeAnimations(QtCharts::QChart::AnimationOptions options) |
|
821 | 821 | { |
|
822 | 822 | XYChart *item = static_cast<XYChart *>(m_item.data()); |
|
823 | 823 | Q_ASSERT(item); |
|
824 | 824 | if (item->animation()) |
|
825 | 825 | item->animation()->stopAndDestroyLater(); |
|
826 | 826 | |
|
827 | 827 | if (options.testFlag(QChart::SeriesAnimations)) |
|
828 | 828 | item->setAnimation(new XYAnimation(item)); |
|
829 | 829 | else |
|
830 | 830 | item->setAnimation(0); |
|
831 | 831 | QAbstractSeriesPrivate::initializeAnimations(options); |
|
832 | 832 | } |
|
833 | 833 | |
|
834 | 834 | void QXYSeriesPrivate::drawSeriesPointLabels(QPainter *painter, const QVector<QPointF> &points, |
|
835 | 835 | const int offset) |
|
836 | 836 | { |
|
837 | 837 | static const QString xPointTag(QLatin1String("@xPoint")); |
|
838 | 838 | static const QString yPointTag(QLatin1String("@yPoint")); |
|
839 | 839 | const int labelOffset = offset + 2; |
|
840 | 840 | |
|
841 | 841 | painter->setFont(m_pointLabelsFont); |
|
842 | 842 | painter->setPen(QPen(m_pointLabelsColor)); |
|
843 | 843 | QFontMetrics fm(painter->font()); |
|
844 | 844 | // m_points is used for the label here as it has the series point information |
|
845 | 845 | // points variable passed is used for positioning because it has the coordinates |
|
846 | 846 | for (int i(0); i < m_points.size(); i++) { |
|
847 | 847 | QString pointLabel = m_pointLabelsFormat; |
|
848 | 848 | pointLabel.replace(xPointTag, presenter()->numberToString(m_points.at(i).x())); |
|
849 | 849 | pointLabel.replace(yPointTag, presenter()->numberToString(m_points.at(i).y())); |
|
850 | 850 | |
|
851 | 851 | // Position text in relation to the point |
|
852 | 852 | int pointLabelWidth = fm.width(pointLabel); |
|
853 | 853 | QPointF position(points.at(i)); |
|
854 | position.setX(position.x() - pointLabelWidth / 2); | |
|
855 |
position.set |
|
|
854 | if (!reverseXAxis()) | |
|
855 | position.setX(position.x() - pointLabelWidth / 2); | |
|
856 | else | |
|
857 | position.setX(domain()->size().width() - position.x() - pointLabelWidth / 2); | |
|
858 | if (!reverseYAxis()) | |
|
859 | position.setY(position.y() - labelOffset); | |
|
860 | else | |
|
861 | position.setY(domain()->size().height() - position.y() - labelOffset); | |
|
856 | 862 | |
|
857 | 863 | painter->drawText(position, pointLabel); |
|
858 | 864 | } |
|
859 | 865 | } |
|
860 | 866 | |
|
861 | 867 | #include "moc_qxyseries.cpp" |
|
862 | 868 | #include "moc_qxyseries_p.cpp" |
|
863 | 869 | |
|
864 | 870 | QT_CHARTS_END_NAMESPACE |
@@ -1,314 +1,316 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #include <QtCharts/QChart> |
|
20 | 20 | #include <QtCharts/QAbstractAxis> |
|
21 | 21 | #include <QtCharts/QValueAxis> |
|
22 | 22 | #include <QtCharts/QLogValueAxis> |
|
23 | 23 | #include "declarativecategoryaxis.h" |
|
24 | 24 | #include <QtCharts/QBarCategoryAxis> |
|
25 | 25 | #include "declarativechart.h" |
|
26 | 26 | #include "declarativepolarchart.h" |
|
27 | 27 | #include "declarativexypoint.h" |
|
28 | 28 | #include "declarativelineseries.h" |
|
29 | 29 | #include "declarativesplineseries.h" |
|
30 | 30 | #include "declarativeareaseries.h" |
|
31 | 31 | #include "declarativescatterseries.h" |
|
32 | 32 | #include "declarativebarseries.h" |
|
33 | 33 | #include "declarativeboxplotseries.h" |
|
34 | 34 | #include "declarativepieseries.h" |
|
35 | 35 | #include "declarativeaxes.h" |
|
36 | 36 | #include <QtCharts/QVXYModelMapper> |
|
37 | 37 | #include <QtCharts/QHXYModelMapper> |
|
38 | 38 | #include <QtCharts/QHPieModelMapper> |
|
39 | 39 | #include <QtCharts/QVPieModelMapper> |
|
40 | 40 | #include <QtCharts/QHBarModelMapper> |
|
41 | 41 | #include <QtCharts/QVBarModelMapper> |
|
42 | 42 | #include "declarativemargins.h" |
|
43 | 43 | #include <QtCharts/QAreaLegendMarker> |
|
44 | 44 | #include <QtCharts/QBarLegendMarker> |
|
45 | 45 | #include <QtCharts/QPieLegendMarker> |
|
46 | 46 | #include <QtCharts/QXYLegendMarker> |
|
47 | 47 | #include <QtCharts/QBoxPlotModelMapper> |
|
48 | 48 | #include <QtCharts/QVBoxPlotModelMapper> |
|
49 | 49 | #ifndef QT_ON_ARM |
|
50 | 50 | #include <QtCharts/QDateTimeAxis> |
|
51 | 51 | #endif |
|
52 | 52 | #include <QtCore/QAbstractItemModel> |
|
53 | 53 | #include <QtQml> |
|
54 | 54 | |
|
55 | 55 | QT_CHARTS_USE_NAMESPACE |
|
56 | 56 | |
|
57 | 57 | QML_DECLARE_TYPE(QList<QPieSlice *>) |
|
58 | 58 | QML_DECLARE_TYPE(QList<QBarSet *>) |
|
59 | 59 | QML_DECLARE_TYPE(QList<QAbstractAxis *>) |
|
60 | 60 | |
|
61 | 61 | QML_DECLARE_TYPE(DeclarativeChart) |
|
62 | 62 | QML_DECLARE_TYPE(DeclarativePolarChart) |
|
63 | 63 | QML_DECLARE_TYPE(DeclarativeMargins) |
|
64 | 64 | QML_DECLARE_TYPE(DeclarativeAreaSeries) |
|
65 | 65 | QML_DECLARE_TYPE(DeclarativeBarSeries) |
|
66 | 66 | QML_DECLARE_TYPE(DeclarativeBarSet) |
|
67 | 67 | QML_DECLARE_TYPE(DeclarativeBoxPlotSeries) |
|
68 | 68 | QML_DECLARE_TYPE(DeclarativeBoxSet) |
|
69 | 69 | QML_DECLARE_TYPE(DeclarativeLineSeries) |
|
70 | 70 | QML_DECLARE_TYPE(DeclarativePieSeries) |
|
71 | 71 | QML_DECLARE_TYPE(DeclarativePieSlice) |
|
72 | 72 | QML_DECLARE_TYPE(DeclarativeScatterSeries) |
|
73 | 73 | QML_DECLARE_TYPE(DeclarativeSplineSeries) |
|
74 | 74 | |
|
75 | 75 | QML_DECLARE_TYPE(QAbstractAxis) |
|
76 | 76 | QML_DECLARE_TYPE(QValueAxis) |
|
77 | 77 | QML_DECLARE_TYPE(QBarCategoryAxis) |
|
78 | 78 | QML_DECLARE_TYPE(QCategoryAxis) |
|
79 | 79 | QML_DECLARE_TYPE(QDateTimeAxis) |
|
80 | 80 | QML_DECLARE_TYPE(QLogValueAxis) |
|
81 | 81 | |
|
82 | 82 | QML_DECLARE_TYPE(QLegend) |
|
83 | 83 | QML_DECLARE_TYPE(QLegendMarker) |
|
84 | 84 | QML_DECLARE_TYPE(QAreaLegendMarker) |
|
85 | 85 | QML_DECLARE_TYPE(QBarLegendMarker) |
|
86 | 86 | QML_DECLARE_TYPE(QPieLegendMarker) |
|
87 | 87 | |
|
88 | 88 | QML_DECLARE_TYPE(QHPieModelMapper) |
|
89 | 89 | QML_DECLARE_TYPE(QHXYModelMapper) |
|
90 | 90 | QML_DECLARE_TYPE(QPieModelMapper) |
|
91 | 91 | QML_DECLARE_TYPE(QHBarModelMapper) |
|
92 | 92 | QML_DECLARE_TYPE(QBarModelMapper) |
|
93 | 93 | QML_DECLARE_TYPE(QVBarModelMapper) |
|
94 | 94 | QML_DECLARE_TYPE(QVPieModelMapper) |
|
95 | 95 | QML_DECLARE_TYPE(QVXYModelMapper) |
|
96 | 96 | QML_DECLARE_TYPE(QXYLegendMarker) |
|
97 | 97 | QML_DECLARE_TYPE(QXYModelMapper) |
|
98 | 98 | QML_DECLARE_TYPE(QBoxPlotModelMapper) |
|
99 | 99 | QML_DECLARE_TYPE(QVBoxPlotModelMapper) |
|
100 | 100 | |
|
101 | 101 | QML_DECLARE_TYPE(QAbstractSeries) |
|
102 | 102 | QML_DECLARE_TYPE(QXYSeries) |
|
103 | 103 | QML_DECLARE_TYPE(QAbstractBarSeries) |
|
104 | 104 | QML_DECLARE_TYPE(QBarSeries) |
|
105 | 105 | QML_DECLARE_TYPE(QBarSet) |
|
106 | 106 | QML_DECLARE_TYPE(QAreaSeries) |
|
107 | 107 | QML_DECLARE_TYPE(QHorizontalBarSeries) |
|
108 | 108 | QML_DECLARE_TYPE(QHorizontalPercentBarSeries) |
|
109 | 109 | QML_DECLARE_TYPE(QHorizontalStackedBarSeries) |
|
110 | 110 | QML_DECLARE_TYPE(QLineSeries) |
|
111 | 111 | QML_DECLARE_TYPE(QPercentBarSeries) |
|
112 | 112 | QML_DECLARE_TYPE(QPieSeries) |
|
113 | 113 | QML_DECLARE_TYPE(QPieSlice) |
|
114 | 114 | QML_DECLARE_TYPE(QScatterSeries) |
|
115 | 115 | QML_DECLARE_TYPE(QSplineSeries) |
|
116 | 116 | QML_DECLARE_TYPE(QStackedBarSeries) |
|
117 | 117 | |
|
118 | 118 | QT_CHARTS_BEGIN_NAMESPACE |
|
119 | 119 | |
|
120 | 120 | class QtChartsQml2Plugin : public QQmlExtensionPlugin |
|
121 | 121 | { |
|
122 | 122 | Q_OBJECT |
|
123 | 123 | |
|
124 | 124 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") |
|
125 | 125 | |
|
126 | 126 | public: |
|
127 | 127 | virtual void registerTypes(const char *uri) |
|
128 | 128 | { |
|
129 | 129 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCharts")); |
|
130 | 130 | |
|
131 | 131 | // @uri QtCharts |
|
132 | 132 | |
|
133 | 133 | qRegisterMetaType<QList<QPieSlice *> >(); |
|
134 | 134 | qRegisterMetaType<QList<QBarSet *> >(); |
|
135 | 135 | qRegisterMetaType<QList<QAbstractAxis *> >(); |
|
136 | 136 | |
|
137 | 137 | // QtCharts 1.0 |
|
138 | 138 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); |
|
139 | 139 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint"); |
|
140 | 140 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); |
|
141 | 141 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); |
|
142 | 142 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); |
|
143 | 143 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); |
|
144 | 144 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
145 | 145 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); |
|
146 | 146 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); |
|
147 | 147 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
148 | 148 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); |
|
149 | 149 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
150 | 150 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); |
|
151 | 151 | qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); |
|
152 | 152 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); |
|
153 | 153 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); |
|
154 | 154 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); |
|
155 | 155 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); |
|
156 | 156 | |
|
157 | 157 | qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis"); |
|
158 | 158 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis"); |
|
159 | 159 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", |
|
160 | 160 | QLatin1String("Trying to create uncreatable: Legend.")); |
|
161 | 161 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", |
|
162 | 162 | QLatin1String("Trying to create uncreatable: XYSeries.")); |
|
163 | 163 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", |
|
164 | 164 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
165 | 165 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", |
|
166 | 166 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); |
|
167 | 167 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
168 | 168 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
169 | 169 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", |
|
170 | 170 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); |
|
171 | 171 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", |
|
172 | 172 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); |
|
173 | 173 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", |
|
174 | 174 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); |
|
175 | 175 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", |
|
176 | 176 | QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); |
|
177 | 177 | qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase", |
|
178 | 178 | QLatin1String("Trying to create uncreatable: BarsetBase.")); |
|
179 | 179 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", |
|
180 | 180 | QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); |
|
181 | 181 | qmlRegisterUncreatableType<DeclarativeAxes>(uri, 1, 0, "DeclarativeAxes", |
|
182 | 182 | QLatin1String("Trying to create uncreatable: DeclarativeAxes.")); |
|
183 | 183 | |
|
184 | 184 | // QtCharts 1.1 |
|
185 | 185 | qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView"); |
|
186 | 186 | qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries"); |
|
187 | 187 | qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries"); |
|
188 | 188 | qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries"); |
|
189 | 189 | qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries"); |
|
190 | 190 | qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries"); |
|
191 | 191 | qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries"); |
|
192 | 192 | qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries"); |
|
193 | 193 | qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries"); |
|
194 | 194 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries"); |
|
195 | 195 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries"); |
|
196 | 196 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries"); |
|
197 | 197 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet"); |
|
198 | 198 | qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis"); |
|
199 | 199 | #ifndef QT_ON_ARM |
|
200 | 200 | qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis"); |
|
201 | 201 | #endif |
|
202 | 202 | qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis"); |
|
203 | 203 | qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange"); |
|
204 | 204 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis"); |
|
205 | 205 | qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins", |
|
206 | 206 | QLatin1String("Trying to create uncreatable: Margins.")); |
|
207 | 207 | |
|
208 | 208 | // QtCharts 1.2 |
|
209 | 209 | qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView"); |
|
210 | 210 | qmlRegisterType<DeclarativeScatterSeries, 2>(uri, 1, 2, "ScatterSeries"); |
|
211 | 211 | qmlRegisterType<DeclarativeLineSeries, 2>(uri, 1, 2, "LineSeries"); |
|
212 | 212 | qmlRegisterType<DeclarativeSplineSeries, 2>(uri, 1, 2, "SplineSeries"); |
|
213 | 213 | qmlRegisterType<DeclarativeAreaSeries, 2>(uri, 1, 2, "AreaSeries"); |
|
214 | 214 | qmlRegisterType<DeclarativeBarSeries, 2>(uri, 1, 2, "BarSeries"); |
|
215 | 215 | qmlRegisterType<DeclarativeStackedBarSeries, 2>(uri, 1, 2, "StackedBarSeries"); |
|
216 | 216 | qmlRegisterType<DeclarativePercentBarSeries, 2>(uri, 1, 2, "PercentBarSeries"); |
|
217 | 217 | qmlRegisterType<DeclarativeHorizontalBarSeries, 2>(uri, 1, 2, "HorizontalBarSeries"); |
|
218 | 218 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 2>(uri, 1, 2, "HorizontalStackedBarSeries"); |
|
219 | 219 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 2>(uri, 1, 2, "HorizontalPercentBarSeries"); |
|
220 | 220 | |
|
221 | 221 | // QtCharts 1.3 |
|
222 | 222 | qmlRegisterType<DeclarativeChart, 3>(uri, 1, 3, "ChartView"); |
|
223 | 223 | qmlRegisterType<DeclarativePolarChart, 1>(uri, 1, 3, "PolarChartView"); |
|
224 | 224 | qmlRegisterType<DeclarativeSplineSeries, 3>(uri, 1, 3, "SplineSeries"); |
|
225 | 225 | qmlRegisterType<DeclarativeScatterSeries, 3>(uri, 1, 3, "ScatterSeries"); |
|
226 | 226 | qmlRegisterType<DeclarativeLineSeries, 3>(uri, 1, 3, "LineSeries"); |
|
227 | 227 | qmlRegisterType<DeclarativeAreaSeries, 3>(uri, 1, 3, "AreaSeries"); |
|
228 | 228 | qmlRegisterType<QLogValueAxis>(uri, 1, 3, "LogValueAxis"); |
|
229 | 229 | qmlRegisterType<DeclarativeBoxPlotSeries>(uri, 1, 3, "BoxPlotSeries"); |
|
230 | 230 | qmlRegisterType<DeclarativeBoxSet>(uri, 1, 3, "BoxSet"); |
|
231 | 231 | |
|
232 | 232 | // QtCharts 1.4 |
|
233 | 233 | qmlRegisterType<DeclarativeAreaSeries, 4>(uri, 1, 4, "AreaSeries"); |
|
234 | 234 | qmlRegisterType<DeclarativeBarSet, 2>(uri, 1, 4, "BarSet"); |
|
235 | 235 | qmlRegisterType<DeclarativeBoxPlotSeries, 1>(uri, 1, 4, "BoxPlotSeries"); |
|
236 | 236 | qmlRegisterType<DeclarativeBoxSet, 1>(uri, 1, 4, "BoxSet"); |
|
237 | 237 | qmlRegisterType<DeclarativePieSlice>(uri, 1, 4, "PieSlice"); |
|
238 | 238 | qmlRegisterType<DeclarativeScatterSeries, 4>(uri, 1, 4, "ScatterSeries"); |
|
239 | 239 | |
|
240 | 240 | // QtCharts 2.0 |
|
241 | 241 | qmlRegisterType<QVBoxPlotModelMapper>(uri, 2, 0, "VBoxPlotModelMapper"); |
|
242 | 242 | qmlRegisterUncreatableType<QBoxPlotModelMapper>(uri, 2, 0, "BoxPlotModelMapper", |
|
243 | 243 | QLatin1String("Trying to create uncreatable: BoxPlotModelMapper.")); |
|
244 | 244 | qmlRegisterType<DeclarativeChart, 4>(uri, 2, 0, "ChartView"); |
|
245 | 245 | qmlRegisterType<DeclarativeXYPoint>(uri, 2, 0, "XYPoint"); |
|
246 | 246 | qmlRegisterType<DeclarativeScatterSeries, 4>(uri, 2, 0, "ScatterSeries"); |
|
247 | 247 | qmlRegisterType<DeclarativeLineSeries, 3>(uri, 2, 0, "LineSeries"); |
|
248 | 248 | qmlRegisterType<DeclarativeSplineSeries, 3>(uri, 2, 0, "SplineSeries"); |
|
249 | 249 | qmlRegisterType<DeclarativeAreaSeries, 4>(uri, 2, 0, "AreaSeries"); |
|
250 | 250 | qmlRegisterType<DeclarativeBarSeries, 2>(uri, 2, 0, "BarSeries"); |
|
251 | 251 | qmlRegisterType<DeclarativeStackedBarSeries, 2>(uri, 2, 0, "StackedBarSeries"); |
|
252 | 252 | qmlRegisterType<DeclarativePercentBarSeries, 2>(uri, 2, 0, "PercentBarSeries"); |
|
253 | 253 | qmlRegisterType<DeclarativePieSeries>(uri, 2, 0, "PieSeries"); |
|
254 | 254 | qmlRegisterType<QPieSlice>(uri, 2, 0, "PieSlice"); |
|
255 | 255 | qmlRegisterType<DeclarativeBarSet, 2>(uri, 2, 0, "BarSet"); |
|
256 | 256 | qmlRegisterType<QHXYModelMapper>(uri, 2, 0, "HXYModelMapper"); |
|
257 | 257 | qmlRegisterType<QVXYModelMapper>(uri, 2, 0, "VXYModelMapper"); |
|
258 | 258 | qmlRegisterType<QHPieModelMapper>(uri, 2, 0, "HPieModelMapper"); |
|
259 | 259 | qmlRegisterType<QVPieModelMapper>(uri, 2, 0, "VPieModelMapper"); |
|
260 | 260 | qmlRegisterType<QHBarModelMapper>(uri, 2, 0, "HBarModelMapper"); |
|
261 | 261 | qmlRegisterType<QVBarModelMapper>(uri, 2, 0, "VBarModelMapper"); |
|
262 | 262 | qmlRegisterType<QValueAxis>(uri, 2, 0, "ValueAxis"); |
|
263 | 263 | #ifndef QT_ON_ARM |
|
264 | 264 | qmlRegisterType<QDateTimeAxis>(uri, 2, 0, "DateTimeAxis"); |
|
265 | 265 | #endif |
|
266 | 266 | qmlRegisterType<DeclarativeCategoryAxis>(uri, 2, 0, "CategoryAxis"); |
|
267 | 267 | qmlRegisterType<DeclarativeCategoryRange>(uri, 2, 0, "CategoryRange"); |
|
268 | 268 | qmlRegisterType<QBarCategoryAxis>(uri, 2, 0, "BarCategoryAxis"); |
|
269 | 269 | qmlRegisterType<DeclarativePolarChart, 1>(uri, 2, 0, "PolarChartView"); |
|
270 | 270 | qmlRegisterType<QLogValueAxis, 1>(uri, 2, 0, "LogValueAxis"); |
|
271 | 271 | qmlRegisterType<DeclarativeBoxPlotSeries, 1>(uri, 2, 0, "BoxPlotSeries"); |
|
272 | 272 | qmlRegisterType<DeclarativeBoxSet, 1>(uri, 2, 0, "BoxSet"); |
|
273 | 273 | qmlRegisterType<DeclarativeHorizontalBarSeries, 2>(uri, 2, 0, "HorizontalBarSeries"); |
|
274 | 274 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 2>(uri, 2, 0, "HorizontalStackedBarSeries"); |
|
275 | 275 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 2>(uri, 2, 0, "HorizontalPercentBarSeries"); |
|
276 | 276 | qmlRegisterType<DeclarativePieSlice>(uri, 2, 0, "PieSlice"); |
|
277 | 277 | qmlRegisterUncreatableType<QLegend>(uri, 2, 0, "Legend", |
|
278 | 278 | QLatin1String("Trying to create uncreatable: Legend.")); |
|
279 | 279 | qmlRegisterUncreatableType<QXYSeries>(uri, 2, 0, "XYSeries", |
|
280 | 280 | QLatin1String("Trying to create uncreatable: XYSeries.")); |
|
281 | 281 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 2, 0, "AbstractItemModel", |
|
282 | 282 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
283 | 283 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 2, 0, "XYModelMapper", |
|
284 | 284 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); |
|
285 | 285 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 2, 0, "PieModelMapper", |
|
286 | 286 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
287 | 287 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 2, 0, "BarModelMapper", |
|
288 | 288 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); |
|
289 | 289 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 2, 0, "AbstractSeries", |
|
290 | 290 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); |
|
291 | 291 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 2, 0, "AbstractBarSeries", |
|
292 | 292 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); |
|
293 | 293 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 2, 0, "AbstractAxis", |
|
294 | 294 | QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); |
|
295 | 295 | qmlRegisterUncreatableType<QBarSet>(uri, 2, 0, "BarSetBase", |
|
296 | 296 | QLatin1String("Trying to create uncreatable: BarsetBase.")); |
|
297 | 297 | qmlRegisterUncreatableType<QPieSeries>(uri, 2, 0, "QPieSeries", |
|
298 | 298 | QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); |
|
299 | 299 | qmlRegisterUncreatableType<DeclarativeAxes>(uri, 2, 0, "DeclarativeAxes", |
|
300 | 300 | QLatin1String("Trying to create uncreatable: DeclarativeAxes.")); |
|
301 | 301 | qmlRegisterUncreatableType<DeclarativeMargins>(uri, 2, 0, "Margins", |
|
302 | 302 | QLatin1String("Trying to create uncreatable: Margins.")); |
|
303 | 303 | |
|
304 | 304 | // QtCharts 2.1 |
|
305 | 305 | qmlRegisterType<DeclarativeCategoryAxis, 1>(uri, 2, 1, "CategoryAxis"); |
|
306 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 2, 1, "AbstractAxis", | |
|
307 | QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); | |
|
306 | 308 | } |
|
307 | 309 | |
|
308 | 310 | }; |
|
309 | 311 | |
|
310 | 312 | QT_CHARTS_END_NAMESPACE |
|
311 | 313 | |
|
312 | 314 | #include "chartsqml2_plugin.moc" |
|
313 | 315 | |
|
314 | 316 | QT_CHARTS_USE_NAMESPACE |
@@ -1,2407 +1,2416 | |||
|
1 | 1 | import QtQuick.tooling 1.1 |
|
2 | 2 | |
|
3 | 3 | // This file describes the plugin-supplied types contained in the library. |
|
4 | 4 | // It is used for QML tooling purposes only. |
|
5 | 5 | // |
|
6 | 6 | // This file was auto-generated by: |
|
7 | 7 | // 'qmlplugindump -nonrelocatable QtCharts 2.0' |
|
8 | 8 | |
|
9 | 9 | Module { |
|
10 | 10 | Component { |
|
11 | 11 | name: "QGraphicsObject" |
|
12 | 12 | defaultProperty: "children" |
|
13 | 13 | prototype: "QObject" |
|
14 | 14 | Property { name: "parent"; type: "QGraphicsObject"; isPointer: true } |
|
15 | 15 | Property { name: "opacity"; type: "double" } |
|
16 | 16 | Property { name: "enabled"; type: "bool" } |
|
17 | 17 | Property { name: "visible"; type: "bool" } |
|
18 | 18 | Property { name: "pos"; type: "QPointF" } |
|
19 | 19 | Property { name: "x"; type: "double" } |
|
20 | 20 | Property { name: "y"; type: "double" } |
|
21 | 21 | Property { name: "z"; type: "double" } |
|
22 | 22 | Property { name: "rotation"; type: "double" } |
|
23 | 23 | Property { name: "scale"; type: "double" } |
|
24 | 24 | Property { name: "transformOriginPoint"; type: "QPointF" } |
|
25 | 25 | Property { name: "effect"; type: "QGraphicsEffect"; isPointer: true } |
|
26 | 26 | Property { |
|
27 | 27 | name: "children" |
|
28 | 28 | type: "QDeclarativeListProperty<QGraphicsObject>" |
|
29 | 29 | isReadonly: true |
|
30 | 30 | } |
|
31 | 31 | Property { name: "width"; type: "double" } |
|
32 | 32 | Property { name: "height"; type: "double" } |
|
33 | 33 | } |
|
34 | 34 | Component { |
|
35 | 35 | name: "QGraphicsWidget" |
|
36 | 36 | defaultProperty: "children" |
|
37 | 37 | prototype: "QGraphicsObject" |
|
38 | 38 | Property { name: "palette"; type: "QPalette" } |
|
39 | 39 | Property { name: "font"; type: "QFont" } |
|
40 | 40 | Property { name: "layoutDirection"; type: "Qt::LayoutDirection" } |
|
41 | 41 | Property { name: "size"; type: "QSizeF" } |
|
42 | 42 | Property { name: "minimumSize"; type: "QSizeF" } |
|
43 | 43 | Property { name: "preferredSize"; type: "QSizeF" } |
|
44 | 44 | Property { name: "maximumSize"; type: "QSizeF" } |
|
45 | 45 | Property { name: "sizePolicy"; type: "QSizePolicy" } |
|
46 | 46 | Property { name: "focusPolicy"; type: "Qt::FocusPolicy" } |
|
47 | 47 | Property { name: "windowFlags"; type: "Qt::WindowFlags" } |
|
48 | 48 | Property { name: "windowTitle"; type: "string" } |
|
49 | 49 | Property { name: "geometry"; type: "QRectF" } |
|
50 | 50 | Property { name: "autoFillBackground"; type: "bool" } |
|
51 | 51 | Property { name: "layout"; type: "QGraphicsLayout"; isPointer: true } |
|
52 | 52 | Method { name: "close"; type: "bool" } |
|
53 | 53 | } |
|
54 | 54 | Component { |
|
55 | 55 | name: "QtCharts::DeclarativeAreaSeries" |
|
56 | 56 | prototype: "QtCharts::QAreaSeries" |
|
57 | 57 | exports: [ |
|
58 | 58 | "QtCharts/AreaSeries 1.0", |
|
59 | 59 | "QtCharts/AreaSeries 1.1", |
|
60 | 60 | "QtCharts/AreaSeries 1.2", |
|
61 | 61 | "QtCharts/AreaSeries 1.3", |
|
62 | 62 | "QtCharts/AreaSeries 1.4", |
|
63 | 63 | "QtCharts/AreaSeries 2.0" |
|
64 | 64 | ] |
|
65 | 65 | exportMetaObjectRevisions: [0, 1, 2, 3, 4, 4] |
|
66 | 66 | Property { name: "upperSeries"; type: "DeclarativeLineSeries"; isPointer: true } |
|
67 | 67 | Property { name: "lowerSeries"; type: "DeclarativeLineSeries"; isPointer: true } |
|
68 | 68 | Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
69 | 69 | Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
70 | 70 | Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
71 | 71 | Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
72 | 72 | Property { name: "axisAngular"; revision: 3; type: "QAbstractAxis"; isPointer: true } |
|
73 | 73 | Property { name: "axisRadial"; revision: 3; type: "QAbstractAxis"; isPointer: true } |
|
74 | 74 | Property { name: "borderWidth"; revision: 1; type: "double" } |
|
75 | 75 | Property { name: "brushFilename"; revision: 4; type: "string" } |
|
76 | 76 | Property { name: "brush"; revision: 4; type: "QBrush" } |
|
77 | 77 | Signal { |
|
78 | 78 | name: "axisXChanged" |
|
79 | 79 | revision: 1 |
|
80 | 80 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
81 | 81 | } |
|
82 | 82 | Signal { |
|
83 | 83 | name: "axisYChanged" |
|
84 | 84 | revision: 1 |
|
85 | 85 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
86 | 86 | } |
|
87 | 87 | Signal { |
|
88 | 88 | name: "borderWidthChanged" |
|
89 | 89 | revision: 1 |
|
90 | 90 | Parameter { name: "width"; type: "double" } |
|
91 | 91 | } |
|
92 | 92 | Signal { |
|
93 | 93 | name: "axisXTopChanged" |
|
94 | 94 | revision: 2 |
|
95 | 95 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
96 | 96 | } |
|
97 | 97 | Signal { |
|
98 | 98 | name: "axisYRightChanged" |
|
99 | 99 | revision: 2 |
|
100 | 100 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
101 | 101 | } |
|
102 | 102 | Signal { |
|
103 | 103 | name: "axisAngularChanged" |
|
104 | 104 | revision: 3 |
|
105 | 105 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
106 | 106 | } |
|
107 | 107 | Signal { |
|
108 | 108 | name: "axisRadialChanged" |
|
109 | 109 | revision: 3 |
|
110 | 110 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
111 | 111 | } |
|
112 | 112 | Signal { name: "brushChanged"; revision: 4 } |
|
113 | 113 | Signal { |
|
114 | 114 | name: "brushFilenameChanged" |
|
115 | 115 | revision: 4 |
|
116 | 116 | Parameter { name: "brushFilename"; type: "string" } |
|
117 | 117 | } |
|
118 | 118 | } |
|
119 | 119 | Component { |
|
120 | 120 | name: "QtCharts::DeclarativeAxes" |
|
121 | 121 | prototype: "QObject" |
|
122 | 122 | exports: [ |
|
123 | 123 | "QtCharts/DeclarativeAxes 1.0", |
|
124 | 124 | "QtCharts/DeclarativeAxes 2.0" |
|
125 | 125 | ] |
|
126 | 126 | isCreatable: false |
|
127 | 127 | exportMetaObjectRevisions: [0, 0] |
|
128 | 128 | Property { name: "axisX"; type: "QAbstractAxis"; isPointer: true } |
|
129 | 129 | Property { name: "axisY"; type: "QAbstractAxis"; isPointer: true } |
|
130 | 130 | Property { name: "axisXTop"; type: "QAbstractAxis"; isPointer: true } |
|
131 | 131 | Property { name: "axisYRight"; type: "QAbstractAxis"; isPointer: true } |
|
132 | 132 | Signal { |
|
133 | 133 | name: "axisXChanged" |
|
134 | 134 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
135 | 135 | } |
|
136 | 136 | Signal { |
|
137 | 137 | name: "axisYChanged" |
|
138 | 138 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
139 | 139 | } |
|
140 | 140 | Signal { |
|
141 | 141 | name: "axisXTopChanged" |
|
142 | 142 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
143 | 143 | } |
|
144 | 144 | Signal { |
|
145 | 145 | name: "axisYRightChanged" |
|
146 | 146 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
147 | 147 | } |
|
148 | 148 | } |
|
149 | 149 | Component { |
|
150 | 150 | name: "QtCharts::DeclarativeBarSeries" |
|
151 | 151 | defaultProperty: "seriesChildren" |
|
152 | 152 | prototype: "QtCharts::QBarSeries" |
|
153 | 153 | exports: [ |
|
154 | 154 | "QtCharts/BarSeries 1.0", |
|
155 | 155 | "QtCharts/BarSeries 1.1", |
|
156 | 156 | "QtCharts/BarSeries 1.2", |
|
157 | 157 | "QtCharts/BarSeries 2.0" |
|
158 | 158 | ] |
|
159 | 159 | exportMetaObjectRevisions: [0, 1, 2, 2] |
|
160 | 160 | Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
161 | 161 | Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
162 | 162 | Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
163 | 163 | Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
164 | 164 | Property { name: "seriesChildren"; type: "QObject"; isList: true; isReadonly: true } |
|
165 | 165 | Signal { |
|
166 | 166 | name: "axisXChanged" |
|
167 | 167 | revision: 1 |
|
168 | 168 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
169 | 169 | } |
|
170 | 170 | Signal { |
|
171 | 171 | name: "axisYChanged" |
|
172 | 172 | revision: 1 |
|
173 | 173 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
174 | 174 | } |
|
175 | 175 | Signal { |
|
176 | 176 | name: "axisXTopChanged" |
|
177 | 177 | revision: 2 |
|
178 | 178 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
179 | 179 | } |
|
180 | 180 | Signal { |
|
181 | 181 | name: "axisYRightChanged" |
|
182 | 182 | revision: 2 |
|
183 | 183 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
184 | 184 | } |
|
185 | 185 | Method { |
|
186 | 186 | name: "appendSeriesChildren" |
|
187 | 187 | Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } |
|
188 | 188 | Parameter { name: "element"; type: "QObject"; isPointer: true } |
|
189 | 189 | } |
|
190 | 190 | Method { |
|
191 | 191 | name: "at" |
|
192 | 192 | type: "DeclarativeBarSet*" |
|
193 | 193 | Parameter { name: "index"; type: "int" } |
|
194 | 194 | } |
|
195 | 195 | Method { |
|
196 | 196 | name: "append" |
|
197 | 197 | type: "DeclarativeBarSet*" |
|
198 | 198 | Parameter { name: "label"; type: "string" } |
|
199 | 199 | Parameter { name: "values"; type: "QVariantList" } |
|
200 | 200 | } |
|
201 | 201 | Method { |
|
202 | 202 | name: "insert" |
|
203 | 203 | type: "DeclarativeBarSet*" |
|
204 | 204 | Parameter { name: "index"; type: "int" } |
|
205 | 205 | Parameter { name: "label"; type: "string" } |
|
206 | 206 | Parameter { name: "values"; type: "QVariantList" } |
|
207 | 207 | } |
|
208 | 208 | Method { |
|
209 | 209 | name: "remove" |
|
210 | 210 | type: "bool" |
|
211 | 211 | Parameter { name: "barset"; type: "QBarSet"; isPointer: true } |
|
212 | 212 | } |
|
213 | 213 | Method { name: "clear" } |
|
214 | 214 | } |
|
215 | 215 | Component { |
|
216 | 216 | name: "QtCharts::DeclarativeBarSet" |
|
217 | 217 | prototype: "QtCharts::QBarSet" |
|
218 | 218 | exports: [ |
|
219 | 219 | "QtCharts/BarSet 1.0", |
|
220 | 220 | "QtCharts/BarSet 1.1", |
|
221 | 221 | "QtCharts/BarSet 1.4", |
|
222 | 222 | "QtCharts/BarSet 2.0" |
|
223 | 223 | ] |
|
224 | 224 | exportMetaObjectRevisions: [0, 0, 2, 2] |
|
225 | 225 | Property { name: "values"; type: "QVariantList" } |
|
226 | 226 | Property { name: "borderWidth"; revision: 1; type: "double" } |
|
227 | 227 | Property { name: "count"; type: "int"; isReadonly: true } |
|
228 | 228 | Property { name: "brushFilename"; revision: 2; type: "string" } |
|
229 | 229 | Signal { |
|
230 | 230 | name: "countChanged" |
|
231 | 231 | Parameter { name: "count"; type: "int" } |
|
232 | 232 | } |
|
233 | 233 | Signal { |
|
234 | 234 | name: "borderWidthChanged" |
|
235 | 235 | revision: 1 |
|
236 | 236 | Parameter { name: "width"; type: "double" } |
|
237 | 237 | } |
|
238 | 238 | Signal { |
|
239 | 239 | name: "brushFilenameChanged" |
|
240 | 240 | revision: 2 |
|
241 | 241 | Parameter { name: "brushFilename"; type: "string" } |
|
242 | 242 | } |
|
243 | 243 | Method { |
|
244 | 244 | name: "append" |
|
245 | 245 | Parameter { name: "value"; type: "double" } |
|
246 | 246 | } |
|
247 | 247 | Method { |
|
248 | 248 | name: "remove" |
|
249 | 249 | Parameter { name: "index"; type: "int" } |
|
250 | 250 | Parameter { name: "count"; type: "int" } |
|
251 | 251 | } |
|
252 | 252 | Method { |
|
253 | 253 | name: "remove" |
|
254 | 254 | Parameter { name: "index"; type: "int" } |
|
255 | 255 | } |
|
256 | 256 | Method { |
|
257 | 257 | name: "replace" |
|
258 | 258 | Parameter { name: "index"; type: "int" } |
|
259 | 259 | Parameter { name: "value"; type: "double" } |
|
260 | 260 | } |
|
261 | 261 | Method { |
|
262 | 262 | name: "at" |
|
263 | 263 | type: "double" |
|
264 | 264 | Parameter { name: "index"; type: "int" } |
|
265 | 265 | } |
|
266 | 266 | } |
|
267 | 267 | Component { |
|
268 | 268 | name: "QtCharts::DeclarativeBoxPlotSeries" |
|
269 | 269 | defaultProperty: "seriesChildren" |
|
270 | 270 | prototype: "QtCharts::QBoxPlotSeries" |
|
271 | 271 | exports: [ |
|
272 | 272 | "QtCharts/BoxPlotSeries 1.3", |
|
273 | 273 | "QtCharts/BoxPlotSeries 1.4", |
|
274 | 274 | "QtCharts/BoxPlotSeries 2.0" |
|
275 | 275 | ] |
|
276 | 276 | exportMetaObjectRevisions: [0, 1, 1] |
|
277 | 277 | Property { name: "axisX"; type: "QAbstractAxis"; isPointer: true } |
|
278 | 278 | Property { name: "axisY"; type: "QAbstractAxis"; isPointer: true } |
|
279 | 279 | Property { name: "axisXTop"; type: "QAbstractAxis"; isPointer: true } |
|
280 | 280 | Property { name: "axisYRight"; type: "QAbstractAxis"; isPointer: true } |
|
281 | 281 | Property { name: "seriesChildren"; type: "QObject"; isList: true; isReadonly: true } |
|
282 | 282 | Property { name: "brushFilename"; revision: 1; type: "string" } |
|
283 | 283 | Signal { |
|
284 | 284 | name: "axisXChanged" |
|
285 | 285 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
286 | 286 | } |
|
287 | 287 | Signal { |
|
288 | 288 | name: "axisYChanged" |
|
289 | 289 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
290 | 290 | } |
|
291 | 291 | Signal { |
|
292 | 292 | name: "axisXTopChanged" |
|
293 | 293 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
294 | 294 | } |
|
295 | 295 | Signal { |
|
296 | 296 | name: "axisYRightChanged" |
|
297 | 297 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
298 | 298 | } |
|
299 | 299 | Signal { |
|
300 | 300 | name: "clicked" |
|
301 | 301 | Parameter { name: "boxset"; type: "DeclarativeBoxSet"; isPointer: true } |
|
302 | 302 | } |
|
303 | 303 | Signal { |
|
304 | 304 | name: "hovered" |
|
305 | 305 | Parameter { name: "status"; type: "bool" } |
|
306 | 306 | Parameter { name: "boxset"; type: "DeclarativeBoxSet"; isPointer: true } |
|
307 | 307 | } |
|
308 | 308 | Signal { |
|
309 | 309 | name: "pressed" |
|
310 | 310 | Parameter { name: "boxset"; type: "DeclarativeBoxSet"; isPointer: true } |
|
311 | 311 | } |
|
312 | 312 | Signal { |
|
313 | 313 | name: "released" |
|
314 | 314 | Parameter { name: "boxset"; type: "DeclarativeBoxSet"; isPointer: true } |
|
315 | 315 | } |
|
316 | 316 | Signal { |
|
317 | 317 | name: "doubleClicked" |
|
318 | 318 | Parameter { name: "boxset"; type: "DeclarativeBoxSet"; isPointer: true } |
|
319 | 319 | } |
|
320 | 320 | Signal { |
|
321 | 321 | name: "brushFilenameChanged" |
|
322 | 322 | revision: 1 |
|
323 | 323 | Parameter { name: "brushFilename"; type: "string" } |
|
324 | 324 | } |
|
325 | 325 | Method { |
|
326 | 326 | name: "appendSeriesChildren" |
|
327 | 327 | Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } |
|
328 | 328 | Parameter { name: "element"; type: "QObject"; isPointer: true } |
|
329 | 329 | } |
|
330 | 330 | Method { |
|
331 | 331 | name: "onHovered" |
|
332 | 332 | Parameter { name: "status"; type: "bool" } |
|
333 | 333 | Parameter { name: "boxset"; type: "QBoxSet"; isPointer: true } |
|
334 | 334 | } |
|
335 | 335 | Method { |
|
336 | 336 | name: "onClicked" |
|
337 | 337 | Parameter { name: "boxset"; type: "QBoxSet"; isPointer: true } |
|
338 | 338 | } |
|
339 | 339 | Method { |
|
340 | 340 | name: "onPressed" |
|
341 | 341 | Parameter { name: "boxset"; type: "QBoxSet"; isPointer: true } |
|
342 | 342 | } |
|
343 | 343 | Method { |
|
344 | 344 | name: "onReleased" |
|
345 | 345 | Parameter { name: "boxset"; type: "QBoxSet"; isPointer: true } |
|
346 | 346 | } |
|
347 | 347 | Method { |
|
348 | 348 | name: "onDoubleClicked" |
|
349 | 349 | Parameter { name: "boxset"; type: "QBoxSet"; isPointer: true } |
|
350 | 350 | } |
|
351 | 351 | Method { |
|
352 | 352 | name: "at" |
|
353 | 353 | type: "DeclarativeBoxSet*" |
|
354 | 354 | Parameter { name: "index"; type: "int" } |
|
355 | 355 | } |
|
356 | 356 | Method { |
|
357 | 357 | name: "append" |
|
358 | 358 | type: "DeclarativeBoxSet*" |
|
359 | 359 | Parameter { name: "label"; type: "string" } |
|
360 | 360 | Parameter { name: "values"; type: "QVariantList" } |
|
361 | 361 | } |
|
362 | 362 | Method { |
|
363 | 363 | name: "append" |
|
364 | 364 | Parameter { name: "box"; type: "DeclarativeBoxSet"; isPointer: true } |
|
365 | 365 | } |
|
366 | 366 | Method { |
|
367 | 367 | name: "insert" |
|
368 | 368 | type: "DeclarativeBoxSet*" |
|
369 | 369 | Parameter { name: "index"; type: "int" } |
|
370 | 370 | Parameter { name: "label"; type: "string" } |
|
371 | 371 | Parameter { name: "values"; type: "QVariantList" } |
|
372 | 372 | } |
|
373 | 373 | Method { |
|
374 | 374 | name: "remove" |
|
375 | 375 | type: "bool" |
|
376 | 376 | Parameter { name: "box"; type: "DeclarativeBoxSet"; isPointer: true } |
|
377 | 377 | } |
|
378 | 378 | Method { name: "clear" } |
|
379 | 379 | } |
|
380 | 380 | Component { |
|
381 | 381 | name: "QtCharts::DeclarativeBoxSet" |
|
382 | 382 | prototype: "QtCharts::QBoxSet" |
|
383 | 383 | exports: [ |
|
384 | 384 | "QtCharts/BoxSet 1.3", |
|
385 | 385 | "QtCharts/BoxSet 1.4", |
|
386 | 386 | "QtCharts/BoxSet 2.0" |
|
387 | 387 | ] |
|
388 | 388 | exportMetaObjectRevisions: [0, 1, 1] |
|
389 | 389 | Enum { |
|
390 | 390 | name: "ValuePositions" |
|
391 | 391 | values: { |
|
392 | 392 | "LowerExtreme": 0, |
|
393 | 393 | "LowerQuartile": 1, |
|
394 | 394 | "Median": 2, |
|
395 | 395 | "UpperQuartile": 3, |
|
396 | 396 | "UpperExtreme": 4 |
|
397 | 397 | } |
|
398 | 398 | } |
|
399 | 399 | Property { name: "values"; type: "QVariantList" } |
|
400 | 400 | Property { name: "label"; type: "string" } |
|
401 | 401 | Property { name: "count"; type: "int"; isReadonly: true } |
|
402 | 402 | Property { name: "brushFilename"; revision: 1; type: "string" } |
|
403 | 403 | Signal { name: "changedValues" } |
|
404 | 404 | Signal { |
|
405 | 405 | name: "changedValue" |
|
406 | 406 | Parameter { name: "index"; type: "int" } |
|
407 | 407 | } |
|
408 | 408 | Signal { |
|
409 | 409 | name: "brushFilenameChanged" |
|
410 | 410 | revision: 1 |
|
411 | 411 | Parameter { name: "brushFilename"; type: "string" } |
|
412 | 412 | } |
|
413 | 413 | Method { |
|
414 | 414 | name: "append" |
|
415 | 415 | Parameter { name: "value"; type: "double" } |
|
416 | 416 | } |
|
417 | 417 | Method { name: "clear" } |
|
418 | 418 | Method { |
|
419 | 419 | name: "at" |
|
420 | 420 | type: "double" |
|
421 | 421 | Parameter { name: "index"; type: "int" } |
|
422 | 422 | } |
|
423 | 423 | Method { |
|
424 | 424 | name: "setValue" |
|
425 | 425 | Parameter { name: "index"; type: "int" } |
|
426 | 426 | Parameter { name: "value"; type: "double" } |
|
427 | 427 | } |
|
428 | 428 | } |
|
429 | 429 | Component { |
|
430 | 430 | name: "QtCharts::DeclarativeCategoryAxis" |
|
431 | 431 | defaultProperty: "axisChildren" |
|
432 | 432 | prototype: "QtCharts::QCategoryAxis" |
|
433 | 433 | exports: [ |
|
434 | 434 | "QtCharts/CategoryAxis 1.1", |
|
435 | 435 | "QtCharts/CategoryAxis 2.0", |
|
436 | 436 | "QtCharts/CategoryAxis 2.1" |
|
437 | 437 | ] |
|
438 | 438 | exportMetaObjectRevisions: [0, 0, 1] |
|
439 | 439 | Enum { |
|
440 | 440 | name: "AxisLabelsPosition" |
|
441 | 441 | values: { |
|
442 | 442 | "AxisLabelsPositionCenter": 0, |
|
443 | 443 | "AxisLabelsPositionOnValue": 1 |
|
444 | 444 | } |
|
445 | 445 | } |
|
446 | 446 | Property { name: "axisChildren"; type: "QObject"; isList: true; isReadonly: true } |
|
447 | 447 | Property { name: "labelsPosition"; revision: 1; type: "AxisLabelsPosition" } |
|
448 | 448 | Signal { |
|
449 | 449 | name: "labelsPositionChanged" |
|
450 | 450 | revision: 1 |
|
451 | 451 | Parameter { name: "position"; type: "AxisLabelsPosition" } |
|
452 | 452 | } |
|
453 | 453 | Method { |
|
454 | 454 | name: "append" |
|
455 | 455 | Parameter { name: "label"; type: "string" } |
|
456 | 456 | Parameter { name: "categoryEndValue"; type: "double" } |
|
457 | 457 | } |
|
458 | 458 | Method { |
|
459 | 459 | name: "remove" |
|
460 | 460 | Parameter { name: "label"; type: "string" } |
|
461 | 461 | } |
|
462 | 462 | Method { |
|
463 | 463 | name: "replace" |
|
464 | 464 | Parameter { name: "oldLabel"; type: "string" } |
|
465 | 465 | Parameter { name: "newLabel"; type: "string" } |
|
466 | 466 | } |
|
467 | 467 | Method { |
|
468 | 468 | name: "appendAxisChildren" |
|
469 | 469 | Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } |
|
470 | 470 | Parameter { name: "element"; type: "QObject"; isPointer: true } |
|
471 | 471 | } |
|
472 | 472 | } |
|
473 | 473 | Component { |
|
474 | 474 | name: "QtCharts::DeclarativeCategoryRange" |
|
475 | 475 | prototype: "QObject" |
|
476 | 476 | exports: ["QtCharts/CategoryRange 1.1", "QtCharts/CategoryRange 2.0"] |
|
477 | 477 | exportMetaObjectRevisions: [0, 0] |
|
478 | 478 | Property { name: "endValue"; type: "double" } |
|
479 | 479 | Property { name: "label"; type: "string" } |
|
480 | 480 | } |
|
481 | 481 | Component { |
|
482 | 482 | name: "QtCharts::DeclarativeChart" |
|
483 | 483 | defaultProperty: "data" |
|
484 | 484 | prototype: "QQuickPaintedItem" |
|
485 | 485 | exports: [ |
|
486 | 486 | "QtCharts/ChartView 1.0", |
|
487 | 487 | "QtCharts/ChartView 1.1", |
|
488 | 488 | "QtCharts/ChartView 1.2", |
|
489 | 489 | "QtCharts/ChartView 1.3", |
|
490 | 490 | "QtCharts/ChartView 2.0" |
|
491 | 491 | ] |
|
492 | 492 | exportMetaObjectRevisions: [0, 1, 2, 3, 4] |
|
493 | 493 | Enum { |
|
494 | 494 | name: "Theme" |
|
495 | 495 | values: { |
|
496 | 496 | "ChartThemeLight": 0, |
|
497 | 497 | "ChartThemeBlueCerulean": 1, |
|
498 | 498 | "ChartThemeDark": 2, |
|
499 | 499 | "ChartThemeBrownSand": 3, |
|
500 | 500 | "ChartThemeBlueNcs": 4, |
|
501 | 501 | "ChartThemeHighContrast": 5, |
|
502 | 502 | "ChartThemeBlueIcy": 6, |
|
503 | 503 | "ChartThemeQt": 7 |
|
504 | 504 | } |
|
505 | 505 | } |
|
506 | 506 | Enum { |
|
507 | 507 | name: "Animation" |
|
508 | 508 | values: { |
|
509 | 509 | "NoAnimation": 0, |
|
510 | 510 | "GridAxisAnimations": 1, |
|
511 | 511 | "SeriesAnimations": 2, |
|
512 | 512 | "AllAnimations": 3 |
|
513 | 513 | } |
|
514 | 514 | } |
|
515 | 515 | Enum { |
|
516 | 516 | name: "SeriesType" |
|
517 | 517 | values: { |
|
518 | 518 | "SeriesTypeLine": 0, |
|
519 | 519 | "SeriesTypeArea": 1, |
|
520 | 520 | "SeriesTypeBar": 2, |
|
521 | 521 | "SeriesTypeStackedBar": 3, |
|
522 | 522 | "SeriesTypePercentBar": 4, |
|
523 | 523 | "SeriesTypeBoxPlot": 5, |
|
524 | 524 | "SeriesTypePie": 6, |
|
525 | 525 | "SeriesTypeScatter": 7, |
|
526 | 526 | "SeriesTypeSpline": 8, |
|
527 | 527 | "SeriesTypeHorizontalBar": 9, |
|
528 | 528 | "SeriesTypeHorizontalStackedBar": 10, |
|
529 | 529 | "SeriesTypeHorizontalPercentBar": 11 |
|
530 | 530 | } |
|
531 | 531 | } |
|
532 | 532 | Property { name: "theme"; type: "Theme" } |
|
533 | 533 | Property { name: "animationOptions"; type: "Animation" } |
|
534 | 534 | Property { name: "title"; type: "string" } |
|
535 | 535 | Property { name: "titleFont"; type: "QFont" } |
|
536 | 536 | Property { name: "titleColor"; type: "QColor" } |
|
537 | 537 | Property { name: "legend"; type: "QLegend"; isReadonly: true; isPointer: true } |
|
538 | 538 | Property { name: "count"; type: "int"; isReadonly: true } |
|
539 | 539 | Property { name: "backgroundColor"; type: "QColor" } |
|
540 | 540 | Property { name: "dropShadowEnabled"; type: "bool" } |
|
541 | 541 | Property { name: "backgroundRoundness"; revision: 3; type: "double" } |
|
542 | 542 | Property { |
|
543 | 543 | name: "margins" |
|
544 | 544 | revision: 2 |
|
545 | 545 | type: "DeclarativeMargins" |
|
546 | 546 | isReadonly: true |
|
547 | 547 | isPointer: true |
|
548 | 548 | } |
|
549 | 549 | Property { name: "plotArea"; revision: 1; type: "QRectF"; isReadonly: true } |
|
550 | 550 | Property { name: "plotAreaColor"; revision: 3; type: "QColor" } |
|
551 | 551 | Property { name: "axes"; revision: 2; type: "QAbstractAxis"; isList: true; isReadonly: true } |
|
552 | 552 | Property { name: "localizeNumbers"; revision: 4; type: "bool" } |
|
553 | 553 | Property { name: "locale"; revision: 4; type: "QLocale" } |
|
554 | 554 | Signal { name: "axisLabelsChanged" } |
|
555 | 555 | Signal { |
|
556 | 556 | name: "titleColorChanged" |
|
557 | 557 | Parameter { name: "color"; type: "QColor" } |
|
558 | 558 | } |
|
559 | 559 | Signal { |
|
560 | 560 | name: "dropShadowEnabledChanged" |
|
561 | 561 | Parameter { name: "enabled"; type: "bool" } |
|
562 | 562 | } |
|
563 | 563 | Signal { name: "marginsChanged"; revision: 2 } |
|
564 | 564 | Signal { |
|
565 | 565 | name: "plotAreaChanged" |
|
566 | 566 | Parameter { name: "plotArea"; type: "QRectF" } |
|
567 | 567 | } |
|
568 | 568 | Signal { |
|
569 | 569 | name: "seriesAdded" |
|
570 | 570 | Parameter { name: "series"; type: "QAbstractSeries"; isPointer: true } |
|
571 | 571 | } |
|
572 | 572 | Signal { |
|
573 | 573 | name: "seriesRemoved" |
|
574 | 574 | Parameter { name: "series"; type: "QAbstractSeries"; isPointer: true } |
|
575 | 575 | } |
|
576 | 576 | Signal { name: "plotAreaColorChanged"; revision: 3 } |
|
577 | 577 | Signal { |
|
578 | 578 | name: "backgroundRoundnessChanged" |
|
579 | 579 | revision: 3 |
|
580 | 580 | Parameter { name: "diameter"; type: "double" } |
|
581 | 581 | } |
|
582 | 582 | Signal { name: "localizeNumbersChanged"; revision: 4 } |
|
583 | 583 | Signal { name: "localeChanged"; revision: 4 } |
|
584 | 584 | Method { |
|
585 | 585 | name: "series" |
|
586 | 586 | type: "QAbstractSeries*" |
|
587 | 587 | Parameter { name: "index"; type: "int" } |
|
588 | 588 | } |
|
589 | 589 | Method { |
|
590 | 590 | name: "series" |
|
591 | 591 | type: "QAbstractSeries*" |
|
592 | 592 | Parameter { name: "seriesName"; type: "string" } |
|
593 | 593 | } |
|
594 | 594 | Method { |
|
595 | 595 | name: "createSeries" |
|
596 | 596 | type: "QAbstractSeries*" |
|
597 | 597 | Parameter { name: "type"; type: "int" } |
|
598 | 598 | Parameter { name: "name"; type: "string" } |
|
599 | 599 | Parameter { name: "axisX"; type: "QAbstractAxis"; isPointer: true } |
|
600 | 600 | Parameter { name: "axisY"; type: "QAbstractAxis"; isPointer: true } |
|
601 | 601 | } |
|
602 | 602 | Method { |
|
603 | 603 | name: "createSeries" |
|
604 | 604 | type: "QAbstractSeries*" |
|
605 | 605 | Parameter { name: "type"; type: "int" } |
|
606 | 606 | Parameter { name: "name"; type: "string" } |
|
607 | 607 | Parameter { name: "axisX"; type: "QAbstractAxis"; isPointer: true } |
|
608 | 608 | } |
|
609 | 609 | Method { |
|
610 | 610 | name: "createSeries" |
|
611 | 611 | type: "QAbstractSeries*" |
|
612 | 612 | Parameter { name: "type"; type: "int" } |
|
613 | 613 | Parameter { name: "name"; type: "string" } |
|
614 | 614 | } |
|
615 | 615 | Method { |
|
616 | 616 | name: "createSeries" |
|
617 | 617 | type: "QAbstractSeries*" |
|
618 | 618 | Parameter { name: "type"; type: "int" } |
|
619 | 619 | } |
|
620 | 620 | Method { |
|
621 | 621 | name: "removeSeries" |
|
622 | 622 | Parameter { name: "series"; type: "QAbstractSeries"; isPointer: true } |
|
623 | 623 | } |
|
624 | 624 | Method { name: "removeAllSeries" } |
|
625 | 625 | Method { |
|
626 | 626 | name: "setAxisX" |
|
627 | 627 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
628 | 628 | Parameter { name: "series"; type: "QAbstractSeries"; isPointer: true } |
|
629 | 629 | } |
|
630 | 630 | Method { |
|
631 | 631 | name: "setAxisX" |
|
632 | 632 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
633 | 633 | } |
|
634 | 634 | Method { |
|
635 | 635 | name: "setAxisY" |
|
636 | 636 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
637 | 637 | Parameter { name: "series"; type: "QAbstractSeries"; isPointer: true } |
|
638 | 638 | } |
|
639 | 639 | Method { |
|
640 | 640 | name: "setAxisY" |
|
641 | 641 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
642 | 642 | } |
|
643 | 643 | Method { |
|
644 | 644 | name: "axisX" |
|
645 | 645 | type: "QAbstractAxis*" |
|
646 | 646 | Parameter { name: "series"; type: "QAbstractSeries"; isPointer: true } |
|
647 | 647 | } |
|
648 | 648 | Method { name: "axisX"; type: "QAbstractAxis*" } |
|
649 | 649 | Method { |
|
650 | 650 | name: "axisY" |
|
651 | 651 | type: "QAbstractAxis*" |
|
652 | 652 | Parameter { name: "series"; type: "QAbstractSeries"; isPointer: true } |
|
653 | 653 | } |
|
654 | 654 | Method { name: "axisY"; type: "QAbstractAxis*" } |
|
655 | 655 | Method { |
|
656 | 656 | name: "zoom" |
|
657 | 657 | Parameter { name: "factor"; type: "double" } |
|
658 | 658 | } |
|
659 | 659 | Method { |
|
660 | 660 | name: "scrollLeft" |
|
661 | 661 | Parameter { name: "pixels"; type: "double" } |
|
662 | 662 | } |
|
663 | 663 | Method { |
|
664 | 664 | name: "scrollRight" |
|
665 | 665 | Parameter { name: "pixels"; type: "double" } |
|
666 | 666 | } |
|
667 | 667 | Method { |
|
668 | 668 | name: "scrollUp" |
|
669 | 669 | Parameter { name: "pixels"; type: "double" } |
|
670 | 670 | } |
|
671 | 671 | Method { |
|
672 | 672 | name: "scrollDown" |
|
673 | 673 | Parameter { name: "pixels"; type: "double" } |
|
674 | 674 | } |
|
675 | 675 | } |
|
676 | 676 | Component { |
|
677 | 677 | name: "QtCharts::DeclarativeHorizontalBarSeries" |
|
678 | 678 | defaultProperty: "seriesChildren" |
|
679 | 679 | prototype: "QtCharts::QHorizontalBarSeries" |
|
680 | 680 | exports: [ |
|
681 | 681 | "QtCharts/HorizontalBarSeries 1.1", |
|
682 | 682 | "QtCharts/HorizontalBarSeries 1.2", |
|
683 | 683 | "QtCharts/HorizontalBarSeries 2.0" |
|
684 | 684 | ] |
|
685 | 685 | exportMetaObjectRevisions: [1, 2, 2] |
|
686 | 686 | Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
687 | 687 | Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
688 | 688 | Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
689 | 689 | Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
690 | 690 | Property { name: "seriesChildren"; type: "QObject"; isList: true; isReadonly: true } |
|
691 | 691 | Signal { |
|
692 | 692 | name: "axisXChanged" |
|
693 | 693 | revision: 1 |
|
694 | 694 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
695 | 695 | } |
|
696 | 696 | Signal { |
|
697 | 697 | name: "axisYChanged" |
|
698 | 698 | revision: 1 |
|
699 | 699 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
700 | 700 | } |
|
701 | 701 | Signal { |
|
702 | 702 | name: "axisXTopChanged" |
|
703 | 703 | revision: 2 |
|
704 | 704 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
705 | 705 | } |
|
706 | 706 | Signal { |
|
707 | 707 | name: "axisYRightChanged" |
|
708 | 708 | revision: 2 |
|
709 | 709 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
710 | 710 | } |
|
711 | 711 | Method { |
|
712 | 712 | name: "appendSeriesChildren" |
|
713 | 713 | Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } |
|
714 | 714 | Parameter { name: "element"; type: "QObject"; isPointer: true } |
|
715 | 715 | } |
|
716 | 716 | Method { |
|
717 | 717 | name: "at" |
|
718 | 718 | type: "DeclarativeBarSet*" |
|
719 | 719 | Parameter { name: "index"; type: "int" } |
|
720 | 720 | } |
|
721 | 721 | Method { |
|
722 | 722 | name: "append" |
|
723 | 723 | type: "DeclarativeBarSet*" |
|
724 | 724 | Parameter { name: "label"; type: "string" } |
|
725 | 725 | Parameter { name: "values"; type: "QVariantList" } |
|
726 | 726 | } |
|
727 | 727 | Method { |
|
728 | 728 | name: "insert" |
|
729 | 729 | type: "DeclarativeBarSet*" |
|
730 | 730 | Parameter { name: "index"; type: "int" } |
|
731 | 731 | Parameter { name: "label"; type: "string" } |
|
732 | 732 | Parameter { name: "values"; type: "QVariantList" } |
|
733 | 733 | } |
|
734 | 734 | Method { |
|
735 | 735 | name: "remove" |
|
736 | 736 | type: "bool" |
|
737 | 737 | Parameter { name: "barset"; type: "QBarSet"; isPointer: true } |
|
738 | 738 | } |
|
739 | 739 | Method { name: "clear" } |
|
740 | 740 | } |
|
741 | 741 | Component { |
|
742 | 742 | name: "QtCharts::DeclarativeHorizontalPercentBarSeries" |
|
743 | 743 | defaultProperty: "seriesChildren" |
|
744 | 744 | prototype: "QtCharts::QHorizontalPercentBarSeries" |
|
745 | 745 | exports: [ |
|
746 | 746 | "QtCharts/HorizontalPercentBarSeries 1.1", |
|
747 | 747 | "QtCharts/HorizontalPercentBarSeries 1.2", |
|
748 | 748 | "QtCharts/HorizontalPercentBarSeries 2.0" |
|
749 | 749 | ] |
|
750 | 750 | exportMetaObjectRevisions: [1, 2, 2] |
|
751 | 751 | Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
752 | 752 | Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
753 | 753 | Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
754 | 754 | Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
755 | 755 | Property { name: "seriesChildren"; type: "QObject"; isList: true; isReadonly: true } |
|
756 | 756 | Signal { |
|
757 | 757 | name: "axisXChanged" |
|
758 | 758 | revision: 1 |
|
759 | 759 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
760 | 760 | } |
|
761 | 761 | Signal { |
|
762 | 762 | name: "axisYChanged" |
|
763 | 763 | revision: 1 |
|
764 | 764 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
765 | 765 | } |
|
766 | 766 | Signal { |
|
767 | 767 | name: "axisXTopChanged" |
|
768 | 768 | revision: 2 |
|
769 | 769 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
770 | 770 | } |
|
771 | 771 | Signal { |
|
772 | 772 | name: "axisYRightChanged" |
|
773 | 773 | revision: 2 |
|
774 | 774 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
775 | 775 | } |
|
776 | 776 | Method { |
|
777 | 777 | name: "appendSeriesChildren" |
|
778 | 778 | Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } |
|
779 | 779 | Parameter { name: "element"; type: "QObject"; isPointer: true } |
|
780 | 780 | } |
|
781 | 781 | Method { |
|
782 | 782 | name: "at" |
|
783 | 783 | type: "DeclarativeBarSet*" |
|
784 | 784 | Parameter { name: "index"; type: "int" } |
|
785 | 785 | } |
|
786 | 786 | Method { |
|
787 | 787 | name: "append" |
|
788 | 788 | type: "DeclarativeBarSet*" |
|
789 | 789 | Parameter { name: "label"; type: "string" } |
|
790 | 790 | Parameter { name: "values"; type: "QVariantList" } |
|
791 | 791 | } |
|
792 | 792 | Method { |
|
793 | 793 | name: "insert" |
|
794 | 794 | type: "DeclarativeBarSet*" |
|
795 | 795 | Parameter { name: "index"; type: "int" } |
|
796 | 796 | Parameter { name: "label"; type: "string" } |
|
797 | 797 | Parameter { name: "values"; type: "QVariantList" } |
|
798 | 798 | } |
|
799 | 799 | Method { |
|
800 | 800 | name: "remove" |
|
801 | 801 | type: "bool" |
|
802 | 802 | Parameter { name: "barset"; type: "QBarSet"; isPointer: true } |
|
803 | 803 | } |
|
804 | 804 | Method { name: "clear" } |
|
805 | 805 | } |
|
806 | 806 | Component { |
|
807 | 807 | name: "QtCharts::DeclarativeHorizontalStackedBarSeries" |
|
808 | 808 | defaultProperty: "seriesChildren" |
|
809 | 809 | prototype: "QtCharts::QHorizontalStackedBarSeries" |
|
810 | 810 | exports: [ |
|
811 | 811 | "QtCharts/HorizontalStackedBarSeries 1.1", |
|
812 | 812 | "QtCharts/HorizontalStackedBarSeries 1.2", |
|
813 | 813 | "QtCharts/HorizontalStackedBarSeries 2.0" |
|
814 | 814 | ] |
|
815 | 815 | exportMetaObjectRevisions: [1, 2, 2] |
|
816 | 816 | Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
817 | 817 | Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
818 | 818 | Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
819 | 819 | Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
820 | 820 | Property { name: "seriesChildren"; type: "QObject"; isList: true; isReadonly: true } |
|
821 | 821 | Signal { |
|
822 | 822 | name: "axisXChanged" |
|
823 | 823 | revision: 1 |
|
824 | 824 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
825 | 825 | } |
|
826 | 826 | Signal { |
|
827 | 827 | name: "axisYChanged" |
|
828 | 828 | revision: 1 |
|
829 | 829 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
830 | 830 | } |
|
831 | 831 | Signal { |
|
832 | 832 | name: "axisXTopChanged" |
|
833 | 833 | revision: 2 |
|
834 | 834 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
835 | 835 | } |
|
836 | 836 | Signal { |
|
837 | 837 | name: "axisYRightChanged" |
|
838 | 838 | revision: 2 |
|
839 | 839 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
840 | 840 | } |
|
841 | 841 | Method { |
|
842 | 842 | name: "appendSeriesChildren" |
|
843 | 843 | Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } |
|
844 | 844 | Parameter { name: "element"; type: "QObject"; isPointer: true } |
|
845 | 845 | } |
|
846 | 846 | Method { |
|
847 | 847 | name: "at" |
|
848 | 848 | type: "DeclarativeBarSet*" |
|
849 | 849 | Parameter { name: "index"; type: "int" } |
|
850 | 850 | } |
|
851 | 851 | Method { |
|
852 | 852 | name: "append" |
|
853 | 853 | type: "DeclarativeBarSet*" |
|
854 | 854 | Parameter { name: "label"; type: "string" } |
|
855 | 855 | Parameter { name: "values"; type: "QVariantList" } |
|
856 | 856 | } |
|
857 | 857 | Method { |
|
858 | 858 | name: "insert" |
|
859 | 859 | type: "DeclarativeBarSet*" |
|
860 | 860 | Parameter { name: "index"; type: "int" } |
|
861 | 861 | Parameter { name: "label"; type: "string" } |
|
862 | 862 | Parameter { name: "values"; type: "QVariantList" } |
|
863 | 863 | } |
|
864 | 864 | Method { |
|
865 | 865 | name: "remove" |
|
866 | 866 | type: "bool" |
|
867 | 867 | Parameter { name: "barset"; type: "QBarSet"; isPointer: true } |
|
868 | 868 | } |
|
869 | 869 | Method { name: "clear" } |
|
870 | 870 | } |
|
871 | 871 | Component { |
|
872 | 872 | name: "QtCharts::DeclarativeLineSeries" |
|
873 | 873 | defaultProperty: "declarativeChildren" |
|
874 | 874 | prototype: "QtCharts::QLineSeries" |
|
875 | 875 | exports: [ |
|
876 | 876 | "QtCharts/LineSeries 1.0", |
|
877 | 877 | "QtCharts/LineSeries 1.1", |
|
878 | 878 | "QtCharts/LineSeries 1.2", |
|
879 | 879 | "QtCharts/LineSeries 1.3", |
|
880 | 880 | "QtCharts/LineSeries 2.0" |
|
881 | 881 | ] |
|
882 | 882 | exportMetaObjectRevisions: [0, 1, 2, 3, 3] |
|
883 | 883 | Property { name: "count"; type: "int"; isReadonly: true } |
|
884 | 884 | Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
885 | 885 | Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
886 | 886 | Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
887 | 887 | Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
888 | 888 | Property { name: "axisAngular"; revision: 3; type: "QAbstractAxis"; isPointer: true } |
|
889 | 889 | Property { name: "axisRadial"; revision: 3; type: "QAbstractAxis"; isPointer: true } |
|
890 | 890 | Property { name: "width"; revision: 1; type: "double" } |
|
891 | 891 | Property { name: "style"; revision: 1; type: "Qt::PenStyle" } |
|
892 | 892 | Property { name: "capStyle"; revision: 1; type: "Qt::PenCapStyle" } |
|
893 | 893 | Property { name: "declarativeChildren"; type: "QObject"; isList: true; isReadonly: true } |
|
894 | 894 | Signal { |
|
895 | 895 | name: "countChanged" |
|
896 | 896 | Parameter { name: "count"; type: "int" } |
|
897 | 897 | } |
|
898 | 898 | Signal { |
|
899 | 899 | name: "axisXChanged" |
|
900 | 900 | revision: 1 |
|
901 | 901 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
902 | 902 | } |
|
903 | 903 | Signal { |
|
904 | 904 | name: "axisYChanged" |
|
905 | 905 | revision: 1 |
|
906 | 906 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
907 | 907 | } |
|
908 | 908 | Signal { |
|
909 | 909 | name: "axisXTopChanged" |
|
910 | 910 | revision: 2 |
|
911 | 911 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
912 | 912 | } |
|
913 | 913 | Signal { |
|
914 | 914 | name: "axisYRightChanged" |
|
915 | 915 | revision: 2 |
|
916 | 916 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
917 | 917 | } |
|
918 | 918 | Signal { |
|
919 | 919 | name: "axisAngularChanged" |
|
920 | 920 | revision: 3 |
|
921 | 921 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
922 | 922 | } |
|
923 | 923 | Signal { |
|
924 | 924 | name: "axisRadialChanged" |
|
925 | 925 | revision: 3 |
|
926 | 926 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
927 | 927 | } |
|
928 | 928 | Signal { |
|
929 | 929 | name: "widthChanged" |
|
930 | 930 | revision: 1 |
|
931 | 931 | Parameter { name: "width"; type: "double" } |
|
932 | 932 | } |
|
933 | 933 | Signal { |
|
934 | 934 | name: "styleChanged" |
|
935 | 935 | revision: 1 |
|
936 | 936 | Parameter { name: "style"; type: "Qt::PenStyle" } |
|
937 | 937 | } |
|
938 | 938 | Signal { |
|
939 | 939 | name: "capStyleChanged" |
|
940 | 940 | revision: 1 |
|
941 | 941 | Parameter { name: "capStyle"; type: "Qt::PenCapStyle" } |
|
942 | 942 | } |
|
943 | 943 | Method { |
|
944 | 944 | name: "appendDeclarativeChildren" |
|
945 | 945 | Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } |
|
946 | 946 | Parameter { name: "element"; type: "QObject"; isPointer: true } |
|
947 | 947 | } |
|
948 | 948 | Method { |
|
949 | 949 | name: "handleCountChanged" |
|
950 | 950 | Parameter { name: "index"; type: "int" } |
|
951 | 951 | } |
|
952 | 952 | Method { |
|
953 | 953 | name: "append" |
|
954 | 954 | Parameter { name: "x"; type: "double" } |
|
955 | 955 | Parameter { name: "y"; type: "double" } |
|
956 | 956 | } |
|
957 | 957 | Method { |
|
958 | 958 | name: "replace" |
|
959 | 959 | Parameter { name: "oldX"; type: "double" } |
|
960 | 960 | Parameter { name: "oldY"; type: "double" } |
|
961 | 961 | Parameter { name: "newX"; type: "double" } |
|
962 | 962 | Parameter { name: "newY"; type: "double" } |
|
963 | 963 | } |
|
964 | 964 | Method { |
|
965 | 965 | name: "replace" |
|
966 | 966 | revision: 3 |
|
967 | 967 | Parameter { name: "index"; type: "int" } |
|
968 | 968 | Parameter { name: "newX"; type: "double" } |
|
969 | 969 | Parameter { name: "newY"; type: "double" } |
|
970 | 970 | } |
|
971 | 971 | Method { |
|
972 | 972 | name: "remove" |
|
973 | 973 | Parameter { name: "x"; type: "double" } |
|
974 | 974 | Parameter { name: "y"; type: "double" } |
|
975 | 975 | } |
|
976 | 976 | Method { |
|
977 | 977 | name: "remove" |
|
978 | 978 | revision: 3 |
|
979 | 979 | Parameter { name: "index"; type: "int" } |
|
980 | 980 | } |
|
981 | 981 | Method { |
|
982 | 982 | name: "insert" |
|
983 | 983 | Parameter { name: "index"; type: "int" } |
|
984 | 984 | Parameter { name: "x"; type: "double" } |
|
985 | 985 | Parameter { name: "y"; type: "double" } |
|
986 | 986 | } |
|
987 | 987 | Method { name: "clear" } |
|
988 | 988 | Method { |
|
989 | 989 | name: "at" |
|
990 | 990 | type: "QPointF" |
|
991 | 991 | Parameter { name: "index"; type: "int" } |
|
992 | 992 | } |
|
993 | 993 | } |
|
994 | 994 | Component { |
|
995 | 995 | name: "QtCharts::DeclarativeMargins" |
|
996 | 996 | prototype: "QObject" |
|
997 | 997 | exports: ["QtCharts/Margins 1.1", "QtCharts/Margins 2.0"] |
|
998 | 998 | isCreatable: false |
|
999 | 999 | exportMetaObjectRevisions: [0, 0] |
|
1000 | 1000 | Property { name: "top"; type: "int" } |
|
1001 | 1001 | Property { name: "bottom"; type: "int" } |
|
1002 | 1002 | Property { name: "left"; type: "int" } |
|
1003 | 1003 | Property { name: "right"; type: "int" } |
|
1004 | 1004 | Signal { |
|
1005 | 1005 | name: "topChanged" |
|
1006 | 1006 | Parameter { name: "top"; type: "int" } |
|
1007 | 1007 | Parameter { name: "bottom"; type: "int" } |
|
1008 | 1008 | Parameter { name: "left"; type: "int" } |
|
1009 | 1009 | Parameter { name: "right"; type: "int" } |
|
1010 | 1010 | } |
|
1011 | 1011 | Signal { |
|
1012 | 1012 | name: "bottomChanged" |
|
1013 | 1013 | Parameter { name: "top"; type: "int" } |
|
1014 | 1014 | Parameter { name: "bottom"; type: "int" } |
|
1015 | 1015 | Parameter { name: "left"; type: "int" } |
|
1016 | 1016 | Parameter { name: "right"; type: "int" } |
|
1017 | 1017 | } |
|
1018 | 1018 | Signal { |
|
1019 | 1019 | name: "leftChanged" |
|
1020 | 1020 | Parameter { name: "top"; type: "int" } |
|
1021 | 1021 | Parameter { name: "bottom"; type: "int" } |
|
1022 | 1022 | Parameter { name: "left"; type: "int" } |
|
1023 | 1023 | Parameter { name: "right"; type: "int" } |
|
1024 | 1024 | } |
|
1025 | 1025 | Signal { |
|
1026 | 1026 | name: "rightChanged" |
|
1027 | 1027 | Parameter { name: "top"; type: "int" } |
|
1028 | 1028 | Parameter { name: "bottom"; type: "int" } |
|
1029 | 1029 | Parameter { name: "left"; type: "int" } |
|
1030 | 1030 | Parameter { name: "right"; type: "int" } |
|
1031 | 1031 | } |
|
1032 | 1032 | } |
|
1033 | 1033 | Component { |
|
1034 | 1034 | name: "QtCharts::DeclarativePercentBarSeries" |
|
1035 | 1035 | defaultProperty: "seriesChildren" |
|
1036 | 1036 | prototype: "QtCharts::QPercentBarSeries" |
|
1037 | 1037 | exports: [ |
|
1038 | 1038 | "QtCharts/PercentBarSeries 1.0", |
|
1039 | 1039 | "QtCharts/PercentBarSeries 1.1", |
|
1040 | 1040 | "QtCharts/PercentBarSeries 1.2", |
|
1041 | 1041 | "QtCharts/PercentBarSeries 2.0" |
|
1042 | 1042 | ] |
|
1043 | 1043 | exportMetaObjectRevisions: [0, 1, 2, 2] |
|
1044 | 1044 | Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
1045 | 1045 | Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
1046 | 1046 | Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
1047 | 1047 | Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
1048 | 1048 | Property { name: "seriesChildren"; type: "QObject"; isList: true; isReadonly: true } |
|
1049 | 1049 | Signal { |
|
1050 | 1050 | name: "axisXChanged" |
|
1051 | 1051 | revision: 1 |
|
1052 | 1052 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1053 | 1053 | } |
|
1054 | 1054 | Signal { |
|
1055 | 1055 | name: "axisYChanged" |
|
1056 | 1056 | revision: 1 |
|
1057 | 1057 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1058 | 1058 | } |
|
1059 | 1059 | Signal { |
|
1060 | 1060 | name: "axisXTopChanged" |
|
1061 | 1061 | revision: 2 |
|
1062 | 1062 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1063 | 1063 | } |
|
1064 | 1064 | Signal { |
|
1065 | 1065 | name: "axisYRightChanged" |
|
1066 | 1066 | revision: 2 |
|
1067 | 1067 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1068 | 1068 | } |
|
1069 | 1069 | Method { |
|
1070 | 1070 | name: "appendSeriesChildren" |
|
1071 | 1071 | Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } |
|
1072 | 1072 | Parameter { name: "element"; type: "QObject"; isPointer: true } |
|
1073 | 1073 | } |
|
1074 | 1074 | Method { |
|
1075 | 1075 | name: "at" |
|
1076 | 1076 | type: "DeclarativeBarSet*" |
|
1077 | 1077 | Parameter { name: "index"; type: "int" } |
|
1078 | 1078 | } |
|
1079 | 1079 | Method { |
|
1080 | 1080 | name: "append" |
|
1081 | 1081 | type: "DeclarativeBarSet*" |
|
1082 | 1082 | Parameter { name: "label"; type: "string" } |
|
1083 | 1083 | Parameter { name: "values"; type: "QVariantList" } |
|
1084 | 1084 | } |
|
1085 | 1085 | Method { |
|
1086 | 1086 | name: "insert" |
|
1087 | 1087 | type: "DeclarativeBarSet*" |
|
1088 | 1088 | Parameter { name: "index"; type: "int" } |
|
1089 | 1089 | Parameter { name: "label"; type: "string" } |
|
1090 | 1090 | Parameter { name: "values"; type: "QVariantList" } |
|
1091 | 1091 | } |
|
1092 | 1092 | Method { |
|
1093 | 1093 | name: "remove" |
|
1094 | 1094 | type: "bool" |
|
1095 | 1095 | Parameter { name: "barset"; type: "QBarSet"; isPointer: true } |
|
1096 | 1096 | } |
|
1097 | 1097 | Method { name: "clear" } |
|
1098 | 1098 | } |
|
1099 | 1099 | Component { |
|
1100 | 1100 | name: "QtCharts::DeclarativePieSeries" |
|
1101 | 1101 | defaultProperty: "seriesChildren" |
|
1102 | 1102 | prototype: "QtCharts::QPieSeries" |
|
1103 | 1103 | exports: [ |
|
1104 | 1104 | "QtCharts/PieSeries 1.0", |
|
1105 | 1105 | "QtCharts/PieSeries 1.1", |
|
1106 | 1106 | "QtCharts/PieSeries 2.0" |
|
1107 | 1107 | ] |
|
1108 | 1108 | exportMetaObjectRevisions: [0, 0, 0] |
|
1109 | 1109 | Property { name: "seriesChildren"; type: "QObject"; isList: true; isReadonly: true } |
|
1110 | 1110 | Signal { |
|
1111 | 1111 | name: "sliceAdded" |
|
1112 | 1112 | Parameter { name: "slice"; type: "QPieSlice"; isPointer: true } |
|
1113 | 1113 | } |
|
1114 | 1114 | Signal { |
|
1115 | 1115 | name: "sliceRemoved" |
|
1116 | 1116 | Parameter { name: "slice"; type: "QPieSlice"; isPointer: true } |
|
1117 | 1117 | } |
|
1118 | 1118 | Method { |
|
1119 | 1119 | name: "appendSeriesChildren" |
|
1120 | 1120 | Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } |
|
1121 | 1121 | Parameter { name: "element"; type: "QObject"; isPointer: true } |
|
1122 | 1122 | } |
|
1123 | 1123 | Method { |
|
1124 | 1124 | name: "handleAdded" |
|
1125 | 1125 | Parameter { name: "slices"; type: "QList<QPieSlice*>" } |
|
1126 | 1126 | } |
|
1127 | 1127 | Method { |
|
1128 | 1128 | name: "handleRemoved" |
|
1129 | 1129 | Parameter { name: "slices"; type: "QList<QPieSlice*>" } |
|
1130 | 1130 | } |
|
1131 | 1131 | Method { |
|
1132 | 1132 | name: "at" |
|
1133 | 1133 | type: "QPieSlice*" |
|
1134 | 1134 | Parameter { name: "index"; type: "int" } |
|
1135 | 1135 | } |
|
1136 | 1136 | Method { |
|
1137 | 1137 | name: "find" |
|
1138 | 1138 | type: "QPieSlice*" |
|
1139 | 1139 | Parameter { name: "label"; type: "string" } |
|
1140 | 1140 | } |
|
1141 | 1141 | Method { |
|
1142 | 1142 | name: "append" |
|
1143 | 1143 | type: "DeclarativePieSlice*" |
|
1144 | 1144 | Parameter { name: "label"; type: "string" } |
|
1145 | 1145 | Parameter { name: "value"; type: "double" } |
|
1146 | 1146 | } |
|
1147 | 1147 | Method { |
|
1148 | 1148 | name: "remove" |
|
1149 | 1149 | type: "bool" |
|
1150 | 1150 | Parameter { name: "slice"; type: "QPieSlice"; isPointer: true } |
|
1151 | 1151 | } |
|
1152 | 1152 | Method { name: "clear" } |
|
1153 | 1153 | } |
|
1154 | 1154 | Component { |
|
1155 | 1155 | name: "QtCharts::DeclarativePieSlice" |
|
1156 | 1156 | prototype: "QtCharts::QPieSlice" |
|
1157 | 1157 | exports: ["QtCharts/PieSlice 1.4", "QtCharts/PieSlice 2.0"] |
|
1158 | 1158 | exportMetaObjectRevisions: [0, 0] |
|
1159 | 1159 | Property { name: "brushFilename"; type: "string" } |
|
1160 | 1160 | Signal { |
|
1161 | 1161 | name: "brushFilenameChanged" |
|
1162 | 1162 | Parameter { name: "brushFilename"; type: "string" } |
|
1163 | 1163 | } |
|
1164 | 1164 | } |
|
1165 | 1165 | Component { |
|
1166 | 1166 | name: "QtCharts::DeclarativePolarChart" |
|
1167 | 1167 | defaultProperty: "data" |
|
1168 | 1168 | prototype: "QtCharts::DeclarativeChart" |
|
1169 | 1169 | exports: [ |
|
1170 | 1170 | "QtCharts/PolarChartView 1.3", |
|
1171 | 1171 | "QtCharts/PolarChartView 2.0" |
|
1172 | 1172 | ] |
|
1173 | 1173 | exportMetaObjectRevisions: [1, 1] |
|
1174 | 1174 | } |
|
1175 | 1175 | Component { |
|
1176 | 1176 | name: "QtCharts::DeclarativeScatterSeries" |
|
1177 | 1177 | defaultProperty: "declarativeChildren" |
|
1178 | 1178 | prototype: "QtCharts::QScatterSeries" |
|
1179 | 1179 | exports: [ |
|
1180 | 1180 | "QtCharts/ScatterSeries 1.0", |
|
1181 | 1181 | "QtCharts/ScatterSeries 1.1", |
|
1182 | 1182 | "QtCharts/ScatterSeries 1.2", |
|
1183 | 1183 | "QtCharts/ScatterSeries 1.3", |
|
1184 | 1184 | "QtCharts/ScatterSeries 1.4", |
|
1185 | 1185 | "QtCharts/ScatterSeries 2.0" |
|
1186 | 1186 | ] |
|
1187 | 1187 | exportMetaObjectRevisions: [0, 1, 2, 3, 4, 4] |
|
1188 | 1188 | Property { name: "count"; type: "int"; isReadonly: true } |
|
1189 | 1189 | Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
1190 | 1190 | Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
1191 | 1191 | Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
1192 | 1192 | Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
1193 | 1193 | Property { name: "axisAngular"; revision: 3; type: "QAbstractAxis"; isPointer: true } |
|
1194 | 1194 | Property { name: "axisRadial"; revision: 3; type: "QAbstractAxis"; isPointer: true } |
|
1195 | 1195 | Property { name: "borderWidth"; revision: 1; type: "double" } |
|
1196 | 1196 | Property { name: "declarativeChildren"; type: "QObject"; isList: true; isReadonly: true } |
|
1197 | 1197 | Property { name: "brushFilename"; revision: 4; type: "string" } |
|
1198 | 1198 | Property { name: "brush"; revision: 4; type: "QBrush" } |
|
1199 | 1199 | Signal { |
|
1200 | 1200 | name: "countChanged" |
|
1201 | 1201 | Parameter { name: "count"; type: "int" } |
|
1202 | 1202 | } |
|
1203 | 1203 | Signal { |
|
1204 | 1204 | name: "axisXChanged" |
|
1205 | 1205 | revision: 1 |
|
1206 | 1206 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1207 | 1207 | } |
|
1208 | 1208 | Signal { |
|
1209 | 1209 | name: "axisYChanged" |
|
1210 | 1210 | revision: 1 |
|
1211 | 1211 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1212 | 1212 | } |
|
1213 | 1213 | Signal { |
|
1214 | 1214 | name: "borderWidthChanged" |
|
1215 | 1215 | revision: 1 |
|
1216 | 1216 | Parameter { name: "width"; type: "double" } |
|
1217 | 1217 | } |
|
1218 | 1218 | Signal { |
|
1219 | 1219 | name: "axisXTopChanged" |
|
1220 | 1220 | revision: 2 |
|
1221 | 1221 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1222 | 1222 | } |
|
1223 | 1223 | Signal { |
|
1224 | 1224 | name: "axisYRightChanged" |
|
1225 | 1225 | revision: 2 |
|
1226 | 1226 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1227 | 1227 | } |
|
1228 | 1228 | Signal { |
|
1229 | 1229 | name: "axisAngularChanged" |
|
1230 | 1230 | revision: 3 |
|
1231 | 1231 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1232 | 1232 | } |
|
1233 | 1233 | Signal { |
|
1234 | 1234 | name: "axisRadialChanged" |
|
1235 | 1235 | revision: 3 |
|
1236 | 1236 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1237 | 1237 | } |
|
1238 | 1238 | Signal { |
|
1239 | 1239 | name: "brushFilenameChanged" |
|
1240 | 1240 | revision: 4 |
|
1241 | 1241 | Parameter { name: "brushFilename"; type: "string" } |
|
1242 | 1242 | } |
|
1243 | 1243 | Signal { name: "brushChanged"; revision: 4 } |
|
1244 | 1244 | Method { |
|
1245 | 1245 | name: "appendDeclarativeChildren" |
|
1246 | 1246 | Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } |
|
1247 | 1247 | Parameter { name: "element"; type: "QObject"; isPointer: true } |
|
1248 | 1248 | } |
|
1249 | 1249 | Method { |
|
1250 | 1250 | name: "handleCountChanged" |
|
1251 | 1251 | Parameter { name: "index"; type: "int" } |
|
1252 | 1252 | } |
|
1253 | 1253 | Method { |
|
1254 | 1254 | name: "append" |
|
1255 | 1255 | Parameter { name: "x"; type: "double" } |
|
1256 | 1256 | Parameter { name: "y"; type: "double" } |
|
1257 | 1257 | } |
|
1258 | 1258 | Method { |
|
1259 | 1259 | name: "replace" |
|
1260 | 1260 | Parameter { name: "oldX"; type: "double" } |
|
1261 | 1261 | Parameter { name: "oldY"; type: "double" } |
|
1262 | 1262 | Parameter { name: "newX"; type: "double" } |
|
1263 | 1263 | Parameter { name: "newY"; type: "double" } |
|
1264 | 1264 | } |
|
1265 | 1265 | Method { |
|
1266 | 1266 | name: "replace" |
|
1267 | 1267 | revision: 3 |
|
1268 | 1268 | Parameter { name: "index"; type: "int" } |
|
1269 | 1269 | Parameter { name: "newX"; type: "double" } |
|
1270 | 1270 | Parameter { name: "newY"; type: "double" } |
|
1271 | 1271 | } |
|
1272 | 1272 | Method { |
|
1273 | 1273 | name: "remove" |
|
1274 | 1274 | Parameter { name: "x"; type: "double" } |
|
1275 | 1275 | Parameter { name: "y"; type: "double" } |
|
1276 | 1276 | } |
|
1277 | 1277 | Method { |
|
1278 | 1278 | name: "remove" |
|
1279 | 1279 | revision: 3 |
|
1280 | 1280 | Parameter { name: "index"; type: "int" } |
|
1281 | 1281 | } |
|
1282 | 1282 | Method { |
|
1283 | 1283 | name: "insert" |
|
1284 | 1284 | Parameter { name: "index"; type: "int" } |
|
1285 | 1285 | Parameter { name: "x"; type: "double" } |
|
1286 | 1286 | Parameter { name: "y"; type: "double" } |
|
1287 | 1287 | } |
|
1288 | 1288 | Method { name: "clear" } |
|
1289 | 1289 | Method { |
|
1290 | 1290 | name: "at" |
|
1291 | 1291 | type: "QPointF" |
|
1292 | 1292 | Parameter { name: "index"; type: "int" } |
|
1293 | 1293 | } |
|
1294 | 1294 | } |
|
1295 | 1295 | Component { |
|
1296 | 1296 | name: "QtCharts::DeclarativeSplineSeries" |
|
1297 | 1297 | defaultProperty: "declarativeChildren" |
|
1298 | 1298 | prototype: "QtCharts::QSplineSeries" |
|
1299 | 1299 | exports: [ |
|
1300 | 1300 | "QtCharts/SplineSeries 1.0", |
|
1301 | 1301 | "QtCharts/SplineSeries 1.1", |
|
1302 | 1302 | "QtCharts/SplineSeries 1.2", |
|
1303 | 1303 | "QtCharts/SplineSeries 1.3", |
|
1304 | 1304 | "QtCharts/SplineSeries 2.0" |
|
1305 | 1305 | ] |
|
1306 | 1306 | exportMetaObjectRevisions: [0, 1, 2, 3, 3] |
|
1307 | 1307 | Property { name: "count"; type: "int"; isReadonly: true } |
|
1308 | 1308 | Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
1309 | 1309 | Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
1310 | 1310 | Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
1311 | 1311 | Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
1312 | 1312 | Property { name: "axisAngular"; revision: 3; type: "QAbstractAxis"; isPointer: true } |
|
1313 | 1313 | Property { name: "axisRadial"; revision: 3; type: "QAbstractAxis"; isPointer: true } |
|
1314 | 1314 | Property { name: "width"; revision: 1; type: "double" } |
|
1315 | 1315 | Property { name: "style"; revision: 1; type: "Qt::PenStyle" } |
|
1316 | 1316 | Property { name: "capStyle"; revision: 1; type: "Qt::PenCapStyle" } |
|
1317 | 1317 | Property { name: "declarativeChildren"; type: "QObject"; isList: true; isReadonly: true } |
|
1318 | 1318 | Signal { |
|
1319 | 1319 | name: "countChanged" |
|
1320 | 1320 | Parameter { name: "count"; type: "int" } |
|
1321 | 1321 | } |
|
1322 | 1322 | Signal { |
|
1323 | 1323 | name: "axisXChanged" |
|
1324 | 1324 | revision: 1 |
|
1325 | 1325 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1326 | 1326 | } |
|
1327 | 1327 | Signal { |
|
1328 | 1328 | name: "axisYChanged" |
|
1329 | 1329 | revision: 1 |
|
1330 | 1330 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1331 | 1331 | } |
|
1332 | 1332 | Signal { |
|
1333 | 1333 | name: "axisXTopChanged" |
|
1334 | 1334 | revision: 2 |
|
1335 | 1335 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1336 | 1336 | } |
|
1337 | 1337 | Signal { |
|
1338 | 1338 | name: "axisYRightChanged" |
|
1339 | 1339 | revision: 2 |
|
1340 | 1340 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1341 | 1341 | } |
|
1342 | 1342 | Signal { |
|
1343 | 1343 | name: "axisAngularChanged" |
|
1344 | 1344 | revision: 3 |
|
1345 | 1345 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1346 | 1346 | } |
|
1347 | 1347 | Signal { |
|
1348 | 1348 | name: "axisRadialChanged" |
|
1349 | 1349 | revision: 3 |
|
1350 | 1350 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1351 | 1351 | } |
|
1352 | 1352 | Signal { |
|
1353 | 1353 | name: "widthChanged" |
|
1354 | 1354 | revision: 1 |
|
1355 | 1355 | Parameter { name: "width"; type: "double" } |
|
1356 | 1356 | } |
|
1357 | 1357 | Signal { |
|
1358 | 1358 | name: "styleChanged" |
|
1359 | 1359 | revision: 1 |
|
1360 | 1360 | Parameter { name: "style"; type: "Qt::PenStyle" } |
|
1361 | 1361 | } |
|
1362 | 1362 | Signal { |
|
1363 | 1363 | name: "capStyleChanged" |
|
1364 | 1364 | revision: 1 |
|
1365 | 1365 | Parameter { name: "capStyle"; type: "Qt::PenCapStyle" } |
|
1366 | 1366 | } |
|
1367 | 1367 | Method { |
|
1368 | 1368 | name: "appendDeclarativeChildren" |
|
1369 | 1369 | Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } |
|
1370 | 1370 | Parameter { name: "element"; type: "QObject"; isPointer: true } |
|
1371 | 1371 | } |
|
1372 | 1372 | Method { |
|
1373 | 1373 | name: "handleCountChanged" |
|
1374 | 1374 | Parameter { name: "index"; type: "int" } |
|
1375 | 1375 | } |
|
1376 | 1376 | Method { |
|
1377 | 1377 | name: "append" |
|
1378 | 1378 | Parameter { name: "x"; type: "double" } |
|
1379 | 1379 | Parameter { name: "y"; type: "double" } |
|
1380 | 1380 | } |
|
1381 | 1381 | Method { |
|
1382 | 1382 | name: "replace" |
|
1383 | 1383 | Parameter { name: "oldX"; type: "double" } |
|
1384 | 1384 | Parameter { name: "oldY"; type: "double" } |
|
1385 | 1385 | Parameter { name: "newX"; type: "double" } |
|
1386 | 1386 | Parameter { name: "newY"; type: "double" } |
|
1387 | 1387 | } |
|
1388 | 1388 | Method { |
|
1389 | 1389 | name: "replace" |
|
1390 | 1390 | revision: 3 |
|
1391 | 1391 | Parameter { name: "index"; type: "int" } |
|
1392 | 1392 | Parameter { name: "newX"; type: "double" } |
|
1393 | 1393 | Parameter { name: "newY"; type: "double" } |
|
1394 | 1394 | } |
|
1395 | 1395 | Method { |
|
1396 | 1396 | name: "remove" |
|
1397 | 1397 | Parameter { name: "x"; type: "double" } |
|
1398 | 1398 | Parameter { name: "y"; type: "double" } |
|
1399 | 1399 | } |
|
1400 | 1400 | Method { |
|
1401 | 1401 | name: "remove" |
|
1402 | 1402 | revision: 3 |
|
1403 | 1403 | Parameter { name: "index"; type: "int" } |
|
1404 | 1404 | } |
|
1405 | 1405 | Method { |
|
1406 | 1406 | name: "insert" |
|
1407 | 1407 | Parameter { name: "index"; type: "int" } |
|
1408 | 1408 | Parameter { name: "x"; type: "double" } |
|
1409 | 1409 | Parameter { name: "y"; type: "double" } |
|
1410 | 1410 | } |
|
1411 | 1411 | Method { name: "clear" } |
|
1412 | 1412 | Method { |
|
1413 | 1413 | name: "at" |
|
1414 | 1414 | type: "QPointF" |
|
1415 | 1415 | Parameter { name: "index"; type: "int" } |
|
1416 | 1416 | } |
|
1417 | 1417 | } |
|
1418 | 1418 | Component { |
|
1419 | 1419 | name: "QtCharts::DeclarativeStackedBarSeries" |
|
1420 | 1420 | defaultProperty: "seriesChildren" |
|
1421 | 1421 | prototype: "QtCharts::QStackedBarSeries" |
|
1422 | 1422 | exports: [ |
|
1423 | 1423 | "QtCharts/StackedBarSeries 1.0", |
|
1424 | 1424 | "QtCharts/StackedBarSeries 1.1", |
|
1425 | 1425 | "QtCharts/StackedBarSeries 1.2", |
|
1426 | 1426 | "QtCharts/StackedBarSeries 2.0" |
|
1427 | 1427 | ] |
|
1428 | 1428 | exportMetaObjectRevisions: [0, 1, 2, 2] |
|
1429 | 1429 | Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
1430 | 1430 | Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } |
|
1431 | 1431 | Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
1432 | 1432 | Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } |
|
1433 | 1433 | Property { name: "seriesChildren"; type: "QObject"; isList: true; isReadonly: true } |
|
1434 | 1434 | Signal { |
|
1435 | 1435 | name: "axisXChanged" |
|
1436 | 1436 | revision: 1 |
|
1437 | 1437 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1438 | 1438 | } |
|
1439 | 1439 | Signal { |
|
1440 | 1440 | name: "axisYChanged" |
|
1441 | 1441 | revision: 1 |
|
1442 | 1442 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1443 | 1443 | } |
|
1444 | 1444 | Signal { |
|
1445 | 1445 | name: "axisXTopChanged" |
|
1446 | 1446 | revision: 2 |
|
1447 | 1447 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1448 | 1448 | } |
|
1449 | 1449 | Signal { |
|
1450 | 1450 | name: "axisYRightChanged" |
|
1451 | 1451 | revision: 2 |
|
1452 | 1452 | Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } |
|
1453 | 1453 | } |
|
1454 | 1454 | Method { |
|
1455 | 1455 | name: "appendSeriesChildren" |
|
1456 | 1456 | Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } |
|
1457 | 1457 | Parameter { name: "element"; type: "QObject"; isPointer: true } |
|
1458 | 1458 | } |
|
1459 | 1459 | Method { |
|
1460 | 1460 | name: "at" |
|
1461 | 1461 | type: "DeclarativeBarSet*" |
|
1462 | 1462 | Parameter { name: "index"; type: "int" } |
|
1463 | 1463 | } |
|
1464 | 1464 | Method { |
|
1465 | 1465 | name: "append" |
|
1466 | 1466 | type: "DeclarativeBarSet*" |
|
1467 | 1467 | Parameter { name: "label"; type: "string" } |
|
1468 | 1468 | Parameter { name: "values"; type: "QVariantList" } |
|
1469 | 1469 | } |
|
1470 | 1470 | Method { |
|
1471 | 1471 | name: "insert" |
|
1472 | 1472 | type: "DeclarativeBarSet*" |
|
1473 | 1473 | Parameter { name: "index"; type: "int" } |
|
1474 | 1474 | Parameter { name: "label"; type: "string" } |
|
1475 | 1475 | Parameter { name: "values"; type: "QVariantList" } |
|
1476 | 1476 | } |
|
1477 | 1477 | Method { |
|
1478 | 1478 | name: "remove" |
|
1479 | 1479 | type: "bool" |
|
1480 | 1480 | Parameter { name: "barset"; type: "QBarSet"; isPointer: true } |
|
1481 | 1481 | } |
|
1482 | 1482 | Method { name: "clear" } |
|
1483 | 1483 | } |
|
1484 | 1484 | Component { |
|
1485 | 1485 | name: "QtCharts::DeclarativeXYPoint" |
|
1486 | 1486 | prototype: "QObject" |
|
1487 | 1487 | exports: ["QtCharts/XYPoint 1.0", "QtCharts/XYPoint 2.0"] |
|
1488 | 1488 | exportMetaObjectRevisions: [0, 0] |
|
1489 | 1489 | Property { name: "x"; type: "double" } |
|
1490 | 1490 | Property { name: "y"; type: "double" } |
|
1491 | 1491 | } |
|
1492 | 1492 | Component { |
|
1493 | 1493 | name: "QtCharts::LegendScroller" |
|
1494 | 1494 | defaultProperty: "children" |
|
1495 | 1495 | prototype: "QtCharts::QLegend" |
|
1496 | 1496 | } |
|
1497 | 1497 | Component { |
|
1498 | 1498 | name: "QtCharts::QAbstractAxis" |
|
1499 | 1499 | prototype: "QObject" |
|
1500 | exports: ["QtCharts/AbstractAxis 1.0", "QtCharts/AbstractAxis 2.0"] | |
|
1500 | exports: [ | |
|
1501 | "QtCharts/AbstractAxis 1.0", | |
|
1502 | "QtCharts/AbstractAxis 2.0", | |
|
1503 | "QtCharts/AbstractAxis 2.1" | |
|
1504 | ] | |
|
1501 | 1505 | isCreatable: false |
|
1502 | exportMetaObjectRevisions: [0, 0] | |
|
1506 | exportMetaObjectRevisions: [0, 0, 0] | |
|
1503 | 1507 | Property { name: "visible"; type: "bool" } |
|
1504 | 1508 | Property { name: "lineVisible"; type: "bool" } |
|
1505 | 1509 | Property { name: "linePen"; type: "QPen" } |
|
1506 | 1510 | Property { name: "color"; type: "QColor" } |
|
1507 | 1511 | Property { name: "labelsVisible"; type: "bool" } |
|
1508 | 1512 | Property { name: "labelsBrush"; type: "QBrush" } |
|
1509 | 1513 | Property { name: "labelsAngle"; type: "int" } |
|
1510 | 1514 | Property { name: "labelsFont"; type: "QFont" } |
|
1511 | 1515 | Property { name: "labelsColor"; type: "QColor" } |
|
1512 | 1516 | Property { name: "gridVisible"; type: "bool" } |
|
1513 | 1517 | Property { name: "gridLinePen"; type: "QPen" } |
|
1514 | 1518 | Property { name: "shadesVisible"; type: "bool" } |
|
1515 | 1519 | Property { name: "shadesColor"; type: "QColor" } |
|
1516 | 1520 | Property { name: "shadesBorderColor"; type: "QColor" } |
|
1517 | 1521 | Property { name: "shadesPen"; type: "QPen" } |
|
1518 | 1522 | Property { name: "shadesBrush"; type: "QBrush" } |
|
1519 | 1523 | Property { name: "titleText"; type: "string" } |
|
1520 | 1524 | Property { name: "titleBrush"; type: "QBrush" } |
|
1521 | 1525 | Property { name: "titleVisible"; type: "bool" } |
|
1522 | 1526 | Property { name: "titleFont"; type: "QFont" } |
|
1523 | 1527 | Property { name: "orientation"; type: "Qt::Orientation"; isReadonly: true } |
|
1524 | 1528 | Property { name: "alignment"; type: "Qt::Alignment"; isReadonly: true } |
|
1529 | Property { name: "reverse"; type: "bool" } | |
|
1525 | 1530 | Signal { |
|
1526 | 1531 | name: "visibleChanged" |
|
1527 | 1532 | Parameter { name: "visible"; type: "bool" } |
|
1528 | 1533 | } |
|
1529 | 1534 | Signal { |
|
1530 | 1535 | name: "linePenChanged" |
|
1531 | 1536 | Parameter { name: "pen"; type: "QPen" } |
|
1532 | 1537 | } |
|
1533 | 1538 | Signal { |
|
1534 | 1539 | name: "lineVisibleChanged" |
|
1535 | 1540 | Parameter { name: "visible"; type: "bool" } |
|
1536 | 1541 | } |
|
1537 | 1542 | Signal { |
|
1538 | 1543 | name: "labelsVisibleChanged" |
|
1539 | 1544 | Parameter { name: "visible"; type: "bool" } |
|
1540 | 1545 | } |
|
1541 | 1546 | Signal { |
|
1542 | 1547 | name: "labelsBrushChanged" |
|
1543 | 1548 | Parameter { name: "brush"; type: "QBrush" } |
|
1544 | 1549 | } |
|
1545 | 1550 | Signal { |
|
1546 | 1551 | name: "labelsFontChanged" |
|
1547 | 1552 | Parameter { name: "pen"; type: "QFont" } |
|
1548 | 1553 | } |
|
1549 | 1554 | Signal { |
|
1550 | 1555 | name: "labelsAngleChanged" |
|
1551 | 1556 | Parameter { name: "angle"; type: "int" } |
|
1552 | 1557 | } |
|
1553 | 1558 | Signal { |
|
1554 | 1559 | name: "gridLinePenChanged" |
|
1555 | 1560 | Parameter { name: "pen"; type: "QPen" } |
|
1556 | 1561 | } |
|
1557 | 1562 | Signal { |
|
1558 | 1563 | name: "gridVisibleChanged" |
|
1559 | 1564 | Parameter { name: "visible"; type: "bool" } |
|
1560 | 1565 | } |
|
1561 | 1566 | Signal { |
|
1562 | 1567 | name: "colorChanged" |
|
1563 | 1568 | Parameter { name: "color"; type: "QColor" } |
|
1564 | 1569 | } |
|
1565 | 1570 | Signal { |
|
1566 | 1571 | name: "labelsColorChanged" |
|
1567 | 1572 | Parameter { name: "color"; type: "QColor" } |
|
1568 | 1573 | } |
|
1569 | 1574 | Signal { |
|
1570 | 1575 | name: "titleTextChanged" |
|
1571 | 1576 | Parameter { name: "title"; type: "string" } |
|
1572 | 1577 | } |
|
1573 | 1578 | Signal { |
|
1574 | 1579 | name: "titleBrushChanged" |
|
1575 | 1580 | Parameter { name: "brush"; type: "QBrush" } |
|
1576 | 1581 | } |
|
1577 | 1582 | Signal { |
|
1578 | 1583 | name: "titleVisibleChanged" |
|
1579 | 1584 | Parameter { name: "visible"; type: "bool" } |
|
1580 | 1585 | } |
|
1581 | 1586 | Signal { |
|
1582 | 1587 | name: "titleFontChanged" |
|
1583 | 1588 | Parameter { name: "font"; type: "QFont" } |
|
1584 | 1589 | } |
|
1585 | 1590 | Signal { |
|
1586 | 1591 | name: "shadesVisibleChanged" |
|
1587 | 1592 | Parameter { name: "visible"; type: "bool" } |
|
1588 | 1593 | } |
|
1589 | 1594 | Signal { |
|
1590 | 1595 | name: "shadesColorChanged" |
|
1591 | 1596 | Parameter { name: "color"; type: "QColor" } |
|
1592 | 1597 | } |
|
1593 | 1598 | Signal { |
|
1594 | 1599 | name: "shadesBorderColorChanged" |
|
1595 | 1600 | Parameter { name: "color"; type: "QColor" } |
|
1596 | 1601 | } |
|
1597 | 1602 | Signal { |
|
1598 | 1603 | name: "shadesPenChanged" |
|
1599 | 1604 | Parameter { name: "pen"; type: "QPen" } |
|
1600 | 1605 | } |
|
1601 | 1606 | Signal { |
|
1602 | 1607 | name: "shadesBrushChanged" |
|
1603 | 1608 | Parameter { name: "brush"; type: "QBrush" } |
|
1604 | 1609 | } |
|
1610 | Signal { | |
|
1611 | name: "reverseChanged" | |
|
1612 | Parameter { name: "reverse"; type: "bool" } | |
|
1613 | } | |
|
1605 | 1614 | } |
|
1606 | 1615 | Component { |
|
1607 | 1616 | name: "QtCharts::QAbstractBarSeries" |
|
1608 | 1617 | prototype: "QtCharts::QAbstractSeries" |
|
1609 | 1618 | exports: [ |
|
1610 | 1619 | "QtCharts/AbstractBarSeries 1.0", |
|
1611 | 1620 | "QtCharts/AbstractBarSeries 2.0" |
|
1612 | 1621 | ] |
|
1613 | 1622 | isCreatable: false |
|
1614 | 1623 | exportMetaObjectRevisions: [0, 0] |
|
1615 | 1624 | Enum { |
|
1616 | 1625 | name: "LabelsPosition" |
|
1617 | 1626 | values: { |
|
1618 | 1627 | "LabelsCenter": 0, |
|
1619 | 1628 | "LabelsInsideEnd": 1, |
|
1620 | 1629 | "LabelsInsideBase": 2, |
|
1621 | 1630 | "LabelsOutsideEnd": 3 |
|
1622 | 1631 | } |
|
1623 | 1632 | } |
|
1624 | 1633 | Property { name: "barWidth"; type: "double" } |
|
1625 | 1634 | Property { name: "count"; type: "int"; isReadonly: true } |
|
1626 | 1635 | Property { name: "labelsVisible"; type: "bool" } |
|
1627 | 1636 | Property { name: "labelsFormat"; type: "string" } |
|
1628 | 1637 | Property { name: "labelsPosition"; type: "LabelsPosition" } |
|
1629 | 1638 | Signal { |
|
1630 | 1639 | name: "clicked" |
|
1631 | 1640 | Parameter { name: "index"; type: "int" } |
|
1632 | 1641 | Parameter { name: "barset"; type: "QBarSet"; isPointer: true } |
|
1633 | 1642 | } |
|
1634 | 1643 | Signal { |
|
1635 | 1644 | name: "hovered" |
|
1636 | 1645 | Parameter { name: "status"; type: "bool" } |
|
1637 | 1646 | Parameter { name: "index"; type: "int" } |
|
1638 | 1647 | Parameter { name: "barset"; type: "QBarSet"; isPointer: true } |
|
1639 | 1648 | } |
|
1640 | 1649 | Signal { |
|
1641 | 1650 | name: "pressed" |
|
1642 | 1651 | Parameter { name: "index"; type: "int" } |
|
1643 | 1652 | Parameter { name: "barset"; type: "QBarSet"; isPointer: true } |
|
1644 | 1653 | } |
|
1645 | 1654 | Signal { |
|
1646 | 1655 | name: "released" |
|
1647 | 1656 | Parameter { name: "index"; type: "int" } |
|
1648 | 1657 | Parameter { name: "barset"; type: "QBarSet"; isPointer: true } |
|
1649 | 1658 | } |
|
1650 | 1659 | Signal { |
|
1651 | 1660 | name: "doubleClicked" |
|
1652 | 1661 | Parameter { name: "index"; type: "int" } |
|
1653 | 1662 | Parameter { name: "barset"; type: "QBarSet"; isPointer: true } |
|
1654 | 1663 | } |
|
1655 | 1664 | Signal { |
|
1656 | 1665 | name: "labelsFormatChanged" |
|
1657 | 1666 | Parameter { name: "format"; type: "string" } |
|
1658 | 1667 | } |
|
1659 | 1668 | Signal { |
|
1660 | 1669 | name: "labelsPositionChanged" |
|
1661 | 1670 | Parameter { name: "position"; type: "QAbstractBarSeries::LabelsPosition" } |
|
1662 | 1671 | } |
|
1663 | 1672 | Signal { |
|
1664 | 1673 | name: "barsetsAdded" |
|
1665 | 1674 | Parameter { name: "sets"; type: "QList<QBarSet*>" } |
|
1666 | 1675 | } |
|
1667 | 1676 | Signal { |
|
1668 | 1677 | name: "barsetsRemoved" |
|
1669 | 1678 | Parameter { name: "sets"; type: "QList<QBarSet*>" } |
|
1670 | 1679 | } |
|
1671 | 1680 | } |
|
1672 | 1681 | Component { |
|
1673 | 1682 | name: "QtCharts::QAbstractSeries" |
|
1674 | 1683 | prototype: "QObject" |
|
1675 | 1684 | exports: [ |
|
1676 | 1685 | "QtCharts/AbstractSeries 1.0", |
|
1677 | 1686 | "QtCharts/AbstractSeries 2.0" |
|
1678 | 1687 | ] |
|
1679 | 1688 | isCreatable: false |
|
1680 | 1689 | exportMetaObjectRevisions: [0, 0] |
|
1681 | 1690 | Enum { |
|
1682 | 1691 | name: "SeriesType" |
|
1683 | 1692 | values: { |
|
1684 | 1693 | "SeriesTypeLine": 0, |
|
1685 | 1694 | "SeriesTypeArea": 1, |
|
1686 | 1695 | "SeriesTypeBar": 2, |
|
1687 | 1696 | "SeriesTypeStackedBar": 3, |
|
1688 | 1697 | "SeriesTypePercentBar": 4, |
|
1689 | 1698 | "SeriesTypePie": 5, |
|
1690 | 1699 | "SeriesTypeScatter": 6, |
|
1691 | 1700 | "SeriesTypeSpline": 7, |
|
1692 | 1701 | "SeriesTypeHorizontalBar": 8, |
|
1693 | 1702 | "SeriesTypeHorizontalStackedBar": 9, |
|
1694 | 1703 | "SeriesTypeHorizontalPercentBar": 10, |
|
1695 | 1704 | "SeriesTypeBoxPlot": 11 |
|
1696 | 1705 | } |
|
1697 | 1706 | } |
|
1698 | 1707 | Property { name: "name"; type: "string" } |
|
1699 | 1708 | Property { name: "visible"; type: "bool" } |
|
1700 | 1709 | Property { name: "opacity"; type: "double" } |
|
1701 | 1710 | Property { name: "type"; type: "SeriesType"; isReadonly: true } |
|
1702 | 1711 | } |
|
1703 | 1712 | Component { |
|
1704 | 1713 | name: "QtCharts::QAreaSeries" |
|
1705 | 1714 | prototype: "QtCharts::QAbstractSeries" |
|
1706 | 1715 | Property { name: "upperSeries"; type: "QLineSeries"; isReadonly: true; isPointer: true } |
|
1707 | 1716 | Property { name: "lowerSeries"; type: "QLineSeries"; isReadonly: true; isPointer: true } |
|
1708 | 1717 | Property { name: "color"; type: "QColor" } |
|
1709 | 1718 | Property { name: "borderColor"; type: "QColor" } |
|
1710 | 1719 | Property { name: "pointLabelsFormat"; type: "string" } |
|
1711 | 1720 | Property { name: "pointLabelsVisible"; type: "bool" } |
|
1712 | 1721 | Property { name: "pointLabelsFont"; type: "QFont" } |
|
1713 | 1722 | Property { name: "pointLabelsColor"; type: "QColor" } |
|
1714 | 1723 | Signal { |
|
1715 | 1724 | name: "clicked" |
|
1716 | 1725 | Parameter { name: "point"; type: "QPointF" } |
|
1717 | 1726 | } |
|
1718 | 1727 | Signal { |
|
1719 | 1728 | name: "hovered" |
|
1720 | 1729 | Parameter { name: "point"; type: "QPointF" } |
|
1721 | 1730 | Parameter { name: "state"; type: "bool" } |
|
1722 | 1731 | } |
|
1723 | 1732 | Signal { |
|
1724 | 1733 | name: "pressed" |
|
1725 | 1734 | Parameter { name: "point"; type: "QPointF" } |
|
1726 | 1735 | } |
|
1727 | 1736 | Signal { |
|
1728 | 1737 | name: "released" |
|
1729 | 1738 | Parameter { name: "point"; type: "QPointF" } |
|
1730 | 1739 | } |
|
1731 | 1740 | Signal { |
|
1732 | 1741 | name: "doubleClicked" |
|
1733 | 1742 | Parameter { name: "point"; type: "QPointF" } |
|
1734 | 1743 | } |
|
1735 | 1744 | Signal { name: "selected" } |
|
1736 | 1745 | Signal { |
|
1737 | 1746 | name: "colorChanged" |
|
1738 | 1747 | Parameter { name: "color"; type: "QColor" } |
|
1739 | 1748 | } |
|
1740 | 1749 | Signal { |
|
1741 | 1750 | name: "borderColorChanged" |
|
1742 | 1751 | Parameter { name: "color"; type: "QColor" } |
|
1743 | 1752 | } |
|
1744 | 1753 | Signal { |
|
1745 | 1754 | name: "pointLabelsFormatChanged" |
|
1746 | 1755 | Parameter { name: "format"; type: "string" } |
|
1747 | 1756 | } |
|
1748 | 1757 | Signal { |
|
1749 | 1758 | name: "pointLabelsVisibilityChanged" |
|
1750 | 1759 | Parameter { name: "visible"; type: "bool" } |
|
1751 | 1760 | } |
|
1752 | 1761 | Signal { |
|
1753 | 1762 | name: "pointLabelsFontChanged" |
|
1754 | 1763 | Parameter { name: "font"; type: "QFont" } |
|
1755 | 1764 | } |
|
1756 | 1765 | Signal { |
|
1757 | 1766 | name: "pointLabelsColorChanged" |
|
1758 | 1767 | Parameter { name: "color"; type: "QColor" } |
|
1759 | 1768 | } |
|
1760 | 1769 | } |
|
1761 | 1770 | Component { |
|
1762 | 1771 | name: "QtCharts::QBarCategoryAxis" |
|
1763 | 1772 | prototype: "QtCharts::QAbstractAxis" |
|
1764 | 1773 | exports: [ |
|
1765 | 1774 | "QtCharts/BarCategoriesAxis 1.0", |
|
1766 | 1775 | "QtCharts/BarCategoryAxis 1.1", |
|
1767 | 1776 | "QtCharts/BarCategoryAxis 2.0" |
|
1768 | 1777 | ] |
|
1769 | 1778 | exportMetaObjectRevisions: [0, 0, 0] |
|
1770 | 1779 | Property { name: "categories"; type: "QStringList" } |
|
1771 | 1780 | Property { name: "min"; type: "string" } |
|
1772 | 1781 | Property { name: "max"; type: "string" } |
|
1773 | 1782 | Property { name: "count"; type: "int"; isReadonly: true } |
|
1774 | 1783 | Signal { |
|
1775 | 1784 | name: "minChanged" |
|
1776 | 1785 | Parameter { name: "min"; type: "string" } |
|
1777 | 1786 | } |
|
1778 | 1787 | Signal { |
|
1779 | 1788 | name: "maxChanged" |
|
1780 | 1789 | Parameter { name: "max"; type: "string" } |
|
1781 | 1790 | } |
|
1782 | 1791 | Signal { |
|
1783 | 1792 | name: "rangeChanged" |
|
1784 | 1793 | Parameter { name: "min"; type: "string" } |
|
1785 | 1794 | Parameter { name: "max"; type: "string" } |
|
1786 | 1795 | } |
|
1787 | 1796 | Method { name: "clear" } |
|
1788 | 1797 | } |
|
1789 | 1798 | Component { |
|
1790 | 1799 | name: "QtCharts::QBarModelMapper" |
|
1791 | 1800 | prototype: "QObject" |
|
1792 | 1801 | exports: [ |
|
1793 | 1802 | "QtCharts/BarModelMapper 1.0", |
|
1794 | 1803 | "QtCharts/BarModelMapper 2.0" |
|
1795 | 1804 | ] |
|
1796 | 1805 | isCreatable: false |
|
1797 | 1806 | exportMetaObjectRevisions: [0, 0] |
|
1798 | 1807 | } |
|
1799 | 1808 | Component { name: "QtCharts::QBarSeries"; prototype: "QtCharts::QAbstractBarSeries" } |
|
1800 | 1809 | Component { |
|
1801 | 1810 | name: "QtCharts::QBarSet" |
|
1802 | 1811 | prototype: "QObject" |
|
1803 | 1812 | exports: ["QtCharts/BarSetBase 1.0", "QtCharts/BarSetBase 2.0"] |
|
1804 | 1813 | isCreatable: false |
|
1805 | 1814 | exportMetaObjectRevisions: [0, 0] |
|
1806 | 1815 | Property { name: "label"; type: "string" } |
|
1807 | 1816 | Property { name: "pen"; type: "QPen" } |
|
1808 | 1817 | Property { name: "brush"; type: "QBrush" } |
|
1809 | 1818 | Property { name: "labelBrush"; type: "QBrush" } |
|
1810 | 1819 | Property { name: "labelFont"; type: "QFont" } |
|
1811 | 1820 | Property { name: "color"; type: "QColor" } |
|
1812 | 1821 | Property { name: "borderColor"; type: "QColor" } |
|
1813 | 1822 | Property { name: "labelColor"; type: "QColor" } |
|
1814 | 1823 | Signal { |
|
1815 | 1824 | name: "clicked" |
|
1816 | 1825 | Parameter { name: "index"; type: "int" } |
|
1817 | 1826 | } |
|
1818 | 1827 | Signal { |
|
1819 | 1828 | name: "hovered" |
|
1820 | 1829 | Parameter { name: "status"; type: "bool" } |
|
1821 | 1830 | Parameter { name: "index"; type: "int" } |
|
1822 | 1831 | } |
|
1823 | 1832 | Signal { |
|
1824 | 1833 | name: "pressed" |
|
1825 | 1834 | Parameter { name: "index"; type: "int" } |
|
1826 | 1835 | } |
|
1827 | 1836 | Signal { |
|
1828 | 1837 | name: "released" |
|
1829 | 1838 | Parameter { name: "index"; type: "int" } |
|
1830 | 1839 | } |
|
1831 | 1840 | Signal { |
|
1832 | 1841 | name: "doubleClicked" |
|
1833 | 1842 | Parameter { name: "index"; type: "int" } |
|
1834 | 1843 | } |
|
1835 | 1844 | Signal { |
|
1836 | 1845 | name: "colorChanged" |
|
1837 | 1846 | Parameter { name: "color"; type: "QColor" } |
|
1838 | 1847 | } |
|
1839 | 1848 | Signal { |
|
1840 | 1849 | name: "borderColorChanged" |
|
1841 | 1850 | Parameter { name: "color"; type: "QColor" } |
|
1842 | 1851 | } |
|
1843 | 1852 | Signal { |
|
1844 | 1853 | name: "labelColorChanged" |
|
1845 | 1854 | Parameter { name: "color"; type: "QColor" } |
|
1846 | 1855 | } |
|
1847 | 1856 | Signal { |
|
1848 | 1857 | name: "valuesAdded" |
|
1849 | 1858 | Parameter { name: "index"; type: "int" } |
|
1850 | 1859 | Parameter { name: "count"; type: "int" } |
|
1851 | 1860 | } |
|
1852 | 1861 | Signal { |
|
1853 | 1862 | name: "valuesRemoved" |
|
1854 | 1863 | Parameter { name: "index"; type: "int" } |
|
1855 | 1864 | Parameter { name: "count"; type: "int" } |
|
1856 | 1865 | } |
|
1857 | 1866 | Signal { |
|
1858 | 1867 | name: "valueChanged" |
|
1859 | 1868 | Parameter { name: "index"; type: "int" } |
|
1860 | 1869 | } |
|
1861 | 1870 | } |
|
1862 | 1871 | Component { |
|
1863 | 1872 | name: "QtCharts::QBoxPlotModelMapper" |
|
1864 | 1873 | prototype: "QObject" |
|
1865 | 1874 | exports: ["QtCharts/BoxPlotModelMapper 2.0"] |
|
1866 | 1875 | isCreatable: false |
|
1867 | 1876 | exportMetaObjectRevisions: [0] |
|
1868 | 1877 | } |
|
1869 | 1878 | Component { |
|
1870 | 1879 | name: "QtCharts::QBoxPlotSeries" |
|
1871 | 1880 | prototype: "QtCharts::QAbstractSeries" |
|
1872 | 1881 | Property { name: "boxOutlineVisible"; type: "bool" } |
|
1873 | 1882 | Property { name: "boxWidth"; type: "double" } |
|
1874 | 1883 | Property { name: "pen"; type: "QPen" } |
|
1875 | 1884 | Property { name: "brush"; type: "QBrush" } |
|
1876 | 1885 | Property { name: "count"; revision: 1; type: "int"; isReadonly: true } |
|
1877 | 1886 | Signal { |
|
1878 | 1887 | name: "clicked" |
|
1879 | 1888 | Parameter { name: "boxset"; type: "QBoxSet"; isPointer: true } |
|
1880 | 1889 | } |
|
1881 | 1890 | Signal { |
|
1882 | 1891 | name: "hovered" |
|
1883 | 1892 | Parameter { name: "status"; type: "bool" } |
|
1884 | 1893 | Parameter { name: "boxset"; type: "QBoxSet"; isPointer: true } |
|
1885 | 1894 | } |
|
1886 | 1895 | Signal { |
|
1887 | 1896 | name: "pressed" |
|
1888 | 1897 | Parameter { name: "boxset"; type: "QBoxSet"; isPointer: true } |
|
1889 | 1898 | } |
|
1890 | 1899 | Signal { |
|
1891 | 1900 | name: "released" |
|
1892 | 1901 | Parameter { name: "boxset"; type: "QBoxSet"; isPointer: true } |
|
1893 | 1902 | } |
|
1894 | 1903 | Signal { |
|
1895 | 1904 | name: "doubleClicked" |
|
1896 | 1905 | Parameter { name: "boxset"; type: "QBoxSet"; isPointer: true } |
|
1897 | 1906 | } |
|
1898 | 1907 | Signal { name: "boxOutlineVisibilityChanged" } |
|
1899 | 1908 | Signal { |
|
1900 | 1909 | name: "boxsetsAdded" |
|
1901 | 1910 | Parameter { name: "sets"; type: "QList<QBoxSet*>" } |
|
1902 | 1911 | } |
|
1903 | 1912 | Signal { |
|
1904 | 1913 | name: "boxsetsRemoved" |
|
1905 | 1914 | Parameter { name: "sets"; type: "QList<QBoxSet*>" } |
|
1906 | 1915 | } |
|
1907 | 1916 | } |
|
1908 | 1917 | Component { |
|
1909 | 1918 | name: "QtCharts::QBoxSet" |
|
1910 | 1919 | prototype: "QObject" |
|
1911 | 1920 | Property { name: "pen"; type: "QPen" } |
|
1912 | 1921 | Property { name: "brush"; type: "QBrush" } |
|
1913 | 1922 | Signal { name: "clicked" } |
|
1914 | 1923 | Signal { |
|
1915 | 1924 | name: "hovered" |
|
1916 | 1925 | Parameter { name: "status"; type: "bool" } |
|
1917 | 1926 | } |
|
1918 | 1927 | Signal { name: "pressed" } |
|
1919 | 1928 | Signal { name: "released" } |
|
1920 | 1929 | Signal { name: "doubleClicked" } |
|
1921 | 1930 | Signal { name: "valuesChanged" } |
|
1922 | 1931 | Signal { |
|
1923 | 1932 | name: "valueChanged" |
|
1924 | 1933 | Parameter { name: "index"; type: "int" } |
|
1925 | 1934 | } |
|
1926 | 1935 | Signal { name: "cleared" } |
|
1927 | 1936 | } |
|
1928 | 1937 | Component { |
|
1929 | 1938 | name: "QtCharts::QCategoryAxis" |
|
1930 | 1939 | prototype: "QtCharts::QValueAxis" |
|
1931 | 1940 | Enum { |
|
1932 | 1941 | name: "AxisLabelsPosition" |
|
1933 | 1942 | values: { |
|
1934 | 1943 | "AxisLabelsPositionCenter": 0, |
|
1935 | 1944 | "AxisLabelsPositionOnValue": 1 |
|
1936 | 1945 | } |
|
1937 | 1946 | } |
|
1938 | 1947 | Property { name: "startValue"; type: "double" } |
|
1939 | 1948 | Property { name: "count"; type: "int"; isReadonly: true } |
|
1940 | 1949 | Property { name: "categoriesLabels"; type: "QStringList"; isReadonly: true } |
|
1941 | 1950 | Property { name: "labelsPosition"; type: "AxisLabelsPosition" } |
|
1942 | 1951 | Signal { name: "categoriesChanged" } |
|
1943 | 1952 | Signal { |
|
1944 | 1953 | name: "labelsPositionChanged" |
|
1945 | 1954 | Parameter { name: "position"; type: "QCategoryAxis::AxisLabelsPosition" } |
|
1946 | 1955 | } |
|
1947 | 1956 | } |
|
1948 | 1957 | Component { |
|
1949 | 1958 | name: "QtCharts::QDateTimeAxis" |
|
1950 | 1959 | prototype: "QtCharts::QAbstractAxis" |
|
1951 | 1960 | exports: ["QtCharts/DateTimeAxis 1.1", "QtCharts/DateTimeAxis 2.0"] |
|
1952 | 1961 | exportMetaObjectRevisions: [0, 0] |
|
1953 | 1962 | Property { name: "tickCount"; type: "int" } |
|
1954 | 1963 | Property { name: "min"; type: "QDateTime" } |
|
1955 | 1964 | Property { name: "max"; type: "QDateTime" } |
|
1956 | 1965 | Property { name: "format"; type: "string" } |
|
1957 | 1966 | Signal { |
|
1958 | 1967 | name: "minChanged" |
|
1959 | 1968 | Parameter { name: "min"; type: "QDateTime" } |
|
1960 | 1969 | } |
|
1961 | 1970 | Signal { |
|
1962 | 1971 | name: "maxChanged" |
|
1963 | 1972 | Parameter { name: "max"; type: "QDateTime" } |
|
1964 | 1973 | } |
|
1965 | 1974 | Signal { |
|
1966 | 1975 | name: "rangeChanged" |
|
1967 | 1976 | Parameter { name: "min"; type: "QDateTime" } |
|
1968 | 1977 | Parameter { name: "max"; type: "QDateTime" } |
|
1969 | 1978 | } |
|
1970 | 1979 | Signal { |
|
1971 | 1980 | name: "formatChanged" |
|
1972 | 1981 | Parameter { name: "format"; type: "string" } |
|
1973 | 1982 | } |
|
1974 | 1983 | Signal { |
|
1975 | 1984 | name: "tickCountChanged" |
|
1976 | 1985 | Parameter { name: "tick"; type: "int" } |
|
1977 | 1986 | } |
|
1978 | 1987 | } |
|
1979 | 1988 | Component { |
|
1980 | 1989 | name: "QtCharts::QHBarModelMapper" |
|
1981 | 1990 | prototype: "QtCharts::QBarModelMapper" |
|
1982 | 1991 | exports: [ |
|
1983 | 1992 | "QtCharts/HBarModelMapper 1.0", |
|
1984 | 1993 | "QtCharts/HBarModelMapper 2.0" |
|
1985 | 1994 | ] |
|
1986 | 1995 | exportMetaObjectRevisions: [0, 0] |
|
1987 | 1996 | Property { name: "series"; type: "QAbstractBarSeries"; isPointer: true } |
|
1988 | 1997 | Property { name: "model"; type: "QAbstractItemModel"; isPointer: true } |
|
1989 | 1998 | Property { name: "firstBarSetRow"; type: "int" } |
|
1990 | 1999 | Property { name: "lastBarSetRow"; type: "int" } |
|
1991 | 2000 | Property { name: "firstColumn"; type: "int" } |
|
1992 | 2001 | Property { name: "columnCount"; type: "int" } |
|
1993 | 2002 | Signal { name: "seriesReplaced" } |
|
1994 | 2003 | Signal { name: "modelReplaced" } |
|
1995 | 2004 | } |
|
1996 | 2005 | Component { |
|
1997 | 2006 | name: "QtCharts::QHPieModelMapper" |
|
1998 | 2007 | prototype: "QtCharts::QPieModelMapper" |
|
1999 | 2008 | exports: [ |
|
2000 | 2009 | "QtCharts/HPieModelMapper 1.0", |
|
2001 | 2010 | "QtCharts/HPieModelMapper 2.0" |
|
2002 | 2011 | ] |
|
2003 | 2012 | exportMetaObjectRevisions: [0, 0] |
|
2004 | 2013 | Property { name: "series"; type: "QPieSeries"; isPointer: true } |
|
2005 | 2014 | Property { name: "model"; type: "QAbstractItemModel"; isPointer: true } |
|
2006 | 2015 | Property { name: "valuesRow"; type: "int" } |
|
2007 | 2016 | Property { name: "labelsRow"; type: "int" } |
|
2008 | 2017 | Property { name: "firstColumn"; type: "int" } |
|
2009 | 2018 | Property { name: "columnCount"; type: "int" } |
|
2010 | 2019 | Signal { name: "seriesReplaced" } |
|
2011 | 2020 | Signal { name: "modelReplaced" } |
|
2012 | 2021 | } |
|
2013 | 2022 | Component { |
|
2014 | 2023 | name: "QtCharts::QHXYModelMapper" |
|
2015 | 2024 | prototype: "QtCharts::QXYModelMapper" |
|
2016 | 2025 | exports: [ |
|
2017 | 2026 | "QtCharts/HXYModelMapper 1.0", |
|
2018 | 2027 | "QtCharts/HXYModelMapper 2.0" |
|
2019 | 2028 | ] |
|
2020 | 2029 | exportMetaObjectRevisions: [0, 0] |
|
2021 | 2030 | Property { name: "series"; type: "QXYSeries"; isPointer: true } |
|
2022 | 2031 | Property { name: "model"; type: "QAbstractItemModel"; isPointer: true } |
|
2023 | 2032 | Property { name: "xRow"; type: "int" } |
|
2024 | 2033 | Property { name: "yRow"; type: "int" } |
|
2025 | 2034 | Property { name: "firstColumn"; type: "int" } |
|
2026 | 2035 | Property { name: "columnCount"; type: "int" } |
|
2027 | 2036 | Signal { name: "seriesReplaced" } |
|
2028 | 2037 | Signal { name: "modelReplaced" } |
|
2029 | 2038 | } |
|
2030 | 2039 | Component { name: "QtCharts::QHorizontalBarSeries"; prototype: "QtCharts::QAbstractBarSeries" } |
|
2031 | 2040 | Component { |
|
2032 | 2041 | name: "QtCharts::QHorizontalPercentBarSeries" |
|
2033 | 2042 | prototype: "QtCharts::QAbstractBarSeries" |
|
2034 | 2043 | } |
|
2035 | 2044 | Component { |
|
2036 | 2045 | name: "QtCharts::QHorizontalStackedBarSeries" |
|
2037 | 2046 | prototype: "QtCharts::QAbstractBarSeries" |
|
2038 | 2047 | } |
|
2039 | 2048 | Component { |
|
2040 | 2049 | name: "QtCharts::QLegend" |
|
2041 | 2050 | defaultProperty: "children" |
|
2042 | 2051 | prototype: "QGraphicsWidget" |
|
2043 | 2052 | exports: ["QtCharts/Legend 1.0", "QtCharts/Legend 2.0"] |
|
2044 | 2053 | isCreatable: false |
|
2045 | 2054 | exportMetaObjectRevisions: [0, 0] |
|
2046 | 2055 | Property { name: "alignment"; type: "Qt::Alignment" } |
|
2047 | 2056 | Property { name: "backgroundVisible"; type: "bool" } |
|
2048 | 2057 | Property { name: "color"; type: "QColor" } |
|
2049 | 2058 | Property { name: "borderColor"; type: "QColor" } |
|
2050 | 2059 | Property { name: "font"; type: "QFont" } |
|
2051 | 2060 | Property { name: "labelColor"; type: "QColor" } |
|
2052 | 2061 | Property { name: "reverseMarkers"; type: "bool" } |
|
2053 | 2062 | Signal { |
|
2054 | 2063 | name: "backgroundVisibleChanged" |
|
2055 | 2064 | Parameter { name: "visible"; type: "bool" } |
|
2056 | 2065 | } |
|
2057 | 2066 | Signal { |
|
2058 | 2067 | name: "colorChanged" |
|
2059 | 2068 | Parameter { name: "color"; type: "QColor" } |
|
2060 | 2069 | } |
|
2061 | 2070 | Signal { |
|
2062 | 2071 | name: "borderColorChanged" |
|
2063 | 2072 | Parameter { name: "color"; type: "QColor" } |
|
2064 | 2073 | } |
|
2065 | 2074 | Signal { |
|
2066 | 2075 | name: "fontChanged" |
|
2067 | 2076 | Parameter { name: "font"; type: "QFont" } |
|
2068 | 2077 | } |
|
2069 | 2078 | Signal { |
|
2070 | 2079 | name: "labelColorChanged" |
|
2071 | 2080 | Parameter { name: "color"; type: "QColor" } |
|
2072 | 2081 | } |
|
2073 | 2082 | Signal { |
|
2074 | 2083 | name: "reverseMarkersChanged" |
|
2075 | 2084 | Parameter { name: "reverseMarkers"; type: "bool" } |
|
2076 | 2085 | } |
|
2077 | 2086 | } |
|
2078 | 2087 | Component { name: "QtCharts::QLineSeries"; prototype: "QtCharts::QXYSeries" } |
|
2079 | 2088 | Component { |
|
2080 | 2089 | name: "QtCharts::QLogValueAxis" |
|
2081 | 2090 | prototype: "QtCharts::QAbstractAxis" |
|
2082 | 2091 | exports: ["QtCharts/LogValueAxis 1.3", "QtCharts/LogValueAxis 2.0"] |
|
2083 | 2092 | exportMetaObjectRevisions: [0, 1] |
|
2084 | 2093 | Property { name: "min"; type: "double" } |
|
2085 | 2094 | Property { name: "max"; type: "double" } |
|
2086 | 2095 | Property { name: "labelFormat"; type: "string" } |
|
2087 | 2096 | Property { name: "base"; type: "double" } |
|
2088 | 2097 | Signal { |
|
2089 | 2098 | name: "minChanged" |
|
2090 | 2099 | Parameter { name: "min"; type: "double" } |
|
2091 | 2100 | } |
|
2092 | 2101 | Signal { |
|
2093 | 2102 | name: "maxChanged" |
|
2094 | 2103 | Parameter { name: "max"; type: "double" } |
|
2095 | 2104 | } |
|
2096 | 2105 | Signal { |
|
2097 | 2106 | name: "rangeChanged" |
|
2098 | 2107 | Parameter { name: "min"; type: "double" } |
|
2099 | 2108 | Parameter { name: "max"; type: "double" } |
|
2100 | 2109 | } |
|
2101 | 2110 | Signal { |
|
2102 | 2111 | name: "labelFormatChanged" |
|
2103 | 2112 | Parameter { name: "format"; type: "string" } |
|
2104 | 2113 | } |
|
2105 | 2114 | Signal { |
|
2106 | 2115 | name: "baseChanged" |
|
2107 | 2116 | Parameter { name: "base"; type: "double" } |
|
2108 | 2117 | } |
|
2109 | 2118 | } |
|
2110 | 2119 | Component { name: "QtCharts::QPercentBarSeries"; prototype: "QtCharts::QAbstractBarSeries" } |
|
2111 | 2120 | Component { |
|
2112 | 2121 | name: "QtCharts::QPieModelMapper" |
|
2113 | 2122 | prototype: "QObject" |
|
2114 | 2123 | exports: [ |
|
2115 | 2124 | "QtCharts/PieModelMapper 1.0", |
|
2116 | 2125 | "QtCharts/PieModelMapper 2.0" |
|
2117 | 2126 | ] |
|
2118 | 2127 | isCreatable: false |
|
2119 | 2128 | exportMetaObjectRevisions: [0, 0] |
|
2120 | 2129 | } |
|
2121 | 2130 | Component { |
|
2122 | 2131 | name: "QtCharts::QPieSeries" |
|
2123 | 2132 | prototype: "QtCharts::QAbstractSeries" |
|
2124 | 2133 | exports: ["QtCharts/QPieSeries 1.0", "QtCharts/QPieSeries 2.0"] |
|
2125 | 2134 | isCreatable: false |
|
2126 | 2135 | exportMetaObjectRevisions: [0, 0] |
|
2127 | 2136 | Property { name: "horizontalPosition"; type: "double" } |
|
2128 | 2137 | Property { name: "verticalPosition"; type: "double" } |
|
2129 | 2138 | Property { name: "size"; type: "double" } |
|
2130 | 2139 | Property { name: "startAngle"; type: "double" } |
|
2131 | 2140 | Property { name: "endAngle"; type: "double" } |
|
2132 | 2141 | Property { name: "count"; type: "int"; isReadonly: true } |
|
2133 | 2142 | Property { name: "sum"; type: "double"; isReadonly: true } |
|
2134 | 2143 | Property { name: "holeSize"; type: "double" } |
|
2135 | 2144 | Signal { |
|
2136 | 2145 | name: "added" |
|
2137 | 2146 | Parameter { name: "slices"; type: "QList<QPieSlice*>" } |
|
2138 | 2147 | } |
|
2139 | 2148 | Signal { |
|
2140 | 2149 | name: "removed" |
|
2141 | 2150 | Parameter { name: "slices"; type: "QList<QPieSlice*>" } |
|
2142 | 2151 | } |
|
2143 | 2152 | Signal { |
|
2144 | 2153 | name: "clicked" |
|
2145 | 2154 | Parameter { name: "slice"; type: "QPieSlice"; isPointer: true } |
|
2146 | 2155 | } |
|
2147 | 2156 | Signal { |
|
2148 | 2157 | name: "hovered" |
|
2149 | 2158 | Parameter { name: "slice"; type: "QPieSlice"; isPointer: true } |
|
2150 | 2159 | Parameter { name: "state"; type: "bool" } |
|
2151 | 2160 | } |
|
2152 | 2161 | Signal { |
|
2153 | 2162 | name: "pressed" |
|
2154 | 2163 | Parameter { name: "slice"; type: "QPieSlice"; isPointer: true } |
|
2155 | 2164 | } |
|
2156 | 2165 | Signal { |
|
2157 | 2166 | name: "released" |
|
2158 | 2167 | Parameter { name: "slice"; type: "QPieSlice"; isPointer: true } |
|
2159 | 2168 | } |
|
2160 | 2169 | Signal { |
|
2161 | 2170 | name: "doubleClicked" |
|
2162 | 2171 | Parameter { name: "slice"; type: "QPieSlice"; isPointer: true } |
|
2163 | 2172 | } |
|
2164 | 2173 | } |
|
2165 | 2174 | Component { |
|
2166 | 2175 | name: "QtCharts::QPieSlice" |
|
2167 | 2176 | prototype: "QObject" |
|
2168 | 2177 | exports: ["QtCharts/PieSlice 1.0", "QtCharts/PieSlice 2.0"] |
|
2169 | 2178 | exportMetaObjectRevisions: [0, 0] |
|
2170 | 2179 | Enum { |
|
2171 | 2180 | name: "LabelPosition" |
|
2172 | 2181 | values: { |
|
2173 | 2182 | "LabelOutside": 0, |
|
2174 | 2183 | "LabelInsideHorizontal": 1, |
|
2175 | 2184 | "LabelInsideTangential": 2, |
|
2176 | 2185 | "LabelInsideNormal": 3 |
|
2177 | 2186 | } |
|
2178 | 2187 | } |
|
2179 | 2188 | Property { name: "label"; type: "string" } |
|
2180 | 2189 | Property { name: "value"; type: "double" } |
|
2181 | 2190 | Property { name: "labelVisible"; type: "bool" } |
|
2182 | 2191 | Property { name: "labelPosition"; type: "LabelPosition" } |
|
2183 | 2192 | Property { name: "exploded"; type: "bool" } |
|
2184 | 2193 | Property { name: "pen"; type: "QPen" } |
|
2185 | 2194 | Property { name: "borderColor"; type: "QColor" } |
|
2186 | 2195 | Property { name: "borderWidth"; type: "int" } |
|
2187 | 2196 | Property { name: "brush"; type: "QBrush" } |
|
2188 | 2197 | Property { name: "color"; type: "QColor" } |
|
2189 | 2198 | Property { name: "labelBrush"; type: "QBrush" } |
|
2190 | 2199 | Property { name: "labelColor"; type: "QColor" } |
|
2191 | 2200 | Property { name: "labelFont"; type: "QFont" } |
|
2192 | 2201 | Property { name: "labelArmLengthFactor"; type: "double" } |
|
2193 | 2202 | Property { name: "explodeDistanceFactor"; type: "double" } |
|
2194 | 2203 | Property { name: "percentage"; type: "double"; isReadonly: true } |
|
2195 | 2204 | Property { name: "startAngle"; type: "double"; isReadonly: true } |
|
2196 | 2205 | Property { name: "angleSpan"; type: "double"; isReadonly: true } |
|
2197 | 2206 | Signal { name: "clicked" } |
|
2198 | 2207 | Signal { |
|
2199 | 2208 | name: "hovered" |
|
2200 | 2209 | Parameter { name: "state"; type: "bool" } |
|
2201 | 2210 | } |
|
2202 | 2211 | Signal { name: "pressed" } |
|
2203 | 2212 | Signal { name: "released" } |
|
2204 | 2213 | Signal { name: "doubleClicked" } |
|
2205 | 2214 | } |
|
2206 | 2215 | Component { |
|
2207 | 2216 | name: "QtCharts::QScatterSeries" |
|
2208 | 2217 | prototype: "QtCharts::QXYSeries" |
|
2209 | 2218 | Enum { |
|
2210 | 2219 | name: "MarkerShape" |
|
2211 | 2220 | values: { |
|
2212 | 2221 | "MarkerShapeCircle": 0, |
|
2213 | 2222 | "MarkerShapeRectangle": 1 |
|
2214 | 2223 | } |
|
2215 | 2224 | } |
|
2216 | 2225 | Property { name: "color"; type: "QColor" } |
|
2217 | 2226 | Property { name: "borderColor"; type: "QColor" } |
|
2218 | 2227 | Property { name: "markerShape"; type: "MarkerShape" } |
|
2219 | 2228 | Property { name: "markerSize"; type: "double" } |
|
2220 | 2229 | Property { name: "brush"; type: "QBrush" } |
|
2221 | 2230 | Signal { |
|
2222 | 2231 | name: "colorChanged" |
|
2223 | 2232 | Parameter { name: "color"; type: "QColor" } |
|
2224 | 2233 | } |
|
2225 | 2234 | Signal { |
|
2226 | 2235 | name: "borderColorChanged" |
|
2227 | 2236 | Parameter { name: "color"; type: "QColor" } |
|
2228 | 2237 | } |
|
2229 | 2238 | } |
|
2230 | 2239 | Component { name: "QtCharts::QSplineSeries"; prototype: "QtCharts::QLineSeries" } |
|
2231 | 2240 | Component { name: "QtCharts::QStackedBarSeries"; prototype: "QtCharts::QAbstractBarSeries" } |
|
2232 | 2241 | Component { |
|
2233 | 2242 | name: "QtCharts::QVBarModelMapper" |
|
2234 | 2243 | prototype: "QtCharts::QBarModelMapper" |
|
2235 | 2244 | exports: [ |
|
2236 | 2245 | "QtCharts/VBarModelMapper 1.0", |
|
2237 | 2246 | "QtCharts/VBarModelMapper 2.0" |
|
2238 | 2247 | ] |
|
2239 | 2248 | exportMetaObjectRevisions: [0, 0] |
|
2240 | 2249 | Property { name: "series"; type: "QAbstractBarSeries"; isPointer: true } |
|
2241 | 2250 | Property { name: "model"; type: "QAbstractItemModel"; isPointer: true } |
|
2242 | 2251 | Property { name: "firstBarSetColumn"; type: "int" } |
|
2243 | 2252 | Property { name: "lastBarSetColumn"; type: "int" } |
|
2244 | 2253 | Property { name: "firstRow"; type: "int" } |
|
2245 | 2254 | Property { name: "rowCount"; type: "int" } |
|
2246 | 2255 | Signal { name: "seriesReplaced" } |
|
2247 | 2256 | Signal { name: "modelReplaced" } |
|
2248 | 2257 | } |
|
2249 | 2258 | Component { |
|
2250 | 2259 | name: "QtCharts::QVBoxPlotModelMapper" |
|
2251 | 2260 | prototype: "QtCharts::QBoxPlotModelMapper" |
|
2252 | 2261 | exports: ["QtCharts/VBoxPlotModelMapper 2.0"] |
|
2253 | 2262 | exportMetaObjectRevisions: [0] |
|
2254 | 2263 | Property { name: "series"; type: "QBoxPlotSeries"; isPointer: true } |
|
2255 | 2264 | Property { name: "model"; type: "QAbstractItemModel"; isPointer: true } |
|
2256 | 2265 | Property { name: "firstBoxSetColumn"; type: "int" } |
|
2257 | 2266 | Property { name: "lastBoxSetColumn"; type: "int" } |
|
2258 | 2267 | Property { name: "firstRow"; type: "int" } |
|
2259 | 2268 | Property { name: "rowCount"; type: "int" } |
|
2260 | 2269 | Signal { name: "seriesReplaced" } |
|
2261 | 2270 | Signal { name: "modelReplaced" } |
|
2262 | 2271 | } |
|
2263 | 2272 | Component { |
|
2264 | 2273 | name: "QtCharts::QVPieModelMapper" |
|
2265 | 2274 | prototype: "QtCharts::QPieModelMapper" |
|
2266 | 2275 | exports: [ |
|
2267 | 2276 | "QtCharts/VPieModelMapper 1.0", |
|
2268 | 2277 | "QtCharts/VPieModelMapper 2.0" |
|
2269 | 2278 | ] |
|
2270 | 2279 | exportMetaObjectRevisions: [0, 0] |
|
2271 | 2280 | Property { name: "series"; type: "QPieSeries"; isPointer: true } |
|
2272 | 2281 | Property { name: "model"; type: "QAbstractItemModel"; isPointer: true } |
|
2273 | 2282 | Property { name: "valuesColumn"; type: "int" } |
|
2274 | 2283 | Property { name: "labelsColumn"; type: "int" } |
|
2275 | 2284 | Property { name: "firstRow"; type: "int" } |
|
2276 | 2285 | Property { name: "rowCount"; type: "int" } |
|
2277 | 2286 | Signal { name: "seriesReplaced" } |
|
2278 | 2287 | Signal { name: "modelReplaced" } |
|
2279 | 2288 | } |
|
2280 | 2289 | Component { |
|
2281 | 2290 | name: "QtCharts::QVXYModelMapper" |
|
2282 | 2291 | prototype: "QtCharts::QXYModelMapper" |
|
2283 | 2292 | exports: [ |
|
2284 | 2293 | "QtCharts/VXYModelMapper 1.0", |
|
2285 | 2294 | "QtCharts/VXYModelMapper 2.0" |
|
2286 | 2295 | ] |
|
2287 | 2296 | exportMetaObjectRevisions: [0, 0] |
|
2288 | 2297 | Property { name: "series"; type: "QXYSeries"; isPointer: true } |
|
2289 | 2298 | Property { name: "model"; type: "QAbstractItemModel"; isPointer: true } |
|
2290 | 2299 | Property { name: "xColumn"; type: "int" } |
|
2291 | 2300 | Property { name: "yColumn"; type: "int" } |
|
2292 | 2301 | Property { name: "firstRow"; type: "int" } |
|
2293 | 2302 | Property { name: "rowCount"; type: "int" } |
|
2294 | 2303 | Signal { name: "seriesReplaced" } |
|
2295 | 2304 | Signal { name: "modelReplaced" } |
|
2296 | 2305 | } |
|
2297 | 2306 | Component { |
|
2298 | 2307 | name: "QtCharts::QValueAxis" |
|
2299 | 2308 | prototype: "QtCharts::QAbstractAxis" |
|
2300 | 2309 | exports: [ |
|
2301 | 2310 | "QtCharts/ValueAxis 1.1", |
|
2302 | 2311 | "QtCharts/ValueAxis 2.0", |
|
2303 | 2312 | "QtCharts/ValuesAxis 1.0" |
|
2304 | 2313 | ] |
|
2305 | 2314 | exportMetaObjectRevisions: [0, 0, 0] |
|
2306 | 2315 | Property { name: "tickCount"; type: "int" } |
|
2307 | 2316 | Property { name: "min"; type: "double" } |
|
2308 | 2317 | Property { name: "max"; type: "double" } |
|
2309 | 2318 | Property { name: "labelFormat"; type: "string" } |
|
2310 | 2319 | Signal { |
|
2311 | 2320 | name: "minChanged" |
|
2312 | 2321 | Parameter { name: "min"; type: "double" } |
|
2313 | 2322 | } |
|
2314 | 2323 | Signal { |
|
2315 | 2324 | name: "maxChanged" |
|
2316 | 2325 | Parameter { name: "max"; type: "double" } |
|
2317 | 2326 | } |
|
2318 | 2327 | Signal { |
|
2319 | 2328 | name: "rangeChanged" |
|
2320 | 2329 | Parameter { name: "min"; type: "double" } |
|
2321 | 2330 | Parameter { name: "max"; type: "double" } |
|
2322 | 2331 | } |
|
2323 | 2332 | Signal { |
|
2324 | 2333 | name: "tickCountChanged" |
|
2325 | 2334 | Parameter { name: "tickCount"; type: "int" } |
|
2326 | 2335 | } |
|
2327 | 2336 | Signal { |
|
2328 | 2337 | name: "labelFormatChanged" |
|
2329 | 2338 | Parameter { name: "format"; type: "string" } |
|
2330 | 2339 | } |
|
2331 | 2340 | Method { name: "applyNiceNumbers" } |
|
2332 | 2341 | } |
|
2333 | 2342 | Component { |
|
2334 | 2343 | name: "QtCharts::QXYModelMapper" |
|
2335 | 2344 | prototype: "QObject" |
|
2336 | 2345 | exports: ["QtCharts/XYModelMapper 1.0", "QtCharts/XYModelMapper 2.0"] |
|
2337 | 2346 | isCreatable: false |
|
2338 | 2347 | exportMetaObjectRevisions: [0, 0] |
|
2339 | 2348 | } |
|
2340 | 2349 | Component { |
|
2341 | 2350 | name: "QtCharts::QXYSeries" |
|
2342 | 2351 | prototype: "QtCharts::QAbstractSeries" |
|
2343 | 2352 | exports: ["QtCharts/XYSeries 1.0", "QtCharts/XYSeries 2.0"] |
|
2344 | 2353 | isCreatable: false |
|
2345 | 2354 | exportMetaObjectRevisions: [0, 0] |
|
2346 | 2355 | Property { name: "pointsVisible"; type: "bool" } |
|
2347 | 2356 | Property { name: "color"; type: "QColor" } |
|
2348 | 2357 | Property { name: "pointLabelsFormat"; type: "string" } |
|
2349 | 2358 | Property { name: "pointLabelsVisible"; type: "bool" } |
|
2350 | 2359 | Property { name: "pointLabelsFont"; type: "QFont" } |
|
2351 | 2360 | Property { name: "pointLabelsColor"; type: "QColor" } |
|
2352 | 2361 | Signal { |
|
2353 | 2362 | name: "clicked" |
|
2354 | 2363 | Parameter { name: "point"; type: "QPointF" } |
|
2355 | 2364 | } |
|
2356 | 2365 | Signal { |
|
2357 | 2366 | name: "hovered" |
|
2358 | 2367 | Parameter { name: "point"; type: "QPointF" } |
|
2359 | 2368 | Parameter { name: "state"; type: "bool" } |
|
2360 | 2369 | } |
|
2361 | 2370 | Signal { |
|
2362 | 2371 | name: "pressed" |
|
2363 | 2372 | Parameter { name: "point"; type: "QPointF" } |
|
2364 | 2373 | } |
|
2365 | 2374 | Signal { |
|
2366 | 2375 | name: "released" |
|
2367 | 2376 | Parameter { name: "point"; type: "QPointF" } |
|
2368 | 2377 | } |
|
2369 | 2378 | Signal { |
|
2370 | 2379 | name: "doubleClicked" |
|
2371 | 2380 | Parameter { name: "point"; type: "QPointF" } |
|
2372 | 2381 | } |
|
2373 | 2382 | Signal { |
|
2374 | 2383 | name: "pointReplaced" |
|
2375 | 2384 | Parameter { name: "index"; type: "int" } |
|
2376 | 2385 | } |
|
2377 | 2386 | Signal { |
|
2378 | 2387 | name: "pointRemoved" |
|
2379 | 2388 | Parameter { name: "index"; type: "int" } |
|
2380 | 2389 | } |
|
2381 | 2390 | Signal { |
|
2382 | 2391 | name: "pointAdded" |
|
2383 | 2392 | Parameter { name: "index"; type: "int" } |
|
2384 | 2393 | } |
|
2385 | 2394 | Signal { |
|
2386 | 2395 | name: "colorChanged" |
|
2387 | 2396 | Parameter { name: "color"; type: "QColor" } |
|
2388 | 2397 | } |
|
2389 | 2398 | Signal { name: "pointsReplaced" } |
|
2390 | 2399 | Signal { |
|
2391 | 2400 | name: "pointLabelsFormatChanged" |
|
2392 | 2401 | Parameter { name: "format"; type: "string" } |
|
2393 | 2402 | } |
|
2394 | 2403 | Signal { |
|
2395 | 2404 | name: "pointLabelsVisibilityChanged" |
|
2396 | 2405 | Parameter { name: "visible"; type: "bool" } |
|
2397 | 2406 | } |
|
2398 | 2407 | Signal { |
|
2399 | 2408 | name: "pointLabelsFontChanged" |
|
2400 | 2409 | Parameter { name: "font"; type: "QFont" } |
|
2401 | 2410 | } |
|
2402 | 2411 | Signal { |
|
2403 | 2412 | name: "pointLabelsColorChanged" |
|
2404 | 2413 | Parameter { name: "color"; type: "QColor" } |
|
2405 | 2414 | } |
|
2406 | 2415 | } |
|
2407 | 2416 | } |
@@ -1,318 +1,337 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #include "../qabstractaxis/tst_qabstractaxis.h" |
|
20 | 20 | #include <QtCharts/QCategoryAxis> |
|
21 | 21 | #include <QtCharts/QLineSeries> |
|
22 | 22 | |
|
23 | 23 | class tst_QCategoryAxis: public tst_QAbstractAxis |
|
24 | 24 | { |
|
25 | 25 | Q_OBJECT |
|
26 | 26 | |
|
27 | 27 | public slots: |
|
28 | 28 | void initTestCase(); |
|
29 | 29 | void cleanupTestCase(); |
|
30 | 30 | void init(); |
|
31 | 31 | void cleanup(); |
|
32 | 32 | |
|
33 | 33 | private slots: |
|
34 | 34 | void qcategoryaxis_data(); |
|
35 | 35 | void qcategoryaxis(); |
|
36 | 36 | |
|
37 | 37 | void max_raw_data(); |
|
38 | 38 | void max_raw(); |
|
39 | 39 | void max_data(); |
|
40 | 40 | void max(); |
|
41 | 41 | void max_animation_data(); |
|
42 | 42 | void max_animation(); |
|
43 | 43 | void min_raw_data(); |
|
44 | 44 | void min_raw(); |
|
45 | 45 | void min_data(); |
|
46 | 46 | void min(); |
|
47 | 47 | void min_animation_data(); |
|
48 | 48 | void min_animation(); |
|
49 | 49 | void range_raw_data(); |
|
50 | 50 | void range_raw(); |
|
51 | 51 | void range_data(); |
|
52 | 52 | void range(); |
|
53 | 53 | void range_animation_data(); |
|
54 | 54 | void range_animation(); |
|
55 | 55 | void labels_position(); |
|
56 | 56 | |
|
57 | 57 | void interval_data(); |
|
58 | 58 | void interval(); |
|
59 | void reverse(); | |
|
59 | 60 | |
|
60 | 61 | private: |
|
61 | 62 | QCategoryAxis* m_categoryaxis; |
|
62 | 63 | QLineSeries* m_series; |
|
63 | 64 | }; |
|
64 | 65 | |
|
65 | 66 | void tst_QCategoryAxis::initTestCase() |
|
66 | 67 | { |
|
67 | 68 | qRegisterMetaType<QCategoryAxis::AxisLabelsPosition>("QCategoryAxis::AxisLabelsPosition"); |
|
68 | 69 | } |
|
69 | 70 | |
|
70 | 71 | void tst_QCategoryAxis::cleanupTestCase() |
|
71 | 72 | { |
|
72 | 73 | QTest::qWait(1); // Allow final deleteLaters to run |
|
73 | 74 | } |
|
74 | 75 | |
|
75 | 76 | void tst_QCategoryAxis::init() |
|
76 | 77 | { |
|
77 | 78 | m_categoryaxis = new QCategoryAxis(); |
|
78 | 79 | m_series = new QLineSeries(); |
|
79 | 80 | *m_series << QPointF(-100, -100) << QPointF(0, 0) << QPointF(100, 100); |
|
80 | 81 | tst_QAbstractAxis::init(m_categoryaxis, m_series); |
|
81 | 82 | m_chart->addSeries(m_series); |
|
82 | 83 | m_chart->createDefaultAxes(); |
|
83 | 84 | } |
|
84 | 85 | |
|
85 | 86 | void tst_QCategoryAxis::cleanup() |
|
86 | 87 | { |
|
87 | 88 | delete m_series; |
|
88 | 89 | delete m_categoryaxis; |
|
89 | 90 | m_series = 0; |
|
90 | 91 | m_categoryaxis = 0; |
|
91 | 92 | tst_QAbstractAxis::cleanup(); |
|
92 | 93 | } |
|
93 | 94 | |
|
94 | 95 | void tst_QCategoryAxis::qcategoryaxis_data() |
|
95 | 96 | { |
|
96 | 97 | } |
|
97 | 98 | |
|
98 | 99 | void tst_QCategoryAxis::qcategoryaxis() |
|
99 | 100 | { |
|
100 | 101 | qabstractaxis(); |
|
101 | 102 | |
|
102 | 103 | QVERIFY(qFuzzyCompare(m_categoryaxis->max(), 0)); |
|
103 | 104 | QVERIFY(qFuzzyCompare(m_categoryaxis->min(), 0)); |
|
104 | 105 | QCOMPARE(m_categoryaxis->type(), QAbstractAxis::AxisTypeCategory); |
|
105 | 106 | QCOMPARE(m_categoryaxis->labelsPosition(), QCategoryAxis::AxisLabelsPositionCenter); |
|
106 | 107 | |
|
107 | 108 | m_chart->setAxisX(m_categoryaxis, m_series); |
|
108 | 109 | m_view->show(); |
|
109 | 110 | QTest::qWaitForWindowShown(m_view); |
|
110 | 111 | |
|
111 | 112 | QVERIFY(!qFuzzyCompare(m_categoryaxis->max(), 0)); |
|
112 | 113 | QVERIFY(!qFuzzyCompare(m_categoryaxis->min(), 0)); |
|
114 | ||
|
115 | QCOMPARE(m_categoryaxis->isReverse(), false); | |
|
113 | 116 | } |
|
114 | 117 | |
|
115 | 118 | void tst_QCategoryAxis::max_raw_data() |
|
116 | 119 | { |
|
117 | 120 | QTest::addColumn<qreal>("max"); |
|
118 | 121 | QTest::newRow("1.0") << (qreal)1.0; |
|
119 | 122 | QTest::newRow("50.0") << (qreal)50.0; |
|
120 | 123 | QTest::newRow("101.0") << (qreal)101.0; |
|
121 | 124 | } |
|
122 | 125 | |
|
123 | 126 | void tst_QCategoryAxis::max_raw() |
|
124 | 127 | { |
|
125 | 128 | QFETCH(qreal, max); |
|
126 | 129 | |
|
127 | 130 | QSignalSpy spy0(m_categoryaxis, SIGNAL(maxChanged(qreal))); |
|
128 | 131 | QSignalSpy spy1(m_categoryaxis, SIGNAL(minChanged(qreal))); |
|
129 | 132 | QSignalSpy spy2(m_categoryaxis, SIGNAL(rangeChanged(qreal,qreal))); |
|
130 | 133 | |
|
131 | 134 | m_categoryaxis->setMax(max); |
|
132 | 135 | QVERIFY2(qFuzzyCompare(m_categoryaxis->max(), max), "Not equal"); |
|
133 | 136 | |
|
134 | 137 | QCOMPARE(spy0.count(), 1); |
|
135 | 138 | QCOMPARE(spy1.count(), 0); |
|
136 | 139 | QCOMPARE(spy2.count(), 1); |
|
137 | 140 | } |
|
138 | 141 | |
|
139 | 142 | void tst_QCategoryAxis::max_data() |
|
140 | 143 | { |
|
141 | 144 | max_raw_data(); |
|
142 | 145 | } |
|
143 | 146 | |
|
144 | 147 | void tst_QCategoryAxis::max() |
|
145 | 148 | { |
|
146 | 149 | m_chart->setAxisX(m_categoryaxis, m_series); |
|
147 | 150 | m_view->show(); |
|
148 | 151 | QTest::qWaitForWindowShown(m_view); |
|
149 | 152 | max_raw(); |
|
150 | 153 | } |
|
151 | 154 | |
|
152 | 155 | void tst_QCategoryAxis::max_animation_data() |
|
153 | 156 | { |
|
154 | 157 | max_data(); |
|
155 | 158 | } |
|
156 | 159 | |
|
157 | 160 | void tst_QCategoryAxis::max_animation() |
|
158 | 161 | { |
|
159 | 162 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); |
|
160 | 163 | max(); |
|
161 | 164 | } |
|
162 | 165 | |
|
163 | 166 | void tst_QCategoryAxis::min_raw_data() |
|
164 | 167 | { |
|
165 | 168 | QTest::addColumn<qreal>("min"); |
|
166 | 169 | QTest::newRow("-1.0") << (qreal)-1.0; |
|
167 | 170 | QTest::newRow("-50.0") << (qreal)-50.0; |
|
168 | 171 | QTest::newRow("-101.0") << (qreal)-101.0; |
|
169 | 172 | } |
|
170 | 173 | |
|
171 | 174 | void tst_QCategoryAxis::min_raw() |
|
172 | 175 | { |
|
173 | 176 | QFETCH(qreal, min); |
|
174 | 177 | |
|
175 | 178 | QSignalSpy spy0(m_categoryaxis, SIGNAL(maxChanged(qreal))); |
|
176 | 179 | QSignalSpy spy1(m_categoryaxis, SIGNAL(minChanged(qreal))); |
|
177 | 180 | QSignalSpy spy2(m_categoryaxis, SIGNAL(rangeChanged(qreal,qreal))); |
|
178 | 181 | |
|
179 | 182 | m_categoryaxis->setMin(min); |
|
180 | 183 | QVERIFY2(qFuzzyCompare(m_categoryaxis->min(), min), "Not equal"); |
|
181 | 184 | |
|
182 | 185 | QCOMPARE(spy0.count(), 0); |
|
183 | 186 | QCOMPARE(spy1.count(), 1); |
|
184 | 187 | QCOMPARE(spy2.count(), 1); |
|
185 | 188 | } |
|
186 | 189 | |
|
187 | 190 | void tst_QCategoryAxis::min_data() |
|
188 | 191 | { |
|
189 | 192 | min_raw_data(); |
|
190 | 193 | } |
|
191 | 194 | |
|
192 | 195 | void tst_QCategoryAxis::min() |
|
193 | 196 | { |
|
194 | 197 | m_chart->setAxisX(m_categoryaxis, m_series); |
|
195 | 198 | m_view->show(); |
|
196 | 199 | QTest::qWaitForWindowShown(m_view); |
|
197 | 200 | min_raw(); |
|
198 | 201 | } |
|
199 | 202 | |
|
200 | 203 | void tst_QCategoryAxis::min_animation_data() |
|
201 | 204 | { |
|
202 | 205 | min_data(); |
|
203 | 206 | } |
|
204 | 207 | |
|
205 | 208 | void tst_QCategoryAxis::min_animation() |
|
206 | 209 | { |
|
207 | 210 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); |
|
208 | 211 | min(); |
|
209 | 212 | } |
|
210 | 213 | |
|
211 | 214 | void tst_QCategoryAxis::range_raw_data() |
|
212 | 215 | { |
|
213 | 216 | QTest::addColumn<qreal>("min"); |
|
214 | 217 | QTest::addColumn<qreal>("max"); |
|
215 | 218 | QTest::newRow("1.0 - 101.0") << (qreal)-1.0 << (qreal)101.0; |
|
216 | 219 | QTest::newRow("25.0 - 75.0") << (qreal)25.0 << (qreal)75.0; |
|
217 | 220 | QTest::newRow("101.0") << (qreal)40.0 << (qreal)60.0; |
|
218 | 221 | QTest::newRow("-35.0 - 0.0") << (qreal)-35.0 << (qreal)10.0; |
|
219 | 222 | QTest::newRow("-35.0 - 0.0") << (qreal)-35.0 << (qreal)-15.0; |
|
220 | 223 | QTest::newRow("0.0 - 0.0") << (qreal)-0.1 << (qreal)0.1; |
|
221 | 224 | } |
|
222 | 225 | |
|
223 | 226 | void tst_QCategoryAxis::range_raw() |
|
224 | 227 | { |
|
225 | 228 | QFETCH(qreal, min); |
|
226 | 229 | QFETCH(qreal, max); |
|
227 | 230 | |
|
228 | 231 | QSignalSpy spy0(m_categoryaxis, SIGNAL(maxChanged(qreal))); |
|
229 | 232 | QSignalSpy spy1(m_categoryaxis, SIGNAL(minChanged(qreal))); |
|
230 | 233 | QSignalSpy spy2(m_categoryaxis, SIGNAL(rangeChanged(qreal,qreal))); |
|
231 | 234 | |
|
232 | 235 | m_categoryaxis->setRange(min, max); |
|
233 | 236 | QVERIFY2(qFuzzyCompare(m_categoryaxis->min(), min), "Min not equal"); |
|
234 | 237 | QVERIFY2(qFuzzyCompare(m_categoryaxis->max(), max), "Max not equal"); |
|
235 | 238 | |
|
236 | 239 | QCOMPARE(spy0.count(), 1); |
|
237 | 240 | QCOMPARE(spy1.count(), 1); |
|
238 | 241 | QCOMPARE(spy2.count(), 1); |
|
239 | 242 | } |
|
240 | 243 | |
|
241 | 244 | void tst_QCategoryAxis::range_data() |
|
242 | 245 | { |
|
243 | 246 | range_raw_data(); |
|
244 | 247 | } |
|
245 | 248 | |
|
246 | 249 | void tst_QCategoryAxis::range() |
|
247 | 250 | { |
|
248 | 251 | m_chart->setAxisX(m_categoryaxis, m_series); |
|
249 | 252 | m_view->show(); |
|
250 | 253 | QTest::qWaitForWindowShown(m_view); |
|
251 | 254 | range_raw(); |
|
252 | 255 | } |
|
253 | 256 | |
|
254 | 257 | void tst_QCategoryAxis::range_animation_data() |
|
255 | 258 | { |
|
256 | 259 | range_data(); |
|
257 | 260 | } |
|
258 | 261 | |
|
259 | 262 | void tst_QCategoryAxis::range_animation() |
|
260 | 263 | { |
|
261 | 264 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); |
|
262 | 265 | range(); |
|
263 | 266 | } |
|
264 | 267 | |
|
265 | 268 | void tst_QCategoryAxis::interval_data() |
|
266 | 269 | { |
|
267 | 270 | // |
|
268 | 271 | } |
|
269 | 272 | |
|
270 | 273 | void tst_QCategoryAxis::interval() |
|
271 | 274 | { |
|
272 | 275 | // append one correct interval |
|
273 | 276 | m_categoryaxis->append("first", (qreal)45); |
|
274 | 277 | QCOMPARE(m_categoryaxis->startValue("first"), (qreal)0); |
|
275 | 278 | QCOMPARE(m_categoryaxis->endValue("first"), (qreal)45); |
|
276 | 279 | |
|
277 | 280 | // append one more correct interval |
|
278 | 281 | m_categoryaxis->append("second", (qreal)75); |
|
279 | 282 | QCOMPARE(m_categoryaxis->startValue("second"), (qreal)45); |
|
280 | 283 | QCOMPARE(m_categoryaxis->endValue("second"), (qreal)75); |
|
281 | 284 | |
|
282 | 285 | // append one incorrect interval |
|
283 | 286 | m_categoryaxis->append("third", (qreal)15); |
|
284 | 287 | QCOMPARE(m_categoryaxis->count(), 2); |
|
285 | 288 | QCOMPARE(m_categoryaxis->endValue(m_categoryaxis->categoriesLabels().last()), (qreal)75); |
|
286 | 289 | // QCOMPARE(intervalMax("first"), (qreal)75); |
|
287 | 290 | |
|
288 | 291 | // append one more correct interval |
|
289 | 292 | m_categoryaxis->append("third", (qreal)100); |
|
290 | 293 | QCOMPARE(m_categoryaxis->count(), 3); |
|
291 | 294 | QCOMPARE(m_categoryaxis->startValue("third"), (qreal)75); |
|
292 | 295 | QCOMPARE(m_categoryaxis->endValue("third"), (qreal)100); |
|
293 | 296 | |
|
294 | 297 | // remove one interval |
|
295 | 298 | m_categoryaxis->remove("first"); |
|
296 | 299 | QCOMPARE(m_categoryaxis->count(), 2); |
|
297 | 300 | QCOMPARE(m_categoryaxis->startValue("second"), (qreal)0); // second interval should extend to firstInterval minimum |
|
298 | 301 | QCOMPARE(m_categoryaxis->endValue("second"), (qreal)75); |
|
299 | 302 | |
|
300 | 303 | // remove one interval |
|
301 | 304 | m_categoryaxis->replaceLabel("second", "replaced"); |
|
302 | 305 | QCOMPARE(m_categoryaxis->count(), 2); |
|
303 | 306 | QCOMPARE(m_categoryaxis->startValue("replaced"), (qreal)0); // second interval should extend to firstInterval minimum |
|
304 | 307 | QCOMPARE(m_categoryaxis->endValue("replaced"), (qreal)75); |
|
305 | 308 | } |
|
306 | 309 | |
|
307 | 310 | void tst_QCategoryAxis::labels_position() |
|
308 | 311 | { |
|
309 | 312 | QSignalSpy spy(m_categoryaxis, |
|
310 | 313 | SIGNAL(labelsPositionChanged(QCategoryAxis::AxisLabelsPosition))); |
|
311 | 314 | m_categoryaxis->setLabelsPosition(QCategoryAxis::AxisLabelsPositionOnValue); |
|
312 | 315 | QCOMPARE(m_categoryaxis->labelsPosition(), QCategoryAxis::AxisLabelsPositionOnValue); |
|
313 | 316 | QCOMPARE(spy.count(), 1); |
|
314 | 317 | } |
|
315 | 318 | |
|
319 | void tst_QCategoryAxis::reverse() | |
|
320 | { | |
|
321 | QSignalSpy spy(m_categoryaxis, SIGNAL(reverseChanged(bool))); | |
|
322 | QCOMPARE(m_categoryaxis->isReverse(), false); | |
|
323 | ||
|
324 | m_categoryaxis->setReverse(); | |
|
325 | QCOMPARE(m_categoryaxis->isReverse(), true); | |
|
326 | ||
|
327 | m_chart->setAxisX(m_categoryaxis, m_series); | |
|
328 | QCOMPARE(spy.count(), 1); | |
|
329 | ||
|
330 | m_view->show(); | |
|
331 | QTest::qWaitForWindowShown(m_view); | |
|
332 | QCOMPARE(m_categoryaxis->isReverse(), true); | |
|
333 | } | |
|
334 | ||
|
316 | 335 | QTEST_MAIN(tst_QCategoryAxis) |
|
317 | 336 | #include "tst_qcategoryaxis.moc" |
|
318 | 337 |
@@ -1,312 +1,330 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #include "../qabstractaxis/tst_qabstractaxis.h" |
|
20 | 20 | #include <QtCharts/QDateTimeAxis> |
|
21 | 21 | #include <QtCharts/QLineSeries> |
|
22 | 22 | |
|
23 | 23 | class tst_QDateTimeAxis : public QObject//: public tst_QAbstractAxis |
|
24 | 24 | { |
|
25 | 25 | Q_OBJECT |
|
26 | 26 | |
|
27 | 27 | public slots: |
|
28 | 28 | void initTestCase(); |
|
29 | 29 | void cleanupTestCase(); |
|
30 | 30 | void init(); |
|
31 | 31 | void cleanup(); |
|
32 | 32 | |
|
33 | 33 | private slots: |
|
34 | 34 | void qdatetimeaxis_data(); |
|
35 | 35 | void qdatetimeaxis(); |
|
36 | 36 | |
|
37 | 37 | void max_raw_data(); |
|
38 | 38 | void max_raw(); |
|
39 | 39 | void max_data(); |
|
40 | 40 | void max(); |
|
41 | 41 | void max_animation_data(); |
|
42 | 42 | void max_animation(); |
|
43 | 43 | void min_raw_data(); |
|
44 | 44 | void min_raw(); |
|
45 | 45 | void min_data(); |
|
46 | 46 | void min(); |
|
47 | 47 | void min_animation_data(); |
|
48 | 48 | void min_animation(); |
|
49 | 49 | void range_raw_data(); |
|
50 | 50 | void range_raw(); |
|
51 | 51 | void range_data(); |
|
52 | 52 | void range(); |
|
53 | 53 | void range_animation_data(); |
|
54 | 54 | void range_animation(); |
|
55 | void reverse(); | |
|
55 | 56 | |
|
56 | 57 | private: |
|
57 | 58 | QDateTimeAxis *m_dateTimeAxisX; |
|
58 | 59 | QDateTimeAxis *m_dateTimeAxisY; |
|
59 | 60 | QLineSeries* m_series; |
|
60 | 61 | QChartView* m_view; |
|
61 | 62 | QChart* m_chart; |
|
62 | 63 | }; |
|
63 | 64 | |
|
64 | 65 | void tst_QDateTimeAxis::initTestCase() |
|
65 | 66 | { |
|
66 | 67 | } |
|
67 | 68 | |
|
68 | 69 | void tst_QDateTimeAxis::cleanupTestCase() |
|
69 | 70 | { |
|
70 | 71 | QTest::qWait(1); // Allow final deleteLaters to run |
|
71 | 72 | } |
|
72 | 73 | |
|
73 | 74 | void tst_QDateTimeAxis::init() |
|
74 | 75 | { |
|
75 | 76 | m_dateTimeAxisX = new QDateTimeAxis(); |
|
76 | 77 | m_dateTimeAxisY = new QDateTimeAxis(); |
|
77 | 78 | m_series = new QLineSeries(); |
|
78 | 79 | *m_series << QPointF(-100, -100) << QPointF(0, 0) << QPointF(100, 100); |
|
79 | 80 | // tst_QAbstractAxis::init(m_datetimeaxis, m_series); |
|
80 | 81 | |
|
81 | 82 | m_view = new QChartView; |
|
82 | 83 | m_chart = m_view->chart(); |
|
83 | 84 | m_chart->addSeries(m_series); |
|
84 | 85 | m_chart->setAxisY(m_dateTimeAxisY, m_series); |
|
85 | 86 | m_chart->setAxisX(m_dateTimeAxisX, m_series); |
|
86 | 87 | } |
|
87 | 88 | |
|
88 | 89 | void tst_QDateTimeAxis::cleanup() |
|
89 | 90 | { |
|
90 | 91 | delete m_series; |
|
91 | 92 | delete m_dateTimeAxisX; |
|
92 | 93 | delete m_dateTimeAxisY; |
|
93 | 94 | m_series = 0; |
|
94 | 95 | m_dateTimeAxisX = 0; |
|
95 | 96 | m_dateTimeAxisY = 0; |
|
96 | 97 | delete m_view; |
|
97 | 98 | m_view = 0; |
|
98 | 99 | m_chart = 0; |
|
99 | 100 | // tst_QAbstractAxis::cleanup(); |
|
100 | 101 | } |
|
101 | 102 | |
|
102 | 103 | void tst_QDateTimeAxis::qdatetimeaxis_data() |
|
103 | 104 | { |
|
104 | 105 | } |
|
105 | 106 | |
|
106 | 107 | void tst_QDateTimeAxis::qdatetimeaxis() |
|
107 | 108 | { |
|
108 | 109 | // qabstractaxis(); |
|
109 | 110 | QCOMPARE(m_dateTimeAxisX->type(), QAbstractAxis::AxisTypeDateTime); |
|
110 | 111 | |
|
111 | 112 | m_view->show(); |
|
112 | 113 | QTest::qWaitForWindowShown(m_view); |
|
113 | 114 | |
|
114 | 115 | QVERIFY(m_dateTimeAxisX->max().toMSecsSinceEpoch() != 0); |
|
115 | 116 | QVERIFY(m_dateTimeAxisX->min().toMSecsSinceEpoch() != 0); |
|
117 | ||
|
118 | QCOMPARE(m_dateTimeAxisX->isReverse(), false); | |
|
119 | QCOMPARE(m_dateTimeAxisY->isReverse(), false); | |
|
116 | 120 | } |
|
117 | 121 | |
|
118 | 122 | void tst_QDateTimeAxis::max_raw_data() |
|
119 | 123 | { |
|
120 | 124 | QTest::addColumn<QDateTime>("max"); |
|
121 | 125 | QTest::addColumn<bool>("valid"); |
|
122 | 126 | QDateTime dateTime; |
|
123 | 127 | dateTime.setDate(QDate(2012, 7, 19)); |
|
124 | 128 | QTest::newRow("19.7.2012 - Valid") << dateTime << true; |
|
125 | 129 | dateTime.setDate(QDate(2012, 17, 32)); |
|
126 | 130 | QTest::newRow("32.17.2012 - Invalid") << dateTime << false; |
|
127 | 131 | } |
|
128 | 132 | |
|
129 | 133 | void tst_QDateTimeAxis::max_raw() |
|
130 | 134 | { |
|
131 | 135 | QFETCH(QDateTime, max); |
|
132 | 136 | QFETCH(bool, valid); |
|
133 | 137 | |
|
134 | 138 | QSignalSpy spy0(m_dateTimeAxisX, SIGNAL(maxChanged(QDateTime))); |
|
135 | 139 | QSignalSpy spy1(m_dateTimeAxisX, SIGNAL(minChanged(QDateTime))); |
|
136 | 140 | QSignalSpy spy2(m_dateTimeAxisX, SIGNAL(rangeChanged(QDateTime,QDateTime))); |
|
137 | 141 | |
|
138 | 142 | m_dateTimeAxisX->setMax(max); |
|
139 | 143 | |
|
140 | 144 | if (valid) { |
|
141 | 145 | QVERIFY2(m_dateTimeAxisX->max() == max, "Not equal"); |
|
142 | 146 | QCOMPARE(spy0.count(), 1); |
|
143 | 147 | QCOMPARE(spy1.count(), 0); |
|
144 | 148 | QCOMPARE(spy2.count(), 1); |
|
145 | 149 | } else { |
|
146 | 150 | QVERIFY2(m_dateTimeAxisX->max() != max, "Date is invalid and should not be set"); |
|
147 | 151 | QCOMPARE(spy0.count(), 0); |
|
148 | 152 | QCOMPARE(spy1.count(), 0); |
|
149 | 153 | QCOMPARE(spy2.count(), 0); |
|
150 | 154 | } |
|
151 | 155 | } |
|
152 | 156 | |
|
153 | 157 | void tst_QDateTimeAxis::max_data() |
|
154 | 158 | { |
|
155 | 159 | max_raw_data(); |
|
156 | 160 | } |
|
157 | 161 | |
|
158 | 162 | void tst_QDateTimeAxis::max() |
|
159 | 163 | { |
|
160 | 164 | // m_chart->setAxisX(m_dateTimeAxisX, m_series); |
|
161 | 165 | m_view->show(); |
|
162 | 166 | QTest::qWaitForWindowShown(m_view); |
|
163 | 167 | max_raw(); |
|
164 | 168 | } |
|
165 | 169 | |
|
166 | 170 | void tst_QDateTimeAxis::max_animation_data() |
|
167 | 171 | { |
|
168 | 172 | max_data(); |
|
169 | 173 | } |
|
170 | 174 | |
|
171 | 175 | void tst_QDateTimeAxis::max_animation() |
|
172 | 176 | { |
|
173 | 177 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); |
|
174 | 178 | max(); |
|
175 | 179 | } |
|
176 | 180 | |
|
177 | 181 | void tst_QDateTimeAxis::min_raw_data() |
|
178 | 182 | { |
|
179 | 183 | QTest::addColumn<QDateTime>("min"); |
|
180 | 184 | QTest::addColumn<bool>("valid"); |
|
181 | 185 | QDateTime dateTime; |
|
182 | 186 | dateTime.setDate(QDate(1908, 1, 11)); |
|
183 | 187 | QTest::newRow("11.1.1908 - Valid") << dateTime << true; // negative MSecs from Epoch |
|
184 | 188 | dateTime.setDate(QDate(2012, 17, 32)); |
|
185 | 189 | QTest::newRow("32.17.2012 - Invalid") << dateTime << false; |
|
186 | 190 | } |
|
187 | 191 | |
|
188 | 192 | void tst_QDateTimeAxis::min_raw() |
|
189 | 193 | { |
|
190 | 194 | QFETCH(QDateTime, min); |
|
191 | 195 | QFETCH(bool, valid); |
|
192 | 196 | |
|
193 | 197 | QSignalSpy spy0(m_dateTimeAxisX, SIGNAL(maxChanged(QDateTime))); |
|
194 | 198 | QSignalSpy spy1(m_dateTimeAxisX, SIGNAL(minChanged(QDateTime))); |
|
195 | 199 | QSignalSpy spy2(m_dateTimeAxisX, SIGNAL(rangeChanged(QDateTime,QDateTime))); |
|
196 | 200 | |
|
197 | 201 | m_dateTimeAxisX->setMin(min); |
|
198 | 202 | |
|
199 | 203 | if (valid) { |
|
200 | 204 | QVERIFY2(m_dateTimeAxisX->min() == min, "Not equal"); |
|
201 | 205 | QCOMPARE(spy0.count(), 0); |
|
202 | 206 | QCOMPARE(spy1.count(), 1); |
|
203 | 207 | QCOMPARE(spy2.count(), 1); |
|
204 | 208 | } else { |
|
205 | 209 | QVERIFY2(m_dateTimeAxisX->min() != min, "Date is invalid and should not be set"); |
|
206 | 210 | QCOMPARE(spy0.count(), 0); |
|
207 | 211 | QCOMPARE(spy1.count(), 0); |
|
208 | 212 | QCOMPARE(spy2.count(), 0); |
|
209 | 213 | } |
|
210 | 214 | } |
|
211 | 215 | |
|
212 | 216 | void tst_QDateTimeAxis::min_data() |
|
213 | 217 | { |
|
214 | 218 | min_raw_data(); |
|
215 | 219 | } |
|
216 | 220 | |
|
217 | 221 | void tst_QDateTimeAxis::min() |
|
218 | 222 | { |
|
219 | 223 | // m_chart->setAxisX(m_dateTimeAxisX, m_series); |
|
220 | 224 | m_view->show(); |
|
221 | 225 | QTest::qWaitForWindowShown(m_view); |
|
222 | 226 | min_raw(); |
|
223 | 227 | } |
|
224 | 228 | |
|
225 | 229 | void tst_QDateTimeAxis::min_animation_data() |
|
226 | 230 | { |
|
227 | 231 | min_data(); |
|
228 | 232 | } |
|
229 | 233 | |
|
230 | 234 | void tst_QDateTimeAxis::min_animation() |
|
231 | 235 | { |
|
232 | 236 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); |
|
233 | 237 | min(); |
|
234 | 238 | } |
|
235 | 239 | |
|
236 | 240 | void tst_QDateTimeAxis::range_raw_data() |
|
237 | 241 | { |
|
238 | 242 | QTest::addColumn<QDateTime>("min"); |
|
239 | 243 | QTest::addColumn<bool>("minValid"); |
|
240 | 244 | QTest::addColumn<QDateTime>("max"); |
|
241 | 245 | QTest::addColumn<bool>("maxValid"); |
|
242 | 246 | |
|
243 | 247 | QDateTime minDateTime; |
|
244 | 248 | QDateTime maxDateTime; |
|
245 | 249 | minDateTime.setDate(QDate(1908, 1, 11)); |
|
246 | 250 | maxDateTime.setDate(QDate(1958, 11, 21)); |
|
247 | 251 | QTest::newRow("11.1.1908 - min valid, 21.12.1958 - max valid") << minDateTime << true << maxDateTime << true; // negative MSecs from Epoch, min < max |
|
248 | 252 | |
|
249 | 253 | minDateTime.setDate(QDate(2012, 17, 32)); |
|
250 | 254 | QTest::newRow("32.17.2012 - min invalid, 21.12.1958 - max valid") << minDateTime << false << maxDateTime << true; |
|
251 | 255 | |
|
252 | 256 | maxDateTime.setDate(QDate(2017, 0, 1)); |
|
253 | 257 | QTest::newRow("32.17.2012 - min invalid, 1.0.2017 - max invalid") << minDateTime << false << maxDateTime << false; |
|
254 | 258 | |
|
255 | 259 | minDateTime.setDate(QDate(2012, 1, 1)); |
|
256 | 260 | QTest::newRow("1.1.2012 - min valid, 1.0.2017 - max invalid") << minDateTime << true << maxDateTime << false; |
|
257 | 261 | |
|
258 | 262 | maxDateTime.setDate(QDate(2005, 2, 5)); |
|
259 | 263 | QTest::newRow("1.1.2012 - min valid, 5.2.2005 - max valid") << minDateTime << true << maxDateTime << true; // min > max |
|
260 | 264 | } |
|
261 | 265 | |
|
262 | 266 | void tst_QDateTimeAxis::range_raw() |
|
263 | 267 | { |
|
264 | 268 | QFETCH(QDateTime, min); |
|
265 | 269 | QFETCH(bool, minValid); |
|
266 | 270 | QFETCH(QDateTime, max); |
|
267 | 271 | QFETCH(bool, maxValid); |
|
268 | 272 | |
|
269 | 273 | QSignalSpy spy0(m_dateTimeAxisX, SIGNAL(maxChanged(QDateTime))); |
|
270 | 274 | QSignalSpy spy1(m_dateTimeAxisX, SIGNAL(minChanged(QDateTime))); |
|
271 | 275 | QSignalSpy spy2(m_dateTimeAxisX, SIGNAL(rangeChanged(QDateTime,QDateTime))); |
|
272 | 276 | |
|
273 | 277 | m_dateTimeAxisX->setRange(min, max); |
|
274 | 278 | |
|
275 | 279 | if (minValid && maxValid && min < max) { |
|
276 | 280 | QCOMPARE(spy0.count(), 1); |
|
277 | 281 | QCOMPARE(spy1.count(), 1); |
|
278 | 282 | QCOMPARE(spy2.count(), 1); |
|
279 | 283 | } else { |
|
280 | 284 | QCOMPARE(spy0.count(), 0); |
|
281 | 285 | QCOMPARE(spy1.count(), 0); |
|
282 | 286 | QCOMPARE(spy2.count(), 0); |
|
283 | 287 | } |
|
284 | 288 | } |
|
285 | 289 | |
|
286 | 290 | void tst_QDateTimeAxis::range_data() |
|
287 | 291 | { |
|
288 | 292 | range_raw_data(); |
|
289 | 293 | } |
|
290 | 294 | |
|
291 | 295 | void tst_QDateTimeAxis::range() |
|
292 | 296 | { |
|
293 | 297 | // m_chart->setAxisX(m_dateTimeAxisX, m_series); |
|
294 | 298 | m_view->show(); |
|
295 | 299 | QTest::qWaitForWindowShown(m_view); |
|
296 | 300 | range_raw(); |
|
297 | 301 | } |
|
298 | 302 | |
|
299 | 303 | void tst_QDateTimeAxis::range_animation_data() |
|
300 | 304 | { |
|
301 | 305 | range_data(); |
|
302 | 306 | } |
|
303 | 307 | |
|
304 | 308 | void tst_QDateTimeAxis::range_animation() |
|
305 | 309 | { |
|
306 | 310 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); |
|
307 | 311 | range(); |
|
308 | 312 | } |
|
309 | 313 | |
|
314 | void tst_QDateTimeAxis::reverse() | |
|
315 | { | |
|
316 | QSignalSpy spy(m_dateTimeAxisX, SIGNAL(reverseChanged(bool))); | |
|
317 | QCOMPARE(m_dateTimeAxisX->isReverse(), false); | |
|
318 | ||
|
319 | m_dateTimeAxisX->setReverse(); | |
|
320 | QCOMPARE(m_dateTimeAxisX->isReverse(), true); | |
|
321 | QCOMPARE(spy.count(), 1); | |
|
322 | ||
|
323 | m_view->show(); | |
|
324 | QTest::qWaitForWindowShown(m_view); | |
|
325 | QCOMPARE(m_dateTimeAxisX->isReverse(), true); | |
|
326 | } | |
|
327 | ||
|
310 | 328 | QTEST_MAIN(tst_QDateTimeAxis) |
|
311 | 329 | #include "tst_qdatetimeaxis.moc" |
|
312 | 330 |
@@ -1,386 +1,401 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #include "../qabstractaxis/tst_qabstractaxis.h" |
|
20 | 20 | #include <QtCharts/QLogValueAxis> |
|
21 | 21 | #include <QtCharts/QLineSeries> |
|
22 | 22 | #include <QtCore/QDebug> |
|
23 | 23 | |
|
24 | 24 | class tst_QLogValueAxis: public tst_QAbstractAxis |
|
25 | 25 | { |
|
26 | 26 | Q_OBJECT |
|
27 | 27 | |
|
28 | 28 | public slots: |
|
29 | 29 | void initTestCase(); |
|
30 | 30 | void cleanupTestCase(); |
|
31 | 31 | void init(); |
|
32 | 32 | void cleanup(); |
|
33 | 33 | |
|
34 | 34 | private slots: |
|
35 | 35 | void qlogvalueaxis_data(); |
|
36 | 36 | void qlogvalueaxis(); |
|
37 | 37 | void max_raw_data(); |
|
38 | 38 | void max_raw(); |
|
39 | 39 | void max_data(); |
|
40 | 40 | void max(); |
|
41 | 41 | void max_animation_data(); |
|
42 | 42 | void max_animation(); |
|
43 | 43 | void min_raw_data(); |
|
44 | 44 | void min_raw(); |
|
45 | 45 | void min_data(); |
|
46 | 46 | void min(); |
|
47 | 47 | void min_animation_data(); |
|
48 | 48 | void min_animation(); |
|
49 | 49 | void range_raw_data(); |
|
50 | 50 | void range_raw(); |
|
51 | 51 | void range_data(); |
|
52 | 52 | void range(); |
|
53 | 53 | void range_animation_data(); |
|
54 | 54 | void range_animation(); |
|
55 | 55 | void noautoscale_data(); |
|
56 | 56 | void noautoscale(); |
|
57 | 57 | void autoscale_data(); |
|
58 | 58 | void autoscale(); |
|
59 | 59 | void zoom(); |
|
60 | void reverse(); | |
|
60 | 61 | |
|
61 | 62 | private: |
|
62 | 63 | QLogValueAxis* m_logvaluesaxis; |
|
63 | 64 | QLineSeries* m_series; |
|
64 | 65 | }; |
|
65 | 66 | |
|
66 | 67 | void tst_QLogValueAxis::initTestCase() |
|
67 | 68 | { |
|
68 | 69 | } |
|
69 | 70 | |
|
70 | 71 | void tst_QLogValueAxis::cleanupTestCase() |
|
71 | 72 | { |
|
72 | 73 | QTest::qWait(1); // Allow final deleteLaters to run |
|
73 | 74 | } |
|
74 | 75 | |
|
75 | 76 | void tst_QLogValueAxis::init() |
|
76 | 77 | { |
|
77 | 78 | m_logvaluesaxis = new QLogValueAxis(); |
|
78 | 79 | m_series = new QLineSeries(); |
|
79 | 80 | *m_series << QPointF(1, 1) << QPointF(100, 100); |
|
80 | 81 | tst_QAbstractAxis::init(m_logvaluesaxis,m_series); |
|
81 | 82 | m_chart->addSeries(m_series); |
|
82 | 83 | m_chart->createDefaultAxes(); |
|
83 | 84 | } |
|
84 | 85 | |
|
85 | 86 | void tst_QLogValueAxis::cleanup() |
|
86 | 87 | { |
|
87 | 88 | delete m_series; |
|
88 | 89 | delete m_logvaluesaxis; |
|
89 | 90 | m_series = 0; |
|
90 | 91 | m_logvaluesaxis = 0; |
|
91 | 92 | tst_QAbstractAxis::cleanup(); |
|
92 | 93 | } |
|
93 | 94 | |
|
94 | 95 | void tst_QLogValueAxis::qlogvalueaxis_data() |
|
95 | 96 | { |
|
96 | 97 | } |
|
97 | 98 | |
|
98 | 99 | void tst_QLogValueAxis::qlogvalueaxis() |
|
99 | 100 | { |
|
100 | 101 | qabstractaxis(); |
|
101 | 102 | |
|
102 | 103 | QCOMPARE(m_logvaluesaxis->max(), (qreal)1); |
|
103 | 104 | QCOMPARE(m_logvaluesaxis->min(), (qreal)1); |
|
104 | 105 | QCOMPARE(m_logvaluesaxis->type(), QAbstractAxis::AxisTypeLogValue); |
|
105 | 106 | |
|
106 | 107 | m_chart->setAxisX(m_logvaluesaxis, m_series); |
|
107 | 108 | m_view->show(); |
|
108 | 109 | QTest::qWaitForWindowShown(m_view); |
|
109 | 110 | |
|
110 | 111 | QCOMPARE(m_logvaluesaxis->max(), (qreal)100); |
|
111 | 112 | QCOMPARE(m_logvaluesaxis->min(), (qreal)1); |
|
113 | ||
|
114 | QCOMPARE(m_logvaluesaxis->isReverse(), false); | |
|
112 | 115 | } |
|
113 | 116 | |
|
114 | 117 | void tst_QLogValueAxis::max_raw_data() |
|
115 | 118 | { |
|
116 | 119 | QTest::addColumn<qreal>("max"); |
|
117 | 120 | QTest::addColumn<qreal>("expected"); |
|
118 | 121 | QTest::addColumn<bool>("minChanged"); |
|
119 | 122 | QTest::addColumn<bool>("maxChanged"); |
|
120 | 123 | QTest::newRow("-1.0") << (qreal)-1.0 << (qreal)1.0 << false << false; |
|
121 | 124 | QTest::newRow("0.0") << (qreal)0.0 << (qreal)1.0 << false << false; |
|
122 | 125 | QTest::newRow("0.5") << (qreal)0.5 << (qreal)0.5 << true << true; |
|
123 | 126 | QTest::newRow("101.0") << (qreal)101.0 << (qreal)101.0 << false << true; |
|
124 | 127 | } |
|
125 | 128 | |
|
126 | 129 | void tst_QLogValueAxis::max_raw() |
|
127 | 130 | { |
|
128 | 131 | QFETCH(qreal, max); |
|
129 | 132 | QFETCH(qreal, expected); |
|
130 | 133 | QFETCH(bool, minChanged); |
|
131 | 134 | QFETCH(bool, maxChanged); |
|
132 | 135 | |
|
133 | 136 | // setting the axis in max() changes the max to value other than 1 |
|
134 | 137 | // set it back to 1 |
|
135 | 138 | m_logvaluesaxis->setMax((qreal)1); |
|
136 | 139 | |
|
137 | 140 | QSignalSpy spy0(m_logvaluesaxis, SIGNAL(maxChanged(qreal))); |
|
138 | 141 | QSignalSpy spy1(m_logvaluesaxis, SIGNAL(minChanged(qreal))); |
|
139 | 142 | QSignalSpy spy2(m_logvaluesaxis, SIGNAL(rangeChanged(qreal,qreal))); |
|
140 | 143 | |
|
141 | 144 | m_logvaluesaxis->setMax(max); |
|
142 | 145 | QCOMPARE(m_logvaluesaxis->max(), expected); |
|
143 | 146 | |
|
144 | 147 | QCOMPARE(spy0.count(), (int)maxChanged); |
|
145 | 148 | QCOMPARE(spy1.count(), (int)minChanged); |
|
146 | 149 | QCOMPARE(spy2.count(), (int)maxChanged); |
|
147 | 150 | |
|
148 | 151 | } |
|
149 | 152 | |
|
150 | 153 | void tst_QLogValueAxis::max_data() |
|
151 | 154 | { |
|
152 | 155 | max_raw_data(); |
|
153 | 156 | } |
|
154 | 157 | |
|
155 | 158 | void tst_QLogValueAxis::max() |
|
156 | 159 | { |
|
157 | 160 | m_chart->setAxisX(m_logvaluesaxis, m_series); |
|
158 | 161 | m_view->show(); |
|
159 | 162 | QTest::qWaitForWindowShown(m_view); |
|
160 | 163 | max_raw(); |
|
161 | 164 | } |
|
162 | 165 | |
|
163 | 166 | void tst_QLogValueAxis::max_animation_data() |
|
164 | 167 | { |
|
165 | 168 | max_data(); |
|
166 | 169 | } |
|
167 | 170 | |
|
168 | 171 | void tst_QLogValueAxis::max_animation() |
|
169 | 172 | { |
|
170 | 173 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); |
|
171 | 174 | max(); |
|
172 | 175 | } |
|
173 | 176 | |
|
174 | 177 | void tst_QLogValueAxis::min_raw_data() |
|
175 | 178 | { |
|
176 | 179 | QTest::addColumn<qreal>("min"); |
|
177 | 180 | QTest::addColumn<qreal>("expected"); |
|
178 | 181 | QTest::addColumn<bool>("minChanged"); |
|
179 | 182 | QTest::addColumn<bool>("maxChanged"); |
|
180 | 183 | QTest::newRow("-1.0") << (qreal)-1.0 << (qreal)1.0 << false << false; |
|
181 | 184 | QTest::newRow("0.0") << (qreal)0.0 << (qreal)1.0 << false << false; |
|
182 | 185 | QTest::newRow("0.5") << (qreal)0.5 << (qreal)0.5 << true << false; |
|
183 | 186 | QTest::newRow("101.0") << (qreal)101.0 << (qreal)101.0 << true << true; |
|
184 | 187 | } |
|
185 | 188 | |
|
186 | 189 | void tst_QLogValueAxis::min_raw() |
|
187 | 190 | { |
|
188 | 191 | QFETCH(qreal, min); |
|
189 | 192 | QFETCH(qreal, expected); |
|
190 | 193 | QFETCH(bool, minChanged); |
|
191 | 194 | QFETCH(bool, maxChanged); |
|
192 | 195 | |
|
193 | 196 | QSignalSpy spy0(m_logvaluesaxis, SIGNAL(maxChanged(qreal))); |
|
194 | 197 | QSignalSpy spy1(m_logvaluesaxis, SIGNAL(minChanged(qreal))); |
|
195 | 198 | QSignalSpy spy2(m_logvaluesaxis, SIGNAL(rangeChanged(qreal,qreal))); |
|
196 | 199 | |
|
197 | 200 | m_logvaluesaxis->setMin(min); |
|
198 | 201 | QCOMPARE(m_logvaluesaxis->min(), expected); |
|
199 | 202 | |
|
200 | 203 | QCOMPARE(spy0.count(), (int)maxChanged); |
|
201 | 204 | QCOMPARE(spy1.count(), (int)minChanged); |
|
202 | 205 | QCOMPARE(spy2.count(), (int)minChanged); |
|
203 | 206 | } |
|
204 | 207 | |
|
205 | 208 | void tst_QLogValueAxis::min_data() |
|
206 | 209 | { |
|
207 | 210 | min_raw_data(); |
|
208 | 211 | } |
|
209 | 212 | |
|
210 | 213 | void tst_QLogValueAxis::min() |
|
211 | 214 | { |
|
212 | 215 | m_chart->setAxisX(m_logvaluesaxis, m_series); |
|
213 | 216 | m_view->show(); |
|
214 | 217 | QTest::qWaitForWindowShown(m_view); |
|
215 | 218 | min_raw(); |
|
216 | 219 | } |
|
217 | 220 | |
|
218 | 221 | void tst_QLogValueAxis::min_animation_data() |
|
219 | 222 | { |
|
220 | 223 | min_data(); |
|
221 | 224 | } |
|
222 | 225 | |
|
223 | 226 | void tst_QLogValueAxis::min_animation() |
|
224 | 227 | { |
|
225 | 228 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); |
|
226 | 229 | min(); |
|
227 | 230 | } |
|
228 | 231 | |
|
229 | 232 | void tst_QLogValueAxis::range_raw_data() |
|
230 | 233 | { |
|
231 | 234 | QTest::addColumn<qreal>("min"); |
|
232 | 235 | QTest::addColumn<qreal>("max"); |
|
233 | 236 | QTest::addColumn<qreal>("expectedMin"); |
|
234 | 237 | QTest::addColumn<qreal>("expectedMax"); |
|
235 | 238 | QTest::addColumn<bool>("minChanged"); |
|
236 | 239 | QTest::addColumn<bool>("maxChanged"); |
|
237 | 240 | QTest::newRow("-1.0 - 101.0") << (qreal)-1.0 << (qreal)101.0 << (qreal)1.0 << (qreal)1.0 << false << false; |
|
238 | 241 | QTest::newRow("1.0 - 101.0") << (qreal)1.0 << (qreal)101.0 << (qreal)1.0 << (qreal)101.0 << false << true; |
|
239 | 242 | QTest::newRow("0.1 - 1.0") << (qreal)0.1 << (qreal)1.0 << (qreal)0.1 << (qreal)1.0 << true << false; |
|
240 | 243 | QTest::newRow("25.0 - 75.0") << (qreal)25.0 << (qreal)75.0 << (qreal)25.0 << (qreal)75.0 << true << true; |
|
241 | 244 | QTest::newRow("10.0 - 5.0") << (qreal)10.0 << (qreal)5.0 << (qreal)1.0 << (qreal)1.0 << false << false; |
|
242 | 245 | } |
|
243 | 246 | |
|
244 | 247 | void tst_QLogValueAxis::range_raw() |
|
245 | 248 | { |
|
246 | 249 | QFETCH(qreal, min); |
|
247 | 250 | QFETCH(qreal, max); |
|
248 | 251 | QFETCH(qreal, expectedMin); |
|
249 | 252 | QFETCH(qreal, expectedMax); |
|
250 | 253 | QFETCH(bool, minChanged); |
|
251 | 254 | QFETCH(bool, maxChanged); |
|
252 | 255 | |
|
253 | 256 | m_logvaluesaxis->setRange((qreal)1, (qreal)1); |
|
254 | 257 | |
|
255 | 258 | QSignalSpy spy0(m_logvaluesaxis, SIGNAL(maxChanged(qreal))); |
|
256 | 259 | QSignalSpy spy1(m_logvaluesaxis, SIGNAL(minChanged(qreal))); |
|
257 | 260 | QSignalSpy spy2(m_logvaluesaxis, SIGNAL(rangeChanged(qreal,qreal))); |
|
258 | 261 | |
|
259 | 262 | m_logvaluesaxis->setRange(min, max); |
|
260 | 263 | QCOMPARE(m_logvaluesaxis->min(), expectedMin); |
|
261 | 264 | QCOMPARE(m_logvaluesaxis->max(), expectedMax); |
|
262 | 265 | |
|
263 | 266 | QCOMPARE(spy0.count(), (int)maxChanged); |
|
264 | 267 | QCOMPARE(spy1.count(), (int)minChanged); |
|
265 | 268 | QCOMPARE(spy2.count(), (int)(minChanged || maxChanged)); |
|
266 | 269 | } |
|
267 | 270 | |
|
268 | 271 | void tst_QLogValueAxis::range_data() |
|
269 | 272 | { |
|
270 | 273 | range_raw_data(); |
|
271 | 274 | } |
|
272 | 275 | |
|
273 | 276 | void tst_QLogValueAxis::range() |
|
274 | 277 | { |
|
275 | 278 | m_chart->setAxisX(m_logvaluesaxis, m_series); |
|
276 | 279 | m_view->show(); |
|
277 | 280 | QTest::qWaitForWindowShown(m_view); |
|
278 | 281 | range_raw(); |
|
279 | 282 | } |
|
280 | 283 | |
|
281 | 284 | void tst_QLogValueAxis::range_animation_data() |
|
282 | 285 | { |
|
283 | 286 | range_data(); |
|
284 | 287 | } |
|
285 | 288 | |
|
286 | 289 | void tst_QLogValueAxis::range_animation() |
|
287 | 290 | { |
|
288 | 291 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); |
|
289 | 292 | range(); |
|
290 | 293 | } |
|
291 | 294 | |
|
292 | 295 | void tst_QLogValueAxis::noautoscale_data() |
|
293 | 296 | { |
|
294 | 297 | QTest::addColumn<qreal>("min"); |
|
295 | 298 | QTest::addColumn<qreal>("max"); |
|
296 | 299 | QTest::newRow("0.1 - 101.0") << (qreal)0.1 << (qreal)101.0; |
|
297 | 300 | QTest::newRow("25.0 - 75.0") << (qreal)25.0 << (qreal)75.0; |
|
298 | 301 | } |
|
299 | 302 | |
|
300 | 303 | void tst_QLogValueAxis::noautoscale() |
|
301 | 304 | { |
|
302 | 305 | QFETCH(qreal, min); |
|
303 | 306 | QFETCH(qreal, max); |
|
304 | 307 | |
|
305 | 308 | QSignalSpy spy0(m_logvaluesaxis, SIGNAL(maxChanged(qreal))); |
|
306 | 309 | QSignalSpy spy1(m_logvaluesaxis, SIGNAL(minChanged(qreal))); |
|
307 | 310 | QSignalSpy spy2(m_logvaluesaxis, SIGNAL(rangeChanged(qreal,qreal))); |
|
308 | 311 | |
|
309 | 312 | m_logvaluesaxis->setRange(min, max); |
|
310 | 313 | QCOMPARE(m_logvaluesaxis->min(), min); |
|
311 | 314 | QCOMPARE(m_logvaluesaxis->max(), max); |
|
312 | 315 | |
|
313 | 316 | QCOMPARE(spy0.count(), 1); |
|
314 | 317 | QCOMPARE(spy1.count(), 1); |
|
315 | 318 | QCOMPARE(spy2.count(), 1); |
|
316 | ||
|
317 | m_chart->setAxisX(m_logvaluesaxis, m_series); | |
|
318 | 319 | m_view->show(); |
|
319 | 320 | QTest::qWaitForWindowShown(m_view); |
|
320 | 321 | QCOMPARE(m_logvaluesaxis->min(), min); |
|
321 | 322 | QCOMPARE(m_logvaluesaxis->max(), max); |
|
322 | 323 | } |
|
323 | 324 | |
|
324 | 325 | void tst_QLogValueAxis::autoscale_data() |
|
325 | 326 | { |
|
326 | 327 | |
|
327 | 328 | } |
|
328 | 329 | |
|
329 | 330 | void tst_QLogValueAxis::autoscale() |
|
330 | 331 | { |
|
331 | 332 | QSignalSpy spy0(m_logvaluesaxis, SIGNAL(maxChanged(qreal))); |
|
332 | 333 | QSignalSpy spy1(m_logvaluesaxis, SIGNAL(minChanged(qreal))); |
|
333 | 334 | QSignalSpy spy2(m_logvaluesaxis, SIGNAL(rangeChanged(qreal,qreal))); |
|
334 | 335 | |
|
335 | 336 | QCOMPARE(m_logvaluesaxis->min(), (qreal)1); |
|
336 | 337 | QCOMPARE(m_logvaluesaxis->max(), (qreal)1); |
|
337 | 338 | m_chart->setAxisX(m_logvaluesaxis, m_series); |
|
338 | 339 | |
|
339 | 340 | QCOMPARE(spy0.count(), 1); |
|
340 | 341 | QCOMPARE(spy1.count(), 0); |
|
341 | 342 | QCOMPARE(spy2.count(), 1); |
|
342 | 343 | |
|
343 | 344 | m_view->show(); |
|
344 | 345 | QTest::qWaitForWindowShown(m_view); |
|
345 | 346 | QCOMPARE(m_logvaluesaxis->min(), (qreal)1); |
|
346 | 347 | QCOMPARE(m_logvaluesaxis->max(), (qreal)100); |
|
347 | 348 | } |
|
348 | 349 | |
|
349 | 350 | void tst_QLogValueAxis::zoom() |
|
350 | 351 | { |
|
351 | 352 | m_chart->setAxisX(m_logvaluesaxis, m_series); |
|
352 | 353 | m_view->show(); |
|
353 | 354 | QTest::qWaitForWindowShown(m_view); |
|
354 | 355 | m_logvaluesaxis->setBase(2); |
|
355 | 356 | m_logvaluesaxis->setRange(0.5, 2); |
|
356 | 357 | |
|
357 | 358 | QCOMPARE(m_logvaluesaxis->min(), (qreal)0.5); |
|
358 | 359 | QCOMPARE(m_logvaluesaxis->max(), (qreal)2.0); |
|
359 | 360 | |
|
360 | 361 | m_chart->zoomOut(); |
|
361 | 362 | |
|
362 | 363 | QCOMPARE(m_logvaluesaxis->min(), (qreal)0.25); |
|
363 | 364 | QCOMPARE(m_logvaluesaxis->max(), (qreal)4.0); |
|
364 | 365 | |
|
365 | 366 | m_chart->zoomIn(); |
|
366 | 367 | |
|
367 | 368 | QCOMPARE(m_logvaluesaxis->min(), (qreal)0.5); |
|
368 | 369 | QCOMPARE(m_logvaluesaxis->max(), (qreal)2.0); |
|
369 | 370 | |
|
370 | 371 | m_logvaluesaxis->setRange(0.5, 1024); |
|
371 | 372 | m_chart->zoom(11.0); |
|
372 | 373 | |
|
373 | 374 | QCOMPARE(m_logvaluesaxis->min(), (qreal)16.0); |
|
374 | 375 | QCOMPARE(m_logvaluesaxis->max(), (qreal)32.0); |
|
375 | 376 | |
|
376 | 377 | m_logvaluesaxis->setRange(16, 64); |
|
377 | 378 | m_chart->zoom(1/3.0); |
|
378 | 379 | |
|
379 | 380 | QCOMPARE(m_logvaluesaxis->min(), (qreal)4); |
|
380 | 381 | QCOMPARE(m_logvaluesaxis->max(), (qreal)256.0); |
|
381 | 382 | |
|
382 | 383 | } |
|
383 | 384 | |
|
385 | void tst_QLogValueAxis::reverse() | |
|
386 | { | |
|
387 | QSignalSpy spy(m_logvaluesaxis, SIGNAL(reverseChanged(bool))); | |
|
388 | QCOMPARE(m_logvaluesaxis->isReverse(), false); | |
|
389 | ||
|
390 | m_logvaluesaxis->setReverse(); | |
|
391 | QCOMPARE(m_logvaluesaxis->isReverse(), true); | |
|
392 | QCOMPARE(spy.count(), 1); | |
|
393 | ||
|
394 | m_view->show(); | |
|
395 | QTest::qWaitForWindowShown(m_view); | |
|
396 | QCOMPARE(m_logvaluesaxis->isReverse(), true); | |
|
397 | } | |
|
398 | ||
|
384 | 399 | QTEST_MAIN(tst_QLogValueAxis) |
|
385 | 400 | #include "tst_qlogvalueaxis.moc" |
|
386 | 401 |
@@ -1,97 +1,118 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | import QtQuick 2.0 |
|
20 | 20 | import QtTest 1.0 |
|
21 | 21 | import QtCharts 2.1 |
|
22 | 22 | |
|
23 | 23 | Rectangle { |
|
24 | 24 | width: 400 |
|
25 | 25 | height: 300 |
|
26 | 26 | |
|
27 | 27 | TestCase { |
|
28 | 28 | id: tc1 |
|
29 | 29 | name: "tst_qml-qtquicktest CategoryAxis" |
|
30 | 30 | when: windowShown |
|
31 | 31 | |
|
32 | 32 | function test_minMax() { |
|
33 | 33 | compare(lineSeries1.axisX.min, 0, "AxisX min"); |
|
34 | 34 | compare(lineSeries1.axisX.max, 10, "AxisX max"); |
|
35 | 35 | compare(lineSeries1.axisY.min, 0, "AxisY min"); |
|
36 | 36 | compare(lineSeries1.axisY.max, 10, "AxisY max"); |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | function test_categories() { |
|
40 | 40 | compare(lineSeries1.axisY.startValue, 0, "AxisY start value"); |
|
41 | 41 | compare(lineSeries1.axisY.count, 3, "AxisY count"); |
|
42 | 42 | compare(lineSeries1.axisY.categoriesLabels[0], "label0", "AxisY categories labels"); |
|
43 | 43 | compare(lineSeries1.axisY.categoriesLabels[1], "label1", "AxisY categories labels"); |
|
44 | 44 | compare(lineSeries1.axisY.categoriesLabels[2], "label2", "AxisY categories labels"); |
|
45 | 45 | } |
|
46 | 46 | |
|
47 | 47 | function test_properties() { |
|
48 | 48 | compare(lineSeries1.axisY.labelsPosition, CategoryAxis.AxisLabelsPositionCenter); |
|
49 | verify(lineSeries1.axisX.reverse == false, "AxisX reverse"); | |
|
50 | verify(lineSeries1.axisY.reverse == false, "AxisY reverse"); | |
|
51 | ||
|
52 | // Modify properties | |
|
53 | lineSeries1.axisX.reverse = true; | |
|
54 | verify(lineSeries1.axisX.reverse == true, "AxisX reverse"); | |
|
55 | lineSeries1.axisX.reverse = false; | |
|
56 | verify(lineSeries1.axisX.reverse == false, "AxisX reverse"); | |
|
49 | 57 | } |
|
50 | 58 | |
|
51 | 59 | function test_signals() { |
|
52 | 60 | axisLabelsPositionSpy.clear(); |
|
61 | reverseChangedSpy.clear(); | |
|
53 | 62 | lineSeries1.axisY.labelsPosition = CategoryAxis.AxisLabelsPositionOnValue; |
|
54 | compare(axisLabelsPositionSpy.count, 1, "onLabelsPositionChanged") | |
|
63 | compare(axisLabelsPositionSpy.count, 1, "onLabelsPositionChanged"); | |
|
64 | ||
|
65 | lineSeries1.axisX.reverse = true; | |
|
66 | compare(reverseChangedSpy.count, 1, "onReverseChanged"); | |
|
67 | ||
|
68 | // restore original values | |
|
69 | lineSeries1.axisX.reverse = false; | |
|
70 | compare(reverseChangedSpy.count, 2, "onReverseChanged"); | |
|
55 | 71 | } |
|
56 | 72 | } |
|
57 | 73 | |
|
58 | 74 | ChartView { |
|
59 | 75 | id: chartView |
|
60 | 76 | anchors.fill: parent |
|
61 | 77 | |
|
62 | 78 | LineSeries { |
|
63 | 79 | id: lineSeries1 |
|
64 | 80 | axisX: ValueAxis { |
|
65 | 81 | id: axisX |
|
66 | 82 | min: 0 |
|
67 | 83 | max: 10 |
|
68 | 84 | } |
|
69 | 85 | axisY: CategoryAxis { |
|
70 | 86 | id: axisY |
|
71 | 87 | min: 0 |
|
72 | 88 | max: 10 |
|
73 | 89 | startValue: 0 |
|
74 | 90 | CategoryRange { |
|
75 | 91 | label: "label0" |
|
76 | 92 | endValue: 1 |
|
77 | 93 | } |
|
78 | 94 | CategoryRange { |
|
79 | 95 | label: "label1" |
|
80 | 96 | endValue: 3 |
|
81 | 97 | } |
|
82 | 98 | CategoryRange { |
|
83 | 99 | label: "label2" |
|
84 | 100 | endValue: 10 |
|
85 | 101 | } |
|
86 | 102 | SignalSpy { |
|
87 | 103 | id: axisLabelsPositionSpy |
|
88 | 104 | target: axisY |
|
89 | 105 | signalName: "labelsPositionChanged" |
|
90 | 106 | } |
|
91 | 107 | } |
|
92 | 108 | XYPoint { x: -1; y: -1 } |
|
93 | 109 | XYPoint { x: 0; y: 0 } |
|
94 | 110 | XYPoint { x: 5; y: 5 } |
|
95 | 111 | } |
|
112 | SignalSpy { | |
|
113 | id: reverseChangedSpy | |
|
114 | target: axisX | |
|
115 | signalName: "reverseChanged" | |
|
116 | } | |
|
96 | 117 | } |
|
97 | 118 | } |
@@ -1,114 +1,132 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | import QtQuick 2.0 |
|
20 | 20 | import QtTest 1.0 |
|
21 | 21 | import QtCharts 2.0 |
|
22 | 22 | |
|
23 | 23 | Rectangle { |
|
24 | 24 | width: 400 |
|
25 | 25 | height: 300 |
|
26 | 26 | |
|
27 | 27 | TestCase { |
|
28 | 28 | id: tc1 |
|
29 | 29 | name: "tst_qml-qtquicktest ValueAxis" |
|
30 | 30 | when: windowShown |
|
31 | 31 | |
|
32 | 32 | // test functions are run in alphabetical order, the name has 'a' so that it |
|
33 | 33 | // will be the first function to execute. |
|
34 | 34 | function test_a_properties() { |
|
35 | 35 | // Default properties |
|
36 | 36 | verify(axisX.min < 0, "AxisX min"); |
|
37 | 37 | verify(axisX.max > 0, "AxisX max"); |
|
38 | 38 | verify(axisY.min < 0, "AxisY min"); |
|
39 | 39 | verify(axisY.max > 0, "AxisY max"); |
|
40 | 40 | verify(axisX.tickCount == 5, "AxisX tick count"); |
|
41 | 41 | verify(axisY.tickCount == 5, "AxisY tick count"); |
|
42 | 42 | verify(axisX.labelFormat == "", "label format"); |
|
43 | verify(axisX.reverse == false, "AxisX reverse"); | |
|
44 | verify(axisY.reverse == false, "AxisY reverse"); | |
|
43 | 45 | |
|
44 | 46 | // Modify properties |
|
45 | 47 | axisX.tickCount = 3; |
|
46 | 48 | verify(axisX.tickCount == 3, "set tick count"); |
|
49 | axisX.reverse = true; | |
|
50 | verify(axisX.reverse == true, "AxisX reverse"); | |
|
51 | axisX.reverse = false; | |
|
52 | verify(axisX.reverse == false, "AxisX reverse"); | |
|
47 | 53 | } |
|
48 | 54 | |
|
49 | 55 | function test_functions() { |
|
50 | 56 | // Set the axis ranges to not "nice" ones... |
|
51 | 57 | var min = 0.032456456; |
|
52 | 58 | var max = 10.67845634; |
|
53 | 59 | axisX.min = min; |
|
54 | 60 | axisX.max = max; |
|
55 | 61 | axisY.min = min; |
|
56 | 62 | axisY.max = max; |
|
57 | 63 | |
|
58 | 64 | // ...And then apply nice numbers and verify the range was changed |
|
59 | 65 | axisX.applyNiceNumbers(); |
|
60 | 66 | axisY.applyNiceNumbers(); |
|
61 | 67 | verify(axisX.min != min); |
|
62 | 68 | verify(axisX.max != max); |
|
63 | 69 | verify(axisY.min != min); |
|
64 | 70 | verify(axisY.max != max); |
|
65 | 71 | } |
|
66 | 72 | |
|
67 | 73 | function test_signals() { |
|
68 | 74 | minChangedSpy.clear(); |
|
69 | 75 | maxChangedSpy.clear(); |
|
76 | reverseChangedSpy.clear(); | |
|
77 | ||
|
70 | 78 | axisX.min = 2; |
|
71 | 79 | compare(minChangedSpy.count, 1, "onMinChanged"); |
|
72 | 80 | compare(maxChangedSpy.count, 0, "onMaxChanged"); |
|
73 | 81 | |
|
74 | 82 | axisX.max = 8; |
|
75 | 83 | compare(minChangedSpy.count, 1, "onMinChanged"); |
|
76 | 84 | compare(maxChangedSpy.count, 1, "onMaxChanged"); |
|
77 | 85 | |
|
86 | axisX.reverse = true; | |
|
87 | compare(reverseChangedSpy.count, 1, "onReverseChanged"); | |
|
88 | ||
|
78 | 89 | // restore original values |
|
79 | 90 | axisX.min = 0; |
|
80 | 91 | axisX.max = 10; |
|
92 | axisX.reverse = false; | |
|
81 | 93 | compare(minChangedSpy.count, 2, "onMinChanged"); |
|
82 | 94 | compare(maxChangedSpy.count, 2, "onMaxChanged"); |
|
95 | compare(reverseChangedSpy.count, 2, "onReverseChanged"); | |
|
83 | 96 | } |
|
84 | 97 | } |
|
85 | 98 | |
|
86 | 99 | ChartView { |
|
87 | 100 | id: chartView |
|
88 | 101 | anchors.fill: parent |
|
89 | 102 | |
|
90 | 103 | LineSeries { |
|
91 | 104 | id: lineSeries1 |
|
92 | 105 | axisX: ValueAxis { |
|
93 | 106 | id: axisX |
|
94 | 107 | } |
|
95 | 108 | axisY: ValueAxis { |
|
96 | 109 | id: axisY |
|
97 | 110 | } |
|
98 | 111 | XYPoint { x: -1; y: -1 } |
|
99 | 112 | XYPoint { x: 0; y: 0 } |
|
100 | 113 | XYPoint { x: 5; y: 5 } |
|
101 | 114 | } |
|
102 | 115 | |
|
103 | 116 | SignalSpy { |
|
104 | 117 | id: minChangedSpy |
|
105 | 118 | target: axisX |
|
106 | 119 | signalName: "minChanged" |
|
107 | 120 | } |
|
108 | 121 | SignalSpy { |
|
109 | 122 | id: maxChangedSpy |
|
110 | 123 | target: axisX |
|
111 | 124 | signalName: "maxChanged" |
|
112 | 125 | } |
|
126 | SignalSpy { | |
|
127 | id: reverseChangedSpy | |
|
128 | target: axisX | |
|
129 | signalName: "reverseChanged" | |
|
130 | } | |
|
113 | 131 | } |
|
114 | 132 | } |
@@ -1,411 +1,430 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | #include "../qabstractaxis/tst_qabstractaxis.h" |
|
20 | 20 | #include <QtCharts/QValueAxis> |
|
21 | 21 | #include <QtCharts/QLineSeries> |
|
22 | 22 | |
|
23 | 23 | class tst_QValueAxis: public tst_QAbstractAxis |
|
24 | 24 | { |
|
25 | 25 | Q_OBJECT |
|
26 | 26 | |
|
27 | 27 | public slots: |
|
28 | 28 | void initTestCase(); |
|
29 | 29 | void cleanupTestCase(); |
|
30 | 30 | void init(); |
|
31 | 31 | void cleanup(); |
|
32 | 32 | |
|
33 | 33 | private slots: |
|
34 | 34 | void qvalueaxis_data(); |
|
35 | 35 | void qvalueaxis(); |
|
36 | 36 | void max_raw_data(); |
|
37 | 37 | void max_raw(); |
|
38 | 38 | void max_data(); |
|
39 | 39 | void max(); |
|
40 | 40 | void max_animation_data(); |
|
41 | 41 | void max_animation(); |
|
42 | 42 | void min_raw_data(); |
|
43 | 43 | void min_raw(); |
|
44 | 44 | void min_data(); |
|
45 | 45 | void min(); |
|
46 | 46 | void min_animation_data(); |
|
47 | 47 | void min_animation(); |
|
48 | 48 | void applyNiceNumbers_data(); |
|
49 | 49 | void applyNiceNumbers(); |
|
50 | 50 | void range_raw_data(); |
|
51 | 51 | void range_raw(); |
|
52 | 52 | void range_data(); |
|
53 | 53 | void range(); |
|
54 | 54 | void range_animation_data(); |
|
55 | 55 | void range_animation(); |
|
56 | 56 | void ticksCount_data(); |
|
57 | 57 | void ticksCount(); |
|
58 | 58 | void noautoscale_data(); |
|
59 | 59 | void noautoscale(); |
|
60 | 60 | void autoscale_data(); |
|
61 | 61 | void autoscale(); |
|
62 | void reverse(); | |
|
62 | 63 | |
|
63 | 64 | private: |
|
64 | 65 | QValueAxis* m_valuesaxis; |
|
65 | 66 | QLineSeries* m_series; |
|
66 | 67 | }; |
|
67 | 68 | |
|
68 | 69 | void tst_QValueAxis::initTestCase() |
|
69 | 70 | { |
|
70 | 71 | } |
|
71 | 72 | |
|
72 | 73 | void tst_QValueAxis::cleanupTestCase() |
|
73 | 74 | { |
|
74 | 75 | QTest::qWait(1); // Allow final deleteLaters to run |
|
75 | 76 | } |
|
76 | 77 | |
|
77 | 78 | void tst_QValueAxis::init() |
|
78 | 79 | { |
|
79 | 80 | m_valuesaxis = new QValueAxis(); |
|
80 | 81 | m_series = new QLineSeries(); |
|
81 | 82 | *m_series << QPointF(-100, -100) << QPointF(0, 0) << QPointF(100, 100); |
|
82 | 83 | tst_QAbstractAxis::init(m_valuesaxis,m_series); |
|
83 | 84 | m_chart->addSeries(m_series); |
|
84 | 85 | m_chart->createDefaultAxes(); |
|
85 | 86 | } |
|
86 | 87 | |
|
87 | 88 | void tst_QValueAxis::cleanup() |
|
88 | 89 | { |
|
89 | 90 | delete m_series; |
|
90 | 91 | delete m_valuesaxis; |
|
91 | 92 | m_series = 0; |
|
92 | 93 | m_valuesaxis = 0; |
|
93 | 94 | tst_QAbstractAxis::cleanup(); |
|
94 | 95 | } |
|
95 | 96 | |
|
96 | 97 | void tst_QValueAxis::qvalueaxis_data() |
|
97 | 98 | { |
|
98 | 99 | } |
|
99 | 100 | |
|
100 | 101 | void tst_QValueAxis::qvalueaxis() |
|
101 | 102 | { |
|
102 | 103 | qabstractaxis(); |
|
103 | 104 | |
|
104 | 105 | QVERIFY(qFuzzyCompare(m_valuesaxis->max(), 0)); |
|
105 | 106 | QVERIFY(qFuzzyCompare(m_valuesaxis->min(), 0)); |
|
106 | 107 | QCOMPARE(m_valuesaxis->tickCount(), 5); |
|
107 | 108 | QCOMPARE(m_valuesaxis->type(), QAbstractAxis::AxisTypeValue); |
|
108 | 109 | |
|
109 | 110 | m_chart->setAxisX(m_valuesaxis, m_series); |
|
110 | 111 | m_view->show(); |
|
111 | 112 | QTest::qWaitForWindowShown(m_view); |
|
112 | 113 | |
|
113 | 114 | QVERIFY(!qFuzzyCompare(m_valuesaxis->max(), 0)); |
|
114 | 115 | QVERIFY(!qFuzzyCompare(m_valuesaxis->min(), 0)); |
|
115 | 116 | QCOMPARE(m_valuesaxis->tickCount(), 5); |
|
117 | ||
|
118 | QCOMPARE(m_valuesaxis->isReverse(), false); | |
|
116 | 119 | } |
|
117 | 120 | |
|
118 | 121 | void tst_QValueAxis::max_raw_data() |
|
119 | 122 | { |
|
120 | 123 | QTest::addColumn<qreal>("max"); |
|
121 | 124 | QTest::newRow("1.0") << (qreal)1.0; |
|
122 | 125 | QTest::newRow("50.0") << (qreal)50.0; |
|
123 | 126 | QTest::newRow("101.0") << (qreal)101.0; |
|
124 | 127 | } |
|
125 | 128 | |
|
126 | 129 | void tst_QValueAxis::max_raw() |
|
127 | 130 | { |
|
128 | 131 | QFETCH(qreal, max); |
|
129 | 132 | |
|
130 | 133 | QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); |
|
131 | 134 | QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); |
|
132 | 135 | QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal,qreal))); |
|
133 | 136 | |
|
134 | 137 | m_valuesaxis->setMax(max); |
|
135 | 138 | QVERIFY2(qFuzzyCompare(m_valuesaxis->max(), max), "Not equal"); |
|
136 | 139 | |
|
137 | 140 | QCOMPARE(spy0.count(), 1); |
|
138 | 141 | QCOMPARE(spy1.count(), 0); |
|
139 | 142 | QCOMPARE(spy2.count(), 1); |
|
140 | 143 | |
|
141 | 144 | } |
|
142 | 145 | |
|
143 | 146 | void tst_QValueAxis::max_data() |
|
144 | 147 | { |
|
145 | 148 | max_raw_data(); |
|
146 | 149 | } |
|
147 | 150 | |
|
148 | 151 | void tst_QValueAxis::max() |
|
149 | 152 | { |
|
150 | 153 | m_chart->setAxisX(m_valuesaxis, m_series); |
|
151 | 154 | m_view->show(); |
|
152 | 155 | QTest::qWaitForWindowShown(m_view); |
|
153 | 156 | max_raw(); |
|
154 | 157 | } |
|
155 | 158 | |
|
156 | 159 | void tst_QValueAxis::max_animation_data() |
|
157 | 160 | { |
|
158 | 161 | max_data(); |
|
159 | 162 | } |
|
160 | 163 | |
|
161 | 164 | void tst_QValueAxis::max_animation() |
|
162 | 165 | { |
|
163 | 166 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); |
|
164 | 167 | max(); |
|
165 | 168 | } |
|
166 | 169 | |
|
167 | 170 | void tst_QValueAxis::min_raw_data() |
|
168 | 171 | { |
|
169 | 172 | QTest::addColumn<qreal>("min"); |
|
170 | 173 | QTest::newRow("-1.0") << (qreal)-1.0; |
|
171 | 174 | QTest::newRow("-50.0") << (qreal)-50.0; |
|
172 | 175 | QTest::newRow("-101.0") << (qreal)-101.0; |
|
173 | 176 | } |
|
174 | 177 | |
|
175 | 178 | void tst_QValueAxis::min_raw() |
|
176 | 179 | { |
|
177 | 180 | QFETCH(qreal, min); |
|
178 | 181 | |
|
179 | 182 | QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); |
|
180 | 183 | QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); |
|
181 | 184 | QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal,qreal))); |
|
182 | 185 | |
|
183 | 186 | m_valuesaxis->setMin(min); |
|
184 | 187 | QVERIFY2(qFuzzyCompare(m_valuesaxis->min(), min), "Not equal"); |
|
185 | 188 | |
|
186 | 189 | QCOMPARE(spy0.count(), 0); |
|
187 | 190 | QCOMPARE(spy1.count(), 1); |
|
188 | 191 | QCOMPARE(spy2.count(), 1); |
|
189 | 192 | } |
|
190 | 193 | |
|
191 | 194 | void tst_QValueAxis::min_data() |
|
192 | 195 | { |
|
193 | 196 | min_raw_data(); |
|
194 | 197 | } |
|
195 | 198 | |
|
196 | 199 | void tst_QValueAxis::min() |
|
197 | 200 | { |
|
198 | 201 | m_chart->setAxisX(m_valuesaxis, m_series); |
|
199 | 202 | m_view->show(); |
|
200 | 203 | QTest::qWaitForWindowShown(m_view); |
|
201 | 204 | min_raw(); |
|
202 | 205 | } |
|
203 | 206 | |
|
204 | 207 | void tst_QValueAxis::min_animation_data() |
|
205 | 208 | { |
|
206 | 209 | min_data(); |
|
207 | 210 | } |
|
208 | 211 | |
|
209 | 212 | void tst_QValueAxis::min_animation() |
|
210 | 213 | { |
|
211 | 214 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); |
|
212 | 215 | min(); |
|
213 | 216 | } |
|
214 | 217 | |
|
215 | 218 | void tst_QValueAxis::applyNiceNumbers_data() |
|
216 | 219 | { |
|
217 | 220 | QTest::addColumn<bool>("niceNumbersEnabled"); |
|
218 | 221 | QTest::addColumn<qreal>("min"); |
|
219 | 222 | QTest::addColumn<qreal>("max"); |
|
220 | 223 | QTest::addColumn<int>("ticks"); |
|
221 | 224 | QTest::addColumn<qreal>("expectedMin"); |
|
222 | 225 | QTest::addColumn<qreal>("expectedMax"); |
|
223 | 226 | QTest::addColumn<int>("expectedTicks"); |
|
224 | 227 | QTest::newRow("true 0.1 , 99.0 , 5") << true << (qreal)0.1 << (qreal)99.0 << 5 << (qreal)0.0 << (qreal)100.0 << 6; |
|
225 | 228 | QTest::newRow("true 1 , 10.0 , 5") << true << (qreal)1.0 << (qreal)10.0 << 5 << (qreal)0.0 << (qreal)10.0 << 6; |
|
226 | 229 | QTest::newRow("true 0.1 , 6.6 , 5") << true << (qreal)0.1 << (qreal)6.6 << 5 << (qreal)0.0 << (qreal)8.0 << 5; |
|
227 | 230 | QTest::newRow("false 0.1 , 6.6 , 5") << false << (qreal)0.1 << (qreal)6.6 << 5 << (qreal)0.1 << (qreal)6.6 << 5; |
|
228 | 231 | QTest::newRow("true 0.1, 99, 5") << true << (qreal)0.1 << (qreal)99.0 << 5 << (qreal)0.0 << (qreal)100.0 << 6; |
|
229 | 232 | QTest::newRow("true 5, 93.5 , 5") << true << (qreal)5.0 << (qreal)93.5 << 5 << (qreal)0.0 << (qreal)100.0 << 6; |
|
230 | 233 | } |
|
231 | 234 | |
|
232 | 235 | void tst_QValueAxis::applyNiceNumbers() |
|
233 | 236 | { |
|
234 | 237 | QFETCH(bool, niceNumbersEnabled); |
|
235 | 238 | QFETCH(qreal, min); |
|
236 | 239 | QFETCH(qreal, max); |
|
237 | 240 | QFETCH(int, ticks); |
|
238 | 241 | QFETCH(qreal, expectedMin); |
|
239 | 242 | QFETCH(qreal, expectedMax); |
|
240 | 243 | QFETCH(int, expectedTicks); |
|
241 | 244 | |
|
242 | 245 | m_valuesaxis->setRange(min, max); |
|
243 | 246 | m_valuesaxis->setTickCount(ticks); |
|
244 | 247 | |
|
245 | 248 | QVERIFY2(qFuzzyCompare(m_valuesaxis->min(), min), "Min not equal"); |
|
246 | 249 | QVERIFY2(qFuzzyCompare(m_valuesaxis->max(), max), "Max not equal"); |
|
247 | 250 | |
|
248 | 251 | QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); |
|
249 | 252 | QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); |
|
250 | 253 | QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal,qreal))); |
|
251 | 254 | |
|
252 | 255 | if(niceNumbersEnabled) m_valuesaxis->applyNiceNumbers(); |
|
253 | 256 | |
|
254 | 257 | if(!qFuzzyCompare(expectedMin, min)) |
|
255 | 258 | QCOMPARE(spy1.count(), 1); |
|
256 | 259 | if(!qFuzzyCompare(expectedMax, max)) |
|
257 | 260 | QCOMPARE(spy0.count(), 1); |
|
258 | 261 | if((!qFuzzyCompare(expectedMin, min)) || (!qFuzzyCompare(expectedMax, max))) |
|
259 | 262 | QCOMPARE(spy2.count(), 1); |
|
260 | 263 | |
|
261 | 264 | QVERIFY2(qFuzzyCompare(m_valuesaxis->min(), expectedMin), "Min not equal"); |
|
262 | 265 | QVERIFY2(qFuzzyCompare(m_valuesaxis->max(), expectedMax), "Max not equal"); |
|
263 | 266 | QCOMPARE(m_valuesaxis->tickCount(), expectedTicks); |
|
264 | 267 | |
|
265 | 268 | } |
|
266 | 269 | |
|
267 | 270 | void tst_QValueAxis::range_raw_data() |
|
268 | 271 | { |
|
269 | 272 | QTest::addColumn<qreal>("min"); |
|
270 | 273 | QTest::addColumn<qreal>("max"); |
|
271 | 274 | QTest::newRow("1.0 - 101.0") << (qreal)-1.0 << (qreal)101.0; |
|
272 | 275 | QTest::newRow("25.0 - 75.0") << (qreal)25.0 << (qreal)75.0; |
|
273 | 276 | QTest::newRow("101.0") << (qreal)40.0 << (qreal)60.0; |
|
274 | 277 | } |
|
275 | 278 | |
|
276 | 279 | void tst_QValueAxis::range_raw() |
|
277 | 280 | { |
|
278 | 281 | QFETCH(qreal, min); |
|
279 | 282 | QFETCH(qreal, max); |
|
280 | 283 | |
|
281 | 284 | QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); |
|
282 | 285 | QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); |
|
283 | 286 | QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal,qreal))); |
|
284 | 287 | |
|
285 | 288 | m_valuesaxis->setRange(min, max); |
|
286 | 289 | QVERIFY2(qFuzzyCompare(m_valuesaxis->min(), min), "Min not equal"); |
|
287 | 290 | QVERIFY2(qFuzzyCompare(m_valuesaxis->max(), max), "Max not equal"); |
|
288 | 291 | |
|
289 | 292 | QCOMPARE(spy0.count(), 1); |
|
290 | 293 | QCOMPARE(spy1.count(), 1); |
|
291 | 294 | QCOMPARE(spy2.count(), 1); |
|
292 | 295 | } |
|
293 | 296 | |
|
294 | 297 | void tst_QValueAxis::range_data() |
|
295 | 298 | { |
|
296 | 299 | range_raw_data(); |
|
297 | 300 | } |
|
298 | 301 | |
|
299 | 302 | void tst_QValueAxis::range() |
|
300 | 303 | { |
|
301 | 304 | m_chart->setAxisX(m_valuesaxis, m_series); |
|
302 | 305 | m_view->show(); |
|
303 | 306 | QTest::qWaitForWindowShown(m_view); |
|
304 | 307 | range_raw(); |
|
305 | 308 | } |
|
306 | 309 | |
|
307 | 310 | void tst_QValueAxis::range_animation_data() |
|
308 | 311 | { |
|
309 | 312 | range_data(); |
|
310 | 313 | } |
|
311 | 314 | |
|
312 | 315 | void tst_QValueAxis::range_animation() |
|
313 | 316 | { |
|
314 | 317 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); |
|
315 | 318 | range(); |
|
316 | 319 | } |
|
317 | 320 | |
|
318 | 321 | void tst_QValueAxis::ticksCount_data() |
|
319 | 322 | { |
|
320 | 323 | QTest::addColumn<int>("ticksCount"); |
|
321 | 324 | QTest::addColumn<int>("expectedCount"); |
|
322 | 325 | QTest::newRow("0") << 2; |
|
323 | 326 | QTest::newRow("1") << 2; |
|
324 | 327 | QTest::newRow("2") << 2; |
|
325 | 328 | QTest::newRow("3") << 3; |
|
326 | 329 | QTest::newRow("-1") << 2; |
|
327 | 330 | } |
|
328 | 331 | |
|
329 | 332 | void tst_QValueAxis::ticksCount() |
|
330 | 333 | { |
|
331 | 334 | QFETCH(int, ticksCount); |
|
332 | 335 | |
|
333 | 336 | QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); |
|
334 | 337 | QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); |
|
335 | 338 | QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal,qreal))); |
|
336 | 339 | |
|
337 | 340 | m_valuesaxis->setTickCount(ticksCount); |
|
338 | 341 | QCOMPARE(m_valuesaxis->tickCount(), ticksCount); |
|
339 | 342 | |
|
340 | 343 | QCOMPARE(spy0.count(), 0); |
|
341 | 344 | QCOMPARE(spy1.count(), 0); |
|
342 | 345 | QCOMPARE(spy2.count(), 0); |
|
343 | 346 | |
|
344 | 347 | m_chart->setAxisX(m_valuesaxis, m_series); |
|
345 | 348 | m_view->show(); |
|
346 | 349 | QTest::qWaitForWindowShown(m_view); |
|
347 | 350 | |
|
348 | 351 | QCOMPARE(m_valuesaxis->tickCount(), ticksCount); |
|
349 | 352 | } |
|
350 | 353 | |
|
351 | 354 | void tst_QValueAxis::noautoscale_data() |
|
352 | 355 | { |
|
353 | 356 | QTest::addColumn<qreal>("min"); |
|
354 | 357 | QTest::addColumn<qreal>("max"); |
|
355 | 358 | QTest::newRow("1.0 - 101.0") << (qreal)-1.0 << (qreal)101.0; |
|
356 | 359 | QTest::newRow("25.0 - 75.0") << (qreal)25.0 << (qreal)75.0; |
|
357 | 360 | QTest::newRow("101.0") << (qreal)40.0 << (qreal)60.0; |
|
358 | 361 | } |
|
359 | 362 | |
|
360 | 363 | void tst_QValueAxis::noautoscale() |
|
361 | 364 | { |
|
362 | 365 | QFETCH(qreal, min); |
|
363 | 366 | QFETCH(qreal, max); |
|
364 | 367 | |
|
365 | 368 | QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); |
|
366 | 369 | QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); |
|
367 | 370 | QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal,qreal))); |
|
368 | 371 | |
|
369 | 372 | m_valuesaxis->setRange(min, max); |
|
370 | 373 | QVERIFY2(qFuzzyCompare(m_valuesaxis->min(), min), "Min not equal"); |
|
371 | 374 | QVERIFY2(qFuzzyCompare(m_valuesaxis->max(), max), "Max not equal"); |
|
372 | 375 | |
|
373 | 376 | QCOMPARE(spy0.count(), 1); |
|
374 | 377 | QCOMPARE(spy1.count(), 1); |
|
375 | 378 | QCOMPARE(spy2.count(), 1); |
|
376 | 379 | |
|
377 | 380 | m_chart->setAxisX(m_valuesaxis, m_series); |
|
378 | 381 | m_view->show(); |
|
379 | 382 | QTest::qWaitForWindowShown(m_view); |
|
380 | 383 | QVERIFY2(qFuzzyCompare(m_valuesaxis->min(), min), "Min not equal"); |
|
381 | 384 | QVERIFY2(qFuzzyCompare(m_valuesaxis->max(), max), "Max not equal"); |
|
382 | 385 | } |
|
383 | 386 | |
|
384 | 387 | void tst_QValueAxis::autoscale_data() |
|
385 | 388 | { |
|
386 | 389 | |
|
387 | 390 | } |
|
388 | 391 | |
|
389 | 392 | void tst_QValueAxis::autoscale() |
|
390 | 393 | { |
|
391 | 394 | QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); |
|
392 | 395 | QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); |
|
393 | 396 | QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal,qreal))); |
|
394 | 397 | |
|
395 | 398 | QVERIFY2(qFuzzyCompare(m_valuesaxis->min(), 0), "Min not equal"); |
|
396 | 399 | QVERIFY2(qFuzzyCompare(m_valuesaxis->max(), 0), "Max not equal"); |
|
397 | 400 | m_chart->setAxisX(m_valuesaxis, m_series); |
|
398 | 401 | |
|
399 | 402 | QCOMPARE(spy0.count(), 1); |
|
400 | 403 | QCOMPARE(spy1.count(), 1); |
|
401 | 404 | QCOMPARE(spy2.count(), 1); |
|
402 | 405 | |
|
403 | 406 | m_view->show(); |
|
404 | 407 | QTest::qWaitForWindowShown(m_view); |
|
405 | 408 | QVERIFY2(qFuzzyCompare(m_valuesaxis->min(), -100), "Min not equal"); |
|
406 | 409 | QVERIFY2(qFuzzyCompare(m_valuesaxis->max(), 100), "Max not equal"); |
|
407 | 410 | } |
|
408 | 411 | |
|
412 | void tst_QValueAxis::reverse() | |
|
413 | { | |
|
414 | QSignalSpy spy(m_valuesaxis, SIGNAL(reverseChanged(bool))); | |
|
415 | QCOMPARE(m_valuesaxis->isReverse(), false); | |
|
416 | ||
|
417 | m_valuesaxis->setReverse(); | |
|
418 | QCOMPARE(m_valuesaxis->isReverse(), true); | |
|
419 | ||
|
420 | m_chart->setAxisX(m_valuesaxis, m_series); | |
|
421 | QCOMPARE(spy.count(), 1); | |
|
422 | ||
|
423 | m_view->show(); | |
|
424 | QTest::qWaitForWindowShown(m_view); | |
|
425 | QCOMPARE(m_valuesaxis->isReverse(), true); | |
|
426 | } | |
|
427 | ||
|
409 | 428 | QTEST_MAIN(tst_QValueAxis) |
|
410 | 429 | #include "tst_qvalueaxis.moc" |
|
411 | 430 |
@@ -1,73 +1,67 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | import QtQuick 2.0 |
|
20 | 20 | import QtCharts 2.0 |
|
21 | 21 | |
|
22 | 22 | ChartView { |
|
23 | 23 | id: chartView |
|
24 | 24 | title: "chart axes" |
|
25 | 25 | |
|
26 | // TODO: Do we need a property for orientation or properties "axisX" and "axisY" on ChartView | |
|
27 | // to make an axis the default axis for all series with no other axes defined...? | |
|
28 | // ValueAxis { | |
|
29 | // orientation: ValueAxis.AxisX | |
|
30 | // min: 0 | |
|
31 | // max: 10 | |
|
32 | // } | |
|
33 | // axisX: ValueAxis { | |
|
34 | // min: 0 | |
|
35 | // max: 10 | |
|
36 | // } | |
|
37 | // ...Now that we don't have this implementation, the following axes won't have any affect: | |
|
38 | 26 |
|
|
27 | id: valueAxisX | |
|
39 | 28 | min: 0 |
|
40 | 29 | max: 10 |
|
41 | 30 | } |
|
42 | 31 | ValueAxis { |
|
32 | id: valueAxisY | |
|
43 | 33 | min: 0 |
|
44 | 34 | max: 5 |
|
45 | 35 | } |
|
46 | 36 | |
|
47 | 37 | LineSeries { |
|
48 | 38 | name: "line series" |
|
49 | 39 | XYPoint { x: 0; y: 0 } |
|
50 | 40 | XYPoint { x: 1; y: 1 } |
|
51 | 41 | XYPoint { x: 2; y: 2 } |
|
52 | 42 | XYPoint { x: 3; y: 3 } |
|
53 | 43 | XYPoint { x: 4; y: 4 } |
|
44 | axisX: valueAxisX | |
|
45 | axisY: valueAxisY | |
|
54 | 46 | } |
|
55 | 47 | |
|
56 | 48 | ScatterSeries { |
|
57 | 49 | name: "scatter series" |
|
58 | 50 | XYPoint { x: 0; y: 0 } |
|
59 | 51 | XYPoint { x: 0.5; y: 1 } |
|
60 | 52 | XYPoint { x: 1; y: 2 } |
|
61 | 53 | XYPoint { x: 1.5; y: 3 } |
|
62 | 54 | XYPoint { x: 2; y: 4 } |
|
63 | 55 | XYPoint { x: 1; y: 1 } |
|
64 | 56 | XYPoint { x: 2; y: 2 } |
|
65 | 57 | XYPoint { x: 3; y: 3 } |
|
66 | 58 | XYPoint { x: 4; y: 4 } |
|
59 | axisX: valueAxisX | |
|
60 | axisY: valueAxisY | |
|
67 | 61 | } |
|
68 | 62 | |
|
69 | 63 | // Component.onCompleted: { |
|
70 | 64 | // // You can also set the axes dynamically |
|
71 | 65 | // chartView.setAxisX(axisX, scatter); |
|
72 | 66 | // } |
|
73 | 67 | } |
@@ -1,56 +1,62 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | import QtQuick 2.0 |
|
20 | 20 | import QtCharts 2.0 |
|
21 | 21 | |
|
22 | 22 | ChartView { |
|
23 | 23 | id: chartView |
|
24 | 24 | title: "chart axes reverted" |
|
25 | 25 | |
|
26 | 26 | ValueAxis { |
|
27 | id: valueAxisX | |
|
27 | 28 | min: 0 |
|
28 | 29 | max: 10 |
|
29 | 30 | } |
|
30 | 31 | ValueAxis { |
|
32 | id: valueAxisY | |
|
31 | 33 | min: 0 |
|
32 | 34 | max: 5 |
|
33 | 35 | } |
|
34 | 36 | |
|
35 | 37 | ScatterSeries { |
|
36 | 38 | name: "scatter series" |
|
37 | 39 | XYPoint { x: 0; y: 0 } |
|
38 | 40 | XYPoint { x: 0.5; y: 1 } |
|
39 | 41 | XYPoint { x: 1; y: 2 } |
|
40 | 42 | XYPoint { x: 1.5; y: 3 } |
|
41 | 43 | XYPoint { x: 2; y: 4 } |
|
42 | 44 | XYPoint { x: 1; y: 1 } |
|
43 | 45 | XYPoint { x: 2; y: 2 } |
|
44 | 46 | XYPoint { x: 3; y: 3 } |
|
45 | 47 | XYPoint { x: 4; y: 4 } |
|
48 | axisX: valueAxisX | |
|
49 | axisY: valueAxisY | |
|
46 | 50 | } |
|
47 | 51 | |
|
48 | 52 | LineSeries { |
|
49 | 53 | name: "line series" |
|
50 | 54 | XYPoint { x: 0; y: 0 } |
|
51 | 55 | XYPoint { x: 1; y: 1 } |
|
52 | 56 | XYPoint { x: 2; y: 2 } |
|
53 | 57 | XYPoint { x: 3; y: 3 } |
|
54 | 58 | XYPoint { x: 4; y: 4 } |
|
59 | axisX: valueAxisX | |
|
60 | axisY: valueAxisY | |
|
55 | 61 | } |
|
56 | 62 | } |
@@ -1,108 +1,114 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | import QtQuick 2.0 |
|
20 | 20 | import QtCharts 2.0 |
|
21 | 21 | |
|
22 | 22 | ChartView { |
|
23 | 23 | id: chartView |
|
24 | 24 | title: "Chart Title" |
|
25 | 25 | anchors.fill: parent |
|
26 | 26 | property variant chart: chartView |
|
27 | 27 | |
|
28 | 28 | LineSeries { |
|
29 | 29 | name: "line" |
|
30 | 30 | XYPoint { x: 0; y: 0 } |
|
31 | 31 | XYPoint { x: 1.1; y: 2.1 } |
|
32 | 32 | XYPoint { x: 1.9; y: 3.3 } |
|
33 | 33 | XYPoint { x: 2.1; y: 2.1 } |
|
34 | 34 | XYPoint { x: 2.9; y: 4.9 } |
|
35 | 35 | XYPoint { x: 3.4; y: 3.0 } |
|
36 | 36 | XYPoint { x: 4.1; y: 3.3 } |
|
37 | axisX: axisX | |
|
38 | axisY: axisY | |
|
37 | 39 | } |
|
38 | 40 | |
|
39 | 41 | onVisibleChanged: console.log("chart.onVisibleChanged: " + visible); |
|
40 | 42 | onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color); |
|
41 | 43 | onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + chart.backgroundColor); |
|
42 | 44 | onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled); |
|
43 | 45 | onBackgroundRoundnessChanged: console.log("chart.onBackgroundRoundnessChanged: " + diameter); |
|
44 | 46 | onSeriesAdded: console.log("chart.onSeriesAdded: " + series.name); |
|
45 | 47 | onSeriesRemoved: console.log("chart.onSeriesRemoved: " + series.name); |
|
46 | 48 | onPlotAreaColorChanged: console.log("chart.plotAreaColorChanged: " + chart.plotAreaColor); |
|
47 | 49 | |
|
48 | 50 | legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + chart.legend.visible); |
|
49 | 51 | legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible); |
|
50 | 52 | legend.onColorChanged: console.log("legend.onColorChanged: " + color); |
|
51 | 53 | legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); |
|
52 | 54 | legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color); |
|
53 | 55 | legend.onReverseMarkersChanged: console.log("legend.onReverseMarkersChanged: " |
|
54 | 56 | + chart.legend.reverseMarkers) |
|
55 | 57 | margins.onTopChanged: console.log("chart.margins.onTopChanged: " + top ); |
|
56 | 58 | margins.onBottomChanged: console.log("chart.margins.onBottomChanged: " + bottom); |
|
57 | 59 | margins.onLeftChanged: console.log("chart.margins.onLeftChanged: " + left); |
|
58 | 60 | margins.onRightChanged: console.log("chart.margins.onRightChanged: " + right); |
|
59 | 61 | onPlotAreaChanged: { |
|
60 | 62 | console.log("chart.onPlotAreaChanged, width: " + chartView.plotArea.width |
|
61 | 63 | + " height: " + chartView.plotArea.height |
|
62 | 64 | + " y: " + chartView.plotArea.y |
|
63 | 65 | + " x: " + chartView.plotArea.x); |
|
64 | 66 | marginVisualizer.opacity = 1.0; |
|
65 | 67 | } |
|
66 | 68 | |
|
67 | 69 | ValueAxis{ |
|
70 | id: axisX | |
|
68 | 71 | onColorChanged: console.log("axisX.onColorChanged: " + color); |
|
69 | 72 | onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); |
|
70 | 73 | onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color); |
|
71 | 74 | onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible); |
|
72 | 75 | onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible); |
|
73 | 76 | onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible); |
|
74 | 77 | onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color); |
|
75 | 78 | onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color); |
|
76 | 79 | onMinChanged: console.log("axisX.onMinChanged: " + min); |
|
77 | 80 | onMaxChanged: console.log("axisX.onMaxChanged: " + max); |
|
81 | onReverseChanged: console.log("axisX.onReverseChanged: " + reverse); | |
|
78 | 82 | } |
|
79 | 83 | |
|
80 | 84 | ValueAxis{ |
|
85 | id: axisY | |
|
81 | 86 | onColorChanged: console.log("axisY.onColorChanged: " + color); |
|
82 | 87 | onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible); |
|
83 | 88 | onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color); |
|
84 | 89 | onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible); |
|
85 | 90 | onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible); |
|
86 | 91 | onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible); |
|
87 | 92 | onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color); |
|
88 | 93 | onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color); |
|
89 | 94 | onMinChanged: console.log("axisY.onMinChanged: " + min); |
|
90 | 95 | onMaxChanged: console.log("axisY.onMaxChanged: " + max); |
|
96 | onReverseChanged: console.log("axisY.onReverseChanged: " + reverse); | |
|
91 | 97 | } |
|
92 | 98 | |
|
93 | 99 | Rectangle { |
|
94 | 100 | id: marginVisualizer |
|
95 | 101 | color: "transparent" |
|
96 | 102 | border.color: "red" |
|
97 | 103 | anchors.fill: parent |
|
98 | 104 | anchors.topMargin: chartView.margins.top |
|
99 | 105 | anchors.bottomMargin: chartView.margins.bottom |
|
100 | 106 | anchors.leftMargin: chartView.margins.left |
|
101 | 107 | anchors.rightMargin: chartView.margins.right |
|
102 | 108 | opacity: 0.0 |
|
103 | 109 | onOpacityChanged: if (opacity > 0.9) opacity = 0.0; |
|
104 | 110 | Behavior on opacity { |
|
105 | 111 | NumberAnimation { duration: 800 } |
|
106 | 112 | } |
|
107 | 113 | } |
|
108 | 114 | } |
@@ -1,125 +1,129 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | import QtQuick 2.0 |
|
20 | 20 | |
|
21 | 21 | Row { |
|
22 | 22 | anchors.fill: parent |
|
23 | 23 | spacing: 5 |
|
24 | 24 | property variant axis |
|
25 | 25 | |
|
26 | 26 | Flow { |
|
27 | 27 | spacing: 5 |
|
28 | 28 | flow: Flow.TopToBottom |
|
29 | 29 | height: parent.height |
|
30 | 30 | |
|
31 | 31 | Button { |
|
32 | 32 | text: "axis visible" |
|
33 | 33 | onClicked: axis.visible = !axis.visible; |
|
34 | 34 | } |
|
35 | 35 | Button { |
|
36 | 36 | text: "axis line visible" |
|
37 | 37 | onClicked: axis.lineVisible = !axis.lineVisible; |
|
38 | 38 | } |
|
39 | 39 | Button { |
|
40 | 40 | text: "axis color" |
|
41 | 41 | onClicked: axis.color = main.nextColor(); |
|
42 | 42 | } |
|
43 | 43 | Button { |
|
44 | 44 | text: "axis labels visible" |
|
45 | 45 | onClicked: axis.labelsVisible = !axis.labelsVisible; |
|
46 | 46 | } |
|
47 | 47 | Button { |
|
48 | 48 | text: "axis labels angle +" |
|
49 | 49 | onClicked: axis.labelsAngle += 5; |
|
50 | 50 | } |
|
51 | 51 | Button { |
|
52 | 52 | text: "axis labels angle -" |
|
53 | 53 | onClicked: axis.labelsAngle -= 5; |
|
54 | 54 | } |
|
55 | 55 | Button { |
|
56 | 56 | text: "axis labels color" |
|
57 | 57 | onClicked: axis.labelsColor = main.nextColor(); |
|
58 | 58 | } |
|
59 | 59 | Button { |
|
60 | 60 | text: "axis grid visible" |
|
61 | 61 | onClicked: axis.gridVisible = !axis.gridVisible; |
|
62 | 62 | } |
|
63 | 63 | Button { |
|
64 | 64 | text: "axis shades visible" |
|
65 | 65 | onClicked: axis.shadesVisible = !axis.shadesVisible; |
|
66 | 66 | } |
|
67 | 67 | Button { |
|
68 | 68 | text: "axis shades color" |
|
69 | 69 | onClicked: axis.shadesColor = main.nextColor(); |
|
70 | 70 | } |
|
71 | 71 | Button { |
|
72 | 72 | text: "axis shades bcolor" |
|
73 | 73 | onClicked: axis.shadesBorderColor = main.nextColor(); |
|
74 | 74 | } |
|
75 | 75 | Button { |
|
76 | 76 | text: "axis title text" |
|
77 | 77 | onClicked: axis.titleText = axis.titleText + "X"; |
|
78 | 78 | } |
|
79 | 79 | Button { |
|
80 | 80 | text: "axis title visible" |
|
81 | 81 | onClicked: axis.titleVisible = !axis.titleVisible; |
|
82 | 82 | } |
|
83 | 83 | Button { |
|
84 | 84 | text: "axis max +" |
|
85 | 85 | onClicked: axis.max += 0.1; |
|
86 | 86 | } |
|
87 | 87 | Button { |
|
88 | 88 | text: "axis max -" |
|
89 | 89 | onClicked: axis.max -= 0.1; |
|
90 | 90 | } |
|
91 | 91 | Button { |
|
92 | 92 | text: "axis min +" |
|
93 | 93 | onClicked: axis.min += 0.1; |
|
94 | 94 | } |
|
95 | 95 | Button { |
|
96 | 96 | text: "axis min -" |
|
97 | 97 | onClicked: axis.min -= 0.1; |
|
98 | 98 | } |
|
99 | 99 | Button { |
|
100 | 100 | text: "axis tick count +" |
|
101 | 101 | onClicked: axis.tickCount++; |
|
102 | 102 | } |
|
103 | 103 | Button { |
|
104 | 104 | text: "axis tick count -" |
|
105 | 105 | |
|
106 | 106 | onClicked: axis.tickCount--; |
|
107 | 107 | } |
|
108 | Button { | |
|
109 | text: "axis reverse" | |
|
110 | onClicked: axis.reverse = !axis.reverse; | |
|
111 | } | |
|
108 | 112 | |
|
109 | 113 | FontEditor { |
|
110 | 114 | id: fontEditor |
|
111 | 115 | fontDescription: "axis" |
|
112 | 116 | function editedFont() { |
|
113 | 117 | return axis.labelsFont; |
|
114 | 118 | } |
|
115 | 119 | } |
|
116 | 120 | |
|
117 | 121 | FontEditor { |
|
118 | 122 | id: titleFontEditor |
|
119 | 123 | fontDescription: "title" |
|
120 | 124 | function editedFont() { |
|
121 | 125 | return axis.titleFont; |
|
122 | 126 | } |
|
123 | 127 | } |
|
124 | 128 | } |
|
125 | 129 | } |
General Comments 0
You need to be logged in to leave comments.
Login now