@@ -1,281 +1,346 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativechart.h" |
|
21 | #include "declarativechart.h" | |
22 | #include <QPainter> |
|
22 | #include <QPainter> | |
23 | #include "declarativelineseries.h" |
|
23 | #include "declarativelineseries.h" | |
24 | #include "declarativeareaseries.h" |
|
24 | #include "declarativeareaseries.h" | |
25 | #include "declarativebarseries.h" |
|
25 | #include "declarativebarseries.h" | |
26 | #include "declarativepieseries.h" |
|
26 | #include "declarativepieseries.h" | |
27 | #include "declarativesplineseries.h" |
|
27 | #include "declarativesplineseries.h" | |
28 | #include "declarativescatterseries.h" |
|
28 | #include "declarativescatterseries.h" | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | /*! |
|
32 | /*! | |
33 | \qmlclass ChartView DeclarativeChart |
|
33 | \qmlclass ChartView DeclarativeChart | |
34 |
|
34 | |||
35 | ChartView element is the parent that is responsible for showing different chart series types. |
|
35 | ChartView element is the parent that is responsible for showing different chart series types. | |
36 |
|
36 | |||
37 | \section1 Example Usage |
|
37 | \section1 Example Usage | |
38 |
|
38 | |||
39 | \beginfloatleft |
|
39 | \beginfloatleft | |
40 | \image demos_qmlchart1.png |
|
40 | \image demos_qmlchart1.png | |
41 | \endfloat |
|
41 | \endfloat | |
42 | \clearfloat |
|
42 | \clearfloat | |
43 | */ |
|
43 | */ | |
44 |
|
44 | |||
45 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
|
45 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) | |
46 | : QDeclarativeItem(parent), |
|
46 | : QDeclarativeItem(parent), | |
47 | m_chart(new QChart(this)) |
|
47 | m_chart(new QChart(this)) | |
48 | { |
|
48 | { | |
49 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
49 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
50 | // m_chart->axisX()->setNiceNumbersEnabled(false); |
|
50 | // m_chart->axisX()->setNiceNumbersEnabled(false); | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 | DeclarativeChart::~DeclarativeChart() |
|
53 | DeclarativeChart::~DeclarativeChart() | |
54 | { |
|
54 | { | |
55 | delete m_chart; |
|
55 | delete m_chart; | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | void DeclarativeChart::childEvent(QChildEvent *event) |
|
58 | void DeclarativeChart::childEvent(QChildEvent *event) | |
59 | { |
|
59 | { | |
60 | if (event->type() == QEvent::ChildAdded) { |
|
60 | if (event->type() == QEvent::ChildAdded) { | |
61 | if (qobject_cast<QAbstractSeries *>(event->child())) { |
|
61 | if (qobject_cast<QAbstractSeries *>(event->child())) { | |
62 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); |
|
62 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); | |
63 | } |
|
63 | } | |
64 | } |
|
64 | } | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | void DeclarativeChart::componentComplete() |
|
67 | void DeclarativeChart::componentComplete() | |
68 | { |
|
68 | { | |
69 | // qDebug() << "DeclarativeChart::componentComplete(), maxX: " << axisX()->max(); |
|
69 | // qDebug() << "DeclarativeChart::componentComplete(), maxX: " << axisX()->max(); | |
70 | foreach(QObject *child, children()) { |
|
70 | foreach(QObject *child, children()) { | |
71 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
71 | if (qobject_cast<QAbstractSeries *>(child)) { | |
72 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; |
|
72 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; | |
73 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); |
|
73 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); | |
74 | } |
|
74 | } | |
75 | } |
|
75 | } | |
76 | // qDebug() << "DeclarativeChart::componentComplete(), maxX: " << axisX()->max(); |
|
76 | // qDebug() << "DeclarativeChart::componentComplete(), maxX: " << axisX()->max(); | |
77 |
|
77 | |||
78 | QDeclarativeItem::componentComplete(); |
|
78 | QDeclarativeItem::componentComplete(); | |
79 | } |
|
79 | } | |
80 |
|
80 | |||
81 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
81 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
82 | { |
|
82 | { | |
83 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); |
|
83 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); | |
84 | if (newGeometry.isValid()) { |
|
84 | if (newGeometry.isValid()) { | |
85 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
85 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { | |
86 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
86 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
87 | } |
|
87 | } | |
88 | } |
|
88 | } | |
89 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); |
|
89 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); | |
90 | } |
|
90 | } | |
91 |
|
91 | |||
92 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
92 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
93 | { |
|
93 | { | |
94 | Q_UNUSED(option) |
|
94 | Q_UNUSED(option) | |
95 | Q_UNUSED(widget) |
|
95 | Q_UNUSED(widget) | |
96 |
|
96 | |||
97 | // TODO: optimized? |
|
97 | // TODO: optimized? | |
98 | painter->setRenderHint(QPainter::Antialiasing, true); |
|
98 | painter->setRenderHint(QPainter::Antialiasing, true); | |
99 | } |
|
99 | } | |
100 |
|
100 | |||
101 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
|
101 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) | |
102 | { |
|
102 | { | |
103 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; |
|
103 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; | |
104 | if (chartTheme != m_chart->theme()) { |
|
104 | if (chartTheme != m_chart->theme()) { | |
105 | m_chart->setTheme(chartTheme); |
|
105 | m_chart->setTheme(chartTheme); | |
106 | themeChanged(); |
|
106 | themeChanged(); | |
107 | } |
|
107 | } | |
108 | } |
|
108 | } | |
109 |
|
109 | |||
110 | DeclarativeChart::Theme DeclarativeChart::theme() |
|
110 | DeclarativeChart::Theme DeclarativeChart::theme() | |
111 | { |
|
111 | { | |
112 | return (DeclarativeChart::Theme) m_chart->theme(); |
|
112 | return (DeclarativeChart::Theme) m_chart->theme(); | |
113 | } |
|
113 | } | |
114 |
|
114 | |||
115 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) |
|
115 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) | |
116 | { |
|
116 | { | |
117 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; |
|
117 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; | |
118 | if (animationOptions != m_chart->animationOptions()) { |
|
118 | if (animationOptions != m_chart->animationOptions()) { | |
119 | m_chart->setAnimationOptions(animationOptions); |
|
119 | m_chart->setAnimationOptions(animationOptions); | |
120 | animationOptionsChanged(); |
|
120 | animationOptionsChanged(); | |
121 | } |
|
121 | } | |
122 | } |
|
122 | } | |
123 |
|
123 | |||
124 | DeclarativeChart::Animation DeclarativeChart::animationOptions() |
|
124 | DeclarativeChart::Animation DeclarativeChart::animationOptions() | |
125 | { |
|
125 | { | |
126 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) |
|
126 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) | |
127 | return DeclarativeChart::AllAnimations; |
|
127 | return DeclarativeChart::AllAnimations; | |
128 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) |
|
128 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) | |
129 | return DeclarativeChart::GridAxisAnimations; |
|
129 | return DeclarativeChart::GridAxisAnimations; | |
130 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
130 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) | |
131 | return DeclarativeChart::SeriesAnimations; |
|
131 | return DeclarativeChart::SeriesAnimations; | |
132 | else |
|
132 | else | |
133 | return DeclarativeChart::NoAnimation; |
|
133 | return DeclarativeChart::NoAnimation; | |
134 | } |
|
134 | } | |
135 |
|
135 | |||
136 | void DeclarativeChart::setTitle(QString title) |
|
136 | void DeclarativeChart::setTitle(QString title) | |
137 | { |
|
137 | { | |
138 | if (title != m_chart->title()) { |
|
138 | if (title != m_chart->title()) { | |
139 | m_chart->setTitle(title); |
|
139 | m_chart->setTitle(title); | |
140 | emit titleChanged(); |
|
140 | emit titleChanged(); | |
141 | } |
|
141 | } | |
142 | } |
|
142 | } | |
143 | QString DeclarativeChart::title() |
|
143 | QString DeclarativeChart::title() | |
144 | { |
|
144 | { | |
145 | return m_chart->title(); |
|
145 | return m_chart->title(); | |
146 | } |
|
146 | } | |
147 |
|
147 | |||
148 | QAxis *DeclarativeChart::axisX() |
|
148 | QAxis *DeclarativeChart::axisX() | |
149 | { |
|
149 | { | |
150 | return m_chart->axisX(); |
|
150 | return m_chart->axisX(); | |
151 | } |
|
151 | } | |
152 |
|
152 | |||
153 | QAxis *DeclarativeChart::axisY() |
|
153 | QAxis *DeclarativeChart::axisY() | |
154 | { |
|
154 | { | |
155 | return m_chart->axisY(); |
|
155 | return m_chart->axisY(); | |
156 | } |
|
156 | } | |
157 |
|
157 | |||
158 | QLegend *DeclarativeChart::legend() |
|
158 | QLegend *DeclarativeChart::legend() | |
159 | { |
|
159 | { | |
160 | return m_chart->legend(); |
|
160 | return m_chart->legend(); | |
161 | } |
|
161 | } | |
162 |
|
162 | |||
163 | QVariantList DeclarativeChart::axisXLabels() |
|
163 | QVariantList DeclarativeChart::axisXLabels() | |
164 | { |
|
164 | { | |
165 | QVariantList labels; |
|
165 | QVariantList labels; | |
166 | foreach (qreal value, m_chart->axisX()->categories()->values()) { |
|
166 | foreach (qreal value, m_chart->axisX()->categories()->values()) { | |
167 | labels.append(value); |
|
167 | labels.append(value); | |
168 | labels.append(m_chart->axisX()->categories()->label(value)); |
|
168 | labels.append(m_chart->axisX()->categories()->label(value)); | |
169 | } |
|
169 | } | |
170 | return labels; |
|
170 | return labels; | |
171 | } |
|
171 | } | |
172 |
|
172 | |||
173 | void DeclarativeChart::setAxisXLabels(QVariantList list) |
|
173 | void DeclarativeChart::setAxisXLabels(QVariantList list) | |
174 | { |
|
174 | { | |
175 | QVariant value(QVariant::Invalid); |
|
175 | QVariant value(QVariant::Invalid); | |
176 | foreach (QVariant element, list) { |
|
176 | foreach (QVariant element, list) { | |
177 | if (value.isValid() && element.type() == QVariant::String) { |
|
177 | if (value.isValid() && element.type() == QVariant::String) { | |
178 | m_chart->axisX()->categories()->insert(value.toDouble(), element.toString()); |
|
178 | m_chart->axisX()->categories()->insert(value.toDouble(), element.toString()); | |
179 | value = QVariant(QVariant::Invalid); |
|
179 | value = QVariant(QVariant::Invalid); | |
180 | } else { |
|
180 | } else { | |
181 | if (element.canConvert(QVariant::Double)) |
|
181 | if (element.canConvert(QVariant::Double)) | |
182 | value = element; |
|
182 | value = element; | |
183 | } |
|
183 | } | |
184 | } |
|
184 | } | |
185 | emit axisLabelsChanged(); |
|
185 | emit axisLabelsChanged(); | |
186 | } |
|
186 | } | |
187 |
|
187 | |||
188 | void DeclarativeChart::setTitleColor(QColor color) |
|
188 | void DeclarativeChart::setTitleColor(QColor color) | |
189 | { |
|
189 | { | |
190 | QBrush b = m_chart->titleBrush(); |
|
190 | QBrush b = m_chart->titleBrush(); | |
191 | if (color != b.color()) { |
|
191 | if (color != b.color()) { | |
192 | b.setColor(color); |
|
192 | b.setColor(color); | |
193 | m_chart->setTitleBrush(b); |
|
193 | m_chart->setTitleBrush(b); | |
194 | emit titleColorChanged(); |
|
194 | emit titleColorChanged(); | |
195 | } |
|
195 | } | |
196 | } |
|
196 | } | |
197 |
|
197 | |||
198 | QColor DeclarativeChart::titleColor() |
|
198 | QColor DeclarativeChart::titleColor() | |
199 | { |
|
199 | { | |
200 | return m_chart->titleBrush().color(); |
|
200 | return m_chart->titleBrush().color(); | |
201 | } |
|
201 | } | |
202 |
|
202 | |||
203 | void DeclarativeChart::setBackgroundColor(QColor color) |
|
203 | void DeclarativeChart::setBackgroundColor(QColor color) | |
204 | { |
|
204 | { | |
205 | QBrush b = m_chart->backgroundBrush(); |
|
205 | QBrush b = m_chart->backgroundBrush(); | |
206 | if (color != b.color()) { |
|
206 | if (color != b.color()) { | |
207 | b.setColor(color); |
|
207 | b.setColor(color); | |
208 | m_chart->setBackgroundBrush(b); |
|
208 | m_chart->setBackgroundBrush(b); | |
209 | emit backgroundColorChanged(); |
|
209 | emit backgroundColorChanged(); | |
210 | } |
|
210 | } | |
211 | } |
|
211 | } | |
212 |
|
212 | |||
213 | QColor DeclarativeChart::backgroundColor() |
|
213 | QColor DeclarativeChart::backgroundColor() | |
214 | { |
|
214 | { | |
215 | return m_chart->backgroundBrush().color(); |
|
215 | return m_chart->backgroundBrush().color(); | |
216 | } |
|
216 | } | |
217 |
|
217 | |||
218 | int DeclarativeChart::count() |
|
218 | int DeclarativeChart::count() | |
219 | { |
|
219 | { | |
220 | return m_chart->series().count(); |
|
220 | return m_chart->series().count(); | |
221 | } |
|
221 | } | |
222 |
|
222 | |||
|
223 | void DeclarativeChart::setDropShadowEnabled(bool enabled) | |||
|
224 | { | |||
|
225 | if (enabled != m_chart->isBackgroundDropShadowEnabled()) { | |||
|
226 | m_chart->setBackgroundDropShadowEnabled(enabled); | |||
|
227 | dropShadowEnabledChanged(enabled); | |||
|
228 | } | |||
|
229 | } | |||
|
230 | ||||
|
231 | bool DeclarativeChart::dropShadowEnabled() | |||
|
232 | { | |||
|
233 | return m_chart->isBackgroundDropShadowEnabled(); | |||
|
234 | } | |||
|
235 | ||||
|
236 | void DeclarativeChart::zoom(qreal factor) | |||
|
237 | { | |||
|
238 | m_chart->zoom(factor); | |||
|
239 | } | |||
|
240 | ||||
|
241 | void DeclarativeChart::scrollLeft(qreal pixels) | |||
|
242 | { | |||
|
243 | m_chart->scroll(QPointF(pixels, 0)); | |||
|
244 | } | |||
|
245 | ||||
|
246 | void DeclarativeChart::scrollRight(qreal pixels) | |||
|
247 | { | |||
|
248 | m_chart->scroll(QPointF(-pixels, 0)); | |||
|
249 | } | |||
|
250 | ||||
|
251 | void DeclarativeChart::scrollUp(qreal pixels) | |||
|
252 | { | |||
|
253 | m_chart->scroll(QPointF(0, pixels)); | |||
|
254 | } | |||
|
255 | ||||
|
256 | void DeclarativeChart::scrollDown(qreal pixels) | |||
|
257 | { | |||
|
258 | m_chart->scroll(QPointF(0, -pixels)); | |||
|
259 | } | |||
|
260 | ||||
|
261 | //void DeclarativeChart::scrollLeft(qreal ticks) | |||
|
262 | //{ | |||
|
263 | // m_chart->scroll(QPointF(ticksToPixels(m_chart->axisX(), ticks), 0)); | |||
|
264 | //} | |||
|
265 | ||||
|
266 | //void DeclarativeChart::scrollRight(qreal ticks) | |||
|
267 | //{ | |||
|
268 | // m_chart->scroll(QPointF(-ticksToPixels(m_chart->axisX(), ticks), 0)); | |||
|
269 | //} | |||
|
270 | ||||
|
271 | //void DeclarativeChart::scrollUp(qreal ticks) | |||
|
272 | //{ | |||
|
273 | // m_chart->scroll(QPointF(0, ticksToPixels(m_chart->axisY(), ticks))); | |||
|
274 | //} | |||
|
275 | ||||
|
276 | //void DeclarativeChart::scrollDown(qreal ticks) | |||
|
277 | //{ | |||
|
278 | // m_chart->scroll(QPointF(0, -ticksToPixels(m_chart->axisY(), ticks))); | |||
|
279 | //} | |||
|
280 | ||||
|
281 | //qreal DeclarativeChart::ticksToPixels(QAxis *axis, qreal ticks) | |||
|
282 | //{ | |||
|
283 | // qreal tickCount = axis->max() - axis->min(); | |||
|
284 | // qreal tickPixels = (m_chart->size().width() - m_chart->margins().width() * 2) / tickCount; | |||
|
285 | // return tickPixels * ticks; | |||
|
286 | //} | |||
|
287 | ||||
223 | QAbstractSeries *DeclarativeChart::series(int index) |
|
288 | QAbstractSeries *DeclarativeChart::series(int index) | |
224 | { |
|
289 | { | |
225 | if (index < m_chart->series().count()) { |
|
290 | if (index < m_chart->series().count()) { | |
226 | return m_chart->series().at(index); |
|
291 | return m_chart->series().at(index); | |
227 | } |
|
292 | } | |
228 | return 0; |
|
293 | return 0; | |
229 | } |
|
294 | } | |
230 |
|
295 | |||
231 | QAbstractSeries *DeclarativeChart::series(QString seriesName) |
|
296 | QAbstractSeries *DeclarativeChart::series(QString seriesName) | |
232 | { |
|
297 | { | |
233 | foreach(QAbstractSeries *series, m_chart->series()) { |
|
298 | foreach(QAbstractSeries *series, m_chart->series()) { | |
234 | if (series->name() == seriesName) |
|
299 | if (series->name() == seriesName) | |
235 | return series; |
|
300 | return series; | |
236 | } |
|
301 | } | |
237 | return 0; |
|
302 | return 0; | |
238 | } |
|
303 | } | |
239 |
|
304 | |||
240 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) |
|
305 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) | |
241 | { |
|
306 | { | |
242 | QAbstractSeries *series = 0; |
|
307 | QAbstractSeries *series = 0; | |
243 | switch (type) { |
|
308 | switch (type) { | |
244 | case DeclarativeChart::SeriesTypeLine: |
|
309 | case DeclarativeChart::SeriesTypeLine: | |
245 | series = new DeclarativeLineSeries(); |
|
310 | series = new DeclarativeLineSeries(); | |
246 | break; |
|
311 | break; | |
247 | case DeclarativeChart::SeriesTypeArea: |
|
312 | case DeclarativeChart::SeriesTypeArea: | |
248 | series = new DeclarativeAreaSeries(); |
|
313 | series = new DeclarativeAreaSeries(); | |
249 | break; |
|
314 | break; | |
250 | case DeclarativeChart::SeriesTypeBar: |
|
315 | case DeclarativeChart::SeriesTypeBar: | |
251 | series = new DeclarativeBarSeries(); |
|
316 | series = new DeclarativeBarSeries(); | |
252 | break; |
|
317 | break; | |
253 | case DeclarativeChart::SeriesTypeStackedBar: |
|
318 | case DeclarativeChart::SeriesTypeStackedBar: | |
254 | // TODO |
|
319 | // TODO | |
255 | break; |
|
320 | break; | |
256 | case DeclarativeChart::SeriesTypePercentBar: |
|
321 | case DeclarativeChart::SeriesTypePercentBar: | |
257 | // TODO |
|
322 | // TODO | |
258 | break; |
|
323 | break; | |
259 | case DeclarativeChart::SeriesTypeGroupedBar: |
|
324 | case DeclarativeChart::SeriesTypeGroupedBar: | |
260 | series = new DeclarativeGroupedBarSeries(); |
|
325 | series = new DeclarativeGroupedBarSeries(); | |
261 | break; |
|
326 | break; | |
262 | case DeclarativeChart::SeriesTypePie: |
|
327 | case DeclarativeChart::SeriesTypePie: | |
263 | series = new DeclarativePieSeries(); |
|
328 | series = new DeclarativePieSeries(); | |
264 | break; |
|
329 | break; | |
265 | case DeclarativeChart::SeriesTypeScatter: |
|
330 | case DeclarativeChart::SeriesTypeScatter: | |
266 | series = new DeclarativeScatterSeries(); |
|
331 | series = new DeclarativeScatterSeries(); | |
267 | break; |
|
332 | break; | |
268 | case DeclarativeChart::SeriesTypeSpline: |
|
333 | case DeclarativeChart::SeriesTypeSpline: | |
269 | series = new DeclarativeSplineSeries(); |
|
334 | series = new DeclarativeSplineSeries(); | |
270 | break; |
|
335 | break; | |
271 | default: |
|
336 | default: | |
272 | qWarning() << "Illegal series type"; |
|
337 | qWarning() << "Illegal series type"; | |
273 | } |
|
338 | } | |
274 | series->setName(name); |
|
339 | series->setName(name); | |
275 | m_chart->addSeries(series); |
|
340 | m_chart->addSeries(series); | |
276 | return series; |
|
341 | return series; | |
277 | } |
|
342 | } | |
278 |
|
343 | |||
279 | #include "moc_declarativechart.cpp" |
|
344 | #include "moc_declarativechart.cpp" | |
280 |
|
345 | |||
281 | QTCOMMERCIALCHART_END_NAMESPACE |
|
346 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,130 +1,139 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVECHART_H |
|
21 | #ifndef DECLARATIVECHART_H | |
22 | #define DECLARATIVECHART_H |
|
22 | #define DECLARATIVECHART_H | |
23 |
|
23 | |||
24 | #include <QtCore/QtGlobal> |
|
24 | #include <QtCore/QtGlobal> | |
25 | #include <QDeclarativeItem> |
|
25 | #include <QDeclarativeItem> | |
26 | #include <qchart.h> |
|
26 | #include <qchart.h> | |
27 | #include <QAxis> |
|
27 | #include <QAxis> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | // TODO: Derive from QChart for easier definition of properties? |
|
31 | // TODO: Derive from QChart for easier definition of properties? | |
32 | class DeclarativeChart : public QDeclarativeItem |
|
32 | class DeclarativeChart : public QDeclarativeItem | |
33 | // TODO: for QTQUICK2: extend QQuickPainterItem instead |
|
33 | // TODO: for QTQUICK2: extend QQuickPainterItem instead | |
34 | //class DeclarativeChart : public QQuickPaintedItem, public Chart |
|
34 | //class DeclarativeChart : public QQuickPaintedItem, public Chart | |
35 | { |
|
35 | { | |
36 | Q_OBJECT |
|
36 | Q_OBJECT | |
37 | Q_PROPERTY(Theme theme READ theme WRITE setTheme NOTIFY themeChanged) |
|
37 | Q_PROPERTY(Theme theme READ theme WRITE setTheme NOTIFY themeChanged) | |
38 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions NOTIFY animationOptionsChanged) |
|
38 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions NOTIFY animationOptionsChanged) | |
39 | Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) |
|
39 | Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) | |
|
40 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) | |||
40 | Q_PROPERTY(QAxis *axisX READ axisX) |
|
41 | Q_PROPERTY(QAxis *axisX READ axisX) | |
41 | Q_PROPERTY(QAxis *axisY READ axisY) |
|
42 | Q_PROPERTY(QAxis *axisY READ axisY) | |
42 | Q_PROPERTY(QLegend *legend READ legend) |
|
43 | Q_PROPERTY(QLegend *legend READ legend) | |
43 | // TODO: how to define axis labels? This is not very convenient |
|
44 | // TODO: how to define axis labels? This is not very convenient | |
44 | Q_PROPERTY(QVariantList axisXLabels READ axisXLabels WRITE setAxisXLabels NOTIFY axisLabelsChanged) |
|
45 | Q_PROPERTY(QVariantList axisXLabels READ axisXLabels WRITE setAxisXLabels NOTIFY axisLabelsChanged) | |
45 | Q_PROPERTY(int count READ count) |
|
46 | Q_PROPERTY(int count READ count) | |
46 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) |
|
|||
47 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) |
|
47 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) | |
|
48 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) | |||
48 | Q_ENUMS(Animation) |
|
49 | Q_ENUMS(Animation) | |
49 | Q_ENUMS(Theme) |
|
50 | Q_ENUMS(Theme) | |
50 | Q_ENUMS(SeriesType) |
|
51 | Q_ENUMS(SeriesType) | |
51 |
|
52 | |||
52 | public: |
|
53 | public: | |
53 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api |
|
54 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api | |
54 | enum Theme { |
|
55 | enum Theme { | |
55 | ChartThemeLight = 0, |
|
56 | ChartThemeLight = 0, | |
56 | ChartThemeBlueCerulean, |
|
57 | ChartThemeBlueCerulean, | |
57 | ChartThemeDark, |
|
58 | ChartThemeDark, | |
58 | ChartThemeBrownSand, |
|
59 | ChartThemeBrownSand, | |
59 | ChartThemeBlueNcs, |
|
60 | ChartThemeBlueNcs, | |
60 | ChartThemeHighContrast, |
|
61 | ChartThemeHighContrast, | |
61 | ChartThemeBlueIcy |
|
62 | ChartThemeBlueIcy | |
62 | }; |
|
63 | }; | |
63 |
|
64 | |||
64 | enum Animation { |
|
65 | enum Animation { | |
65 | NoAnimation = 0x0, |
|
66 | NoAnimation = 0x0, | |
66 | GridAxisAnimations = 0x1, |
|
67 | GridAxisAnimations = 0x1, | |
67 | SeriesAnimations =0x2, |
|
68 | SeriesAnimations =0x2, | |
68 | AllAnimations = 0x3 |
|
69 | AllAnimations = 0x3 | |
69 | }; |
|
70 | }; | |
70 |
|
71 | |||
71 | enum SeriesType { |
|
72 | enum SeriesType { | |
72 | SeriesTypeLine, |
|
73 | SeriesTypeLine, | |
73 | SeriesTypeArea, |
|
74 | SeriesTypeArea, | |
74 | SeriesTypeBar, |
|
75 | SeriesTypeBar, | |
75 | SeriesTypeStackedBar, |
|
76 | SeriesTypeStackedBar, | |
76 | SeriesTypePercentBar, |
|
77 | SeriesTypePercentBar, | |
77 | SeriesTypeGroupedBar, |
|
78 | SeriesTypeGroupedBar, | |
78 | SeriesTypePie, |
|
79 | SeriesTypePie, | |
79 | SeriesTypeScatter, |
|
80 | SeriesTypeScatter, | |
80 | SeriesTypeSpline |
|
81 | SeriesTypeSpline | |
81 | }; |
|
82 | }; | |
82 |
|
83 | |||
83 | public: |
|
84 | public: | |
84 | DeclarativeChart(QDeclarativeItem *parent = 0); |
|
85 | DeclarativeChart(QDeclarativeItem *parent = 0); | |
85 | ~DeclarativeChart(); |
|
86 | ~DeclarativeChart(); | |
86 |
|
87 | |||
87 | public: // From QDeclarativeItem/QGraphicsItem |
|
88 | public: // From QDeclarativeItem/QGraphicsItem | |
88 | void childEvent(QChildEvent *event); |
|
89 | void childEvent(QChildEvent *event); | |
89 | void componentComplete(); |
|
90 | void componentComplete(); | |
90 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); |
|
91 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); | |
91 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
92 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
92 |
|
93 | |||
93 | public: |
|
94 | public: | |
94 | void setTheme(DeclarativeChart::Theme theme); |
|
95 | void setTheme(DeclarativeChart::Theme theme); | |
95 | DeclarativeChart::Theme theme(); |
|
96 | DeclarativeChart::Theme theme(); | |
96 | void setAnimationOptions(DeclarativeChart::Animation animations); |
|
97 | void setAnimationOptions(DeclarativeChart::Animation animations); | |
97 | DeclarativeChart::Animation animationOptions(); |
|
98 | DeclarativeChart::Animation animationOptions(); | |
98 | void setTitle(QString title); |
|
99 | void setTitle(QString title); | |
99 | QString title(); |
|
100 | QString title(); | |
100 | QAxis *axisX(); |
|
101 | QAxis *axisX(); | |
101 | QAxis *axisY(); |
|
102 | QAxis *axisY(); | |
102 | QLegend *legend(); |
|
103 | QLegend *legend(); | |
103 | QVariantList axisXLabels(); |
|
104 | QVariantList axisXLabels(); | |
104 | void setAxisXLabels(QVariantList list); |
|
105 | void setAxisXLabels(QVariantList list); | |
105 | void setTitleColor(QColor color); |
|
106 | void setTitleColor(QColor color); | |
106 | QColor titleColor(); |
|
107 | QColor titleColor(); | |
107 | void setBackgroundColor(QColor color); |
|
108 | void setBackgroundColor(QColor color); | |
108 | QColor backgroundColor(); |
|
109 | QColor backgroundColor(); | |
109 | int count(); |
|
110 | int count(); | |
|
111 | void setDropShadowEnabled(bool enabled); | |||
|
112 | bool dropShadowEnabled(); | |||
|
113 | Q_INVOKABLE void zoom(qreal factor); | |||
|
114 | Q_INVOKABLE void scrollLeft(qreal pixels); | |||
|
115 | Q_INVOKABLE void scrollRight(qreal pixels); | |||
|
116 | Q_INVOKABLE void scrollUp(qreal pixels); | |||
|
117 | Q_INVOKABLE void scrollDown(qreal pixels); | |||
110 | Q_INVOKABLE QAbstractSeries *series(int index); |
|
118 | Q_INVOKABLE QAbstractSeries *series(int index); | |
111 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); |
|
119 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); | |
112 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); |
|
120 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); | |
113 |
|
121 | |||
114 | Q_SIGNALS: |
|
122 | Q_SIGNALS: | |
115 | void themeChanged(); |
|
123 | void themeChanged(); | |
116 | void animationOptionsChanged(); |
|
124 | void animationOptionsChanged(); | |
117 | void titleChanged(); |
|
125 | void titleChanged(); | |
118 | void axisLabelsChanged(); |
|
126 | void axisLabelsChanged(); | |
119 | void titleColorChanged(); |
|
127 | void titleColorChanged(); | |
120 | void backgroundColorChanged(); |
|
128 | void backgroundColorChanged(); | |
|
129 | void dropShadowEnabledChanged(bool enabled); | |||
121 |
|
130 | |||
122 | public: |
|
131 | public: | |
123 | // Extending QChart with DeclarativeChart is not possible because QObject does not support |
|
132 | // Extending QChart with DeclarativeChart is not possible because QObject does not support | |
124 | // multi inheritance, so we now have a QChart as a member instead |
|
133 | // multi inheritance, so we now have a QChart as a member instead | |
125 | QChart *m_chart; |
|
134 | QChart *m_chart; | |
126 | }; |
|
135 | }; | |
127 |
|
136 | |||
128 | QTCOMMERCIALCHART_END_NAMESPACE |
|
137 | QTCOMMERCIALCHART_END_NAMESPACE | |
129 |
|
138 | |||
130 | #endif // DECLARATIVECHART_H |
|
139 | #endif // DECLARATIVECHART_H |
@@ -1,254 +1,283 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | Flow { |
|
25 | Flow { | |
26 | id: flow |
|
26 | id: flow | |
27 | spacing: 5 |
|
27 | spacing: 5 | |
28 | flow: Flow.TopToBottom |
|
28 | flow: Flow.TopToBottom | |
29 | property variant series // TODO: rename to chart |
|
29 | property variant series // TODO: rename to chart | |
30 |
|
30 | |||
31 | onSeriesChanged: { |
|
31 | onSeriesChanged: { | |
32 | legendConnections.target = series.legend; |
|
32 | legendConnections.target = series.legend; | |
33 | axisXConnections.target = series.axisX; |
|
33 | axisXConnections.target = series.axisX; | |
34 | axisYConnections.target = series.axisY; |
|
34 | axisYConnections.target = series.axisY; | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | Connections { |
|
37 | Connections { | |
38 | target: series |
|
38 | target: series | |
39 | ignoreUnknownSignals: true |
|
39 | ignoreUnknownSignals: true | |
40 | onVisibleChanged: console.log("chart.onVisibleChanged: " + series.visible); |
|
40 | onVisibleChanged: console.log("chart.onVisibleChanged: " + series.visible); | |
41 | onThemeChanged: console.log("chart.onThemeChanged: " + series.theme); |
|
41 | onThemeChanged: console.log("chart.onThemeChanged: " + series.theme); | |
42 | onLegendChanged: console.log("chart.onLegendChanged: " + series.legend); |
|
42 | onLegendChanged: console.log("chart.onLegendChanged: " + series.legend); | |
43 | onAnimationOptionsChanged: console.log("chart.onAnimationOptionsChanged: " + series.animationOptions); |
|
43 | onAnimationOptionsChanged: console.log("chart.onAnimationOptionsChanged: " + series.animationOptions); | |
44 | onTitleColorChanged: console.log("chart.onTitleColorChanged: " + series.titleColor); |
|
44 | onTitleColorChanged: console.log("chart.onTitleColorChanged: " + series.titleColor); | |
45 | onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor); |
|
45 | onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor); | |
|
46 | onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled); | |||
46 | } |
|
47 | } | |
47 |
|
48 | |||
48 | Connections { |
|
49 | Connections { | |
49 | id: legendConnections |
|
50 | id: legendConnections | |
50 | ignoreUnknownSignals: true |
|
51 | ignoreUnknownSignals: true | |
51 | onAlignmentChanged: console.log("legend.onAlignmentChanged: " + alignment); |
|
52 | onAlignmentChanged: console.log("legend.onAlignmentChanged: " + alignment); | |
52 | onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible); |
|
53 | onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible); | |
53 | onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible); |
|
54 | onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible); | |
54 | onColorChanged: console.log("legend.onColorChanged: " + color); |
|
55 | onColorChanged: console.log("legend.onColorChanged: " + color); | |
55 | onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); |
|
56 | onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); | |
56 | } |
|
57 | } | |
57 |
|
58 | |||
58 | Connections { |
|
59 | Connections { | |
59 | id: axisXConnections |
|
60 | id: axisXConnections | |
60 | ignoreUnknownSignals: true |
|
61 | ignoreUnknownSignals: true | |
61 | onColorChanged: console.log("axisX.onColorChanged: " + color); |
|
62 | onColorChanged: console.log("axisX.onColorChanged: " + color); | |
62 | onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); |
|
63 | onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); | |
63 | onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color); |
|
64 | onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color); | |
64 | onLabelsAngleChanged: console.log("axisX.onLabelsAngleChanged: " + angle); |
|
65 | onLabelsAngleChanged: console.log("axisX.onLabelsAngleChanged: " + angle); | |
65 | onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible); |
|
66 | onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible); | |
66 | onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible); |
|
67 | onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible); | |
67 | onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible); |
|
68 | onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible); | |
68 | onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color); |
|
69 | onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color); | |
69 | onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color); |
|
70 | onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color); | |
70 | onNiceNumbersEnabledChanged: console.log("axisX.onNiceNumbersEnabledChanged: " + enabled); |
|
71 | onNiceNumbersEnabledChanged: console.log("axisX.onNiceNumbersEnabledChanged: " + enabled); | |
71 | onTicksCountChanged: console.log("axisX.onTicksCountChanged: " + count); |
|
72 | onTicksCountChanged: console.log("axisX.onTicksCountChanged: " + count); | |
72 | } |
|
73 | } | |
73 |
|
74 | |||
74 | Connections { |
|
75 | Connections { | |
75 | id: axisYConnections |
|
76 | id: axisYConnections | |
76 | ignoreUnknownSignals: true |
|
77 | ignoreUnknownSignals: true | |
77 | onColorChanged: console.log("axisY.onColorChanged: " + color); |
|
78 | onColorChanged: console.log("axisY.onColorChanged: " + color); | |
78 | onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible); |
|
79 | onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible); | |
79 | onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color); |
|
80 | onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color); | |
80 | onLabelsAngleChanged: console.log("axisY.onLabelsAngleChanged: " + angle); |
|
81 | onLabelsAngleChanged: console.log("axisY.onLabelsAngleChanged: " + angle); | |
81 | onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible); |
|
82 | onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible); | |
82 | onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible); |
|
83 | onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible); | |
83 | onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible); |
|
84 | onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible); | |
84 | onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color); |
|
85 | onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color); | |
85 | onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color); |
|
86 | onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color); | |
86 | onNiceNumbersEnabledChanged: console.log("axisY.onNiceNumbersEnabledChanged: " + enabled); |
|
87 | onNiceNumbersEnabledChanged: console.log("axisY.onNiceNumbersEnabledChanged: " + enabled); | |
87 | onTicksCountChanged: console.log("axisY.onTicksCountChanged: " + count); |
|
88 | onTicksCountChanged: console.log("axisY.onTicksCountChanged: " + count); | |
88 | } |
|
89 | } | |
89 |
|
90 | |||
90 | Button { |
|
91 | Button { | |
91 | text: "visible" |
|
92 | text: "visible" | |
92 | onClicked: series.visible = !series.visible; |
|
93 | onClicked: series.visible = !series.visible; | |
93 | } |
|
94 | } | |
94 | Button { |
|
95 | Button { | |
95 | text: "theme +" |
|
96 | text: "theme +" | |
96 | onClicked: series.theme++; |
|
97 | onClicked: series.theme++; | |
97 | } |
|
98 | } | |
98 | Button { |
|
99 | Button { | |
99 | text: "theme -" |
|
100 | text: "theme -" | |
100 | onClicked: series.theme--; |
|
101 | onClicked: series.theme--; | |
101 | } |
|
102 | } | |
102 | Button { |
|
103 | Button { | |
103 | text: "animation opt +" |
|
104 | text: "animation opt +" | |
104 | onClicked: series.animationOptions++; |
|
105 | onClicked: series.animationOptions++; | |
105 | } |
|
106 | } | |
106 | Button { |
|
107 | Button { | |
107 | text: "animation opt -" |
|
108 | text: "animation opt -" | |
108 | onClicked: series.animationOptions--; |
|
109 | onClicked: series.animationOptions--; | |
109 | } |
|
110 | } | |
110 | Button { |
|
111 | Button { | |
111 | text: "title color" |
|
112 | text: "title color" | |
112 | onClicked: series.titleColor = main.nextColor(); |
|
113 | onClicked: series.titleColor = main.nextColor(); | |
113 | } |
|
114 | } | |
114 | Button { |
|
115 | Button { | |
115 | text: "background color" |
|
116 | text: "background color" | |
116 | onClicked: series.backgroundColor = main.nextColor(); |
|
117 | onClicked: series.backgroundColor = main.nextColor(); | |
117 | } |
|
118 | } | |
118 | Button { |
|
119 | Button { | |
|
120 | text: "drop shadow enabled" | |||
|
121 | onClicked: series.dropShadowEnabled = !series.dropShadowEnabled; | |||
|
122 | } | |||
|
123 | Button { | |||
|
124 | text: "zoom +" | |||
|
125 | onClicked: series.zoom(2); | |||
|
126 | } | |||
|
127 | Button { | |||
|
128 | text: "zoom -" | |||
|
129 | onClicked: series.zoom(0.5); | |||
|
130 | } | |||
|
131 | Button { | |||
|
132 | text: "scroll left" | |||
|
133 | onClicked: series.scrollLeft(10); | |||
|
134 | } | |||
|
135 | Button { | |||
|
136 | text: "scroll right" | |||
|
137 | onClicked: series.scrollRight(10); | |||
|
138 | } | |||
|
139 | Button { | |||
|
140 | text: "scroll up" | |||
|
141 | onClicked: series.scrollUp(10); | |||
|
142 | } | |||
|
143 | Button { | |||
|
144 | text: "scroll down" | |||
|
145 | onClicked: series.scrollDown(10); | |||
|
146 | } | |||
|
147 | Button { | |||
119 | text: "legend visible" |
|
148 | text: "legend visible" | |
120 | onClicked: series.legend.visible = !series.legend.visible; |
|
149 | onClicked: series.legend.visible = !series.legend.visible; | |
121 | } |
|
150 | } | |
122 | Button { |
|
151 | Button { | |
123 | text: "legend bckgrd visible" |
|
152 | text: "legend bckgrd visible" | |
124 | onClicked: series.legend.backgroundVisible = !series.legend.backgroundVisible; |
|
153 | onClicked: series.legend.backgroundVisible = !series.legend.backgroundVisible; | |
125 | } |
|
154 | } | |
126 | Button { |
|
155 | Button { | |
127 | text: "legend color" |
|
156 | text: "legend color" | |
128 | onClicked: series.legend.color = main.nextColor(); |
|
157 | onClicked: series.legend.color = main.nextColor(); | |
129 | } |
|
158 | } | |
130 | Button { |
|
159 | Button { | |
131 | text: "legend border color" |
|
160 | text: "legend border color" | |
132 | onClicked: series.legend.borderColor = main.nextColor(); |
|
161 | onClicked: series.legend.borderColor = main.nextColor(); | |
133 | } |
|
162 | } | |
134 | Button { |
|
163 | Button { | |
135 | text: "legend top" |
|
164 | text: "legend top" | |
136 | onClicked: series.legend.alignment ^= Qt.AlignTop; |
|
165 | onClicked: series.legend.alignment ^= Qt.AlignTop; | |
137 | } |
|
166 | } | |
138 | Button { |
|
167 | Button { | |
139 | text: "legend bottom" |
|
168 | text: "legend bottom" | |
140 | onClicked: series.legend.alignment ^= Qt.AlignBottom; |
|
169 | onClicked: series.legend.alignment ^= Qt.AlignBottom; | |
141 | } |
|
170 | } | |
142 | Button { |
|
171 | Button { | |
143 | text: "legend left" |
|
172 | text: "legend left" | |
144 | onClicked: series.legend.alignment ^= Qt.AlignLeft; |
|
173 | onClicked: series.legend.alignment ^= Qt.AlignLeft; | |
145 | } |
|
174 | } | |
146 | Button { |
|
175 | Button { | |
147 | text: "legend right" |
|
176 | text: "legend right" | |
148 | onClicked: series.legend.alignment ^= Qt.AlignRight; |
|
177 | onClicked: series.legend.alignment ^= Qt.AlignRight; | |
149 | } |
|
178 | } | |
150 | Button { |
|
179 | Button { | |
151 | text: "axis X nice nmb" |
|
180 | text: "axis X nice nmb" | |
152 | onClicked: series.axisX.niceNumbersEnabled = !series.axisX.niceNumbersEnabled; |
|
181 | onClicked: series.axisX.niceNumbersEnabled = !series.axisX.niceNumbersEnabled; | |
153 | } |
|
182 | } | |
154 | Button { |
|
183 | Button { | |
155 | text: "axis X visible" |
|
184 | text: "axis X visible" | |
156 | onClicked: series.axisX.visible = !series.axisX.visible; |
|
185 | onClicked: series.axisX.visible = !series.axisX.visible; | |
157 | } |
|
186 | } | |
158 | Button { |
|
187 | Button { | |
159 | text: "axis X grid visible" |
|
188 | text: "axis X grid visible" | |
160 | onClicked: series.axisX.gridVisible = !series.axisX.gridVisible; |
|
189 | onClicked: series.axisX.gridVisible = !series.axisX.gridVisible; | |
161 | } |
|
190 | } | |
162 | Button { |
|
191 | Button { | |
163 | text: "axis X labels visible" |
|
192 | text: "axis X labels visible" | |
164 | onClicked: series.axisX.labelsVisible = !series.axisX.labelsVisible; |
|
193 | onClicked: series.axisX.labelsVisible = !series.axisX.labelsVisible; | |
165 | } |
|
194 | } | |
166 | Button { |
|
195 | Button { | |
167 | text: "axis X color" |
|
196 | text: "axis X color" | |
168 | onClicked: series.axisX.color = main.nextColor(); |
|
197 | onClicked: series.axisX.color = main.nextColor(); | |
169 | } |
|
198 | } | |
170 | Button { |
|
199 | Button { | |
171 | text: "axis X labels color" |
|
200 | text: "axis X labels color" | |
172 | onClicked: series.axisX.labelsColor = main.nextColor(); |
|
201 | onClicked: series.axisX.labelsColor = main.nextColor(); | |
173 | } |
|
202 | } | |
174 | Button { |
|
203 | Button { | |
175 | text: "axis X labels angle +" |
|
204 | text: "axis X labels angle +" | |
176 | onClicked: series.axisX.labelsAngle += 5; |
|
205 | onClicked: series.axisX.labelsAngle += 5; | |
177 | } |
|
206 | } | |
178 | Button { |
|
207 | Button { | |
179 | text: "axis X labels angle -" |
|
208 | text: "axis X labels angle -" | |
180 | onClicked: series.axisX.labelsAngle -= 5; |
|
209 | onClicked: series.axisX.labelsAngle -= 5; | |
181 | } |
|
210 | } | |
182 | Button { |
|
211 | Button { | |
183 | text: "axis X shades visible" |
|
212 | text: "axis X shades visible" | |
184 | onClicked: series.axisX.shadesVisible = !series.axisX.shadesVisible; |
|
213 | onClicked: series.axisX.shadesVisible = !series.axisX.shadesVisible; | |
185 | } |
|
214 | } | |
186 | Button { |
|
215 | Button { | |
187 | text: "axis X shades color" |
|
216 | text: "axis X shades color" | |
188 | onClicked: series.axisX.shadesColor = main.nextColor(); |
|
217 | onClicked: series.axisX.shadesColor = main.nextColor(); | |
189 | } |
|
218 | } | |
190 | Button { |
|
219 | Button { | |
191 | text: "axis X shades bcolor" |
|
220 | text: "axis X shades bcolor" | |
192 | onClicked: series.axisX.shadesBorderColor = main.nextColor(); |
|
221 | onClicked: series.axisX.shadesBorderColor = main.nextColor(); | |
193 | } |
|
222 | } | |
194 | Button { |
|
223 | Button { | |
195 | text: "axis X ticks count +" |
|
224 | text: "axis X ticks count +" | |
196 | onClicked: series.axisX.ticksCount++; |
|
225 | onClicked: series.axisX.ticksCount++; | |
197 | } |
|
226 | } | |
198 | Button { |
|
227 | Button { | |
199 | text: "axis X ticks count -" |
|
228 | text: "axis X ticks count -" | |
200 | onClicked: series.axisX.ticksCount--; |
|
229 | onClicked: series.axisX.ticksCount--; | |
201 | } |
|
230 | } | |
202 | Button { |
|
231 | Button { | |
203 | text: "axis Y nice nmb" |
|
232 | text: "axis Y nice nmb" | |
204 | onClicked: series.axisY.niceNumbersEnabled = !series.axisY.niceNumbersEnabled; |
|
233 | onClicked: series.axisY.niceNumbersEnabled = !series.axisY.niceNumbersEnabled; | |
205 | } |
|
234 | } | |
206 | Button { |
|
235 | Button { | |
207 | text: "axis Y visible" |
|
236 | text: "axis Y visible" | |
208 | onClicked: series.axisY.visible = !series.axisY.visible; |
|
237 | onClicked: series.axisY.visible = !series.axisY.visible; | |
209 | } |
|
238 | } | |
210 | Button { |
|
239 | Button { | |
211 | text: "axis Y grid visible" |
|
240 | text: "axis Y grid visible" | |
212 | onClicked: series.axisY.gridVisible = !series.axisY.gridVisible; |
|
241 | onClicked: series.axisY.gridVisible = !series.axisY.gridVisible; | |
213 | } |
|
242 | } | |
214 | Button { |
|
243 | Button { | |
215 | text: "axis Y labels visible" |
|
244 | text: "axis Y labels visible" | |
216 | onClicked: series.axisY.labelsVisible = !series.axisY.labelsVisible; |
|
245 | onClicked: series.axisY.labelsVisible = !series.axisY.labelsVisible; | |
217 | } |
|
246 | } | |
218 | Button { |
|
247 | Button { | |
219 | text: "axis Y color" |
|
248 | text: "axis Y color" | |
220 | onClicked: series.axisY.color = main.nextColor(); |
|
249 | onClicked: series.axisY.color = main.nextColor(); | |
221 | } |
|
250 | } | |
222 | Button { |
|
251 | Button { | |
223 | text: "axis Y labels color" |
|
252 | text: "axis Y labels color" | |
224 | onClicked: series.axisY.labelsColor = main.nextColor(); |
|
253 | onClicked: series.axisY.labelsColor = main.nextColor(); | |
225 | } |
|
254 | } | |
226 | Button { |
|
255 | Button { | |
227 | text: "axis Y labels angle +" |
|
256 | text: "axis Y labels angle +" | |
228 | onClicked: series.axisY.labelsAngle += 5; |
|
257 | onClicked: series.axisY.labelsAngle += 5; | |
229 | } |
|
258 | } | |
230 | Button { |
|
259 | Button { | |
231 | text: "axis Y labels angle -" |
|
260 | text: "axis Y labels angle -" | |
232 | onClicked: series.axisY.labelsAngle -= 5; |
|
261 | onClicked: series.axisY.labelsAngle -= 5; | |
233 | } |
|
262 | } | |
234 | Button { |
|
263 | Button { | |
235 | text: "axis Y shades visible" |
|
264 | text: "axis Y shades visible" | |
236 | onClicked: series.axisY.shadesVisible = !series.axisY.shadesVisible; |
|
265 | onClicked: series.axisY.shadesVisible = !series.axisY.shadesVisible; | |
237 | } |
|
266 | } | |
238 | Button { |
|
267 | Button { | |
239 | text: "axis Y shades color" |
|
268 | text: "axis Y shades color" | |
240 | onClicked: series.axisY.shadesColor = main.nextColor(); |
|
269 | onClicked: series.axisY.shadesColor = main.nextColor(); | |
241 | } |
|
270 | } | |
242 | Button { |
|
271 | Button { | |
243 | text: "axis Y shades bcolor" |
|
272 | text: "axis Y shades bcolor" | |
244 | onClicked: series.axisY.shadesBorderColor = main.nextColor(); |
|
273 | onClicked: series.axisY.shadesBorderColor = main.nextColor(); | |
245 | } |
|
274 | } | |
246 | Button { |
|
275 | Button { | |
247 | text: "axis Y ticks count +" |
|
276 | text: "axis Y ticks count +" | |
248 | onClicked: series.axisY.ticksCount++; |
|
277 | onClicked: series.axisY.ticksCount++; | |
249 | } |
|
278 | } | |
250 | Button { |
|
279 | Button { | |
251 | text: "axis Y ticks count -" |
|
280 | text: "axis Y ticks count -" | |
252 | onClicked: series.axisY.ticksCount--; |
|
281 | onClicked: series.axisY.ticksCount--; | |
253 | } |
|
282 | } | |
254 | } |
|
283 | } |
General Comments 0
You need to be logged in to leave comments.
Login now