@@ -31,9 +31,9 Rectangle { | |||||
31 | legend: Chart.LegendBottom |
|
31 | legend: Chart.LegendBottom | |
32 |
|
32 | |||
33 | PieSeries { |
|
33 | PieSeries { | |
34 |
horizontalPosition: 0. |
|
34 | horizontalPosition: 0.5 | |
35 |
verticalPosition: 0. |
|
35 | verticalPosition: 0.5 | |
36 |
size: 0. |
|
36 | size: 0.7 | |
37 | slices: [ |
|
37 | slices: [ | |
38 | PieSlice { label: "Volkswagen"; value: 13.5 }, |
|
38 | PieSlice { label: "Volkswagen"; value: 13.5 }, | |
39 | PieSlice { label: "Toyota"; value: 10.9 }, |
|
39 | PieSlice { label: "Toyota"; value: 10.9 }, | |
@@ -43,10 +43,5 Rectangle { | |||||
43 | PieSlice { label: "Others"; value: 52.0 } |
|
43 | PieSlice { label: "Others"; value: 52.0 } | |
44 | ] |
|
44 | ] | |
45 | } |
|
45 | } | |
46 |
|
||||
47 | BarSeries { |
|
|||
48 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] |
|
|||
49 | // data implementation missing |
|
|||
50 | } |
|
|||
51 | } |
|
46 | } | |
52 | } |
|
47 | } |
@@ -31,20 +31,20 Rectangle { | |||||
31 | legend: Chart.LegendTop |
|
31 | legend: Chart.LegendTop | |
32 |
|
32 | |||
33 | AreaSeries { |
|
33 | AreaSeries { | |
34 |
name: " |
|
34 | name: "Swedish" | |
35 | points: [ |
|
35 | points: [ | |
36 |
XyPoint { x: 0; y: |
|
36 | XyPoint { x: 0; y: 1 }, | |
37 |
XyPoint { x: 1; y: |
|
37 | XyPoint { x: 1; y: 1 }, | |
38 |
XyPoint { x: 2; y: |
|
38 | XyPoint { x: 2; y: 3 }, | |
39 |
XyPoint { x: 3; y: |
|
39 | XyPoint { x: 3; y: 3 }, | |
40 |
XyPoint { x: 4; y: |
|
40 | XyPoint { x: 4; y: 2 }, | |
41 | XyPoint { x: 5; y: 0 }, |
|
41 | XyPoint { x: 5; y: 0 }, | |
42 |
XyPoint { x: 6; y: |
|
42 | XyPoint { x: 6; y: 2 }, | |
43 |
XyPoint { x: 7; y: |
|
43 | XyPoint { x: 7; y: 1 }, | |
44 |
XyPoint { x: 8; y: |
|
44 | XyPoint { x: 8; y: 2 }, | |
45 |
XyPoint { x: 9; y: |
|
45 | XyPoint { x: 9; y: 1 }, | |
46 |
XyPoint { x: 10; y: |
|
46 | XyPoint { x: 10; y: 3 }, | |
47 |
XyPoint { x: 11; y: |
|
47 | XyPoint { x: 11; y: 3 } | |
48 | ] |
|
48 | ] | |
49 | lowerPoints: [ |
|
49 | lowerPoints: [ | |
50 | XyPoint { x: 0; y: 0 }, |
|
50 | XyPoint { x: 0; y: 0 }, | |
@@ -95,20 +95,20 Rectangle { | |||||
95 | } |
|
95 | } | |
96 |
|
96 | |||
97 | AreaSeries { |
|
97 | AreaSeries { | |
98 |
name: " |
|
98 | name: "Finnish" | |
99 | points: [ |
|
99 | points: [ | |
100 |
XyPoint { x: 0; y: |
|
100 | XyPoint { x: 0; y: 0 }, | |
101 |
XyPoint { x: 1; y: |
|
101 | XyPoint { x: 1; y: 0 }, | |
102 |
XyPoint { x: 2; y: |
|
102 | XyPoint { x: 2; y: 0 }, | |
103 |
XyPoint { x: 3; y: |
|
103 | XyPoint { x: 3; y: 0 }, | |
104 |
XyPoint { x: 4; y: |
|
104 | XyPoint { x: 4; y: 0 }, | |
105 | XyPoint { x: 5; y: 0 }, |
|
105 | XyPoint { x: 5; y: 0 }, | |
106 |
XyPoint { x: 6; y: |
|
106 | XyPoint { x: 6; y: 1 }, | |
107 |
XyPoint { x: 7; y: |
|
107 | XyPoint { x: 7; y: 0 }, | |
108 |
XyPoint { x: 8; y: |
|
108 | XyPoint { x: 8; y: 0 }, | |
109 |
XyPoint { x: 9; y: |
|
109 | XyPoint { x: 9; y: 0 }, | |
110 |
XyPoint { x: 10; y: |
|
110 | XyPoint { x: 10; y: 0 }, | |
111 |
XyPoint { x: 11; y: |
|
111 | XyPoint { x: 11; y: 1 } | |
112 | ] |
|
112 | ] | |
113 | lowerPoints: [ |
|
113 | lowerPoints: [ | |
114 | XyPoint { x: 0; y: 0 }, |
|
114 | XyPoint { x: 0; y: 0 }, |
@@ -40,7 +40,7 Rectangle { | |||||
40 | Loader { |
|
40 | Loader { | |
41 | id: loader |
|
41 | id: loader | |
42 | anchors.fill: parent |
|
42 | anchors.fill: parent | |
43 |
source: "View" + (__viewNumber % |
|
43 | source: "View" + (__viewNumber % 5 + 1) + ".qml"; | |
44 | } |
|
44 | } | |
45 |
|
45 | |||
46 | MouseArea { |
|
46 | MouseArea { |
@@ -6,5 +6,6 | |||||
6 | <file>qml/qmlchart/View2.qml</file> |
|
6 | <file>qml/qmlchart/View2.qml</file> | |
7 | <file>qml/qmlchart/View3.qml</file> |
|
7 | <file>qml/qmlchart/View3.qml</file> | |
8 | <file>qml/qmlchart/View4.qml</file> |
|
8 | <file>qml/qmlchart/View4.qml</file> | |
|
9 | <file>qml/qmlchart/View5.qml</file> | |||
9 | </qresource> |
|
10 | </qresource> | |
10 | </RCC> |
|
11 | </RCC> |
@@ -30,11 +30,6 DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) : | |||||
30 | { |
|
30 | { | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | QAbstractSeries *DeclarativeAreaSeries::series() |
|
|||
34 | { |
|
|||
35 | return this; |
|
|||
36 | } |
|
|||
37 |
|
||||
38 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeAreaSeries::points() |
|
33 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeAreaSeries::points() | |
39 | { |
|
34 | { | |
40 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeAreaSeries::appendPoints); |
|
35 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeAreaSeries::appendPoints); |
@@ -37,7 +37,6 public: | |||||
37 | explicit DeclarativeAreaSeries(QObject *parent = 0); |
|
37 | explicit DeclarativeAreaSeries(QObject *parent = 0); | |
38 |
|
38 | |||
39 | public: |
|
39 | public: | |
40 | QAbstractSeries *series(); |
|
|||
41 | QDeclarativeListProperty<DeclarativeXyPoint> points(); |
|
40 | QDeclarativeListProperty<DeclarativeXyPoint> points(); | |
42 | QDeclarativeListProperty<DeclarativeXyPoint> lowerPoints(); |
|
41 | QDeclarativeListProperty<DeclarativeXyPoint> lowerPoints(); | |
43 |
|
42 |
@@ -19,6 +19,7 | |||||
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativechart.h" |
|
21 | #include "declarativechart.h" | |
|
22 | #include "declarativepieseries.h" | |||
22 | #include <QPainter> |
|
23 | #include <QPainter> | |
23 |
|
24 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
@@ -36,6 +37,26 DeclarativeChart::~DeclarativeChart() | |||||
36 | delete m_chart; |
|
37 | delete m_chart; | |
37 | } |
|
38 | } | |
38 |
|
39 | |||
|
40 | void DeclarativeChart::childEvent(QChildEvent *event) | |||
|
41 | { | |||
|
42 | if (event->type() == QEvent::ChildAdded) { | |||
|
43 | if (qobject_cast<QAbstractSeries *>(event->child())) { | |||
|
44 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); | |||
|
45 | } | |||
|
46 | } | |||
|
47 | } | |||
|
48 | ||||
|
49 | void DeclarativeChart::componentComplete() | |||
|
50 | { | |||
|
51 | foreach(QObject *child, children()) { | |||
|
52 | if (qobject_cast<QAbstractSeries *>(child)) { | |||
|
53 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); | |||
|
54 | } | |||
|
55 | } | |||
|
56 | ||||
|
57 | QDeclarativeItem::componentComplete(); | |||
|
58 | } | |||
|
59 | ||||
39 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
60 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
40 | { |
|
61 | { | |
41 | Q_UNUSED(oldGeometry) |
|
62 | Q_UNUSED(oldGeometry) |
@@ -53,6 +53,8 public: | |||||
53 | ~DeclarativeChart(); |
|
53 | ~DeclarativeChart(); | |
54 |
|
54 | |||
55 | public: // From QDeclarativeItem/QGraphicsItem |
|
55 | public: // From QDeclarativeItem/QGraphicsItem | |
|
56 | void childEvent(QChildEvent *event); | |||
|
57 | void componentComplete(); | |||
56 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); |
|
58 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); | |
57 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
59 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
58 |
|
60 |
@@ -30,11 +30,6 DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) : | |||||
30 | { |
|
30 | { | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | QAbstractSeries *DeclarativeLineSeries::series() |
|
|||
34 | { |
|
|||
35 | return this; |
|
|||
36 | } |
|
|||
37 |
|
||||
38 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeLineSeries::points() |
|
33 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeLineSeries::points() | |
39 | { |
|
34 | { | |
40 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeXySeries::appendPoints); |
|
35 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeXySeries::appendPoints); |
@@ -37,7 +37,6 public: | |||||
37 | explicit DeclarativeLineSeries(QObject *parent = 0); |
|
37 | explicit DeclarativeLineSeries(QObject *parent = 0); | |
38 |
|
38 | |||
39 | public: |
|
39 | public: | |
40 | QAbstractSeries *series(); |
|
|||
41 | QDeclarativeListProperty<DeclarativeXyPoint> points(); |
|
40 | QDeclarativeListProperty<DeclarativeXyPoint> points(); | |
42 | }; |
|
41 | }; | |
43 |
|
42 |
@@ -25,25 +25,10 | |||||
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
26 |
|
26 | |||
27 | DeclarativePieSeries::DeclarativePieSeries(QObject *parent) : |
|
27 | DeclarativePieSeries::DeclarativePieSeries(QObject *parent) : | |
28 |
QPieSeries(parent) |
|
28 | QPieSeries(parent) | |
29 | m_chart(0) |
|
|||
30 | { |
|
29 | { | |
31 | } |
|
30 | } | |
32 |
|
31 | |||
33 | void DeclarativePieSeries::classBegin() |
|
|||
34 | { |
|
|||
35 | } |
|
|||
36 |
|
||||
37 | void DeclarativePieSeries::componentComplete() |
|
|||
38 | { |
|
|||
39 | DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent()); |
|
|||
40 | if (declarativeChart) { |
|
|||
41 | QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart); |
|
|||
42 | Q_ASSERT(chart); |
|
|||
43 | chart->addSeries(this); |
|
|||
44 | } |
|
|||
45 | } |
|
|||
46 |
|
||||
47 | QDeclarativeListProperty<QPieSlice> DeclarativePieSeries::slices() |
|
32 | QDeclarativeListProperty<QPieSlice> DeclarativePieSeries::slices() | |
48 | { |
|
33 | { | |
49 | return QDeclarativeListProperty<QPieSlice>(this, 0, &DeclarativePieSeries::appendSlice); |
|
34 | return QDeclarativeListProperty<QPieSlice>(this, 0, &DeclarativePieSeries::appendSlice); |
@@ -24,32 +24,24 | |||||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "qpieslice.h" |
|
25 | #include "qpieslice.h" | |
26 | #include "qpieseries.h" |
|
26 | #include "qpieseries.h" | |
27 |
#include <QDeclarative |
|
27 | #include <QDeclarativeListProperty> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class QChart; |
|
31 | class QChart; | |
32 |
|
32 | |||
33 |
class DeclarativePieSeries : public QPieSeries |
|
33 | class DeclarativePieSeries : public QPieSeries | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 | Q_INTERFACES(QDeclarativeParserStatus) |
|
|||
37 | Q_PROPERTY(QDeclarativeListProperty<QPieSlice> slices READ slices) |
|
36 | Q_PROPERTY(QDeclarativeListProperty<QPieSlice> slices READ slices) | |
38 |
|
37 | |||
39 | public: |
|
38 | public: | |
40 | explicit DeclarativePieSeries(QObject *parent = 0); |
|
39 | explicit DeclarativePieSeries(QObject *parent = 0); | |
41 | QDeclarativeListProperty<QPieSlice> slices(); |
|
40 | QDeclarativeListProperty<QPieSlice> slices(); | |
42 |
|
41 | |||
43 | public: // from QDeclarativeParserStatus |
|
|||
44 | void classBegin(); |
|
|||
45 | void componentComplete(); |
|
|||
46 |
|
||||
47 | public Q_SLOTS: |
|
42 | public Q_SLOTS: | |
48 | static void appendSlice(QDeclarativeListProperty<QPieSlice> *list, |
|
43 | static void appendSlice(QDeclarativeListProperty<QPieSlice> *list, | |
49 | QPieSlice *element); |
|
44 | QPieSlice *element); | |
50 |
|
||||
51 | private: |
|
|||
52 | QChart *m_chart; |
|
|||
53 | }; |
|
45 | }; | |
54 |
|
46 | |||
55 | QTCOMMERCIALCHART_END_NAMESPACE |
|
47 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -30,11 +30,6 DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : | |||||
30 | { |
|
30 | { | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | QAbstractSeries *DeclarativeScatterSeries::series() |
|
|||
34 | { |
|
|||
35 | return this; |
|
|||
36 | } |
|
|||
37 |
|
||||
38 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeScatterSeries::points() |
|
33 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeScatterSeries::points() | |
39 | { |
|
34 | { | |
40 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeXySeries::appendPoints); |
|
35 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeXySeries::appendPoints); |
@@ -37,7 +37,6 public: | |||||
37 | explicit DeclarativeScatterSeries(QObject *parent = 0); |
|
37 | explicit DeclarativeScatterSeries(QObject *parent = 0); | |
38 |
|
38 | |||
39 | public: |
|
39 | public: | |
40 | QAbstractSeries *series(); |
|
|||
41 | QDeclarativeListProperty<DeclarativeXyPoint> points(); |
|
40 | QDeclarativeListProperty<DeclarativeXyPoint> points(); | |
42 | }; |
|
41 | }; | |
43 |
|
42 |
@@ -29,11 +29,6 DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) : | |||||
29 | { |
|
29 | { | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | QAbstractSeries *DeclarativeSplineSeries::series() |
|
|||
33 | { |
|
|||
34 | return this; |
|
|||
35 | } |
|
|||
36 |
|
||||
37 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeSplineSeries::points() |
|
32 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeSplineSeries::points() | |
38 | { |
|
33 | { | |
39 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeXySeries::appendPoints); |
|
34 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeXySeries::appendPoints); |
@@ -37,7 +37,6 public: | |||||
37 | explicit DeclarativeSplineSeries(QObject *parent = 0); |
|
37 | explicit DeclarativeSplineSeries(QObject *parent = 0); | |
38 |
|
38 | |||
39 | public: |
|
39 | public: | |
40 | QAbstractSeries *series(); |
|
|||
41 | QDeclarativeListProperty<DeclarativeXyPoint> points(); |
|
40 | QDeclarativeListProperty<DeclarativeXyPoint> points(); | |
42 | }; |
|
41 | }; | |
43 |
|
42 |
@@ -33,22 +33,6 DeclarativeXySeries::~DeclarativeXySeries() | |||||
33 | { |
|
33 | { | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | void DeclarativeXySeries::classBegin() |
|
|||
37 | { |
|
|||
38 | } |
|
|||
39 |
|
||||
40 | void DeclarativeXySeries::componentComplete() |
|
|||
41 | { |
|
|||
42 | QAbstractSeries *thisObj = reinterpret_cast<QAbstractSeries *>(series()); |
|
|||
43 | DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(thisObj->parent()); |
|
|||
44 |
|
||||
45 | if (declarativeChart) { |
|
|||
46 | QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart); |
|
|||
47 | Q_ASSERT(chart); |
|
|||
48 | chart->addSeries(thisObj); |
|
|||
49 | } |
|
|||
50 | } |
|
|||
51 |
|
||||
52 | void DeclarativeXySeries::appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, |
|
36 | void DeclarativeXySeries::appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
53 | DeclarativeXyPoint *element) |
|
37 | DeclarativeXyPoint *element) | |
54 | { |
|
38 | { |
@@ -23,7 +23,6 | |||||
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "declarativexypoint.h" |
|
25 | #include "declarativexypoint.h" | |
26 | #include <QDeclarativeParserStatus> |
|
|||
27 | #include <QDeclarativeListProperty> |
|
26 | #include <QDeclarativeListProperty> | |
28 |
|
27 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
@@ -31,7 +30,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
31 | class QChart; |
|
30 | class QChart; | |
32 | class QAbstractSeries; |
|
31 | class QAbstractSeries; | |
33 |
|
32 | |||
34 | class DeclarativeXySeries : public QDeclarativeParserStatus |
|
33 | class DeclarativeXySeries | |
35 | { |
|
34 | { | |
36 | Q_INTERFACES(QDeclarativeParserStatus) |
|
35 | Q_INTERFACES(QDeclarativeParserStatus) | |
37 |
|
36 | |||
@@ -39,12 +38,7 public: | |||||
39 | explicit DeclarativeXySeries(); |
|
38 | explicit DeclarativeXySeries(); | |
40 | ~DeclarativeXySeries(); |
|
39 | ~DeclarativeXySeries(); | |
41 |
|
40 | |||
42 | public: // from QDeclarativeParserStatus |
|
|||
43 | virtual void classBegin(); |
|
|||
44 | virtual void componentComplete(); |
|
|||
45 |
|
||||
46 | public: |
|
41 | public: | |
47 | virtual QAbstractSeries *series() = 0; |
|
|||
48 | virtual QDeclarativeListProperty<DeclarativeXyPoint> points() = 0; |
|
42 | virtual QDeclarativeListProperty<DeclarativeXyPoint> points() = 0; | |
49 |
|
43 | |||
50 | public Q_SLOTS: |
|
44 | public Q_SLOTS: |
General Comments 0
You need to be logged in to leave comments.
Login now