##// END OF EJS Templates
color and borderColor properties to XY charts; removed unnecessary signals
Tero Ahola -
r1481:3fafc6aab8aa
parent child
Show More
@@ -1,93 +1,69
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "declarativeareaseries.h"
22 22 #include "declarativechart.h"
23 23 #include "qchart.h"
24 24 #include "qxymodelmapper.h"
25 25
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 28 /*!
29 29 \qmlclass AreaSeries QAreaSeries
30 30
31 31 \section1 Example Usage
32 32
33 33 \beginfloatleft
34 34 \image demos_qmlchart4.png
35 35 \endfloat
36 36 \clearfloat
37 37
38 38 The following QML shows how to create a simple area chart:
39 39 \snippet ../demos/qmlchart/qml/qmlchart/View4.qml 1
40 40 */
41 41
42 42 DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) :
43 43 QAreaSeries(parent)
44 44 {
45 45 }
46 46
47 47 void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries* series)
48 48 {
49 49 QAreaSeries::setUpperSeries(series);
50 50 }
51 51
52 52 DeclarativeLineSeries* DeclarativeAreaSeries::upperSeries() const
53 53 {
54 54 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::upperSeries());
55 55 }
56 56
57 57 void DeclarativeAreaSeries::setLowerSeries(DeclarativeLineSeries* series)
58 58 {
59 59 QAreaSeries::setLowerSeries(series);
60 60 }
61 61
62 62 DeclarativeLineSeries* DeclarativeAreaSeries::lowerSeries() const
63 63 {
64 64 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::lowerSeries());
65 65 }
66 66
67 QColor DeclarativeAreaSeries::penColor() const
68 {
69 return pen().color();
70 }
71
72 void DeclarativeAreaSeries::setPenColor(QColor color)
73 {
74 QPen p = pen();
75 p.setColor(color);
76 setPen(p);
77 }
78
79 QColor DeclarativeAreaSeries::brushColor() const
80 {
81 return brush().color();
82 }
83
84 void DeclarativeAreaSeries::setBrushColor(QColor color)
85 {
86 QBrush b = brush();
87 b.setColor(color);
88 setBrush(b);
89 }
90
91 67 #include "moc_declarativeareaseries.cpp"
92 68
93 69 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,52 +1,46
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef DECLARATIVEAREASERIES_H
22 22 #define DECLARATIVEAREASERIES_H
23 23
24 24 #include "qchartglobal.h"
25 25 #include "qareaseries.h"
26 26 #include "declarativelineseries.h"
27 27
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29
30 30 class DeclarativeAreaSeries : public QAreaSeries
31 31 {
32 32 Q_OBJECT
33 33 Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries)
34 34 Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries)
35 Q_PROPERTY(QColor color READ brushColor WRITE setBrushColor)
36 Q_PROPERTY(QColor borderColor READ penColor WRITE setPenColor)
37 35
38 36 public:
39 37 explicit DeclarativeAreaSeries(QObject *parent = 0);
40 38 void setUpperSeries(DeclarativeLineSeries* series);
41 39 DeclarativeLineSeries* upperSeries() const;
42 40 void setLowerSeries(DeclarativeLineSeries* series);
43 41 DeclarativeLineSeries* lowerSeries() const;
44 QColor penColor() const;
45 void setPenColor(QColor color);
46 QColor brushColor() const;
47 void setBrushColor(QColor color);
48 42 };
49 43
50 44 QTCOMMERCIALCHART_END_NAMESPACE
51 45
52 46 #endif // DECLARATIVEAREASERIES_H
@@ -1,379 +1,373
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "declarativechart.h"
22 22 #include <QPainter>
23 23 #include "declarativelineseries.h"
24 24 #include "declarativeareaseries.h"
25 25 #include "declarativebarseries.h"
26 26 #include "declarativepieseries.h"
27 27 #include "declarativesplineseries.h"
28 28 #include "declarativescatterseries.h"
29 29
30 30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 31
32 32 /*!
33 33 \qmlclass ChartView DeclarativeChart
34 34
35 35 ChartView element is the parent that is responsible for showing different chart series types.
36 36
37 37 The following QML shows how to create a simple line chart:
38 38 \snippet ../demos/qmlchart/qml/qmlchart/View2.qml 1
39 39
40 40 \beginfloatleft
41 41 \image demos_qmlchart2.png
42 42 \endfloat
43 43 \clearfloat
44 44 */
45 45
46 46 /*!
47 47 \qmlproperty Theme ChartView::theme
48 48 Theme defines the visual appearance of the chart, including for example colors, fonts, line
49 49 widths and chart background.
50 50 */
51 51
52 52 /*!
53 53 \qmlproperty Animation ChartView::animation
54 54 Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations,
55 55 ChartView.SeriesAnimations or ChartView.AllAnimations.
56 56 */
57 57
58 58 /*!
59 59 \qmlproperty string ChartView::title
60 60 The title of the chart, shown on top of the chart.
61 61 \sa ChartView::titleColor
62 62 */
63 63
64 64 /*!
65 65 \qmlproperty string ChartView::titleColor
66 66 The color of the title text.
67 67 */
68 68
69 69 /*!
70 70 \qmlproperty Axis ChartView::axisX
71 71 The x-axis of the chart.
72 72 */
73 73
74 74 /*!
75 75 \qmlproperty Axis ChartView::axisY
76 76 The default y-axis of the chart.
77 77 */
78 78
79 79 /*!
80 80 \qmlproperty Legend ChartView::legend
81 81 The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart.
82 82 */
83 83
84 84 /*!
85 85 \qmlproperty int ChartView::count
86 86 The count of series added to the chart.
87 87 */
88 88
89 89 /*!
90 90 \qmlproperty color ChartView::backgroundColor
91 91 The color of the chart's background. By default background color is defined by chart theme.
92 92 \sa ChartView::theme
93 93 */
94 94
95 95 /*!
96 96 \qmlproperty bool ChartView::dropShadowEnabled
97 97 The chart's border drop shadow. Set to true to enable drop shadow.
98 98 */
99 99
100 100 /*!
101 101 \qmlmethod Axis ChartView::axisY(QAbstractSeries *series)
102 102 The y-axis of the series. This is the same as the default y-axis of the chart, unless you have
103 103 explicitly defined the series to have a non-default y-axis.
104 104 */
105 105
106 106 DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent)
107 107 : QDeclarativeItem(parent),
108 108 m_chart(new QChart(this))
109 109 {
110 110 setFlag(QGraphicsItem::ItemHasNoContents, false);
111 111 // m_chart->axisX()->setNiceNumbersEnabled(false);
112 112 }
113 113
114 114 DeclarativeChart::~DeclarativeChart()
115 115 {
116 116 delete m_chart;
117 117 }
118 118
119 119 void DeclarativeChart::childEvent(QChildEvent *event)
120 120 {
121 121 if (event->type() == QEvent::ChildAdded) {
122 122 if (qobject_cast<QAbstractSeries *>(event->child())) {
123 123 m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child()));
124 124 }
125 125 }
126 126 }
127 127
128 128 void DeclarativeChart::componentComplete()
129 129 {
130 130 foreach(QObject *child, children()) {
131 131 if (qobject_cast<QAbstractSeries *>(child)) {
132 132 // qDebug() << "DeclarativeChart::componentComplete(), add: " << child;
133 133 // TODO: how about optional y-axis?
134 134 m_chart->addSeries(qobject_cast<QAbstractSeries *>(child));
135 135 }
136 136 }
137 137 QDeclarativeItem::componentComplete();
138 138 }
139 139
140 140 void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
141 141 {
142 142 // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height();
143 143 if (newGeometry.isValid()) {
144 144 if (newGeometry.width() > 0 && newGeometry.height() > 0) {
145 145 m_chart->resize(newGeometry.width(), newGeometry.height());
146 146 }
147 147 }
148 148 QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
149 149 }
150 150
151 151 void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
152 152 {
153 153 Q_UNUSED(option)
154 154 Q_UNUSED(widget)
155 155
156 156 // TODO: optimized?
157 157 painter->setRenderHint(QPainter::Antialiasing, true);
158 158 }
159 159
160 160 void DeclarativeChart::setTheme(DeclarativeChart::Theme theme)
161 161 {
162 162 QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme;
163 if (chartTheme != m_chart->theme()) {
163 if (chartTheme != m_chart->theme())
164 164 m_chart->setTheme(chartTheme);
165 themeChanged();
166 }
167 165 }
168 166
169 167 DeclarativeChart::Theme DeclarativeChart::theme()
170 168 {
171 169 return (DeclarativeChart::Theme) m_chart->theme();
172 170 }
173 171
174 172 void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations)
175 173 {
176 174 QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations;
177 if (animationOptions != m_chart->animationOptions()) {
175 if (animationOptions != m_chart->animationOptions())
178 176 m_chart->setAnimationOptions(animationOptions);
179 animationOptionsChanged();
180 }
181 177 }
182 178
183 179 DeclarativeChart::Animation DeclarativeChart::animationOptions()
184 180 {
185 181 if (m_chart->animationOptions().testFlag(QChart::AllAnimations))
186 182 return DeclarativeChart::AllAnimations;
187 183 else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations))
188 184 return DeclarativeChart::GridAxisAnimations;
189 185 else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations))
190 186 return DeclarativeChart::SeriesAnimations;
191 187 else
192 188 return DeclarativeChart::NoAnimation;
193 189 }
194 190
195 191 void DeclarativeChart::setTitle(QString title)
196 192 {
197 if (title != m_chart->title()) {
193 if (title != m_chart->title())
198 194 m_chart->setTitle(title);
199 emit titleChanged();
200 }
201 195 }
202 196 QString DeclarativeChart::title()
203 197 {
204 198 return m_chart->title();
205 199 }
206 200
207 201 QAxis *DeclarativeChart::axisX()
208 202 {
209 203 return m_chart->axisX();
210 204 }
211 205
212 206 QAxis *DeclarativeChart::axisY(QAbstractSeries *series)
213 207 {
214 208 return m_chart->axisY(series);
215 209 }
216 210
217 211 QLegend *DeclarativeChart::legend()
218 212 {
219 213 return m_chart->legend();
220 214 }
221 215
222 216 QVariantList DeclarativeChart::axisXLabels()
223 217 {
224 218 QVariantList labels;
225 219 foreach (qreal value, m_chart->axisX()->categories()->values()) {
226 220 labels.append(value);
227 221 labels.append(m_chart->axisX()->categories()->label(value));
228 222 }
229 223 return labels;
230 224 }
231 225
232 226 void DeclarativeChart::setAxisXLabels(QVariantList list)
233 227 {
234 228 QVariant value(QVariant::Invalid);
235 229 foreach (QVariant element, list) {
236 230 if (value.isValid() && element.type() == QVariant::String) {
237 231 m_chart->axisX()->categories()->insert(value.toDouble(), element.toString());
238 232 value = QVariant(QVariant::Invalid);
239 233 } else {
240 234 if (element.canConvert(QVariant::Double))
241 235 value = element;
242 236 }
243 237 }
244 238 emit axisLabelsChanged();
245 239 }
246 240
247 241 void DeclarativeChart::setTitleColor(QColor color)
248 242 {
249 243 QBrush b = m_chart->titleBrush();
250 244 if (color != b.color()) {
251 245 b.setColor(color);
252 246 m_chart->setTitleBrush(b);
253 247 emit titleColorChanged();
254 248 }
255 249 }
256 250
257 251 QColor DeclarativeChart::titleColor()
258 252 {
259 253 return m_chart->titleBrush().color();
260 254 }
261 255
262 256 void DeclarativeChart::setBackgroundColor(QColor color)
263 257 {
264 258 QBrush b = m_chart->backgroundBrush();
265 259 if (b.style() != Qt::SolidPattern || color != b.color()) {
266 260 b.setStyle(Qt::SolidPattern);
267 261 b.setColor(color);
268 262 m_chart->setBackgroundBrush(b);
269 263 emit backgroundColorChanged();
270 264 }
271 265 }
272 266
273 267 QColor DeclarativeChart::backgroundColor()
274 268 {
275 269 return m_chart->backgroundBrush().color();
276 270 }
277 271
278 272 int DeclarativeChart::count()
279 273 {
280 274 return m_chart->series().count();
281 275 }
282 276
283 277 void DeclarativeChart::setDropShadowEnabled(bool enabled)
284 278 {
285 279 if (enabled != m_chart->isDropShadowEnabled()) {
286 280 m_chart->setDropShadowEnabled(enabled);
287 281 dropShadowEnabledChanged(enabled);
288 282 }
289 283 }
290 284
291 285 bool DeclarativeChart::dropShadowEnabled()
292 286 {
293 287 return m_chart->isDropShadowEnabled();
294 288 }
295 289
296 290 void DeclarativeChart::zoom(qreal factor)
297 291 {
298 292 m_chart->zoom(factor);
299 293 }
300 294
301 295 void DeclarativeChart::scrollLeft(qreal pixels)
302 296 {
303 297 m_chart->scroll(QPointF(pixels, 0));
304 298 }
305 299
306 300 void DeclarativeChart::scrollRight(qreal pixels)
307 301 {
308 302 m_chart->scroll(QPointF(-pixels, 0));
309 303 }
310 304
311 305 void DeclarativeChart::scrollUp(qreal pixels)
312 306 {
313 307 m_chart->scroll(QPointF(0, pixels));
314 308 }
315 309
316 310 void DeclarativeChart::scrollDown(qreal pixels)
317 311 {
318 312 m_chart->scroll(QPointF(0, -pixels));
319 313 }
320 314
321 315 QAbstractSeries *DeclarativeChart::series(int index)
322 316 {
323 317 if (index < m_chart->series().count()) {
324 318 return m_chart->series().at(index);
325 319 }
326 320 return 0;
327 321 }
328 322
329 323 QAbstractSeries *DeclarativeChart::series(QString seriesName)
330 324 {
331 325 foreach(QAbstractSeries *series, m_chart->series()) {
332 326 if (series->name() == seriesName)
333 327 return series;
334 328 }
335 329 return 0;
336 330 }
337 331
338 332 QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name)
339 333 {
340 334 QAbstractSeries *series = 0;
341 335 switch (type) {
342 336 case DeclarativeChart::SeriesTypeLine:
343 337 series = new DeclarativeLineSeries();
344 338 break;
345 339 case DeclarativeChart::SeriesTypeArea:
346 340 series = new DeclarativeAreaSeries();
347 341 break;
348 342 case DeclarativeChart::SeriesTypeBar:
349 343 series = new DeclarativeBarSeries();
350 344 break;
351 345 case DeclarativeChart::SeriesTypeStackedBar:
352 346 // TODO
353 347 break;
354 348 case DeclarativeChart::SeriesTypePercentBar:
355 349 // TODO
356 350 break;
357 351 case DeclarativeChart::SeriesTypeGroupedBar:
358 352 series = new DeclarativeGroupedBarSeries();
359 353 break;
360 354 case DeclarativeChart::SeriesTypePie:
361 355 series = new DeclarativePieSeries();
362 356 break;
363 357 case DeclarativeChart::SeriesTypeScatter:
364 358 series = new DeclarativeScatterSeries();
365 359 break;
366 360 case DeclarativeChart::SeriesTypeSpline:
367 361 series = new DeclarativeSplineSeries();
368 362 break;
369 363 default:
370 364 qWarning() << "Illegal series type";
371 365 }
372 366 series->setName(name);
373 367 m_chart->addSeries(series);
374 368 return series;
375 369 }
376 370
377 371 #include "moc_declarativechart.cpp"
378 372
379 373 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,139 +1,136
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef DECLARATIVECHART_H
22 22 #define DECLARATIVECHART_H
23 23
24 24 #include <QtCore/QtGlobal>
25 25 #include <QDeclarativeItem>
26 26 #include <qchart.h>
27 27 #include <QAxis>
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30
31 31 // TODO: Derive from QChart for easier definition of properties?
32 32 class DeclarativeChart : public QDeclarativeItem
33 33 // TODO: for QTQUICK2: extend QQuickPainterItem instead
34 34 //class DeclarativeChart : public QQuickPaintedItem, public Chart
35 35 {
36 36 Q_OBJECT
37 Q_PROPERTY(Theme theme READ theme WRITE setTheme NOTIFY themeChanged)
38 Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions NOTIFY animationOptionsChanged)
39 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
37 Q_PROPERTY(Theme theme READ theme WRITE setTheme)
38 Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions)
39 Q_PROPERTY(QString title READ title WRITE setTitle)
40 40 Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged)
41 41 Q_PROPERTY(QAxis *axisX READ axisX)
42 42 Q_PROPERTY(QAxis *axisY READ axisY)
43 43 Q_PROPERTY(QLegend *legend READ legend)
44 44 // TODO: how to define axis labels? This is not very convenient
45 45 Q_PROPERTY(QVariantList axisXLabels READ axisXLabels WRITE setAxisXLabels NOTIFY axisLabelsChanged)
46 46 Q_PROPERTY(int count READ count)
47 47 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
48 48 Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged)
49 49 Q_ENUMS(Animation)
50 50 Q_ENUMS(Theme)
51 51 Q_ENUMS(SeriesType)
52 52
53 53 public:
54 54 // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api
55 55 enum Theme {
56 56 ChartThemeLight = 0,
57 57 ChartThemeBlueCerulean,
58 58 ChartThemeDark,
59 59 ChartThemeBrownSand,
60 60 ChartThemeBlueNcs,
61 61 ChartThemeHighContrast,
62 62 ChartThemeBlueIcy
63 63 };
64 64
65 65 enum Animation {
66 66 NoAnimation = 0x0,
67 67 GridAxisAnimations = 0x1,
68 68 SeriesAnimations =0x2,
69 69 AllAnimations = 0x3
70 70 };
71 71
72 72 enum SeriesType {
73 73 SeriesTypeLine,
74 74 SeriesTypeArea,
75 75 SeriesTypeBar,
76 76 SeriesTypeStackedBar,
77 77 SeriesTypePercentBar,
78 78 SeriesTypeGroupedBar,
79 79 SeriesTypePie,
80 80 SeriesTypeScatter,
81 81 SeriesTypeSpline
82 82 };
83 83
84 84 public:
85 85 DeclarativeChart(QDeclarativeItem *parent = 0);
86 86 ~DeclarativeChart();
87 87
88 88 public: // From QDeclarativeItem/QGraphicsItem
89 89 void childEvent(QChildEvent *event);
90 90 void componentComplete();
91 91 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
92 92 void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
93 93
94 94 public:
95 95 void setTheme(DeclarativeChart::Theme theme);
96 96 DeclarativeChart::Theme theme();
97 97 void setAnimationOptions(DeclarativeChart::Animation animations);
98 98 DeclarativeChart::Animation animationOptions();
99 99 void setTitle(QString title);
100 100 QString title();
101 101 QAxis *axisX();
102 102 Q_INVOKABLE QAxis *axisY(QAbstractSeries *series = 0);
103 103 QLegend *legend();
104 104 QVariantList axisXLabels();
105 105 void setAxisXLabels(QVariantList list);
106 106 void setTitleColor(QColor color);
107 107 QColor titleColor();
108 108 void setBackgroundColor(QColor color);
109 109 QColor backgroundColor();
110 110 int count();
111 111 void setDropShadowEnabled(bool enabled);
112 112 bool dropShadowEnabled();
113 113 Q_INVOKABLE void zoom(qreal factor);
114 114 Q_INVOKABLE void scrollLeft(qreal pixels);
115 115 Q_INVOKABLE void scrollRight(qreal pixels);
116 116 Q_INVOKABLE void scrollUp(qreal pixels);
117 117 Q_INVOKABLE void scrollDown(qreal pixels);
118 118 Q_INVOKABLE QAbstractSeries *series(int index);
119 119 Q_INVOKABLE QAbstractSeries *series(QString seriesName);
120 120 Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = "");
121 121
122 122 Q_SIGNALS:
123 void themeChanged();
124 void animationOptionsChanged();
125 void titleChanged();
126 123 void axisLabelsChanged();
127 124 void titleColorChanged();
128 125 void backgroundColorChanged();
129 126 void dropShadowEnabledChanged(bool enabled);
130 127
131 128 public:
132 129 // Extending QChart with DeclarativeChart is not possible because QObject does not support
133 130 // multi inheritance, so we now have a QChart as a member instead
134 131 QChart *m_chart;
135 132 };
136 133
137 134 QTCOMMERCIALCHART_END_NAMESPACE
138 135
139 136 #endif // DECLARATIVECHART_H
@@ -1,67 +1,66
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef DECLARATIVELINESERIES_H
22 22 #define DECLARATIVELINESERIES_H
23 23
24 24 #include "qchartglobal.h"
25 25 #include "qlineseries.h"
26 26 #include "declarativexyseries.h"
27 27 #include <QDeclarativeParserStatus>
28 28 #include <QDeclarativeListProperty>
29 29 #include <QDeclarativeParserStatus>
30 30
31 31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32 32
33 33 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
34 34 {
35 35 Q_OBJECT
36 36 Q_INTERFACES(QDeclarativeParserStatus)
37 Q_PROPERTY(QColor color READ penColor WRITE setPenColor)
38 37 Q_PROPERTY(int count READ count NOTIFY countChanged)
39 38 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
40 39 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
41 40
42 41 public:
43 42 explicit DeclarativeLineSeries(QObject *parent = 0);
44 43 QXYSeries *xySeries();
45 44 QDeclarativeListProperty<QObject> declarativeChildren();
46 45
47 46 public: // from QDeclarativeParserStatus
48 47 void classBegin() { DeclarativeXySeries::classBegin(); }
49 48 void componentComplete() { DeclarativeXySeries::componentComplete(); }
50 49
51 50 public: // from QLineSeries
52 51 Q_INVOKABLE void append(qreal x, qreal y) { QLineSeries::append(x, y); }
53 52 Q_INVOKABLE void remove(qreal x, qreal y) { QLineSeries::remove(x, y); }
54 53 Q_INVOKABLE void clear() { QLineSeries::clear(); }
55 54 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
56 55
57 56 Q_SIGNALS:
58 57 void countChanged(int count);
59 58
60 59 public Q_SLOTS:
61 60 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
62 61 void handleCountChanged(int index);
63 62 };
64 63
65 64 QTCOMMERCIALCHART_END_NAMESPACE
66 65
67 66 #endif // DECLARATIVELINESERIES_H
@@ -1,85 +1,73
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "declarativescatterseries.h"
22 22 #include "declarativechart.h"
23 23 #include "qchart.h"
24 24 #include "qscatterseries.h"
25 25
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 28 /*!
29 29 \qmlclass ScatterSeries QScatterSeries
30 30
31 31 The following QML shows how to create a chart with two simple scatter series:
32 32 \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 1
33 33 \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 2
34 34
35 35 \beginfloatleft
36 36 \image demos_qmlchart5.png
37 37 \endfloat
38 38 \clearfloat
39 39 */
40 40
41 41 DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) :
42 42 QScatterSeries(parent)
43 43 {
44 44 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
45 45 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
46 46 }
47 47
48 48 QXYSeries *DeclarativeScatterSeries::xySeries()
49 49 {
50 50 return this;
51 51 }
52 52
53 53 void DeclarativeScatterSeries::handleCountChanged(int index)
54 54 {
55 55 Q_UNUSED(index)
56 56 emit countChanged(QScatterSeries::count());
57 57 }
58 58
59 59 QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren()
60 60 {
61 61 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
62 62 }
63 63
64 64 void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
65 65 {
66 66 Q_UNUSED(list)
67 67 Q_UNUSED(element)
68 68 // Empty implementation, childs are parsed in componentComplete
69 69 }
70 70
71 QColor DeclarativeScatterSeries::brushColor()
72 {
73 return brush().color();
74 }
75
76 void DeclarativeScatterSeries::setBrushColor(QColor color)
77 {
78 QBrush b = brush();
79 b.setColor(color);
80 setBrush(b);
81 }
82
83 71 #include "moc_declarativescatterseries.cpp"
84 72
85 73 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,69 +1,65
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef DECLARATIVESCATTERSERIES_H
22 22 #define DECLARATIVESCATTERSERIES_H
23 23
24 24 #include "qchartglobal.h"
25 25 #include "qscatterseries.h"
26 26 #include "declarativexyseries.h"
27 27 #include <QDeclarativeListProperty>
28 28 #include <QDeclarativeParserStatus>
29 29
30 30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 31
32 32 class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
33 33 {
34 34 Q_OBJECT
35 35 Q_INTERFACES(QDeclarativeParserStatus)
36 Q_PROPERTY(QColor color READ brushColor WRITE setBrushColor)
37 Q_PROPERTY(QColor borderColor READ penColor WRITE setPenColor)
38 36 Q_PROPERTY(int count READ count NOTIFY countChanged)
39 37 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
40 38 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
41 39
42 40 public:
43 41 explicit DeclarativeScatterSeries(QObject *parent = 0);
44 42 QXYSeries *xySeries();
45 43 QDeclarativeListProperty<QObject> declarativeChildren();
46 QColor brushColor();
47 void setBrushColor(QColor color);
48 44
49 45 public: // from QDeclarativeParserStatus
50 46 void classBegin() { DeclarativeXySeries::classBegin(); }
51 47 void componentComplete() { DeclarativeXySeries::componentComplete(); }
52 48
53 49 public: // from QScatterSeries
54 50 Q_INVOKABLE void append(qreal x, qreal y) { QScatterSeries::append(x, y); }
55 51 Q_INVOKABLE void remove(qreal x, qreal y) { QScatterSeries::remove(x, y); }
56 52 Q_INVOKABLE void clear() { QScatterSeries::clear(); }
57 53 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
58 54
59 55 Q_SIGNALS:
60 56 void countChanged(int count);
61 57
62 58 public Q_SLOTS:
63 59 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
64 60 void handleCountChanged(int index);
65 61 };
66 62
67 63 QTCOMMERCIALCHART_END_NAMESPACE
68 64
69 65 #endif // DECLARATIVESCATTERSERIES_H
@@ -1,66 +1,65
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef DECLARATIVESPLINESERIES_H
22 22 #define DECLARATIVESPLINESERIES_H
23 23
24 24 #include "qchartglobal.h"
25 25 #include "qsplineseries.h"
26 26 #include "declarativexyseries.h"
27 27 #include <QDeclarativeParserStatus>
28 28 #include <QDeclarativeListProperty>
29 29 #include <QDeclarativeParserStatus>
30 30
31 31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32 32
33 33 class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
34 34 {
35 35 Q_OBJECT
36 36 Q_INTERFACES(QDeclarativeParserStatus)
37 Q_PROPERTY(QColor color READ penColor WRITE setPenColor)
38 37 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
39 38 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
40 39
41 40 public:
42 41 explicit DeclarativeSplineSeries(QObject *parent = 0);
43 42 QXYSeries *xySeries();
44 43 QDeclarativeListProperty<QObject> declarativeChildren();
45 44
46 45 public: // from QDeclarativeParserStatus
47 46 void classBegin() { DeclarativeXySeries::classBegin(); }
48 47 void componentComplete() { DeclarativeXySeries::componentComplete(); }
49 48
50 49 public: // from QSplineSeries
51 50 Q_INVOKABLE void append(qreal x, qreal y) { QSplineSeries::append(x, y); }
52 51 Q_INVOKABLE void remove(qreal x, qreal y) { QSplineSeries::remove(x, y); }
53 52 Q_INVOKABLE void clear() { QSplineSeries::clear(); }
54 53 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
55 54
56 55 Q_SIGNALS:
57 56 void countChanged(int count);
58 57
59 58 public Q_SLOTS:
60 59 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
61 60 void handleCountChanged(int index);
62 61 };
63 62
64 63 QTCOMMERCIALCHART_END_NAMESPACE
65 64
66 65 #endif // DECLARATIVESPLINESERIES_H
@@ -1,94 +1,77
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 //#include "DeclarativeXySeries.h"
22 22 #include "declarativexyseries.h"
23 23 #include "declarativechart.h"
24 24 #include <QXYSeries>
25 25 #include <QVXYModelMapper>
26 26 #include <QHXYModelMapper>
27 27 #include <QDeclarativeListProperty>
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30
31 31 DeclarativeXySeries::DeclarativeXySeries()
32 32 {
33 33 }
34 34
35 35 DeclarativeXySeries::~DeclarativeXySeries()
36 36 {
37 37 }
38 38
39 39 void DeclarativeXySeries::classBegin()
40 40 {
41 41 }
42 42
43 43 void DeclarativeXySeries::componentComplete()
44 44 {
45 45 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
46 46 Q_ASSERT(series);
47 47
48 48 foreach(QObject *child, series->children()) {
49 49 if (qobject_cast<DeclarativeXyPoint *>(child)) {
50 50 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(child);
51 51 series->append(point->x(), point->y());
52 52 } else if(qobject_cast<QVXYModelMapper *>(child)) {
53 53 QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child);
54 54 mapper->setSeries(series);
55 55 } else if(qobject_cast<QHXYModelMapper *>(child)) {
56 56 QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child);
57 57 mapper->setSeries(series);
58 58 }
59 59 }
60 60 }
61 61
62 QColor DeclarativeXySeries::penColor()
63 {
64 // All the inherited objects must be of type QXYSeries, so it is safe to cast
65 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
66 Q_ASSERT(series);
67 return series->pen().color();
68 }
69
70 void DeclarativeXySeries::setPenColor(QColor color)
71 {
72 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
73 Q_ASSERT(series);
74 QPen pen = series->pen();
75 pen.setColor(color);
76 series->setPen(pen);
77 }
78
79 62 DeclarativeXyPoint *DeclarativeXySeries::at(int index)
80 63 {
81 64 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
82 65 Q_ASSERT(series);
83 66 if (index < series->count()) {
84 67 QPointF point = series->points().at(index);
85 68 DeclarativeXyPoint *xyPoint = new DeclarativeXyPoint(series);
86 69 xyPoint->setX(point.x());
87 70 xyPoint->setY(point.y());
88 71 return xyPoint;
89 72 }
90 73 return 0;
91 74 }
92 75
93 76
94 77 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,51 +1,49
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef DECLARATIVE_XY_SERIES_H
22 22 #define DECLARATIVE_XY_SERIES_H
23 23
24 24 #include "qchartglobal.h"
25 25 #include "declarativexypoint.h"
26 26 #include <QColor>
27 27 #include <QXYSeries>
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30
31 31 class QChart;
32 32 class QAbstractSeries;
33 33
34 34 class DeclarativeXySeries
35 35 {
36 36 public:
37 37 explicit DeclarativeXySeries();
38 38 ~DeclarativeXySeries();
39 39
40 40 public:
41 41 void classBegin();
42 42 void componentComplete();
43 43 virtual QXYSeries *xySeries() = 0;
44 QColor penColor();
45 void setPenColor(QColor color);
46 44 DeclarativeXyPoint *at(int index);
47 45 };
48 46
49 47 QTCOMMERCIALCHART_END_NAMESPACE
50 48
51 49 #endif // DECLARATIVE_XY_SERIES_H
@@ -1,291 +1,344
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qareaseries.h"
22 22 #include "qareaseries_p.h"
23 23 #include "qlineseries.h"
24 24 #include "areachartitem_p.h"
25 25 #include "legendmarker_p.h"
26 26 #include "domain_p.h"
27 27 #include "chartdataset_p.h"
28 28 #include "charttheme_p.h"
29 29 #include "chartanimator_p.h"
30 30
31 31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32 32
33 33 /*!
34 34 \class QAreaSeries
35 35 \brief The QAreaSeries class is used for making area charts.
36 36
37 37 \mainclass
38 38
39 39 An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line
40 40 is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance,
41 41 which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line.
42 42 In that case QAreaSeries should be initiated with two QLineSerie instances. Please note terms "upper" and "lower" boundary can be misleading in cases
43 43 where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled.
44 44
45 45 See the \l {AreaChart Example} {area chart example} to learn how to create a simple area chart.
46 46 \image examples_areachart.png
47 47 */
48 48
49 49 /*!
50 50 \property QAreaSeries::upperSeries
51 51 \brief The upper one of the two line series used to define area series boundaries.
52 52 */
53 53
54 54 /*!
55 55 \property QAreaSeries::lowerSeries
56 56 The lower one of the two line series used to define are series boundaries. Note if
57 57 QAreaSeries was counstucted wihtout a\ lowerSeries this is null.
58 58 */
59 59
60 60 /*!
61 \property QAreaSeries::color
62 Fill (brush) color of the series. This is a convenience property for modifying the color of brush.
63 \sa QAreaSeries::brush()
64 */
65
66 /*!
67 \property QAreaSeries::borderColor
68 Line (pen) color of the series. This is a convenience property for modifying the color of pen.
69 \sa QAreaSeries::pen()
70 */
71
72 /*!
61 73 \fn QPen QAreaSeries::pen() const
62 74 \brief Returns the pen used to draw line for this series.
63 75 \sa setPen()
64 76 */
65 77
66 78 /*!
67 79 \fn QPen QAreaSeries::brush() const
68 80 \brief Returns the brush used to draw line for this series.
69 81 \sa setBrush()
70 82 */
71 83
72 84 /*!
85 \fn void QAreaSeries::colorChanged(QColor color)
86 \brief Signal is emitted when the fill (brush) color has changed to \a color.
87 */
88
89 /*!
90 \fn void QAreaSeries::borderColorChanged(QColor color)
91 \brief Signal is emitted when the line (pen) color has changed to \a color.
92 */
93
94 /*!
73 95 \fn bool QAreaSeries::pointsVisible() const
74 96 \brief Returns if the points are drawn for this series.
75 97 \sa setPointsVisible()
76 98 */
77 99
78 100 /*!
79 101 \fn void QAreaSeries::clicked(const QPointF& point)
80 102 \brief Signal is emitted when user clicks the \a point on area chart.
81 103 */
82 104
83 105 /*!
84 106 \fn void QAreaSeries::selected()
85 107
86 108 The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be
87 109 implemented by the user of QAreaSeries API.
88 110 */
89 111
90 112 /*!
91 113 \fn void QAreaSeriesPrivate::updated()
92 114 \brief \internal
93 115 */
94 116
95 117 /*!
96 118 Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a
97 119 upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead.
98 120 When series object is added to QChartView or QChart instance ownerships is transferred.
99 121 */
100 122 QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries)
101 123 : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries)
102 124 {
103 125 }
104 126
105 127 /*!
106 128 Constructs area series object without upper or lower series with \a parent object.
107 129 */
108 130 QAreaSeries::QAreaSeries(QObject *parent)
109 131 : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent)
110 132 {
111 133 }
112 134
113 135 /*!
114 136 Destroys the object. Series added to QChartView or QChart instances are owned by those,
115 137 and are deleted when mentioned object are destroyed.
116 138 */
117 139 QAreaSeries::~QAreaSeries()
118 140 {
119 141 }
120 142
121 143 /*!
122 144 Returns QChartSeries::SeriesTypeArea.
123 145 */
124 146 QAbstractSeries::SeriesType QAreaSeries::type() const
125 147 {
126 148 return QAbstractSeries::SeriesTypeArea;
127 149 }
128 150
129 151 /*!
130 152 Sets the \a series that is to be used as the area chart upper series.
131 153 */
132 154 void QAreaSeries::setUpperSeries(QLineSeries* series)
133 155 {
134 156 Q_D(QAreaSeries);
135 157 d->m_upperSeries = series;
136 158 }
137 159
138 160 QLineSeries* QAreaSeries::upperSeries() const
139 161 {
140 162 Q_D(const QAreaSeries);
141 163 return d->m_upperSeries;
142 164 }
143 165
144 166 /*!
145 167 Sets the \a series that is to be used as the area chart lower series.
146 168 */
147 169 void QAreaSeries::setLowerSeries(QLineSeries* series)
148 170 {
149 171 Q_D(QAreaSeries);
150 172 d->m_lowerSeries = series;
151 173 }
152 174
153 175 QLineSeries* QAreaSeries::lowerSeries() const
154 176 {
155 177 Q_D(const QAreaSeries);
156 178 return d->m_lowerSeries;
157 179 }
158 180
159 181 /*!
160 182 Sets \a pen used for drawing area outline.
161 183 */
162 184 void QAreaSeries::setPen(const QPen &pen)
163 185 {
164 186 Q_D(QAreaSeries);
165 187 if (d->m_pen != pen) {
166 188 d->m_pen = pen;
167 189 emit d->updated();
168 190 }
169 191 }
170 192
171 193 QPen QAreaSeries::pen() const
172 194 {
173 195 Q_D(const QAreaSeries);
174 196 return d->m_pen;
175 197 }
176 198
177 199 /*!
178 200 Sets \a brush used for filling the area.
179 201 */
180 202 void QAreaSeries::setBrush(const QBrush &brush)
181 203 {
182 204 Q_D(QAreaSeries);
183 205 if (d->m_brush != brush) {
184 206 d->m_brush = brush;
185 207 emit d->updated();
186 208 }
187 209 }
188 210
189 211 QBrush QAreaSeries::brush() const
190 212 {
191 213 Q_D(const QAreaSeries);
192 214 return d->m_brush;
193 215 }
216
217 void QAreaSeries::setColor(const QColor &color)
218 {
219 QBrush b = brush();
220 if (b.color() != color) {
221 b.setColor(color);
222 setBrush(b);
223 emit colorChanged(color);
224 }
225 }
226
227 QColor QAreaSeries::color() const
228 {
229 return brush().color();
230 }
231
232 void QAreaSeries::setBorderColor(const QColor &color)
233 {
234 QPen p = pen();
235 if (p.color() != color) {
236 p.setColor(color);
237 setPen(p);
238 emit borderColorChanged(color);
239 }
240 }
241
242 QColor QAreaSeries::borderColor() const
243 {
244 return pen().color();
245 }
246
194 247 /*!
195 248 Sets if data points are \a visible and should be drawn on line.
196 249 */
197 250 void QAreaSeries::setPointsVisible(bool visible)
198 251 {
199 252 Q_D(QAreaSeries);
200 253 if (d->m_pointsVisible != visible) {
201 254 d->m_pointsVisible = visible;
202 255 emit d->updated();
203 256 }
204 257 }
205 258
206 259 bool QAreaSeries::pointsVisible() const
207 260 {
208 261 Q_D(const QAreaSeries);
209 262 return d->m_pointsVisible;
210 263 }
211 264
212 265 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
213 266
214 267 QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) :
215 268 QAbstractSeriesPrivate(q),
216 269 m_upperSeries(upperSeries),
217 270 m_lowerSeries(lowerSeries),
218 271 m_pointsVisible(false)
219 272 {
220 273 }
221 274
222 275 void QAreaSeriesPrivate::scaleDomain(Domain& domain)
223 276 {
224 277 Q_Q(QAreaSeries);
225 278
226 279 qreal minX(domain.minX());
227 280 qreal minY(domain.minY());
228 281 qreal maxX(domain.maxX());
229 282 qreal maxY(domain.maxY());
230 283 int tickXCount(domain.tickXCount());
231 284 int tickYCount(domain.tickYCount());
232 285
233 286 QLineSeries* upperSeries = q->upperSeries();
234 287 QLineSeries* lowerSeries = q->lowerSeries();
235 288
236 289 const QList<QPointF>& points = upperSeries->points();
237 290
238 291 for (int i = 0; i < points.count(); i++)
239 292 {
240 293 qreal x = points[i].x();
241 294 qreal y = points[i].y();
242 295 minX = qMin(minX, x);
243 296 minY = qMin(minY, y);
244 297 maxX = qMax(maxX, x);
245 298 maxY = qMax(maxY, y);
246 299 }
247 300 if(lowerSeries) {
248 301
249 302 const QList<QPointF>& points = lowerSeries->points();
250 303
251 304 for (int i = 0; i < points.count(); i++)
252 305 {
253 306 qreal x = points[i].x();
254 307 qreal y = points[i].y();
255 308 minX = qMin(minX, x);
256 309 minY = qMin(minY, y);
257 310 maxX = qMax(maxX, x);
258 311 maxY = qMax(maxY, y);
259 312 }}
260 313
261 314 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
262 315 }
263 316
264 317 Chart* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter)
265 318 {
266 319 Q_Q(QAreaSeries);
267 320
268 321 AreaChartItem* area = new AreaChartItem(q,presenter);
269 322 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
270 323 area->upperLineItem()->setAnimator(presenter->animator());
271 324 area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem()));
272 325 if(q->lowerSeries()) {
273 326 area->lowerLineItem()->setAnimator(presenter->animator());
274 327 area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem()));
275 328 }
276 329 }
277 330 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
278 331 return area;
279 332 }
280 333
281 334 QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend)
282 335 {
283 336 Q_Q(QAreaSeries);
284 337 QList<LegendMarker*> list;
285 338 return list << new AreaLegendMarker(q,legend);
286 339 }
287 340
288 341 #include "moc_qareaseries.cpp"
289 342 #include "moc_qareaseries_p.cpp"
290 343
291 344 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,74 +1,84
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef QAREASERIES_H
22 22 #define QAREASERIES_H
23 23
24 24 #include <qchartglobal.h>
25 25 #include <qabstractseries.h>
26 26 #include <QPen>
27 27 #include <QBrush>
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30 class QLineSeries;
31 31 class QAreaSeriesPrivate;
32 32
33 33 class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QAbstractSeries
34 34 {
35 35 Q_OBJECT
36 36 Q_PROPERTY(QAbstractSeries *upperSeries READ upperSeries)
37 37 Q_PROPERTY(QAbstractSeries *lowerSeries READ lowerSeries)
38 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
39 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
38 40
39 41 public:
40 42 explicit QAreaSeries(QObject *parent = 0);
41 43 explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0);
42 44 ~QAreaSeries();
43 45
44 46 public:
45 47 QAbstractSeries::SeriesType type() const;
46 48
47 49 void setUpperSeries(QLineSeries* series);
48 50 QLineSeries* upperSeries() const;
49 51 void setLowerSeries(QLineSeries* series);
50 52 QLineSeries* lowerSeries() const;
51 53
52 54 void setPen(const QPen &pen);
53 55 QPen pen() const;
54 56
55 57 void setBrush(const QBrush &brush);
56 58 QBrush brush() const;
57 59
60 void setColor(const QColor &color);
61 QColor color() const;
62
63 void setBorderColor(const QColor &color);
64 QColor borderColor() const;
65
58 66 void setPointsVisible(bool visible = true);
59 67 bool pointsVisible() const;
60 68
61 69 Q_SIGNALS:
62 70 void clicked(const QPointF &point);
63 71 void selected();
72 void colorChanged(QColor color);
73 void borderColorChanged(QColor color);
64 74
65 75 private:
66 Q_DECLARE_PRIVATE(QAreaSeries);
67 Q_DISABLE_COPY(QAreaSeries);
76 Q_DECLARE_PRIVATE(QAreaSeries)
77 Q_DISABLE_COPY(QAreaSeries)
68 78 friend class AreaLegendMarker;
69 79 friend class AreaChartItem;
70 80 };
71 81
72 82 QTCOMMERCIALCHART_END_NAMESPACE
73 83
74 84 #endif
@@ -1,674 +1,654
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qaxis.h"
22 22 #include "qaxis_p.h"
23 23
24 24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25 25
26 26 /*!
27 27 \class QAxis
28 28 \brief The QAxis class is used for manipulating chart's axis
29 29 and for adding optional axes to the chart.
30 30 \mainclass
31 31
32 32 There is only one x Axis, however there can be multiple y axes.
33 33 Each chart series can be bound to exactly one Y axis and the shared common X axis.
34 34 Axis can be setup to show axis line with tick marks, grid lines and shades.
35 35 */
36 36
37 37 /*!
38 38 \qmlclass Axis QAxis
39 39 \brief The Axis element is used for manipulating chart's axes
40 40
41 41 There is only one x Axis, however there can be multiple y axes on a ChartView.
42 42 Each chart series can be bound to exactly one Y axis and the shared common X axis.
43 43 Axis can be setup to show axis line with tick marks, grid lines and shades.
44 44
45 45 To access Axes you can use ChartView API. For example:
46 46 \code
47 47 ChartView {
48 48 axisX.min: 0
49 49 axisX.max: 3
50 50 axisX.ticksCount: 4
51 51 axisY.min: 0
52 52 axisY.max: 4
53 53 // Add a few series...
54 54 }
55 55 \endcode
56 56 */
57 57
58 58 /*!
59 59 \property QAxis::labelsVisible
60 60 Defines if axis labels are visible.
61 61 */
62 62 /*!
63 63 \qmlproperty bool Axis::labelsVisible
64 64 Defines if axis labels are visible.
65 65 */
66 66
67 67 /*!
68 68 \property QAxis::min
69 69 Defines the minimum value on the axis.
70 70 */
71 71 /*!
72 72 \qmlproperty real Axis::min
73 73 Defines the minimum value on the axis.
74 74 */
75 75
76 76 /*!
77 77 \property QAxis::max
78 78 Defines the maximum value on the axis.
79 79 */
80 80 /*!
81 81 \qmlproperty real Axis::max
82 82 Defines the maximum value on the axis.
83 83 */
84 84
85 85 /*!
86 86 \property QAxis::visible
87 87 The visibility of the axis.
88 88 */
89 89 /*!
90 90 \qmlproperty bool Axis::visible
91 91 The visibility of the axis.
92 92 */
93 93
94 94 /*!
95 95 \property QAxis::gridVisible
96 96 The visibility of the grid lines.
97 97 */
98 98 /*!
99 99 \qmlproperty bool Axis::gridVisible
100 100 The visibility of the grid lines.
101 101 */
102 102
103 103 /*!
104 104 \property QAxis::color
105 105 The color of the axis and ticks.
106 106 */
107 107 /*!
108 108 \qmlproperty color Axis::color
109 109 The color of the axis and ticks.
110 110 */
111 111
112 112 /*!
113 113 \property QAxis::labelsColor
114 114 The color of the axis labels.
115 115 */
116 116 /*!
117 117 \qmlproperty color Axis::labelsColor
118 118 The color of the axis labels.
119 119 */
120 120
121 121 /*!
122 122 \property QAxis::labelsAngle
123 123 The angle of the axis labels in degrees.
124 124 */
125 125 /*!
126 126 \qmlproperty int Axis::labelsAngle
127 127 The angle of the axis labels in degrees.
128 128 */
129 129
130 130 /*!
131 131 \property QAxis::shadesVisible
132 132 The visibility of the axis shades.
133 133 */
134 134 /*!
135 135 \qmlproperty bool Axis::shadesVisible
136 136 The visibility of the axis shades.
137 137 */
138 138
139 139 /*!
140 140 \property QAxis::shadesColor
141 141 The fill (brush) color of the axis shades.
142 142 */
143 143 /*!
144 144 \qmlproperty color Axis::shadesColor
145 145 The fill (brush) color of the axis shades.
146 146 */
147 147
148 148 /*!
149 149 \property QAxis::shadesBorderColor
150 150 The border (pen) color of the axis shades.
151 151 */
152 152 /*!
153 153 \qmlproperty color Axis::shadesBorderColor
154 154 The border (pen) color of the axis shades.
155 155 */
156 156
157 157 /*!
158 158 \property QAxis::ticksCount
159 159 The number of tick marks for the axis.
160 160 */
161 161 /*!
162 162 \qmlproperty int Axis::ticksCount
163 163 The number of tick marks for the axis.
164 164 */
165 165
166 166 /*!
167 167 \property QAxis::niceNumbersEnabled
168 168 Whether the nice numbers algorithm is enabled or not for the axis.
169 169 */
170 170 /*!
171 171 \qmlproperty bool Axis::niceNumbersEnabled
172 172 Whether the nice numbers algorithm is enabled or not for the axis.
173 173 */
174 174
175 175 /*!
176 176 \fn void QAxis::visibleChanged(bool)
177 177 Visiblity of the axis has changed to \a visible.
178 178 */
179 179
180 180 /*!
181 181 \fn void QAxis::labelsVisibleChanged(bool)
182 182 Visiblity of the labels of the axis has changed to \a visible.
183 183 */
184 184
185 185 /*!
186 186 \fn void QAxis::gridVisibleChanged(bool)
187 187 Visiblity of the grid lines of the axis has changed to \a visible.
188 188 */
189 189
190 190 /*!
191 191 \fn void QAxis::minChanged(qreal min)
192 192 Axis emits signal when \a min of axis has changed.
193 193 */
194 194
195 195 /*!
196 196 \fn void QAxis::maxChanged(qreal max)
197 197 Axis emits signal when \a max of axis has changed.
198 198 */
199 199
200 200 /*!
201 201 \fn void QAxis::rangeChanged(qreal min, qreal max)
202 202 Axis emits signal when \a min or \a max of axis has changed.
203 203 */
204 204
205 205 /*!
206 206 \fn QChartAxisCategories* QAxis::categories()
207 207 Returns pointer to the list of categories which correspond to the values on the axis.
208 208 */
209 209
210 210 /*!
211 211 \fn void QAxis::colorChanged(QColor)
212 212 Emitted if the \a color of the axis is changed.
213 213 */
214 214
215 215 /*!
216 216 \fn void QAxis::labelsColorChanged(QColor)
217 217 Emitted if the \a color of the axis labels is changed.
218 218 */
219 219
220 220 /*!
221 \fn void QAxis::labelsAngleChanged(int)
222 Emitted if the \a angle of the axis labels is changed.
223 */
224
225 /*!
226 221 \fn void QAxis::shadesVisibleChanged(bool)
227 222 Emitted if the visibility of the axis shades is changed to \a visible.
228 223 */
229 224
230 225 /*!
231 226 \fn void QAxis::shadesColorChanged(QColor)
232 227 Emitted if the \a color of the axis shades is changed.
233 228 */
234 229
235 230 /*!
236 231 \fn void QAxis::shadesBorderColorChanged(QColor)
237 232 Emitted if the border \a color of the axis shades is changed.
238 233 */
239 234
240 235 /*!
241 \fn void QAxis::ticksCountChanged(int count)
242 \brief Emits the new \a count of ticks on the axis
243 Signal is emitted when the number of the ticks on the axis has been changed to a different value.
244 Parementer count\a count is the new number of ticks on the axis.
245 */
246
247 /*!
248 \fn void QAxis::niceNumbersEnabledChanged(bool)
249 Nice numbers algorithm was \a enabled or disabled.
250 */
251
252 /*!
253 236 Constructs new axis object which is a child of \a parent. Ownership is taken by
254 237 QChart when axis added.
255 238 */
256 239 QAxis::QAxis(QObject *parent) : QObject(parent),
257 240 d_ptr(new QAxisPrivate(this))
258 241 {
259 242
260 243 }
261 244
262 245 /*!
263 246 Destructor of the axis object. When axis is added to chart, chart object takes ownership.
264 247 */
265 248
266 249 QAxis::~QAxis()
267 250 {
268 251 }
269 252
270 253 /*!
271 254 Sets \a pen used to draw axis line and ticks.
272 255 */
273 256 void QAxis::setAxisPen(const QPen &pen)
274 257 {
275 258 if (d_ptr->m_axisPen!=pen) {
276 259 d_ptr->m_axisPen = pen;
277 260 emit d_ptr->updated();
278 261 }
279 262 }
280 263
281 264 /*!
282 265 Returns pen used to draw axis and ticks.
283 266 */
284 267 QPen QAxis::axisPen() const
285 268 {
286 269 return d_ptr->m_axisPen;
287 270 }
288 271
289 272 void QAxis::setAxisPenColor(QColor color)
290 273 {
291 274 QPen p = d_ptr->m_axisPen;
292 275 if (p.color() != color) {
293 276 p.setColor(color);
294 277 setAxisPen(p);
295 278 emit colorChanged(color);
296 279 }
297 280 }
298 281
299 282 QColor QAxis::axisPenColor() const
300 283 {
301 284 return d_ptr->m_axisPen.color();
302 285 }
303 286
304 287 /*!
305 288 Sets if axis and ticks are \a visible.
306 289 */
307 290 void QAxis::setAxisVisible(bool visible)
308 291 {
309 292 if (d_ptr->m_axisVisible != visible) {
310 293 d_ptr->m_axisVisible = visible;
311 294 emit d_ptr->updated();
312 295 emit visibleChanged(visible);
313 296 }
314 297 }
315 298
316 299 bool QAxis::isAxisVisible() const
317 300 {
318 301 return d_ptr->m_axisVisible;
319 302 }
320 303
321 304 void QAxis::setGridLineVisible(bool visible)
322 305 {
323 306 if (d_ptr->m_gridLineVisible != visible) {
324 307 d_ptr->m_gridLineVisible = visible;
325 308 emit d_ptr->updated();
326 309 emit gridVisibleChanged(visible);
327 310 }
328 311 }
329 312
330 313 bool QAxis::isGridLineVisible() const
331 314 {
332 315 return d_ptr->m_gridLineVisible;
333 316 }
334 317
335 318 /*!
336 319 Sets \a pen used to draw grid line.
337 320 */
338 321 void QAxis::setGridLinePen(const QPen &pen)
339 322 {
340 323 if (d_ptr->m_gridLinePen != pen) {
341 324 d_ptr->m_gridLinePen = pen;
342 325 emit d_ptr->updated();
343 326 }
344 327 }
345 328
346 329 /*!
347 330 Returns pen used to draw grid.
348 331 */
349 332 QPen QAxis::gridLinePen() const
350 333 {
351 334 return d_ptr->m_gridLinePen;
352 335 }
353 336
354 337 void QAxis::setLabelsVisible(bool visible)
355 338 {
356 339 if (d_ptr->m_labelsVisible != visible) {
357 340 d_ptr->m_labelsVisible = visible;
358 341 emit d_ptr->updated();
359 342 emit labelsVisibleChanged(visible);
360 343 }
361 344 }
362 345
363 346 bool QAxis::labelsVisible() const
364 347 {
365 348 return d_ptr->m_labelsVisible;
366 349 }
367 350
368 351 /*!
369 352 Sets \a pen used to draw labels.
370 353 */
371 354 void QAxis::setLabelsPen(const QPen &pen)
372 355 {
373 356 if (d_ptr->m_labelsPen != pen) {
374 357 d_ptr->m_labelsPen = pen;
375 358 emit d_ptr->updated();
376 359 }
377 360 }
378 361
379 362 /*!
380 363 Returns the pen used to labels.
381 364 */
382 365 QPen QAxis::labelsPen() const
383 366 {
384 367 return d_ptr->m_labelsPen;
385 368 }
386 369
387 370 /*!
388 371 Sets \a brush used to draw labels.
389 372 */
390 373 void QAxis::setLabelsBrush(const QBrush &brush)
391 374 {
392 375 if (d_ptr->m_labelsBrush != brush) {
393 376 d_ptr->m_labelsBrush = brush;
394 377 emit d_ptr->updated();
395 378 }
396 379 }
397 380
398 381 /*!
399 382 Returns brush used to draw labels.
400 383 */
401 384 QBrush QAxis::labelsBrush() const
402 385 {
403 386 return d_ptr->m_labelsBrush;
404 387 }
405 388
406 389 /*!
407 390 Sets \a font used to draw labels.
408 391 */
409 392 void QAxis::setLabelsFont(const QFont &font)
410 393 {
411 394 if (d_ptr->m_labelsFont != font) {
412 395 d_ptr->m_labelsFont = font;
413 396 emit d_ptr->updated();
414 397 }
415 398 }
416 399
417 400 /*!
418 401 Returns font used to draw labels.
419 402 */
420 403 QFont QAxis::labelsFont() const
421 404 {
422 405 return d_ptr->m_labelsFont;
423 406 }
424 407
425 408 void QAxis::setLabelsAngle(int angle)
426 409 {
427 410 if (d_ptr->m_labelsAngle != angle) {
428 411 d_ptr->m_labelsAngle = angle;
429 412 emit d_ptr->updated();
430 emit labelsAngleChanged(angle);
431 413 }
432 414 }
433 415
434 416 int QAxis::labelsAngle() const
435 417 {
436 418 return d_ptr->m_labelsAngle;
437 419 }
438 420
439 421 void QAxis::setLabelsColor(QColor color)
440 422 {
441 423 QBrush b = d_ptr->m_labelsBrush;
442 424 if (b.color() != color) {
443 425 b.setColor(color);
444 426 setLabelsBrush(b);
445 427 emit labelsColorChanged(color);
446 428 }
447 429 }
448 430
449 431 QColor QAxis::labelsColor() const
450 432 {
451 433 return d_ptr->m_labelsBrush.color();
452 434 }
453 435
454 436 void QAxis::setShadesVisible(bool visible)
455 437 {
456 438 if (d_ptr->m_shadesVisible != visible) {
457 439 d_ptr->m_shadesVisible = visible;
458 440 emit d_ptr->updated();
459 441 emit shadesVisibleChanged(visible);
460 442 }
461 443 }
462 444
463 445 bool QAxis::shadesVisible() const
464 446 {
465 447 return d_ptr->m_shadesVisible;
466 448 }
467 449
468 450 /*!
469 451 Sets \a pen used to draw shades.
470 452 */
471 453 void QAxis::setShadesPen(const QPen &pen)
472 454 {
473 455 if (d_ptr->m_shadesPen != pen) {
474 456 d_ptr->m_shadesPen = pen;
475 457 emit d_ptr->updated();
476 458 }
477 459 }
478 460
479 461 /*!
480 462 Returns pen used to draw shades.
481 463 */
482 464 QPen QAxis::shadesPen() const
483 465 {
484 466 return d_ptr->m_shadesPen;
485 467 }
486 468
487 469 /*!
488 470 Sets \a brush used to draw shades.
489 471 */
490 472 void QAxis::setShadesBrush(const QBrush &brush)
491 473 {
492 474 if (d_ptr->m_shadesBrush != brush) {
493 475 d_ptr->m_shadesBrush = brush;
494 476 emit d_ptr->updated();
495 477 emit shadesColorChanged(brush.color());
496 478 }
497 479 }
498 480
499 481 /*!
500 482 \brief Returns brush used to draw shades.
501 483 */
502 484 QBrush QAxis::shadesBrush() const
503 485 {
504 486 return d_ptr->m_shadesBrush;
505 487 }
506 488
507 489 void QAxis::setShadesColor(QColor color)
508 490 {
509 491 QBrush b = d_ptr->m_shadesBrush;
510 492 b.setColor(color);
511 493 setShadesBrush(b);
512 494 }
513 495
514 496 QColor QAxis::shadesColor() const
515 497 {
516 498 return d_ptr->m_shadesBrush.color();
517 499 }
518 500
519 501 void QAxis::setShadesBorderColor(QColor color)
520 502 {
521 503 QPen p = d_ptr->m_shadesPen;
522 504 p.setColor(color);
523 505 setShadesPen(p);
524 506 }
525 507
526 508 QColor QAxis::shadesBorderColor() const
527 509 {
528 510 return d_ptr->m_shadesPen.color();
529 511 }
530 512
531 513 void QAxis::setMin(qreal min)
532 514 {
533 515 setRange(min,d_ptr->m_max);
534 516 }
535 517
536 518 qreal QAxis::min() const
537 519 {
538 520 return d_ptr->m_min;
539 521 }
540 522
541 523 void QAxis::setMax(qreal max)
542 524 {
543 525 setRange(d_ptr->m_min,max);
544 526 }
545 527
546 528 qreal QAxis::max() const
547 529 {
548 530 return d_ptr->m_max;
549 531 }
550 532
551 533 /*!
552 534 Sets range from \a min to \a max on the axis.
553 535 */
554 536 void QAxis::setRange(qreal min, qreal max)
555 537 {
556 538 bool changed = false;
557 539 if (!qFuzzyIsNull(d_ptr->m_min - min)) {
558 540 d_ptr->m_min = min;
559 541 changed = true;
560 542 emit minChanged(min);
561 543 }
562 544
563 545 if (!qFuzzyIsNull(d_ptr->m_max - max)) {
564 546 d_ptr->m_max = max;
565 547 changed = true;
566 548 emit maxChanged(max);
567 549 }
568 550
569 551 if (changed) {
570 552 emit rangeChanged(d_ptr->m_min,d_ptr->m_max);
571 553 emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
572 554 }
573 555 }
574 556
575 557 /*!
576 558 Sets \a count for ticks on the axis.
577 559 */
578 560 void QAxis::setTicksCount(int count)
579 561 {
580 562 if (d_ptr->m_ticksCount != count) {
581 563 d_ptr->m_ticksCount = count;
582 emit ticksCountChanged(count);
583 564 emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
584 565 }
585 566 }
586 567
587 568 /*!
588 569 \fn int QAxis::ticksCount() const
589 570 Return number of ticks on the axis
590 571 */
591 572 int QAxis::ticksCount() const
592 573 {
593 574 return d_ptr->m_ticksCount;
594 575 }
595 576
596 577 /*!
597 578 Sets axis, shades, labels and grid lines to be visible.
598 579 */
599 580 void QAxis::show()
600 581 {
601 582 d_ptr->m_axisVisible=true;
602 583 d_ptr->m_gridLineVisible=true;
603 584 d_ptr->m_labelsVisible=true;
604 585 d_ptr->m_shadesVisible=true;
605 586 emit d_ptr->updated();
606 587 }
607 588
608 589 /*!
609 590 Sets axis, shades, labels and grid lines to not be visible.
610 591 */
611 592 void QAxis::hide()
612 593 {
613 594 d_ptr->m_axisVisible = false;
614 595 d_ptr->m_gridLineVisible = false;
615 596 d_ptr->m_labelsVisible = false;
616 597 d_ptr->m_shadesVisible = false;
617 598 emit d_ptr->updated();
618 599 }
619 600
620 601 void QAxis::setNiceNumbersEnabled(bool enable)
621 602 {
622 603 if (d_ptr->m_niceNumbers != enable){
623 604 d_ptr->m_niceNumbers = enable;
624 605 emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
625 emit niceNumbersEnabledChanged(enable);
626 606 }
627 607 }
628 608
629 609 bool QAxis::niceNumbersEnabled() const
630 610 {
631 611 return d_ptr->m_niceNumbers;
632 612 }
633 613
634 614 QAxisCategories* QAxis::categories()
635 615 {
636 616 return &d_ptr->m_category;
637 617 }
638 618
639 619 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
640 620
641 621 QAxisPrivate::QAxisPrivate(QAxis* q):
642 622 q_ptr(q),
643 623 m_axisVisible(true),
644 624 m_gridLineVisible(true),
645 625 m_labelsVisible(true),
646 626 m_labelsAngle(0),
647 627 m_shadesVisible(false),
648 628 m_shadesBrush(Qt::SolidPattern),
649 629 m_shadesOpacity(1.0),
650 630 m_min(0),
651 631 m_max(0),
652 632 m_ticksCount(5),
653 633 m_niceNumbers(false)
654 634 {
655 635
656 636 }
657 637
658 638 QAxisPrivate::~QAxisPrivate()
659 639 {
660 640
661 641 }
662 642
663 643 void QAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
664 644 {
665 645 q_ptr->setRange(min,max);
666 646 q_ptr->setTicksCount(count);
667 647 }
668 648
669 649 QTCOMMERCIALCHART_END_NAMESPACE
670 650
671 651 QTCOMMERCIALCHART_USE_NAMESPACE
672 652
673 653 #include "moc_qaxis.cpp"
674 654 #include "moc_qaxis_p.cpp"
@@ -1,138 +1,135
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef QAXIS_H
22 22 #define QAXIS_H
23 23
24 24 #include <qchartglobal.h>
25 25 #include <qaxiscategories.h>
26 26 #include <QPen>
27 27 #include <QFont>
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30
31 31 class QAxisPrivate;
32 32
33 33 class QTCOMMERCIALCHART_EXPORT QAxis : public QObject
34 34 {
35 35 Q_OBJECT
36 36 Q_PROPERTY(bool visible READ isAxisVisible WRITE setAxisVisible NOTIFY visibleChanged)
37 37 Q_PROPERTY(QColor color READ axisPenColor WRITE setAxisPenColor NOTIFY colorChanged)
38 38 Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
39 Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged)
39 Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle)
40 40 Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged)
41 41 Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged)
42 42 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
43 43 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
44 44 Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
45 45 Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged)
46 46 Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged)
47 Q_PROPERTY(int ticksCount READ ticksCount WRITE setTicksCount NOTIFY ticksCountChanged)
48 Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled NOTIFY niceNumbersEnabledChanged)
47 Q_PROPERTY(int ticksCount READ ticksCount WRITE setTicksCount)
48 Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled)
49 49
50 50 public:
51 51
52 52 QAxis(QObject *parent =0);
53 53 ~QAxis();
54 54
55 55 //axis handling
56 56 bool isAxisVisible() const;
57 57 void setAxisVisible(bool visible = true);
58 58 void setAxisPen(const QPen &pen);
59 59 QPen axisPen() const;
60 60 void setAxisPenColor(QColor color);
61 61 QColor axisPenColor() const;
62 62
63 63 //grid handling
64 64 bool isGridLineVisible() const;
65 65 void setGridLineVisible(bool visible = true);
66 66 void setGridLinePen(const QPen &pen);
67 67 QPen gridLinePen() const;
68 68
69 69 //labels handling
70 70 bool labelsVisible() const;
71 71 void setLabelsVisible(bool visible = true);
72 72 void setLabelsPen(const QPen &pen);
73 73 QPen labelsPen() const;
74 74 void setLabelsBrush(const QBrush &brush);
75 75 QBrush labelsBrush() const;
76 76 void setLabelsFont(const QFont &font);
77 77 QFont labelsFont() const;
78 78 void setLabelsAngle(int angle);
79 79 int labelsAngle() const;
80 80 void setLabelsColor(QColor color);
81 81 QColor labelsColor() const;
82 82
83 83 //shades handling
84 84 bool shadesVisible() const;
85 85 void setShadesVisible(bool visible = true);
86 86 void setShadesPen(const QPen &pen);
87 87 QPen shadesPen() const;
88 88 void setShadesBrush(const QBrush &brush);
89 89 QBrush shadesBrush() const;
90 90 void setShadesColor(QColor color);
91 91 QColor shadesColor() const;
92 92 void setShadesBorderColor(QColor color);
93 93 QColor shadesBorderColor() const;
94 94
95 95 //range handling
96 96 void setMin(qreal min);
97 97 qreal min() const;
98 98 void setMax(qreal max);
99 99 qreal max() const;
100 100 void setRange(qreal min, qreal max);
101 101
102 102 //ticks handling
103 103 void setTicksCount(int count);
104 104 int ticksCount() const;
105 105
106 106 void setNiceNumbersEnabled(bool enable = true);
107 107 bool niceNumbersEnabled() const;
108 108
109 109 QAxisCategories* categories();
110 110
111 111 void show();
112 112 void hide();
113 113
114 114 Q_SIGNALS:
115 115 void visibleChanged(bool visible);
116 116 void labelsVisibleChanged(bool visible);
117 117 void gridVisibleChanged(bool visible);
118 118 void rangeChanged(qreal min, qreal max);
119 119 void colorChanged(QColor color);
120 120 void labelsColorChanged(QColor color);
121 void labelsAngleChanged(int angle);
122 121 void shadesVisibleChanged(bool visible);
123 122 void shadesColorChanged(QColor color);
124 123 void shadesBorderColorChanged(QColor color);
125 124 void minChanged(qreal min);
126 125 void maxChanged(qreal max);
127 void ticksCountChanged(int count);
128 void niceNumbersEnabledChanged(bool enabled);
129 126
130 127 private:
131 128 QScopedPointer<QAxisPrivate> d_ptr;
132 129 Q_DISABLE_COPY(QAxis)
133 130 friend class ChartDataSet;
134 131 friend class ChartAxis;
135 132 };
136 133
137 134 QTCOMMERCIALCHART_END_NAMESPACE
138 135 #endif /* QCHARTAXIS_H_ */
@@ -1,768 +1,762
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qlegend.h"
22 22 #include "qlegend_p.h"
23 23 #include "qabstractseries.h"
24 24 #include "qabstractseries_p.h"
25 25 #include "qchart_p.h"
26 26
27 27 #include "legendmarker_p.h"
28 28 #include "qxyseries.h"
29 29 #include "qlineseries.h"
30 30 #include "qareaseries.h"
31 31 #include "qscatterseries.h"
32 32 #include "qsplineseries.h"
33 33 #include "qbarseries.h"
34 34 #include "qstackedbarseries.h"
35 35 #include "qpercentbarseries.h"
36 36 #include "qbarset.h"
37 37 #include "qpieseries.h"
38 38 #include "qpieseries_p.h"
39 39 #include "qpieslice.h"
40 40 #include "chartpresenter_p.h"
41 41 #include <QPainter>
42 42 #include <QPen>
43 43 #include <QTimer>
44 44
45 45 #include <QGraphicsSceneEvent>
46 46
47 47 QTCOMMERCIALCHART_BEGIN_NAMESPACE
48 48
49 49 /*!
50 50 \class QLegend
51 51 \brief part of QtCommercial chart API.
52 52 \mainclass
53 53
54 54 QLegend is a graphical object, whics displays legend of the chart. Legend state is updated by QChart, when
55 55 series have been changed. By default, legend is drawn by QChart, but user can set a new parent to legend and
56 56 handle the drawing manually.
57 57 User isn't supposed to create or delete legend objects, but can reference it via QChart class.
58 58
59 59 \image examples_percentbarchart_legend.png
60 60
61 61 \sa QChart
62 62 */
63 63 /*!
64 64 \qmlclass Legend QLegend
65 65 \brief Legend is part of QtCommercial Chart QML API.
66 66
67 67 Legend is a graphical object, whics displays legend of the chart. Legend state is updated by ChartView, when
68 68 series have been changed. Legend is used via ChartView class. For example:
69 69 \code
70 70 ChartView {
71 71 legend.visible: true
72 72 legend.alignment: Qt.AlignBottom
73 73 // Add a few series...
74 74 }
75 75 \endcode
76 76
77 77 \image examples_percentbarchart_legend.png
78 78 */
79 79
80 80 /*!
81 81 \property QLegend::alignment
82 82 \brief The alignment of the legend.
83 83
84 84 Legend paints on the defined position in the chart. The following alignments are supported:
85 85 Qt::AlignTop, Qt::AlignBottom, Qt::AlignLeft, Qt::AlignRight. If you set more than one flag the result is undefined.
86 86 */
87 87 /*!
88 88 \qmlproperty Qt.Alignment Legend::alignment
89 89 \brief The alignment of the legend.
90 90
91 91 Legend paints on the defined position in the chart. The following alignments are supported:
92 92 Qt.AlignTop, Qt.AlignBottom, Qt.AlignLeft, Qt.AlignRight. If you set more than one flag the result is undefined.
93 93 */
94 94
95 95 /*!
96 96 \property QLegend::backgroundVisible
97 97 Whether the legend background is visible or not.
98 98 */
99 99 /*!
100 100 \qmlproperty bool Legend::backgroundVisible
101 101 Whether the legend background is visible or not.
102 102 */
103 103
104 104 /*!
105 105 \property QLegend::color
106 106 The color of the legend, i.e. the background (brush) color. Note that if you change the color
107 107 of the legend, the style of the legend brush is set to Qt::SolidPattern.
108 108 */
109 109 /*!
110 110 \qmlproperty color Legend::color
111 111 The color of the legend, i.e. the background (brush) color.
112 112 */
113 113
114 114 /*!
115 115 \property QLegend::borderColor
116 116 The border color of the legend, i.e. the line color.
117 117 */
118 118 /*!
119 119 \qmlproperty color Legend::borderColor
120 120 The border color of the legend, i.e. the line color.
121 121 */
122 122
123 123 /*!
124 \fn void QLegend::alignmentChanged(Qt::Alignment)
125 Emitted when the \a alignment of the legend changes.
126 */
127
128 /*!
129 124 \fn void QLegend::backgroundVisibleChanged(bool)
130 125 The visibility of the legend background changed to \a visible.
131 126 */
132 127
133 128 /*!
134 129 \fn void QLegend::colorChanged(QColor)
135 130 The color of the legend background changed to \a color.
136 131 */
137 132
138 133 /*!
139 134 \fn void QLegend::borderColorChanged(QColor)
140 135 The border color of the legend background changed to \a color.
141 136 */
142 137
143 138 /*!
144 139 \fn qreal QLegend::minWidth() const
145 140 Returns minimum width of the legend
146 141 */
147 142
148 143 /*!
149 144 \fn qreal QLegend::minHeight() const
150 145 Returns minimum height of the legend
151 146 */
152 147
153 148 /*!
154 149 Constructs the legend object and sets the parent to \a parent
155 150 */
156 151
157 152 QLegend::QLegend(QChart *chart):QGraphicsWidget(chart),
158 153 d_ptr(new QLegendPrivate(chart->d_ptr->m_presenter,chart,this))
159 154 {
160 155 setZValue(ChartPresenter::LegendZValue);
161 156 setFlags(QGraphicsItem::ItemClipsChildrenToShape);
162 157 QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesAdded(QAbstractSeries*,Domain*)),d_ptr.data(),SLOT(handleSeriesAdded(QAbstractSeries*,Domain*)));
163 158 QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesRemoved(QAbstractSeries*)),d_ptr.data(),SLOT(handleSeriesRemoved(QAbstractSeries*)));
164 159 QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesUpdated(QAbstractSeries*)),d_ptr.data(),SLOT(handleSeriesUpdated(QAbstractSeries*)));
165 160 }
166 161
167 162 /*!
168 163 Destroys the legend object. Legend is always owned by a QChart, so an application should never call this.
169 164 */
170 165 QLegend::~QLegend()
171 166 {
172 167 }
173 168
174 169 /*!
175 170 Paints the legend to given \a painter. Paremeters \a option and \a widget arent used.
176 171 */
177 172
178 173 void QLegend::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
179 174 {
180 175 Q_UNUSED(option)
181 176 Q_UNUSED(widget)
182 177 if(!d_ptr->m_backgroundVisible) return;
183 178
184 179 painter->setOpacity(opacity());
185 180 painter->setPen(d_ptr->m_pen);
186 181 painter->setBrush(d_ptr->m_brush);
187 182 painter->drawRoundRect(rect(),d_ptr->roundness(rect().width()),d_ptr->roundness(rect().height()));
188 183 }
189 184
190 185 /*!
191 186 Bounding rect of legend.
192 187 */
193 188
194 189 QRectF QLegend::boundingRect() const
195 190 {
196 191 return d_ptr->m_rect;
197 192 }
198 193
199 194 /*!
200 195 Sets the \a brush of legend. Brush affects the background of legend.
201 196 */
202 197 void QLegend::setBrush(const QBrush &brush)
203 198 {
204 199 if (d_ptr->m_brush != brush) {
205 200 d_ptr->m_brush = brush;
206 201 update();
207 202 }
208 203 }
209 204
210 205 /*!
211 206 Returns the brush used by legend.
212 207 */
213 208 QBrush QLegend::brush() const
214 209 {
215 210 return d_ptr->m_brush;
216 211 }
217 212
218 213 void QLegend::setColor(QColor color)
219 214 {
220 215 QBrush b = d_ptr->m_brush;
221 216 if (b.style() != Qt::SolidPattern || b.color() != color) {
222 217 b.setStyle(Qt::SolidPattern);
223 218 b.setColor(color);
224 219 setBrush(b);
225 220 emit colorChanged(color);
226 221 }
227 222 }
228 223
229 224 QColor QLegend::color()
230 225 {
231 226 return d_ptr->m_brush.color();
232 227 }
233 228
234 229 /*!
235 230 Sets the \a pen of legend. Pen affects the legend borders.
236 231 */
237 232 void QLegend::setPen(const QPen &pen)
238 233 {
239 234 if (d_ptr->m_pen != pen) {
240 235 d_ptr->m_pen = pen;
241 236 update();
242 237 }
243 238 }
244 239
245 240 /*!
246 241 Returns the pen used by legend
247 242 */
248 243
249 244 QPen QLegend::pen() const
250 245 {
251 246 return d_ptr->m_pen;
252 247 }
253 248
254 249 void QLegend::setBorderColor(QColor color)
255 250 {
256 251 QPen p = d_ptr->m_pen;
257 252 if (p.color() != color) {
258 253 p.setColor(color);
259 254 setPen(p);
260 255 emit borderColorChanged(color);
261 256 }
262 257 }
263 258
264 259 QColor QLegend::borderColor()
265 260 {
266 261 return d_ptr->m_pen.color();
267 262 }
268 263
269 264 void QLegend::setAlignment(Qt::Alignment alignment)
270 265 {
271 266 if(d_ptr->m_alignment!=alignment) {
272 267 d_ptr->m_alignment = alignment;
273 268 d_ptr->updateLayout();
274 alignmentChanged(alignment);
275 269 }
276 270 }
277 271
278 272 Qt::Alignment QLegend::alignment() const
279 273 {
280 274 return d_ptr->m_alignment;
281 275 }
282 276
283 277 /*!
284 278 Detaches the legend from chart. Chart won't change layout of the legend.
285 279 */
286 280 void QLegend::detachFromChart()
287 281 {
288 282 d_ptr->m_attachedToChart = false;
289 283 }
290 284
291 285 /*!
292 286 Attaches the legend to chart. Chart may change layout of the legend.
293 287 */
294 288 void QLegend::attachToChart()
295 289 {
296 290 d_ptr->attachToChart();
297 291 }
298 292
299 293 /*!
300 294 Returns true, if legend is attached to chart.
301 295 */
302 296 bool QLegend::isAttachedToChart()
303 297 {
304 298 return d_ptr->m_attachedToChart;
305 299 }
306 300
307 301 /*!
308 302 Sets the visibility of legend background to \a visible
309 303 */
310 304 void QLegend::setBackgroundVisible(bool visible)
311 305 {
312 306 if(d_ptr->m_backgroundVisible != visible) {
313 307 d_ptr->m_backgroundVisible = visible;
314 308 update();
315 309 emit backgroundVisibleChanged(visible);
316 310 }
317 311 }
318 312
319 313 /*!
320 314 Returns the visibility of legend background
321 315 */
322 316 bool QLegend::isBackgroundVisible() const
323 317 {
324 318 return d_ptr->m_backgroundVisible;
325 319 }
326 320
327 321 /*!
328 322 \internal \a event see QGraphicsWidget for details
329 323 */
330 324 void QLegend::resizeEvent(QGraphicsSceneResizeEvent *event)
331 325 {
332 326 const QRectF& rect = QRectF(QPoint(0,0),event->newSize());
333 327 QGraphicsWidget::resizeEvent(event);
334 328 if(d_ptr->m_rect != rect) {
335 329 d_ptr->m_rect = rect;
336 330 d_ptr->updateLayout();
337 331 }
338 332 }
339 333
340 334 /*!
341 335 \internal \a event see QGraphicsWidget for details
342 336 */
343 337 void QLegend::hideEvent(QHideEvent *event)
344 338 {
345 339 QGraphicsWidget::hideEvent(event);
346 340 setEnabled(false);
347 341 d_ptr->updateLayout();
348 342 }
349 343
350 344 /*!
351 345 \internal \a event see QGraphicsWidget for details
352 346 */
353 347 void QLegend::showEvent(QShowEvent *event)
354 348 {
355 349 QGraphicsWidget::showEvent(event);
356 350 setEnabled(true);
357 351 d_ptr->updateLayout();
358 352 }
359 353
360 354 qreal QLegend::minWidth() const
361 355 {
362 356 return d_ptr->m_minWidth;
363 357 }
364 358
365 359 qreal QLegend::minHeight() const
366 360 {
367 361 return d_ptr->m_minHeight;
368 362 }
369 363
370 364 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
371 365
372 366 QLegendPrivate::QLegendPrivate(ChartPresenter* presenter, QChart *chart, QLegend *q):
373 367 q_ptr(q),
374 368 m_presenter(presenter),
375 369 m_chart(chart),
376 370 m_markers(new QGraphicsItemGroup(q)),
377 371 m_alignment(Qt::AlignTop),
378 372 m_brush(QBrush()),
379 373 m_pen(QPen()),
380 374 m_offsetX(0),
381 375 m_offsetY(0),
382 376 m_minWidth(0),
383 377 m_minHeight(0),
384 378 m_width(0),
385 379 m_height(0),
386 380 m_diameter(5),
387 381 m_attachedToChart(true),
388 382 m_backgroundVisible(false)
389 383 {
390 384
391 385 }
392 386
393 387 QLegendPrivate::~QLegendPrivate()
394 388 {
395 389
396 390 }
397 391
398 392 void QLegendPrivate::setOffset(qreal x, qreal y)
399 393 {
400 394 bool scrollHorizontal = true;
401 395 switch(m_alignment) {
402 396 case Qt::AlignTop:
403 397 case Qt::AlignBottom: {
404 398 scrollHorizontal = true;
405 399 break;
406 400 }
407 401 case Qt::AlignLeft:
408 402 case Qt::AlignRight: {
409 403 scrollHorizontal = false;
410 404 break;
411 405 }
412 406 }
413 407
414 408 // If detached, the scrolling direction is vertical instead of horizontal and vice versa.
415 409 if (!m_attachedToChart) {
416 410 scrollHorizontal = !scrollHorizontal;
417 411 }
418 412
419 413 // Limit offset between m_minOffset and m_maxOffset
420 414 if (scrollHorizontal) {
421 415 if(m_width<=m_rect.width()) return;
422 416
423 417 if (x != m_offsetX) {
424 418 m_offsetX = qBound(m_minOffsetX, x, m_maxOffsetX);
425 419 m_markers->setPos(-m_offsetX,m_rect.top());
426 420 }
427 421 } else {
428 422 if(m_height<=m_rect.height()) return;
429 423
430 424 if (y != m_offsetY) {
431 425 m_offsetY = qBound(m_minOffsetY, y, m_maxOffsetY);
432 426 m_markers->setPos(m_rect.left(),-m_offsetY);
433 427 }
434 428 }
435 429 }
436 430
437 431 QPointF QLegendPrivate::offset() const
438 432 {
439 433 return QPointF(m_offsetX,m_offsetY);
440 434 }
441 435
442 436 void QLegendPrivate::updateLayout()
443 437 {
444 438 if (!m_attachedToChart) {
445 439 updateDetachedLayout();
446 440 return;
447 441 }
448 442
449 443 m_offsetX=0;
450 444 QList<QGraphicsItem *> items = m_markers->childItems();
451 445
452 446 if(items.isEmpty()) return;
453 447
454 448 m_minWidth=0;
455 449 m_minHeight=0;
456 450
457 451 switch(m_alignment) {
458 452
459 453 case Qt::AlignTop:
460 454 case Qt::AlignBottom: {
461 455 QPointF point = m_rect.topLeft();
462 456 m_width = 0;
463 457 foreach (QGraphicsItem *item, items) {
464 458 if (item->isVisible()) {
465 459 item->setPos(point.x(),m_rect.height()/2 -item->boundingRect().height()/2);
466 460 const QRectF& rect = item->boundingRect();
467 461 qreal w = rect.width();
468 462 m_minWidth=qMax(m_minWidth,w);
469 463 m_minHeight=qMax(m_minHeight,rect.height());
470 464 m_width+=w;
471 465 point.setX(point.x() + w);
472 466 }
473 467 }
474 468 if(m_width<m_rect.width()) {
475 469 m_markers->setPos(m_rect.width()/2-m_width/2,m_rect.top());
476 470 }
477 471 else {
478 472 m_markers->setPos(m_rect.topLeft());
479 473 }
480 474 m_height=m_minHeight;
481 475 }
482 476 break;
483 477 case Qt::AlignLeft:
484 478 case Qt::AlignRight: {
485 479 QPointF point = m_rect.topLeft();
486 480 m_height = 0;
487 481 foreach (QGraphicsItem *item, items) {
488 482 if (item->isVisible()) {
489 483 item->setPos(point);
490 484 const QRectF& rect = item->boundingRect();
491 485 qreal h = rect.height();
492 486 m_minWidth=qMax(m_minWidth,rect.width());
493 487 m_minHeight=qMax(m_minHeight,h);
494 488 m_height+=h;
495 489 point.setY(point.y() + h);
496 490 }
497 491 }
498 492 if(m_height<m_rect.height()) {
499 493 m_markers->setPos(m_rect.left(),m_rect.height()/2-m_height/2);
500 494 }
501 495 else {
502 496 m_markers->setPos(m_rect.topLeft());
503 497 }
504 498 m_width=m_minWidth;
505 499 }
506 500 break;
507 501 }
508 502
509 503 m_minOffsetX = 0;
510 504 m_minOffsetY = 0;
511 505 m_maxOffsetX = m_width - m_rect.width();
512 506 m_maxOffsetY = m_height - m_rect.height();
513 507
514 508 m_presenter->updateLayout();
515 509 }
516 510
517 511 void QLegendPrivate::updateDetachedLayout()
518 512 {
519 513 // Detached layout is different.
520 514 // In detached mode legend may have multiple rows and columns, so layout calculations
521 515 // differ a log from attached mode.
522 516 // Also the scrolling logic is bit different.
523 517 m_offsetX=0;
524 518 m_offsetY=0;
525 519 QList<QGraphicsItem *> items = m_markers->childItems();
526 520
527 521 if(items.isEmpty()) return;
528 522
529 523 m_minWidth = 0;
530 524 m_minHeight = 0;
531 525
532 526 switch (m_alignment) {
533 527 case Qt::AlignTop: {
534 528 QPointF point = m_rect.topLeft();
535 529 m_width = 0;
536 530 m_height = 0;
537 531 for (int i=0; i<items.count(); i++) {
538 532 QGraphicsItem *item = items.at(i);
539 533 if (item->isVisible()) {
540 534 const QRectF& rect = item->boundingRect();
541 535 qreal w = rect.width();
542 536 qreal h = rect.height();
543 537 m_minWidth = qMax(m_minWidth,w);
544 538 m_minHeight = qMax(m_minHeight,rect.height());
545 539 m_height = qMax(m_height,h);
546 540 item->setPos(point.x(),point.y());
547 541 point.setX(point.x() + w);
548 542 if (point.x() + w > m_rect.topLeft().x() + m_rect.width()) {
549 543 // Next item would go off rect.
550 544 point.setX(m_rect.topLeft().x());
551 545 point.setY(point.y() + h);
552 546 if (i+1 < items.count()) {
553 547 m_height += h;
554 548 }
555 549 }
556 550 }
557 551 }
558 552 m_markers->setPos(m_rect.topLeft());
559 553 m_width = m_minWidth;
560 554
561 555 m_minOffsetX = 0;
562 556 m_minOffsetY = 0;
563 557 m_maxOffsetX = m_width - m_rect.width();
564 558 m_maxOffsetY = m_height - m_rect.height();
565 559 }
566 560 break;
567 561 case Qt::AlignBottom: {
568 562 QPointF point = m_rect.bottomLeft();
569 563 m_width = 0;
570 564 m_height = 0;
571 565 for (int i=0; i<items.count(); i++) {
572 566 QGraphicsItem *item = items.at(i);
573 567 if (item->isVisible()) {
574 568 const QRectF& rect = item->boundingRect();
575 569 qreal w = rect.width();
576 570 qreal h = rect.height();
577 571 m_minWidth = qMax(m_minWidth,w);
578 572 m_minHeight = qMax(m_minHeight,rect.height());
579 573 m_height = qMax(m_height,h);
580 574 item->setPos(point.x(),point.y() - h);
581 575 point.setX(point.x() + w);
582 576 if (point.x() + w > m_rect.bottomLeft().x() + m_rect.width()) {
583 577 // Next item would go off rect.
584 578 point.setX(m_rect.bottomLeft().x());
585 579 point.setY(point.y() - h);
586 580 if (i+1 < items.count()) {
587 581 m_height += h;
588 582 }
589 583 }
590 584 }
591 585 }
592 586 m_markers->setPos(m_rect.topLeft());
593 587 m_width = m_minWidth;
594 588
595 589 m_minOffsetX = 0;
596 590 m_minOffsetY = qMin(m_rect.topLeft().y(), m_rect.topLeft().y() - m_height + m_rect.height());
597 591 m_maxOffsetX = m_width - m_rect.width();
598 592 m_maxOffsetY = 0;
599 593 }
600 594 break;
601 595 case Qt::AlignLeft: {
602 596 QPointF point = m_rect.topLeft();
603 597 m_width = 0;
604 598 m_height = 0;
605 599 qreal maxWidth = 0;
606 600 for (int i=0; i<items.count(); i++) {
607 601 QGraphicsItem *item = items.at(i);
608 602 if (item->isVisible()) {
609 603 const QRectF& rect = item->boundingRect();
610 604 qreal w = rect.width();
611 605 qreal h = rect.height();
612 606 m_minWidth = qMax(m_minWidth,rect.width());
613 607 m_minHeight = qMax(m_minHeight,h);
614 608 maxWidth = qMax(maxWidth,w);
615 609 item->setPos(point.x(),point.y());
616 610 point.setY(point.y() + h);
617 611 if (point.y() + h > m_rect.topLeft().y() + m_rect.height()) {
618 612 // Next item would go off rect.
619 613 point.setX(point.x() + maxWidth);
620 614 point.setY(m_rect.topLeft().y());
621 615 if (i+1 < items.count()) {
622 616 m_width += maxWidth;
623 617 maxWidth = 0;
624 618 }
625 619 }
626 620 }
627 621 }
628 622 m_width += maxWidth;
629 623 m_markers->setPos(m_rect.topLeft());
630 624 m_height = m_minHeight;
631 625
632 626 m_minOffsetX = 0;
633 627 m_minOffsetY = 0;
634 628 m_maxOffsetX = m_width - m_rect.width();
635 629 m_maxOffsetY = m_height - m_rect.height();
636 630 }
637 631 break;
638 632 case Qt::AlignRight: {
639 633 QPointF point = m_rect.topRight();
640 634 m_width = 0;
641 635 m_height = 0;
642 636 qreal maxWidth = 0;
643 637 for (int i=0; i<items.count(); i++) {
644 638 QGraphicsItem *item = items.at(i);
645 639 if (item->isVisible()) {
646 640 const QRectF& rect = item->boundingRect();
647 641 qreal w = rect.width();
648 642 qreal h = rect.height();
649 643 m_minWidth = qMax(m_minWidth,rect.width());
650 644 m_minHeight = qMax(m_minHeight,h);
651 645 maxWidth = qMax(maxWidth,w);
652 646 item->setPos(point.x() - w,point.y());
653 647 point.setY(point.y() + h);
654 648 if (point.y() + h > m_rect.topLeft().y() + m_rect.height()) {
655 649 // Next item would go off rect.
656 650 point.setX(point.x() - maxWidth);
657 651 point.setY(m_rect.topLeft().y());
658 652 if (i+1 < items.count()) {
659 653 m_width += maxWidth;
660 654 maxWidth = 0;
661 655 }
662 656 }
663 657 }
664 658 }
665 659 m_width += maxWidth;
666 660 m_markers->setPos(m_rect.topLeft());
667 661 m_height = m_minHeight;
668 662
669 663 m_minOffsetX = qMin(m_rect.topLeft().x(), m_rect.topLeft().x() - m_width + m_rect.width());
670 664 m_minOffsetY = 0;
671 665 m_maxOffsetX = 0;
672 666 m_maxOffsetY = m_height - m_rect.height();
673 667 }
674 668 break;
675 669 default:
676 670 break;
677 671 }
678 672 }
679 673
680 674 void QLegendPrivate::attachToChart()
681 675 {
682 676 m_attachedToChart = true;
683 677 q_ptr->setParent(m_chart);
684 678 }
685 679
686 680 int QLegendPrivate::roundness(qreal size)
687 681 {
688 682 return 100*m_diameter/int(size);
689 683 }
690 684
691 685 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain)
692 686 {
693 687 Q_UNUSED(domain)
694 688
695 689 QList<LegendMarker*> markers = series->d_ptr->createLegendMarker(q_ptr);
696 690 foreach(LegendMarker* marker, markers)
697 691 m_markers->addToGroup(marker);
698 692
699 693 QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
700 694
701 695 if(series->type() == QAbstractSeries::SeriesTypePie) {
702 696 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
703 697 QObject::connect(pieSeries, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries()));
704 698 QObject::connect(pieSeries, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries()));
705 699 }
706 700
707 701 updateLayout();
708 702 }
709 703
710 704 void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series)
711 705 {
712 706 QList<QGraphicsItem *> items = m_markers->childItems();
713 707
714 708 foreach (QGraphicsItem *markers, items) {
715 709 LegendMarker *marker = static_cast<LegendMarker*>(markers);
716 710 if (marker->series() == series) {
717 711 delete marker;
718 712 }
719 713 }
720 714
721 715 if(series->type() == QAbstractSeries::SeriesTypePie)
722 716 {
723 717 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
724 718 QObject::disconnect(pieSeries, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries()));
725 719 QObject::disconnect(pieSeries, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries()));
726 720 }
727 721
728 722 updateLayout();
729 723 }
730 724
731 725 void QLegendPrivate::handleSeriesUpdated(QAbstractSeries *series)
732 726 {
733 727 // TODO: find out which markers are are added or removed. Update them
734 728 // TODO: better implementation
735 729 handleSeriesRemoved(series);
736 730 Domain domain;
737 731 handleSeriesAdded(series, &domain);
738 732 }
739 733
740 734 void QLegendPrivate::handleUpdatePieSeries()
741 735 {
742 736 //TODO: reimplement to be optimal
743 737 QPieSeries* series = qobject_cast<QPieSeries *> (sender());
744 738 Q_ASSERT(series);
745 739 handleSeriesRemoved(series);
746 740 handleSeriesAdded(series, 0);
747 741 }
748 742
749 743 void QLegendPrivate::handleSeriesVisibleChanged()
750 744 {
751 745 QAbstractSeries* series = qobject_cast<QAbstractSeries *> (sender());
752 746 QList<QGraphicsItem *> items = m_markers->childItems();
753 747
754 748 foreach (QGraphicsItem *markers, items) {
755 749 LegendMarker *marker = static_cast<LegendMarker*>(markers);
756 750 if (marker->series() == series) {
757 751 marker->setVisible(!marker->isVisible());
758 752 }
759 753 }
760 754
761 755 updateLayout();
762 756 }
763 757
764 758
765 759 #include "moc_qlegend.cpp"
766 760 #include "moc_qlegend_p.cpp"
767 761
768 762 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,102 +1,101
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef QLEGEND_H
22 22 #define QLEGEND_H
23 23
24 24 #include <QChartGlobal>
25 25 #include <QGraphicsWidget>
26 26 #include <QPen>
27 27 #include <QBrush>
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30
31 31 class Domain;
32 32 class LegendMarker;
33 33 class QPieSlice;
34 34 class QXYSeries;
35 35 class QBarSet;
36 36 class QBarSeries;
37 37 class QPieSeries;
38 38 class QAreaSeries;
39 39 class LegendScrollButton;
40 40 class QChart;
41 41 class QLegendPrivate;
42 42
43 43 class QTCOMMERCIALCHART_EXPORT QLegend : public QGraphicsWidget
44 44 {
45 45 Q_OBJECT
46 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
46 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
47 47 Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible NOTIFY backgroundVisibleChanged)
48 48 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
49 49 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
50 50
51 51 private:
52 52 explicit QLegend(QChart *chart);
53 53
54 54 public:
55 55 ~QLegend();
56 56
57 57 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
58 58 QRectF boundingRect() const;
59 59
60 60 void setBrush(const QBrush &brush);
61 61 QBrush brush() const;
62 62 void setColor(QColor color);
63 63 QColor color();
64 64
65 65 void setPen(const QPen &pen);
66 66 QPen pen() const;
67 67 void setBorderColor(QColor color);
68 68 QColor borderColor();
69 69
70 70 void setAlignment(Qt::Alignment alignment);
71 71 Qt::Alignment alignment() const;
72 72
73 73 void detachFromChart();
74 74 void attachToChart();
75 75 bool isAttachedToChart();
76 76
77 77 qreal minWidth() const;
78 78 qreal minHeight() const;
79 79
80 80 void setBackgroundVisible(bool visible = true);
81 81 bool isBackgroundVisible() const;
82 82
83 83 protected:
84 84 void resizeEvent(QGraphicsSceneResizeEvent *event);
85 85 void hideEvent(QHideEvent *event);
86 86 void showEvent(QShowEvent *event);
87 87
88 88 Q_SIGNALS:
89 void alignmentChanged(Qt::Alignment alignment);
90 89 void backgroundVisibleChanged(bool visible);
91 90 void colorChanged(QColor color);
92 91 void borderColorChanged(QColor color);
93 92
94 93 private:
95 94 QScopedPointer<QLegendPrivate> d_ptr;
96 95 Q_DISABLE_COPY(QLegend)
97 96 friend class LegendScroller;
98 97 };
99 98
100 99 QTCOMMERCIALCHART_END_NAMESPACE
101 100
102 101 #endif // QLEGEND_H
@@ -1,178 +1,207
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qscatterseries.h"
22 22 #include "qscatterseries_p.h"
23 23 #include "scatterchartitem_p.h"
24 24 #include "chartdataset_p.h"
25 25 #include "charttheme_p.h"
26 26 #include "chartanimator_p.h"
27 27
28 28 /*!
29 29 \class QScatterSeries
30 30 \brief The QScatterSeries class is used for making scatter charts.
31 31
32 32 \mainclass
33 33
34 34 The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis
35 35 and the vertical axis.
36 36
37 37 \image examples_scatterchart.png
38 38
39 39 Creating basic scatter chart is simple:
40 40 \code
41 41 QScatterSeries* series = new QScatterSeries();
42 42 series->append(0, 6);
43 43 series->append(2, 4);
44 44 ...
45 45 chart->addSeries(series);
46 46 \endcode
47 47 */
48 48
49 49 /*!
50 50 \enum QScatterSeries::MarkerShape
51 51
52 52 This enum describes the shape used when rendering marker items.
53 53
54 54 \value MarkerShapeCircle
55 55 \value MarkerShapeRectangle
56 56 */
57 57
58 58 /*!
59 \property QScatterSeries::markerShape
60
61 Defines the shape of the marker used to draw the points in the series.
59 \property QScatterSeries::color
60 Fill (brush) color of the series. This is a convenience property for modifying the color of brush.
61 \sa QScatterSeries::brush()
62 62 */
63 63
64 64 /*!
65 \fn void QScatterSeries::markerShapeChanged()
66 Emitted when marker shape is changed
65 \property QScatterSeries::borderColor
66 Line (pen) color of the series. This is a convenience property for modifying the color of pen.
67 \sa QScatterSeries::pen()
67 68 */
68 69
69 70 /*!
70 \fn void QScatterSeries::markerSizeChanged()
71 Emitted when marker size is changed
71 \property QScatterSeries::markerShape
72
73 Defines the shape of the marker used to draw the points in the series. The default shape is MarkerShapeCircle.
72 74 */
73 75
74 76 /*!
75 77 \property QScatterSeries::markerSize
76 78
77 Defines the size of the marker used to draw the points in the series.
79 Defines the size of the marker used to draw the points in the series. The default size is 15.0.
80 */
81
82 /*!
83 \fn void QScatterSeries::colorChanged(QColor color)
84 \brief Signal is emitted when the fill (brush) color has changed to \a color.
85 */
86
87 /*!
88 \fn void QScatterSeries::borderColorChanged(QColor color)
89 \brief Signal is emitted when the line (pen) color has changed to \a color.
78 90 */
79 91
80 92 /*!
81 93 \fn QChartSeriesType QScatterSeries::type() const
82 94 \brief Returns QChartSeries::SeriesTypeScatter.
83 95 \sa QAbstractSeries, SeriesType
84 96 */
85 97
86 98 QTCOMMERCIALCHART_BEGIN_NAMESPACE
87 99
88 100 /*!
89 101 Constructs a series object which is a child of \a parent.
90 102 */
91 103 QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent)
92 104 {
93 105 }
94 106
95 107 /*!
96 108 Destroys the object. Note that adding series to QChart transfers the ownership to the chart.
97 109 */
98 110 QScatterSeries::~QScatterSeries()
99 111 {
100 112 Q_D(QScatterSeries);
101 113 if(d->m_dataset) {
102 114 d->m_dataset->removeSeries(this);
103 115 }
104 116 }
105 117
106 118 QAbstractSeries::SeriesType QScatterSeries::type() const
107 119 {
108 120 return QAbstractSeries::SeriesTypeScatter;
109 121 }
110 122
111 /*!
112 Returns the shape used for drawing markers.
113 */
123 void QScatterSeries::setColor(const QColor &color)
124 {
125 QBrush b = brush();
126 if (b.color() != color) {
127 b.setColor(color);
128 setBrush(b);
129 emit colorChanged(color);
130 }
131 }
132
133 QColor QScatterSeries::color() const
134 {
135 return brush().color();
136 }
137
138 void QScatterSeries::setBorderColor(const QColor &color)
139 {
140 QPen p = pen();
141 if (p.color() != color) {
142 p.setColor(color);
143 setPen(p);
144 emit borderColorChanged(color);
145 }
146 }
147
148 QColor QScatterSeries::borderColor() const
149 {
150 return pen().color();
151 }
152
114 153 QScatterSeries::MarkerShape QScatterSeries::markerShape() const
115 154 {
116 155 Q_D(const QScatterSeries);
117 156 return d->m_shape;
118 157 }
119 158
120 /*!
121 Overrides the default shape of the marker items with a user defined \a shape. The default shape
122 is defined by chart theme setting.
123 */
124 159 void QScatterSeries::setMarkerShape(MarkerShape shape)
125 160 {
126 161 Q_D(QScatterSeries);
127 162 if (d->m_shape != shape) {
128 163 d->m_shape = shape;
129 emit markerShapeChanged();
164 emit d->updated();
130 165 }
131 166 }
132 167
133 /*!
134 Returns the size of the marker items.
135 */
136 168 qreal QScatterSeries::markerSize() const
137 169 {
138 170 Q_D(const QScatterSeries);
139 171 return d->m_size;
140 172 }
141 173
142 /*!
143 Set the \a size of the marker items. The default size is 15.
144 */
145 174 void QScatterSeries::setMarkerSize(qreal size)
146 175 {
147 176 Q_D(QScatterSeries);
148 177
149 178 if (!qFuzzyIsNull(d->m_size - size)) {
150 179 d->m_size = size;
151 emit markerSizeChanged();
180 emit d->updated();
152 181 }
153 182 }
154 183
155 184 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
156 185
157 186 QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q):QXYSeriesPrivate(q),
158 187 m_shape(QScatterSeries::MarkerShapeCircle),
159 188 m_size(15.0)
160 189 {
161 190
162 191 };
163 192
164 193 Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter)
165 194 {
166 195 Q_Q(QScatterSeries);
167 196 ScatterChartItem *scatter = new ScatterChartItem(q,presenter);
168 197 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
169 198 scatter->setAnimator(presenter->animator());
170 199 scatter->setAnimation(new XYAnimation(scatter));
171 200 }
172 201 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
173 202 return scatter;
174 203 }
175 204
176 205 #include "moc_qscatterseries.cpp"
177 206
178 207 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,66 +1,71
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef QSCATTERSERIES_H
22 22 #define QSCATTERSERIES_H
23 23
24 24 #include <qchartglobal.h>
25 25 #include <qxyseries.h>
26 26
27 27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 28
29 29 class QScatterSeriesPrivate;
30 30
31 31 class QTCOMMERCIALCHART_EXPORT QScatterSeries : public QXYSeries
32 32 {
33 33 Q_OBJECT
34 Q_PROPERTY(MarkerShape markerShape READ markerShape WRITE setMarkerShape NOTIFY markerShapeChanged)
35 Q_PROPERTY(qreal markerSize READ markerSize WRITE setMarkerSize NOTIFY markerSizeChanged)
34 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
35 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
36 Q_PROPERTY(MarkerShape markerShape READ markerShape WRITE setMarkerShape)
37 Q_PROPERTY(qreal markerSize READ markerSize WRITE setMarkerSize)
36 38 Q_ENUMS(MarkerShape)
37 39
38 40 public:
39 41 enum MarkerShape {
40 42 MarkerShapeCircle,
41 43 MarkerShapeRectangle
42 44 };
43 45
44 46 public:
45 47 explicit QScatterSeries(QObject *parent = 0);
46 48 ~QScatterSeries();
47 49 QAbstractSeries::SeriesType type() const;
50 void setColor(const QColor &color);
51 QColor color() const;
52 void setBorderColor(const QColor &color);
53 QColor borderColor() const;
48 54 MarkerShape markerShape() const;
49 55 void setMarkerShape(MarkerShape shape);
50 56 qreal markerSize() const;
51 57 void setMarkerSize(qreal size);
52 58
53 59 Q_SIGNALS:
54 void markerShapeChanged();
55 void markerSizeChanged();
60 void colorChanged(QColor color);
61 void borderColorChanged(QColor color);
56 62
57 63 private:
58 64 Q_DECLARE_PRIVATE(QScatterSeries)
59 65 Q_DISABLE_COPY(QScatterSeries)
60 66 friend class ScatterChartItem;
61
62 67 };
63 68
64 69 QTCOMMERCIALCHART_END_NAMESPACE
65 70
66 71 #endif // QSCATTERSERIES_H
@@ -1,207 +1,205
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "scatterchartitem_p.h"
22 22 #include "qscatterseries.h"
23 23 #include "qscatterseries_p.h"
24 24 #include "chartpresenter_p.h"
25 25 #include <QPainter>
26 26 #include <QGraphicsScene>
27 27 #include <QDebug>
28 28 #include <QGraphicsSceneMouseEvent>
29 29
30 30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 31
32 32 ScatterChartItem::ScatterChartItem(QScatterSeries *series, ChartPresenter *presenter) :
33 33 XYChart(series,presenter),
34 34 QGraphicsItem(presenter ? presenter->rootItem() : 0),
35 35 m_series(series),
36 36 m_items(this),
37 37 m_visible(true),
38 38 m_shape(QScatterSeries::MarkerShapeRectangle),
39 39 m_size(15)
40 40 {
41 41 QObject::connect(m_series->d_func(),SIGNAL(updated()), this, SLOT(handleUpdated()));
42 QObject::connect(m_series, SIGNAL(markerShapeChanged()), this, SLOT(handleUpdated()));
43 QObject::connect(m_series, SIGNAL(markerSizeChanged()), this, SLOT(handleUpdated()));
44 42 QObject::connect(m_series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated()));
45 43
46 44 setZValue(ChartPresenter::ScatterSeriesZValue);
47 45 setFlags(QGraphicsItem::ItemClipsChildrenToShape);
48 46
49 47 handleUpdated();
50 48
51 49 m_items.setHandlesChildEvents(false);
52 50
53 51 // TODO: how to draw a drop shadow?
54 52 // QGraphicsDropShadowEffect *dropShadow = new QGraphicsDropShadowEffect();
55 53 // dropShadow->setOffset(2.0);
56 54 // dropShadow->setBlurRadius(2.0);
57 55 // setGraphicsEffect(dropShadow);
58 56 }
59 57
60 58 QRectF ScatterChartItem::boundingRect() const
61 59 {
62 60 return m_rect;
63 61 }
64 62
65 63 void ScatterChartItem::createPoints(int count)
66 64 {
67 65 for (int i = 0; i < count; ++i) {
68 66
69 67 QGraphicsItem *item = 0;
70 68
71 69 switch (m_shape) {
72 70 case QScatterSeries::MarkerShapeCircle: {
73 71 QGraphicsEllipseItem* i = new QGraphicsEllipseItem(0,0,m_size,m_size);
74 72 const QRectF& rect = i->boundingRect();
75 73 i->setPos(-rect.width()/2,-rect.height()/2);
76 74 item = new Marker(i,this);
77 75 break;
78 76 }
79 77 case QScatterSeries::MarkerShapeRectangle: {
80 78 QGraphicsRectItem* i = new QGraphicsRectItem(0,0,m_size,m_size);
81 79 i->setPos(-m_size/2,-m_size/2);
82 80 item = new Marker(i,this);
83 81 break;
84 82 }
85 83 default:
86 84 qWarning()<<"Unsupported marker type";
87 85 break;
88 86
89 87 }
90 88 m_items.addToGroup(item);
91 89 }
92 90 }
93 91
94 92 void ScatterChartItem::deletePoints(int count)
95 93 {
96 94 QList<QGraphicsItem *> items = m_items.childItems();
97 95
98 96 for (int i = 0; i < count; ++i) {
99 97 delete(items.takeLast());
100 98 }
101 99 }
102 100
103 101 void ScatterChartItem::markerSelected(Marker *marker)
104 102 {
105 103 emit XYChart::clicked(calculateDomainPoint(marker->point()));
106 104 }
107 105
108 106 void ScatterChartItem::updateGeometry()
109 107 {
110 108
111 109 const QVector<QPointF>& points = geometryPoints();
112 110
113 111 if(points.size()==0)
114 112 {
115 113 deletePoints(m_items.childItems().count());
116 114 return;
117 115 }
118 116
119 117 int diff = m_items.childItems().size() - points.size();
120 118
121 119 if(diff>0) {
122 120 deletePoints(diff);
123 121 }
124 122 else if(diff<0) {
125 123 createPoints(-diff);
126 124 }
127 125
128 126 if(diff!=0) handleUpdated();
129 127
130 128 QList<QGraphicsItem*> items = m_items.childItems();
131 129
132 130 for (int i = 0; i < points.size(); i++) {
133 131 Marker* item = static_cast<Marker*>(items.at(i));
134 132 const QPointF& point = points.at(i);
135 133 const QRectF& rect = item->boundingRect();
136 134 item->setPoint(point);
137 135 item->setPos(point.x()-rect.width()/2,point.y()-rect.height()/2);
138 136 if(!m_visible || !clipRect().contains(point)) {
139 137 item->setVisible(false);
140 138 }
141 139 else {
142 140 item->setVisible(true);
143 141 }
144 142 }
145 143
146 144 prepareGeometryChange();
147 145 m_rect = clipRect();
148 146 setPos(origin());
149 147 }
150 148
151 149 void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
152 150 {
153 151 Q_UNUSED(painter)
154 152 Q_UNUSED(option)
155 153 Q_UNUSED(widget)
156 154 }
157 155
158 156 void ScatterChartItem::setPen(const QPen& pen)
159 157 {
160 158 foreach(QGraphicsItem* item , m_items.childItems()) {
161 159 static_cast<Marker*>(item)->setPen(pen);
162 160 }
163 161 }
164 162
165 163 void ScatterChartItem::setBrush(const QBrush& brush)
166 164 {
167 165 foreach(QGraphicsItem* item , m_items.childItems()) {
168 166 static_cast<Marker*>(item)->setBrush(brush);
169 167 }
170 168 }
171 169
172 170 void ScatterChartItem::handleUpdated()
173 171 {
174 172 int count = m_items.childItems().count();
175 173
176 174 if(count==0) return;
177 175
178 176 bool recreate = m_visible != m_series->isVisible()
179 177 || m_size != m_series->markerSize()
180 178 || m_shape != m_series->markerShape();
181 179
182 180 m_visible = m_series->isVisible();
183 181 m_size = m_series->markerSize();
184 182 m_shape = m_series->markerShape();
185 183
186 184 if(recreate) {
187 185 // TODO: optimize handleUpdate to recreate points only in case shape changed
188 186 deletePoints(count);
189 187 createPoints(count);
190 188
191 189 // Updating geometry is now safe, because it won't call handleUpdated unless it creates/deletes points
192 190 updateGeometry();
193 191 }
194 192
195 193 setPen(m_series->pen());
196 194 setBrush(m_series->brush());
197 195 update();
198 196 }
199 197
200 198 void ScatterChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
201 199 {
202 200 emit XYChart::clicked(calculateDomainPoint(event->pos()));
203 201 }
204 202
205 203 #include "moc_scatterchartitem_p.cpp"
206 204
207 205 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,350 +1,369
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qxyseries.h"
22 22 #include "qxyseries_p.h"
23 23 #include "domain_p.h"
24 24 #include "legendmarker_p.h"
25 25
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 28 /*!
29 29 \class QXYSeries
30 30 \brief The QXYSeries class is a base class for line, spline and scatter series.
31 31 */
32 32
33 33 /*!
34 34 \property QXYSeries::pointsVisible
35 35
36 36 Controls if the data points are visible and should be drawn.
37 37 */
38 38
39 39 /*!
40 40 \fn QPen QXYSeries::pen() const
41 41 \brief Returns pen used to draw points for series.
42 42 \sa setPen()
43 43 */
44 44
45 45 /*!
46 46 \fn QBrush QXYSeries::brush() const
47 47 \brief Returns brush used to draw points for series.
48 48 \sa setBrush()
49 49 */
50 50
51 51 /*!
52 \property QXYSeries::color
53 Line (pen) color of the series. This is a convenience property for modifying the color of pen.
54 \sa QXYSeries::pen()
55 */
56
57 /*!
52 58 \fn void QXYSeries::clicked(const QPointF& point)
53 59 \brief Signal is emitted when user clicks the \a point on chart.
54 60 */
55 61
56 62 /*!
57 63 \fn void QXYSeries::pointReplaced(int index)
58 64 \brief Signal is emitted when user replaces a point at \a index.
59 65 \sa replace()
60 66 */
61 67
62 68 /*!
63 69 \fn void QXYSeries::pointAdded(int index)
64 70 \brief Signal is emitted when user adds a point at \a index.
65 71 \sa append(), insert()
66 72 */
67 73
68 74 /*!
69 75 \fn void QXYSeries::pointRemoved(int index)
70 76 \brief Signal is emitted when user removes a point at \a index.
71 77 \sa remove()
72 78 */
73 79
74 80 /*!
75 \fn void QXYSeries::pointsVisibleChanged(bool visible)
76 \brief Signal is emitted when the point visibility has changed to \a visible.
81 \fn void QXYSeries::colorChanged(QColor color)
82 \brief Signal is emitted when the line (pen) color has changed to \a color.
77 83 */
78 84
79 85 /*!
80 86 \fn void QXYSeriesPrivate::updated()
81 87 \brief \internal
82 88 */
83 89
84 90 /*!
85 91 \internal
86 92
87 93 Constructs empty series object which is a child of \a parent.
88 94 When series object is added to QChartView or QChart instance ownerships is transferred.
89 95 */
90 96 QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) : QAbstractSeries(d, parent)
91 97 {
92 98 }
93 99
94 100 /*!
95 101 Destroys the object. Series added to QChartView or QChart instances are owned by those,
96 102 and are deleted when mentioned object are destroyed.
97 103 */
98 104 QXYSeries::~QXYSeries()
99 105 {
100 106 }
101 107
102 108 /*!
103 109 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
104 110 */
105 111 void QXYSeries::append(qreal x,qreal y)
106 112 {
107 113 append(QPointF(x,y));
108 114 }
109 115
110 116 /*!
111 117 This is an overloaded function.
112 118 Adds data \a point to the series. Points are connected with lines on the chart.
113 119 */
114 120 void QXYSeries::append(const QPointF &point)
115 121 {
116 122 Q_D(QXYSeries);
117 123 d->m_points<<point;
118 124 // emit d->pointAdded(d->m_points.count()-1);
119 125 emit pointAdded(d->m_points.count()-1);
120 126 }
121 127
122 128 /*!
123 129 This is an overloaded function.
124 130 Adds list of data \a points to the series. Points are connected with lines on the chart.
125 131 */
126 132 void QXYSeries::append(const QList<QPointF> &points)
127 133 {
128 134 foreach(const QPointF& point , points) {
129 135 append(point);
130 136 }
131 137 }
132 138
133 139 /*!
134 140 Replaces data point \a oldX \a oldY with data point \a newX \a newY.
135 141 */
136 142 void QXYSeries::replace(qreal oldX,qreal oldY,qreal newX,qreal newY)
137 143 {
138 144 replace(QPointF(oldX,oldY),QPointF(newX,newY));
139 145 }
140 146
141 147 /*!
142 148 Replaces \a oldPoint with \a newPoint.
143 149 */
144 150 void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint)
145 151 {
146 152 Q_D(QXYSeries);
147 153 int index = d->m_points.indexOf(oldPoint);
148 154 if(index==-1) return;
149 155 d->m_points[index] = newPoint;
150 156 // emit d->pointReplaced(index);
151 157 emit pointReplaced(index);
152 158 }
153 159
154 160 /*!
155 161 Removes current \a x and \a y value.
156 162 */
157 163 void QXYSeries::remove(qreal x,qreal y)
158 164 {
159 165 remove(QPointF(x,y));
160 166 }
161 167
162 168 /*!
163 169 Removes current \a point x value.
164 170
165 171 Note: point y value is ignored.
166 172 */
167 173 void QXYSeries::remove(const QPointF &point)
168 174 {
169 175 Q_D(QXYSeries);
170 176 int index = d->m_points.indexOf(point);
171 177 if(index==-1) return;
172 178 d->m_points.remove(index);
173 179 // emit d->pointRemoved(index);
174 180 emit pointRemoved(index);
175 181 }
176 182
177 183 /*!
178 184 Inserts a \a point in the series at \a index position.
179 185 */
180 186 void QXYSeries::insert(int index, const QPointF &point)
181 187 {
182 188 Q_D(QXYSeries);
183 189 d->m_points.insert(index, point);
184 190 // emit d->pointAdded(index);
185 191 emit pointAdded(index);
186 192 }
187 193
188 194 /*!
189 195 Removes all points from the series.
190 196 */
191 197 void QXYSeries::clear()
192 198 {
193 199 Q_D(QXYSeries);
194 200 for (int i = d->m_points.size() - 1; i >= 0; i--)
195 201 remove(d->m_points.at(i));
196 202 }
197 203
198 204 /*!
199 205 \internal \a pos
200 206 */
201 207 QList<QPointF> QXYSeries::points() const
202 208 {
203 209 Q_D(const QXYSeries);
204 210 return d->m_points.toList();
205 211 }
206 212
207 213 /*!
208 214 Returns number of data points within series.
209 215 */
210 216 int QXYSeries::count() const
211 217 {
212 218 Q_D(const QXYSeries);
213 219 return d->m_points.count();
214 220 }
215 221
216 222
217 223 /*!
218 224 Sets \a pen used for drawing points on the chart. If the pen is not defined, the
219 225 pen from chart theme is used.
220 226 \sa QChart::setTheme()
221 227 */
222 228 void QXYSeries::setPen(const QPen &pen)
223 229 {
224 230 Q_D(QXYSeries);
225 231 if (d->m_pen!=pen) {
226 232 d->m_pen = pen;
227 233 emit d->updated();
228 234 }
229 235 }
230 236
231 237 QPen QXYSeries::pen() const
232 238 {
233 239 Q_D(const QXYSeries);
234 240 return d->m_pen;
235 241 }
236 242
237 243 /*!
238 244 Sets \a brush used for drawing points on the chart. If the brush is not defined, brush
239 245 from chart theme setting is used.
240 246 \sa QChart::setTheme()
241 247 */
242 248 void QXYSeries::setBrush(const QBrush &brush)
243 249 {
244 250 Q_D(QXYSeries);
245 251 if (d->m_brush!=brush) {
246 252 d->m_brush = brush;
247 253 emit d->updated();
248 254 }
249 255 }
250 256
251 257 QBrush QXYSeries::brush() const
252 258 {
253 259 Q_D(const QXYSeries);
254 260 return d->m_brush;
255 261 }
256 262
263 void QXYSeries::setColor(const QColor &color)
264 {
265 QPen p = pen();
266 if (p.color() != color) {
267 p.setColor(color);
268 setPen(p);
269 emit colorChanged(color);
270 }
271 }
272
273 QColor QXYSeries::color() const
274 {
275 return pen().color();
276 }
257 277
258 278 void QXYSeries::setPointsVisible(bool visible)
259 279 {
260 280 Q_D(QXYSeries);
261 281 if (d->m_pointsVisible != visible){
262 282 d->m_pointsVisible = visible;
263 283 emit d->updated();
264 emit pointsVisibleChanged(visible);
265 284 }
266 285 }
267 286
268 287 bool QXYSeries::pointsVisible() const
269 288 {
270 289 Q_D(const QXYSeries);
271 290 return d->m_pointsVisible;
272 291 }
273 292
274 293
275 294 /*!
276 295 Stream operator for adding a data \a point to the series.
277 296 \sa append()
278 297 */
279 298 QXYSeries& QXYSeries::operator<< (const QPointF &point)
280 299 {
281 300 append(point);
282 301 return *this;
283 302 }
284 303
285 304
286 305 /*!
287 306 Stream operator for adding a list of \a points to the series.
288 307 \sa append()
289 308 */
290 309
291 310 QXYSeries& QXYSeries::operator<< (const QList<QPointF>& points)
292 311 {
293 312 append(points);
294 313 return *this;
295 314 }
296 315
297 316 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
298 317
299 318
300 319 QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) :
301 320 QAbstractSeriesPrivate(q),
302 321 m_pointsVisible(false)
303 322 {
304 323 }
305 324
306 325 void QXYSeriesPrivate::scaleDomain(Domain& domain)
307 326 {
308 327 qreal minX(domain.minX());
309 328 qreal minY(domain.minY());
310 329 qreal maxX(domain.maxX());
311 330 qreal maxY(domain.maxY());
312 331 int tickXCount(domain.tickXCount());
313 332 int tickYCount(domain.tickYCount());
314 333
315 334 Q_Q(QXYSeries);
316 335
317 336 const QList<QPointF>& points = q->points();
318 337
319 338
320 339 if(points.isEmpty()){
321 340 minX=0.0;
322 341 minY=0.0;
323 342 maxX=1.0;
324 343 maxY=1.0;
325 344 }
326 345
327 346 for (int i = 0; i < points.count(); i++)
328 347 {
329 348 qreal x = points[i].x();
330 349 qreal y = points[i].y();
331 350 minX = qMin(minX, x);
332 351 minY = qMin(minY, y);
333 352 maxX = qMax(maxX, x);
334 353 maxY = qMax(maxY, y);
335 354 }
336 355
337 356 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
338 357 }
339 358
340 359 QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend)
341 360 {
342 361 Q_Q(QXYSeries);
343 362 QList<LegendMarker*> list;
344 363 return list << new XYLegendMarker(q,legend);
345 364 }
346 365
347 366 #include "moc_qxyseries.cpp"
348 367 #include "moc_qxyseries_p.cpp"
349 368
350 369 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,88 +1,91
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef QXYSERIES_H
22 22 #define QXYSERIES_H
23 23
24 24 #include <qchartglobal.h>
25 25 #include <qabstractseries.h>
26 26 #include <QPen>
27 27 #include <QBrush>
28 28
29 29 class QModelIndex;
30 30
31 31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32 32
33 33 class QXYSeriesPrivate;
34 34 class QXYModelMapper;
35 35
36 36 class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries
37 37 {
38 38 Q_OBJECT
39 Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible NOTIFY pointsVisibleChanged)
39 Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible)
40 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
40 41
41 42 protected:
42 43 explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0);
43 44
44 45 public:
45 46 ~QXYSeries();
46 47 void append(qreal x, qreal y);
47 48 void append(const QPointF &point);
48 49 void append(const QList<QPointF> &points);
49 50 void replace(qreal oldX,qreal oldY,qreal newX,qreal newY);
50 51 void replace(const QPointF &oldPoint,const QPointF &newPoint);
51 52 void remove(qreal x, qreal y);
52 53 void remove(const QPointF &point);
53 54 void insert(int index, const QPointF &point);
54 55 void clear();
55 56
56 57 int count() const;
57 58 QList<QPointF> points() const;
58 59
59 60 QXYSeries& operator << (const QPointF &point);
60 61 QXYSeries& operator << (const QList<QPointF> &points);
61 62
62 63 void setPen(const QPen &pen);
63 64 QPen pen() const;
64 65
65 66 void setBrush(const QBrush &brush);
66 67 QBrush brush() const;
67 68
69 virtual void setColor(const QColor &color);
70 virtual QColor color() const;
71
68 72 void setPointsVisible(bool visible = true);
69 73 bool pointsVisible() const;
70 74
71 75 Q_SIGNALS:
72 76 void clicked(const QPointF &point);
73 77 void pointReplaced(int index);
74 78 void pointRemoved(int index);
75 79 void pointAdded(int index);
76 void pointsVisibleChanged(bool visible);
77
80 void colorChanged(QColor color);
78 81
79 82 private:
80 83 Q_DECLARE_PRIVATE(QXYSeries)
81 84 Q_DISABLE_COPY(QXYSeries)
82 85 friend class XYLegendMarker;
83 86 friend class XYChart;
84 87 };
85 88
86 89 QTCOMMERCIALCHART_END_NAMESPACE
87 90
88 91 #endif
@@ -1,73 +1,77
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24
25 25 Flow {
26 26 id: flow
27 27 spacing: 5
28 28 flow: Flow.TopToBottom
29 29 property variant series
30 30
31 31 onSeriesChanged: {
32 seriesConnections.target = series;
32 if (series && series.name == "area 1") {
33 seriesConnections.target = series;
34 } else {
35 seriesConnections.target = null;
36 }
33 37 }
34 38
35 39 Connections {
36 40 id: seriesConnections
37 ignoreUnknownSignals: true
41 target: null
38 42 onNameChanged: console.log("series.onNameChanged: " + series.name);
39 43 onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible);
40 44 onColorChanged: console.log("series.onColorChanged: " + series.color);
41 45 onBorderColorChanged: console.log("series.onBorderColorChanged: " + series.borderColor);
42 46 onCountChanged: console.log("series.onCountChanged: " + series.count);
43 47 }
44 48
45 49 Button {
46 50 text: "visible"
47 51 onClicked: series.visible = !series.visible;
48 52 }
49 53 Button {
50 54 text: "color"
51 55 onClicked: series.color = main.nextColor();
52 56 }
53 57 Button {
54 58 text: "borderColor"
55 59 onClicked: series.borderColor = main.nextColor();
56 60 }
57 61 Button {
58 62 text: "upper color"
59 63 onClicked: series.upperSeries.color = main.nextColor();
60 64 }
61 65 Button {
62 66 text: "lower color"
63 67 onClicked: series.lowerSeries.color = main.nextColor();
64 68 }
65 69 Button {
66 70 text: "upper points visible"
67 71 onClicked: series.upperSeries.pointsVisible = !series.pointsVisible;
68 72 }
69 73 Button {
70 74 text: "lower points visible"
71 75 onClicked: series.lowerSeries.pointsVisible = !series.pointsVisible;
72 76 }
73 77 }
@@ -1,39 +1,40
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24 ChartView {
25 25 title: "Bar series"
26 26 anchors.fill: parent
27 27 theme: ChartView.ChartThemeLight
28 28 legend.alignment: Qt.AlignBottom
29 29 axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"]
30 30
31 31 property variant series: daSeries
32 32
33 33 BarSeries {
34 34 id: daSeries
35 name: "bar"
35 36 BarSet { label: "Bob"; values: [4, 7, 3, 10, 5, 6] }
36 37 BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 8] }
37 38 BarSet { label: "James"; values: [3, 5, 8, 5, 4, 7] }
38 39 }
39 40 }
@@ -1,90 +1,95
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24 Flow {
25 25 id: flow
26 26 spacing: 5
27 27 flow: Flow.TopToBottom
28 28 property variant series
29 29
30 30 onSeriesChanged: {
31 seriesConnections.target = series;
32 setConnections.target = series.at(0);
31 if (series && series.name == "bar") {
32 seriesConnections.target = series;
33 setConnections.target = series.at(0);
34 } else {
35 seriesConnections.target = null;
36 setConnections.target = null;
37 }
33 38 }
34 39
35 40 Connections {
36 41 id: seriesConnections
37 ignoreUnknownSignals: true
42 target: null
38 43 onNameChanged: console.log("series.onNameChanged: " + series.name);
39 44 onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible);
40 45 onBarWidthChanged: console.log("series.onBardWidthChanged: " + width)
41 46 onLabelsVisibleChanged: console.log("series.onLabelsVisibleChanged: " + series.labelsVisible);
42 47 onCountChanged: console.log("series.onCountChanged: " + count);
43 48 }
44 49
45 50 Connections {
46 51 id: setConnections
47 ignoreUnknownSignals: true
52 target: null
48 53 onColorChanged: console.log("series.onColorChanged: " + color);
49 54 onBorderColorChanged: console.log("series.onBorderColorChanged: " + color);
50 55 onLabelColorChanged: console.log("series.onLabelColorChanged: " + color);
51 56 onCountChanged: console.log("series.onCountChanged: " + count);
52 57 }
53 58
54 59 Button {
55 60 text: "visible"
56 61 onClicked: series.visible = !series.visible;
57 62 }
58 63 Button {
59 64 text: "labels visible"
60 65 onClicked: series.labelsVisible = !series.labelsVisible;
61 66 }
62 67 Button {
63 68 text: "bar width +"
64 69 onClicked: series.barWidth += 0.1;
65 70 }
66 71 Button {
67 72 text: "bar width -"
68 73 onClicked: series.barWidth -= 0.1;
69 74 }
70 75 Button {
71 76 text: "set 1 color"
72 77 onClicked: series.at(0).color = main.nextColor();
73 78 }
74 79 Button {
75 80 text: "set 1 border color"
76 81 onClicked: series.at(0).borderColor = main.nextColor();
77 82 }
78 83 Button {
79 84 text: "set 1 label color"
80 85 onClicked: series.at(0).labelColor = main.nextColor();
81 86 }
82 87 Button {
83 88 text: "set 1 font size +"
84 89 onClicked: series.at(0).labelFont.pixelSize += 1;
85 90 }
86 91 Button {
87 92 text: "set 1 font size -"
88 93 onClicked: series.at(0).labelFont.pixelSize -= 1;
89 94 }
90 95 }
@@ -1,319 +1,316
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24
25 25 Flow {
26 26 id: flow
27 27 spacing: 5
28 28 flow: Flow.TopToBottom
29 29 property variant series // TODO: rename to chart
30 30
31 31 onSeriesChanged: {
32 legendConnections.target = series.legend;
33 axisXConnections.target = series.axisX;
34 axisYConnections.target = series.axisY;
32 if (series && series.name == "") {
33 chartConnections.target = series;
34 legendConnections.target = series.legend;
35 axisXConnections.target = series.axisX;
36 axisYConnections.target = series.axisY;
37 } else {
38 legendConnections.target = null;
39 axisXConnections.target = null;
40 axisYConnections.target = null;
41 }
35 42 }
36 43
37 44 Connections {
38 target: series
39 ignoreUnknownSignals: true
45 id: chartConnections
46 target: null
40 47 onVisibleChanged: console.log("chart.onVisibleChanged: " + series.visible);
41 onThemeChanged: console.log("chart.onThemeChanged: " + series.theme);
42 onLegendChanged: console.log("chart.onLegendChanged: " + series.legend);
43 onAnimationOptionsChanged: console.log("chart.onAnimationOptionsChanged: " + series.animationOptions);
44 48 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + series.titleColor);
45 49 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor);
46 50 onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
47 51 }
48 52
49 53 Connections {
50 54 id: legendConnections
51 ignoreUnknownSignals: true
52 onAlignmentChanged: console.log("legend.onAlignmentChanged: " + alignment);
55 target: null
53 56 onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible);
54 57 onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
55 58 onColorChanged: console.log("legend.onColorChanged: " + color);
56 59 onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color);
57 60 }
58 61
59 62 Connections {
60 63 id: axisXConnections
61 ignoreUnknownSignals: true
64 target: null
62 65 onColorChanged: console.log("axisX.onColorChanged: " + color);
63 66 onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
64 67 onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
65 onLabelsAngleChanged: console.log("axisX.onLabelsAngleChanged: " + angle);
66 68 onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
67 69 onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
68 70 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
69 71 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
70 72 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
71 73 onMinChanged: console.log("axisX.onMinChanged: " + min);
72 74 onMaxChanged: console.log("axisX.onMaxChanged: " + max);
73 onTicksCountChanged: console.log("axisX.onTicksCountChanged: " + count);
74 onNiceNumbersEnabledChanged: console.log("axisX.onNiceNumbersEnabledChanged: " + enabled);
75 75 }
76 76
77 77 Connections {
78 78 id: axisYConnections
79 ignoreUnknownSignals: true
79 target: null
80 80 onColorChanged: console.log("axisY.onColorChanged: " + color);
81 81 onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
82 82 onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
83 onLabelsAngleChanged: console.log("axisY.onLabelsAngleChanged: " + angle);
84 83 onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
85 84 onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
86 85 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
87 86 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
88 87 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
89 88 onMinChanged: console.log("axisY.onMinChanged: " + min);
90 89 onMaxChanged: console.log("axisY.onMaxChanged: " + max);
91 onTicksCountChanged: console.log("axisY.onTicksCountChanged: " + count);
92 onNiceNumbersEnabledChanged: console.log("axisY.onNiceNumbersEnabledChanged: " + enabled);
93 90 }
94 91
95 92 Button {
96 93 text: "visible"
97 94 onClicked: series.visible = !series.visible;
98 95 }
99 96 Button {
100 97 text: "theme +"
101 98 onClicked: series.theme++;
102 99 }
103 100 Button {
104 101 text: "theme -"
105 102 onClicked: series.theme--;
106 103 }
107 104 Button {
108 105 text: "animation opt +"
109 106 onClicked: series.animationOptions++;
110 107 }
111 108 Button {
112 109 text: "animation opt -"
113 110 onClicked: series.animationOptions--;
114 111 }
115 112 Button {
116 113 text: "title color"
117 114 onClicked: series.titleColor = main.nextColor();
118 115 }
119 116 Button {
120 117 text: "background color"
121 118 onClicked: series.backgroundColor = main.nextColor();
122 119 }
123 120 Button {
124 121 text: "drop shadow enabled"
125 122 onClicked: series.dropShadowEnabled = !series.dropShadowEnabled;
126 123 }
127 124 Button {
128 125 text: "zoom +"
129 126 onClicked: series.zoom(2);
130 127 }
131 128 Button {
132 129 text: "zoom -"
133 130 onClicked: series.zoom(0.5);
134 131 }
135 132 Button {
136 133 text: "scroll left"
137 134 onClicked: series.scrollLeft(10);
138 135 }
139 136 Button {
140 137 text: "scroll right"
141 138 onClicked: series.scrollRight(10);
142 139 }
143 140 Button {
144 141 text: "scroll up"
145 142 onClicked: series.scrollUp(10);
146 143 }
147 144 Button {
148 145 text: "scroll down"
149 146 onClicked: series.scrollDown(10);
150 147 }
151 148 Button {
152 149 text: "legend visible"
153 150 onClicked: series.legend.visible = !series.legend.visible;
154 151 }
155 152 Button {
156 153 text: "legend bckgrd visible"
157 154 onClicked: series.legend.backgroundVisible = !series.legend.backgroundVisible;
158 155 }
159 156 Button {
160 157 text: "legend color"
161 158 onClicked: series.legend.color = main.nextColor();
162 159 }
163 160 Button {
164 161 text: "legend border color"
165 162 onClicked: series.legend.borderColor = main.nextColor();
166 163 }
167 164 Button {
168 165 text: "legend top"
169 166 onClicked: series.legend.alignment ^= Qt.AlignTop;
170 167 }
171 168 Button {
172 169 text: "legend bottom"
173 170 onClicked: series.legend.alignment ^= Qt.AlignBottom;
174 171 }
175 172 Button {
176 173 text: "legend left"
177 174 onClicked: series.legend.alignment ^= Qt.AlignLeft;
178 175 }
179 176 Button {
180 177 text: "legend right"
181 178 onClicked: series.legend.alignment ^= Qt.AlignRight;
182 179 }
183 180 Button {
184 181 text: "axis X visible"
185 182 onClicked: series.axisX.visible = !series.axisX.visible;
186 183 }
187 184 Button {
188 185 text: "axis X grid visible"
189 186 onClicked: series.axisX.gridVisible = !series.axisX.gridVisible;
190 187 }
191 188 Button {
192 189 text: "axis X labels visible"
193 190 onClicked: series.axisX.labelsVisible = !series.axisX.labelsVisible;
194 191 }
195 192 Button {
196 193 text: "axis X color"
197 194 onClicked: series.axisX.color = main.nextColor();
198 195 }
199 196 Button {
200 197 text: "axis X labels color"
201 198 onClicked: series.axisX.labelsColor = main.nextColor();
202 199 }
203 200 Button {
204 201 text: "axis X labels angle +"
205 202 onClicked: series.axisX.labelsAngle += 5;
206 203 }
207 204 Button {
208 205 text: "axis X labels angle -"
209 206 onClicked: series.axisX.labelsAngle -= 5;
210 207 }
211 208 Button {
212 209 text: "axis X shades visible"
213 210 onClicked: series.axisX.shadesVisible = !series.axisX.shadesVisible;
214 211 }
215 212 Button {
216 213 text: "axis X shades color"
217 214 onClicked: series.axisX.shadesColor = main.nextColor();
218 215 }
219 216 Button {
220 217 text: "axis X shades bcolor"
221 218 onClicked: series.axisX.shadesBorderColor = main.nextColor();
222 219 }
223 220 Button {
224 221 text: "axis X max +"
225 222 onClicked: series.axisX.max += 0.1;
226 223 }
227 224 Button {
228 225 text: "axis X max -"
229 226 onClicked: series.axisX.max -= 0.1;
230 227 }
231 228 Button {
232 229 text: "axis X min +"
233 230 onClicked: series.axisX.min += 0.1;
234 231 }
235 232 Button {
236 233 text: "axis X min -"
237 234 onClicked: series.axisX.min -= 0.1;
238 235 }
239 236 Button {
240 237 text: "axis X ticks count +"
241 238 onClicked: series.axisX.ticksCount++;
242 239 }
243 240 Button {
244 241 text: "axis X ticks count -"
245 242 onClicked: series.axisX.ticksCount--;
246 243 }
247 244 Button {
248 245 text: "axis X nice nmb"
249 246 onClicked: series.axisX.niceNumbersEnabled = !series.axisX.niceNumbersEnabled;
250 247 }
251 248 Button {
252 249 text: "axis Y visible"
253 250 onClicked: series.axisY.visible = !series.axisY.visible;
254 251 }
255 252 Button {
256 253 text: "axis Y grid visible"
257 254 onClicked: series.axisY.gridVisible = !series.axisY.gridVisible;
258 255 }
259 256 Button {
260 257 text: "axis Y labels visible"
261 258 onClicked: series.axisY.labelsVisible = !series.axisY.labelsVisible;
262 259 }
263 260 Button {
264 261 text: "axis Y color"
265 262 onClicked: series.axisY.color = main.nextColor();
266 263 }
267 264 Button {
268 265 text: "axis Y labels color"
269 266 onClicked: series.axisY.labelsColor = main.nextColor();
270 267 }
271 268 Button {
272 269 text: "axis Y labels angle +"
273 270 onClicked: series.axisY.labelsAngle += 5;
274 271 }
275 272 Button {
276 273 text: "axis Y labels angle -"
277 274 onClicked: series.axisY.labelsAngle -= 5;
278 275 }
279 276 Button {
280 277 text: "axis Y shades visible"
281 278 onClicked: series.axisY.shadesVisible = !series.axisY.shadesVisible;
282 279 }
283 280 Button {
284 281 text: "axis Y shades color"
285 282 onClicked: series.axisY.shadesColor = main.nextColor();
286 283 }
287 284 Button {
288 285 text: "axis Y shades bcolor"
289 286 onClicked: series.axisY.shadesBorderColor = main.nextColor();
290 287 }
291 288 Button {
292 289 text: "axis Y max +"
293 290 onClicked: series.axisY.max += 0.1;
294 291 }
295 292 Button {
296 293 text: "axis Y max -"
297 294 onClicked: series.axisY.max -= 0.1;
298 295 }
299 296 Button {
300 297 text: "axis Y min +"
301 298 onClicked: series.axisY.min += 0.1;
302 299 }
303 300 Button {
304 301 text: "axis Y min -"
305 302 onClicked: series.axisY.min -= 0.1;
306 303 }
307 304 Button {
308 305 text: "axis Y ticks count +"
309 306 onClicked: series.axisY.ticksCount++;
310 307 }
311 308 Button {
312 309 text: "axis Y ticks count -"
313 310 onClicked: series.axisY.ticksCount--;
314 311 }
315 312 Button {
316 313 text: "axis Y nice nmb"
317 314 onClicked: series.axisY.niceNumbersEnabled = !series.axisY.niceNumbersEnabled;
318 315 }
319 316 }
@@ -1,39 +1,40
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24 ChartView {
25 25 title: "Grouped bar series"
26 26 anchors.fill: parent
27 27 theme: ChartView.ChartThemeLight
28 28 legend.alignment: Qt.AlignBottom
29 29 axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"]
30 30
31 31 property variant series: daSeries
32 32
33 33 GroupedBarSeries {
34 34 id: daSeries
35 name: "bar"
35 36 BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] }
36 37 BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
37 38 BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
38 39 }
39 40 }
@@ -1,57 +1,60
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24
25 25 Flow {
26 26 id: flow
27 27 spacing: 5
28 28 flow: Flow.TopToBottom
29 29 property variant series
30 30
31 31 onSeriesChanged: {
32 seriesConnections.target = series;
32 if (series && (series.name == "line 1" || series.name == "spline 1")) {
33 seriesConnections.target = series;
34 } else {
35 seriesConnections.target = null;
36 }
33 37 }
34 38
35 39 Connections {
36 40 id: seriesConnections
37 ignoreUnknownSignals: true
41 target: null
38 42 onNameChanged: console.log("series.onNameChanged: " + series.name);
39 43 onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible);
40 onPointsVisibleChanged: console.log("series.onPointsVisibleChanged: " + series.pointsVisible);
41 44 onColorChanged: console.log("series.onColorChanged: " + series.color);
42 45 onCountChanged: console.log("series.onCountChanged: " + series.count);
43 46 }
44 47
45 48 Button {
46 49 text: "visible"
47 50 onClicked: series.visible = !series.visible;
48 51 }
49 52 Button {
50 53 text: "color"
51 54 onClicked: series.color = main.nextColor();
52 55 }
53 56 Button {
54 57 text: "points visible"
55 58 onClicked: series.pointsVisible = !series.pointsVisible
56 59 }
57 60 }
@@ -1,39 +1,40
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24 ChartView {
25 25 title: "Percent bar series"
26 26 anchors.fill: parent
27 27 theme: ChartView.ChartThemeLight
28 28 legend.alignment: Qt.AlignBottom
29 29 axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"]
30 30
31 31 property variant series: daSeries
32 32
33 33 PercentBarSeries {
34 34 id: daSeries
35 name: "bar"
35 36 BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] }
36 37 BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
37 38 BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
38 39 }
39 40 }
@@ -1,37 +1,38
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24 ChartView {
25 25 id: chart
26 26 title: "pie series"
27 27 animationOptions: ChartView.SeriesAnimations
28 28
29 29 property variant series: pieSeries
30 30
31 31 PieSeries {
32 32 id: pieSeries
33 name: "pie"
33 34 PieSlice { id: daSlice; label: "slice1"; value: 11 }
34 35 PieSlice { label: "slice2"; value: 22 }
35 36 PieSlice { label: "slice3"; value: 33 }
36 37 }
37 38 }
@@ -1,168 +1,173
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24 Flow {
25 25 id: flow
26 26 spacing: 5
27 27 flow: Flow.TopToBottom
28 28 property variant series
29 29
30 30 onSeriesChanged: {
31 seriesConnections.target = series;
32 sliceConnections.target = series.at(0);
31 if (series && series.name == "pie") {
32 seriesConnections.target = series;
33 sliceConnections.target = series.at(0);
34 } else {
35 seriesConnections.target = null;
36 sliceConnections.target = null;
37 }
33 38 }
34 39
35 40 Connections {
36 41 id: seriesConnections
37 ignoreUnknownSignals: true
42 target: null
38 43 onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible);
39 44 onHorizontalPositionChanged:console.log("series.onHorizontalPositionChanged: " + series.horizontalPosition);
40 45 onVerticalPositionChanged: console.log("series.onVerticalPositionChanged: " + series.verticalPosition);
41 46 onSizeChanged: console.log("series.onSizeChanged: " + series.size);
42 47 onStartAngleChanged: console.log("series.onStartAngleChanged: " + series.startAngle);
43 48 onEndAngleChanged: console.log("series.onEndAngleChanged: " + series.endAngle);
44 49 onCountChanged: console.log("series.onCountChanged: " + series.count);
45 50 onSumChanged: console.log("series.onSumChanged: " + series.sum);
46 51 }
47 52
48 53 Connections {
49 54 id: sliceConnections
50 ignoreUnknownSignals: true
55 target: null
51 56 onValueChanged: console.log("slice.onValueChanged: " + series.at(0).value);
52 57 onLabelVisibleChanged: console.log("slice.onLabelVisibleChanged: " + series.at(0).labelVisible);
53 58 onLabelPositionChanged: console.log("slice.onLabelPositionChanged: " + series.at(0).labelPosition);
54 59 onExplodedChanged: console.log("slice.onExplodedChanged: " + series.at(0).exploded);
55 60 onPenChanged: console.log("slice.onPenChanged: " + series.at(0).pen);
56 61 onBorderColorChanged: console.log("slice.onBorderColorChanged: " + series.at(0).borderColor);
57 62 onBorderWidthChanged: console.log("slice.onBorderWidthChanged: " + series.at(0).borderWidth);
58 63 onBrushChanged: console.log("slice.onBrushChanged: " + series.at(0).brush);
59 64 onColorChanged: console.log("slice.onColorChanged: " + series.at(0).color);
60 65 onLabelColorChanged: console.log("slice.onLabelColorChanged: " + series.at(0).labelColor);
61 66 onLabelBrushChanged: console.log("slice.onLabelBrushChanged: " + series.at(0).labelBrush);
62 67 onLabelFontChanged: console.log("slice.onLabelFontChanged: " + series.at(0).labelFont);
63 68 onLabelArmLengthFactorChanged: console.log("slice.onLabelArmLengthFactorChanged: " + series.at(0).labelArmLengthFactor);
64 69 onExplodeDistanceFactorChanged: console.log("slice.onExplodeDistanceFactorChanged: " + series.at(0).explodeDistanceFactor);
65 70 onPercentageChanged: console.log("slice.onPercentageChanged: " + series.at(0).percentage);
66 71 onStartAngleChanged: console.log("slice.onStartAngleChanged: " + series.at(0).startAngle);
67 72 onAngleSpanChanged: console.log("slice.onAngleSpanChanged: " + series.at(0).angleSpan);
68 73 onClicked: console.log("slice.onClicked");
69 74 onHovered: console.log("slice.onHovered: " + state);
70 75 }
71 76
72 77 Button {
73 78 text: "visible"
74 79 onClicked: series.visible = !series.visible;
75 80 }
76 81 Button {
77 82 text: "series hpos +"
78 83 onClicked: series.horizontalPosition += 0.1;
79 84 }
80 85 Button {
81 86 text: "series hpos -"
82 87 onClicked: series.horizontalPosition -= 0.1;
83 88 }
84 89 Button {
85 90 text: "series vpos +"
86 91 onClicked: series.verticalPosition += 0.1;
87 92 }
88 93 Button {
89 94 text: "series vpos -"
90 95 onClicked: series.verticalPosition -= 0.1;
91 96 }
92 97 Button {
93 98 text: "series size +"
94 99 onClicked: series.size += 0.1;
95 100 }
96 101 Button {
97 102 text: "series size -"
98 103 onClicked: series.size -= 0.1;
99 104 }
100 105 Button {
101 106 text: "series start angle +"
102 107 onClicked: series.startAngle += 1.1;
103 108 }
104 109 Button {
105 110 text: "series start angle -"
106 111 onClicked: series.startAngle -= 1.1;
107 112 }
108 113 Button {
109 114 text: "series end angle +"
110 115 onClicked: series.endAngle += 1.1;
111 116 }
112 117 Button {
113 118 text: "series end angle -"
114 119 onClicked: series.endAngle -= 1.1;
115 120 }
116 121 Button {
117 122 text: "slice color"
118 123 onClicked: series.at(0).color = main.nextColor();
119 124 }
120 125 Button {
121 126 text: "slice border color"
122 127 onClicked: series.at(0).borderColor = main.nextColor();
123 128 }
124 129 Button {
125 130 text: "slice border width +"
126 131 onClicked: series.at(0).borderWidth++;
127 132 }
128 133 Button {
129 134 text: "slice border width -"
130 135 onClicked: series.at(0).borderWidth--;
131 136 }
132 137 Button {
133 138 text: "slice label visible"
134 139 onClicked: series.at(0).labelVisible = !series.at(0).labelVisible;
135 140 }
136 141 Button {
137 142 text: "slice label position inside"
138 143 onClicked: series.at(0).labelPosition = PieSlice.LabelInside;
139 144 }
140 145 Button {
141 146 text: "slice label position outside"
142 147 onClicked: series.at(0).labelPosition = PieSlice.LabelOutside;
143 148 }
144 149 Button {
145 150 text: "slice label arm len +"
146 151 onClicked: series.at(0).labelArmLengthFactor += 0.1;
147 152 }
148 153 Button {
149 154 text: "slice label arm len -"
150 155 onClicked: series.at(0).labelArmLengthFactor -= 0.1;
151 156 }
152 157 Button {
153 158 text: "slice label color"
154 159 onClicked: series.at(0).labelColor = main.nextColor();
155 160 }
156 161 Button {
157 162 text: "slice exploded"
158 163 onClicked: series.at(0).exploded = !series.at(0).exploded;
159 164 }
160 165 Button {
161 166 text: "slice explode dist +"
162 167 onClicked: series.at(0).explodeDistanceFactor += 0.1;
163 168 }
164 169 Button {
165 170 text: "slice explode dist -"
166 171 onClicked: series.at(0).explodeDistanceFactor -= 0.1;
167 172 }
168 173 }
@@ -1,72 +1,73
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24
25 25 Flow {
26 26 id: flow
27 27 spacing: 5
28 28 flow: Flow.TopToBottom
29 29 property variant series
30 30
31 31 onSeriesChanged: {
32 seriesConnections.target = series;
32 if (series && series.name == "scatter 1") {
33 seriesConnections.target = series;
34 } else {
35 seriesConnections.target = null;
36 }
33 37 }
34 38
35 39 Connections {
36 40 id: seriesConnections
37 ignoreUnknownSignals: true
41 target: null
38 42 onNameChanged: console.log("series.onNameChanged: " + series.name);
39 43 onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible);
40 onPointsVisibleChanged: console.log("series.onPointsVisibleChanged: " + series.pointsVisible);
41 44 onColorChanged: console.log("series.onColorChanged: " + series.color);
42 45 onBorderColorChanged: console.log("series.onBorderColorChanged: " + series.borderColor);
43 46 onCountChanged: console.log("series.onCountChanged: " + series.count);
44 onMarkerSizeChanged: console.log("series.onMarkerSizeChanged: " + series.markerSize);
45 onMarkerShapeChanged: console.log("series.onMarkerShapeChanged: " + series.markerShape);
46 47 }
47 48
48 49 Button {
49 50 text: "visible"
50 51 onClicked: series.visible = !series.visible;
51 52 }
52 53 Button {
53 54 text: "color"
54 55 onClicked: series.color = main.nextColor();
55 56 }
56 57 Button {
57 58 text: "borderColor"
58 59 onClicked: series.borderColor = main.nextColor();
59 60 }
60 61 Button {
61 62 text: "markerSize +"
62 63 onClicked: series.markerSize += 1.0;
63 64 }
64 65 Button {
65 66 text: "markerSize -"
66 67 onClicked: series.markerSize -= 1.0;
67 68 }
68 69 Button {
69 70 text: "markerShape"
70 71 onClicked: series.markerShape = ((series.markerShape + 1) % 2);
71 72 }
72 73 }
@@ -1,39 +1,40
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24 ChartView {
25 25 title: "Stacked bar series"
26 26 anchors.fill: parent
27 27 theme: ChartView.ChartThemeLight
28 28 legend.alignment: Qt.AlignBottom
29 29 axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"]
30 30
31 31 property variant series: daSeries
32 32
33 33 StackedBarSeries {
34 34 id: daSeries
35 name: "bar"
35 36 BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] }
36 37 BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
37 38 BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
38 39 }
39 40 }
General Comments 0
You need to be logged in to leave comments. Login now