@@ -1,65 +1,65 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativechart.h" |
|
21 | #include "declarativechart.h" | |
22 | #include <QPainter> |
|
22 | #include <QPainter> | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
|
26 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) | |
27 | : QDeclarativeItem(parent), |
|
27 | : QDeclarativeItem(parent), | |
28 | m_chart(new QChart(this)) |
|
28 | m_chart(new QChart(this)) | |
29 | { |
|
29 | { | |
30 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
30 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | DeclarativeChart::~DeclarativeChart() |
|
33 | DeclarativeChart::~DeclarativeChart() | |
34 | { |
|
34 | { | |
35 | delete m_chart; |
|
35 | delete m_chart; | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 |
|
|
38 | QChart::ChartTheme DeclarativeChart::theme() | |
39 | { |
|
39 | { | |
40 |
return |
|
40 | return m_chart->theme(); | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
43 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
44 | { |
|
44 | { | |
45 | Q_UNUSED(oldGeometry) |
|
45 | Q_UNUSED(oldGeometry) | |
46 |
|
46 | |||
47 | if (newGeometry.isValid()) { |
|
47 | if (newGeometry.isValid()) { | |
48 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
48 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { | |
49 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
49 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
50 | } |
|
50 | } | |
51 | } |
|
51 | } | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
54 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
55 | { |
|
55 | { | |
56 | Q_UNUSED(option) |
|
56 | Q_UNUSED(option) | |
57 | Q_UNUSED(widget) |
|
57 | Q_UNUSED(widget) | |
58 |
|
58 | |||
59 | // TODO: optimized? |
|
59 | // TODO: optimized? | |
60 | painter->setRenderHint(QPainter::Antialiasing, true); |
|
60 | painter->setRenderHint(QPainter::Antialiasing, true); | |
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 | #include "moc_declarativechart.cpp" |
|
63 | #include "moc_declarativechart.cpp" | |
64 |
|
64 | |||
65 | QTCOMMERCIALCHART_END_NAMESPACE |
|
65 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,68 +1,57 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVECHART_H |
|
21 | #ifndef DECLARATIVECHART_H | |
22 | #define DECLARATIVECHART_H |
|
22 | #define DECLARATIVECHART_H | |
23 |
|
23 | |||
24 | #include <QtCore/QtGlobal> |
|
24 | #include <QtCore/QtGlobal> | |
25 | #include <QDeclarativeItem> |
|
25 | #include <QDeclarativeItem> | |
26 | #include <qchart.h> |
|
26 | #include <qchart.h> | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | class DeclarativeChart : public QDeclarativeItem |
|
30 | class DeclarativeChart : public QDeclarativeItem | |
31 | // TODO: for QTQUICK2: extend QQuickPainterItem instead |
|
31 | // TODO: for QTQUICK2: extend QQuickPainterItem instead | |
32 | //class DeclarativeChart : public QQuickPaintedItem, public Chart |
|
32 | //class DeclarativeChart : public QQuickPaintedItem, public Chart | |
33 | { |
|
33 | { | |
34 | Q_OBJECT |
|
34 | Q_OBJECT | |
35 | Q_ENUMS(ChartTheme) |
|
35 | Q_PROPERTY(QChart::ChartTheme theme READ theme WRITE setTheme) | |
36 | Q_PROPERTY(ChartTheme theme READ theme WRITE setTheme) |
|
|||
37 |
|
36 | |||
38 | public: |
|
37 | public: | |
39 | enum ChartTheme { |
|
|||
40 | ThemeDefault, |
|
|||
41 | ThemeLight, |
|
|||
42 | ThemeBlueCerulean, |
|
|||
43 | ThemeDark, |
|
|||
44 | ThemeBrownSand, |
|
|||
45 | ThemeBlueNcs, |
|
|||
46 | ThemeHighContrast, |
|
|||
47 | ThemeBlueIcy |
|
|||
48 | }; |
|
|||
49 | DeclarativeChart(QDeclarativeItem *parent = 0); |
|
38 | DeclarativeChart(QDeclarativeItem *parent = 0); | |
50 | ~DeclarativeChart(); |
|
39 | ~DeclarativeChart(); | |
51 |
|
40 | |||
52 | public: // From QDeclarativeItem/QGraphicsItem |
|
41 | public: // From QDeclarativeItem/QGraphicsItem | |
53 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); |
|
42 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); | |
54 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
43 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
55 |
|
44 | |||
56 | public: |
|
45 | public: | |
57 |
void setTheme(ChartTheme theme) {m_chart->setTheme( |
|
46 | void setTheme(QChart::ChartTheme theme) {m_chart->setTheme(theme);} | |
58 | ChartTheme theme(); |
|
47 | QChart::ChartTheme theme(); | |
59 |
|
48 | |||
60 | public: |
|
49 | public: | |
61 | // Extending QChart with DeclarativeChart is not possible because QObject does not support |
|
50 | // Extending QChart with DeclarativeChart is not possible because QObject does not support | |
62 | // multi inheritance, so we now have a QChart as a member instead |
|
51 | // multi inheritance, so we now have a QChart as a member instead | |
63 | QChart *m_chart; |
|
52 | QChart *m_chart; | |
64 | }; |
|
53 | }; | |
65 |
|
54 | |||
66 | QTCOMMERCIALCHART_END_NAMESPACE |
|
55 | QTCOMMERCIALCHART_END_NAMESPACE | |
67 |
|
56 | |||
68 | #endif // DECLARATIVECHART_H |
|
57 | #endif // DECLARATIVECHART_H |
@@ -1,58 +1,59 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QtDeclarative/qdeclarativeextensionplugin.h> |
|
21 | #include <QtDeclarative/qdeclarativeextensionplugin.h> | |
22 | #include <QtDeclarative/qdeclarative.h> |
|
22 | #include <QtDeclarative/qdeclarative.h> | |
|
23 | #include "qchart.h" | |||
23 | #include "declarativechart.h" |
|
24 | #include "declarativechart.h" | |
24 | #include "declarativexypoint.h" |
|
25 | #include "declarativexypoint.h" | |
25 | #include "declarativelineseries.h" |
|
26 | #include "declarativelineseries.h" | |
26 | #include "declarativesplineseries.h" |
|
27 | #include "declarativesplineseries.h" | |
27 | #include "declarativescatterseries.h" |
|
28 | #include "declarativescatterseries.h" | |
28 | #include "declarativebarseries.h" |
|
29 | #include "declarativebarseries.h" | |
29 | #include "declarativepieseries.h" |
|
30 | #include "declarativepieseries.h" | |
30 |
|
31 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
33 | |||
33 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin |
|
34 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin | |
34 | { |
|
35 | { | |
35 | Q_OBJECT |
|
36 | Q_OBJECT | |
36 | public: |
|
37 | public: | |
37 | virtual void registerTypes(const char *uri) |
|
38 | virtual void registerTypes(const char *uri) | |
38 | { |
|
39 | { | |
39 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); |
|
40 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); | |
40 |
|
41 | |||
41 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "Chart"); |
|
42 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "Chart"); | |
42 | qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint"); |
|
43 | qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint"); | |
43 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); |
|
44 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); | |
44 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); |
|
45 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); | |
45 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); |
|
46 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); | |
46 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
47 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); | |
47 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
48 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); | |
48 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); |
|
49 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); | |
49 | } |
|
50 | } | |
50 | }; |
|
51 | }; | |
51 |
|
52 | |||
52 | #include "plugin.moc" |
|
53 | #include "plugin.moc" | |
53 |
|
54 | |||
54 | QTCOMMERCIALCHART_END_NAMESPACE |
|
55 | QTCOMMERCIALCHART_END_NAMESPACE | |
55 |
|
56 | |||
56 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
57 | QTCOMMERCIALCHART_USE_NAMESPACE | |
57 |
|
58 | |||
58 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
|
59 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
@@ -1,117 +1,119 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QCHART_H |
|
21 | #ifndef QCHART_H | |
22 | #define QCHART_H |
|
22 | #define QCHART_H | |
23 |
|
23 | |||
24 | #include <QSeries> |
|
24 | #include <QSeries> | |
25 | #include <QGraphicsWidget> |
|
25 | #include <QGraphicsWidget> | |
26 |
|
26 | |||
27 | class QGraphicsSceneResizeEvent; |
|
27 | class QGraphicsSceneResizeEvent; | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class QSeries; |
|
31 | class QSeries; | |
32 | class QChartAxis; |
|
32 | class QChartAxis; | |
33 | class QLegend; |
|
33 | class QLegend; | |
34 | struct QChartPrivate; |
|
34 | struct QChartPrivate; | |
35 |
|
35 | |||
36 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget |
|
36 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget | |
37 | { |
|
37 | { | |
38 | Q_OBJECT |
|
38 | Q_OBJECT | |
|
39 | Q_ENUMS(ChartTheme) | |||
|
40 | ||||
39 | public: |
|
41 | public: | |
40 | enum ChartTheme { |
|
42 | enum ChartTheme { | |
41 | ChartThemeDefault, |
|
43 | ChartThemeDefault, | |
42 | ChartThemeLight, |
|
44 | ChartThemeLight, | |
43 | ChartThemeBlueCerulean, |
|
45 | ChartThemeBlueCerulean, | |
44 | ChartThemeDark, |
|
46 | ChartThemeDark, | |
45 | ChartThemeBrownSand, |
|
47 | ChartThemeBrownSand, | |
46 | ChartThemeBlueNcs, |
|
48 | ChartThemeBlueNcs, | |
47 | ChartThemeHighContrast, |
|
49 | ChartThemeHighContrast, | |
48 | ChartThemeBlueIcy, |
|
50 | ChartThemeBlueIcy, | |
49 | ChartThemeCount |
|
51 | ChartThemeCount | |
50 | }; |
|
52 | }; | |
51 |
|
53 | |||
52 | enum AnimationOption { |
|
54 | enum AnimationOption { | |
53 | NoAnimation = 0x0, |
|
55 | NoAnimation = 0x0, | |
54 | GridAxisAnimations = 0x1, |
|
56 | GridAxisAnimations = 0x1, | |
55 | SeriesAnimations =0x2, |
|
57 | SeriesAnimations =0x2, | |
56 | AllAnimations = 0x3 |
|
58 | AllAnimations = 0x3 | |
57 | }; |
|
59 | }; | |
58 |
|
60 | |||
59 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) |
|
61 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) | |
60 |
|
62 | |||
61 | public: |
|
63 | public: | |
62 | explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); |
|
64 | explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); | |
63 | ~QChart(); |
|
65 | ~QChart(); | |
64 |
|
66 | |||
65 | void addSeries(QSeries *series, QChartAxis *axisY = 0); |
|
67 | void addSeries(QSeries *series, QChartAxis *axisY = 0); | |
66 | void removeSeries(QSeries *series); |
|
68 | void removeSeries(QSeries *series); | |
67 | void removeAllSeries(); |
|
69 | void removeAllSeries(); | |
68 |
|
70 | |||
69 | void setTheme(QChart::ChartTheme theme); |
|
71 | void setTheme(QChart::ChartTheme theme); | |
70 | QChart::ChartTheme theme() const; |
|
72 | QChart::ChartTheme theme() const; | |
71 |
|
73 | |||
72 | void setTitle(const QString& title); |
|
74 | void setTitle(const QString& title); | |
73 | QString title() const; |
|
75 | QString title() const; | |
74 | void setTitleFont(const QFont& font); |
|
76 | void setTitleFont(const QFont& font); | |
75 | QFont titleFont() const; |
|
77 | QFont titleFont() const; | |
76 | void setTitleBrush(const QBrush &brush); |
|
78 | void setTitleBrush(const QBrush &brush); | |
77 | QBrush titleBrush() const; |
|
79 | QBrush titleBrush() const; | |
78 | void setBackgroundBrush(const QBrush &brush); |
|
80 | void setBackgroundBrush(const QBrush &brush); | |
79 | QBrush backgroundBrush() const; |
|
81 | QBrush backgroundBrush() const; | |
80 | void setBackgroundPen(const QPen &pen); |
|
82 | void setBackgroundPen(const QPen &pen); | |
81 | QPen backgroundPen() const; |
|
83 | QPen backgroundPen() const; | |
82 |
|
84 | |||
83 | void setBackgroundVisible(bool visible); |
|
85 | void setBackgroundVisible(bool visible); | |
84 | bool isBackgroundVisible() const; |
|
86 | bool isBackgroundVisible() const; | |
85 |
|
87 | |||
86 | void setAnimationOptions(AnimationOptions options); |
|
88 | void setAnimationOptions(AnimationOptions options); | |
87 | AnimationOptions animationOptions() const; |
|
89 | AnimationOptions animationOptions() const; | |
88 |
|
90 | |||
89 | void zoomIn(); |
|
91 | void zoomIn(); | |
90 | void zoomIn(const QRectF &rect); |
|
92 | void zoomIn(const QRectF &rect); | |
91 | void zoomOut(); |
|
93 | void zoomOut(); | |
92 | void scrollLeft(); |
|
94 | void scrollLeft(); | |
93 | void scrollRight(); |
|
95 | void scrollRight(); | |
94 | void scrollUp(); |
|
96 | void scrollUp(); | |
95 | void scrollDown(); |
|
97 | void scrollDown(); | |
96 |
|
98 | |||
97 | QChartAxis* axisX() const; |
|
99 | QChartAxis* axisX() const; | |
98 | QChartAxis* axisY() const; |
|
100 | QChartAxis* axisY() const; | |
99 |
|
101 | |||
100 | QLegend* legend() const; |
|
102 | QLegend* legend() const; | |
101 |
|
103 | |||
102 | QRect padding() const; |
|
104 | QRect padding() const; | |
103 |
|
105 | |||
104 | protected: |
|
106 | protected: | |
105 | void resizeEvent(QGraphicsSceneResizeEvent *event); |
|
107 | void resizeEvent(QGraphicsSceneResizeEvent *event); | |
106 |
|
108 | |||
107 | protected: |
|
109 | protected: | |
108 | QScopedPointer<QChartPrivate> d_ptr; |
|
110 | QScopedPointer<QChartPrivate> d_ptr; | |
109 | friend class QLegend; |
|
111 | friend class QLegend; | |
110 | Q_DISABLE_COPY(QChart) |
|
112 | Q_DISABLE_COPY(QChart) | |
111 | }; |
|
113 | }; | |
112 |
|
114 | |||
113 | QTCOMMERCIALCHART_END_NAMESPACE |
|
115 | QTCOMMERCIALCHART_END_NAMESPACE | |
114 |
|
116 | |||
115 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions) |
|
117 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions) | |
116 |
|
118 | |||
117 | #endif |
|
119 | #endif |
@@ -1,123 +1,123 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 |
|
23 | |||
24 | Rectangle { |
|
24 | Rectangle { | |
25 | width: parent.width |
|
25 | width: parent.width | |
26 | height: parent.height |
|
26 | height: parent.height | |
27 |
|
27 | |||
28 | // Another option for QML data api: |
|
28 | // Another option for QML data api: | |
29 | // ListModel { |
|
29 | // ListModel { | |
30 | // id: listModelForPie |
|
30 | // id: listModelForPie | |
31 | // // PieDataElement |
|
31 | // // PieDataElement | |
32 | // ListElement { |
|
32 | // ListElement { | |
33 | // label: "Apple" |
|
33 | // label: "Apple" | |
34 | // value: 4.3 |
|
34 | // value: 4.3 | |
35 | // } |
|
35 | // } | |
36 | // ListElement { |
|
36 | // ListElement { | |
37 | // label: "Blackberry" |
|
37 | // label: "Blackberry" | |
38 | // value: 15.1 |
|
38 | // value: 15.1 | |
39 | // } |
|
39 | // } | |
40 | // } |
|
40 | // } | |
41 |
|
41 | |||
42 | Component.onCompleted: { |
|
42 | Component.onCompleted: { | |
43 | // console.log("model:" + myModel.item(0)); |
|
43 | // console.log("model:" + myModel.item(0)); | |
44 | // myModel.insert(1, {"time":1.4; "speed":41.1 }); |
|
44 | // myModel.insert(1, {"time":1.4; "speed":41.1 }); | |
45 | // scatter.appendData(); |
|
45 | // scatter.appendData(); | |
46 | // chart1.theme = Chart.ThemeHighContrast; |
|
46 | // chart1.theme = Chart.ThemeHighContrast; | |
47 | // chart2.theme = Chart.ThemeHighContrast; |
|
47 | // chart2.theme = Chart.ThemeHighContrast; | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 |
|
50 | |||
51 | Chart { |
|
51 | Chart { | |
52 | id: chart1 |
|
52 | id: chart1 | |
53 | anchors.top: parent.top |
|
53 | anchors.top: parent.top | |
54 | anchors.left: parent.left |
|
54 | anchors.left: parent.left | |
55 | anchors.right: parent.right |
|
55 | anchors.right: parent.right | |
56 | height: parent.height / 2 |
|
56 | height: parent.height / 2 | |
57 | theme: Chart.ThemeBlueCerulean |
|
57 | theme: Chart.ChartThemeBlueCerulean | |
58 |
|
58 | |||
59 | BarSeries { |
|
59 | BarSeries { | |
60 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] |
|
60 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] | |
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 | PieSeries { |
|
63 | PieSeries { | |
64 | slices: [ |
|
64 | slices: [ | |
65 | PieSlice { label: "Volkswagen"; value: 13.5 }, |
|
65 | PieSlice { label: "Volkswagen"; value: 13.5 }, | |
66 | PieSlice { label: "Toyota"; value: 10.9 }, |
|
66 | PieSlice { label: "Toyota"; value: 10.9 }, | |
67 | PieSlice { label: "Ford"; value: 8.6 }, |
|
67 | PieSlice { label: "Ford"; value: 8.6 }, | |
68 | PieSlice { label: "Skoda"; value: 8.2 }, |
|
68 | PieSlice { label: "Skoda"; value: 8.2 }, | |
69 | PieSlice { label: "Volvo"; value: 6.8 }, |
|
69 | PieSlice { label: "Volvo"; value: 6.8 }, | |
70 | PieSlice { label: "Others"; value: 52.0 } |
|
70 | PieSlice { label: "Others"; value: 52.0 } | |
71 | ] |
|
71 | ] | |
72 | } |
|
72 | } | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 |
|
75 | |||
76 | Chart { |
|
76 | Chart { | |
77 | id: chart2 |
|
77 | id: chart2 | |
78 | anchors.top: chart1.bottom |
|
78 | anchors.top: chart1.bottom | |
79 | anchors.bottom: parent.bottom |
|
79 | anchors.bottom: parent.bottom | |
80 | anchors.left: parent.left |
|
80 | anchors.left: parent.left | |
81 | anchors.right: parent.right |
|
81 | anchors.right: parent.right | |
82 |
theme: Chart. |
|
82 | theme: Chart.ChartThemeHighContrast | |
83 |
|
83 | |||
84 | LineSeries { |
|
84 | LineSeries { | |
85 | points: [ |
|
85 | points: [ | |
86 | XyPoint { x: 0.0; y: 0.0 }, |
|
86 | XyPoint { x: 0.0; y: 0.0 }, | |
87 | XyPoint { x: 1.1; y: 2.1 }, |
|
87 | XyPoint { x: 1.1; y: 2.1 }, | |
88 | XyPoint { x: 2.9; y: 4.9 }, |
|
88 | XyPoint { x: 2.9; y: 4.9 }, | |
89 | XyPoint { x: 3.2; y: 3.0 } |
|
89 | XyPoint { x: 3.2; y: 3.0 } | |
90 | ] |
|
90 | ] | |
91 | } |
|
91 | } | |
92 |
|
92 | |||
93 | SplineSeries { |
|
93 | SplineSeries { | |
94 | points: [ |
|
94 | points: [ | |
95 | XyPoint { x: 0.0; y: 0.3 }, |
|
95 | XyPoint { x: 0.0; y: 0.3 }, | |
96 | XyPoint { x: 1.1; y: 3.2 }, |
|
96 | XyPoint { x: 1.1; y: 3.2 }, | |
97 | XyPoint { x: 4.17; y: 3.15 } |
|
97 | XyPoint { x: 4.17; y: 3.15 } | |
98 | ] |
|
98 | ] | |
99 | } |
|
99 | } | |
100 |
|
100 | |||
101 | ScatterSeries { |
|
101 | ScatterSeries { | |
102 | points: [ |
|
102 | points: [ | |
103 | XyPoint { x: 1.5; y: 1.5 }, |
|
103 | XyPoint { x: 1.5; y: 1.5 }, | |
104 | XyPoint { x: 1.5; y: 1.6 }, |
|
104 | XyPoint { x: 1.5; y: 1.6 }, | |
105 | XyPoint { x: 1.57; y: 1.55 } |
|
105 | XyPoint { x: 1.57; y: 1.55 } | |
106 | ] |
|
106 | ] | |
107 | } |
|
107 | } | |
108 | ScatterSeries { |
|
108 | ScatterSeries { | |
109 | points: [ |
|
109 | points: [ | |
110 | XyPoint { x: 2.0; y: 2.0 }, |
|
110 | XyPoint { x: 2.0; y: 2.0 }, | |
111 | XyPoint { x: 2.0; y: 2.1 }, |
|
111 | XyPoint { x: 2.0; y: 2.1 }, | |
112 | XyPoint { x: 2.07; y: 2.05 } |
|
112 | XyPoint { x: 2.07; y: 2.05 } | |
113 | ] |
|
113 | ] | |
114 | } |
|
114 | } | |
115 | ScatterSeries { |
|
115 | ScatterSeries { | |
116 | points: [ |
|
116 | points: [ | |
117 | XyPoint { x: 2.6; y: 2.6 }, |
|
117 | XyPoint { x: 2.6; y: 2.6 }, | |
118 | XyPoint { x: 2.6; y: 2.7 }, |
|
118 | XyPoint { x: 2.6; y: 2.7 }, | |
119 | XyPoint { x: 2.67; y: 2.65 } |
|
119 | XyPoint { x: 2.67; y: 2.65 } | |
120 | ] |
|
120 | ] | |
121 | } |
|
121 | } | |
122 | } |
|
122 | } | |
123 | } |
|
123 | } |
General Comments 0
You need to be logged in to leave comments.
Login now