@@ -26,7 +26,7 Rectangle { | |||
|
26 | 26 | |
|
27 | 27 | ChartView { |
|
28 | 28 | id: chart |
|
29 |
title: " |
|
|
29 | title: "Top-5 car brand shares in Finland" | |
|
30 | 30 | anchors.top: parent.top |
|
31 | 31 | anchors.bottom: button.top |
|
32 | 32 | anchors.left: parent.left |
@@ -33,99 +33,83 Rectangle { | |||
|
33 | 33 | "6", "2006", "7", "2007", "8", "2008", "9", "2009", "10", "2010", "11", "2011"] |
|
34 | 34 | |
|
35 | 35 | AreaSeries { |
|
36 | name: "Russian" | |
|
37 | upperModel: russianModel | |
|
38 | lowerModel: zerosModel | |
|
39 | } | |
|
40 | AreaSeries { | |
|
36 | 41 | name: "Swedish" |
|
37 | points: [ | |
|
38 | XyPoint { x: 0; y: 1 }, | |
|
39 | XyPoint { x: 1; y: 1 }, | |
|
40 | XyPoint { x: 2; y: 3 }, | |
|
41 | XyPoint { x: 3; y: 3 }, | |
|
42 | XyPoint { x: 4; y: 2 }, | |
|
43 | XyPoint { x: 5; y: 0 }, | |
|
44 | XyPoint { x: 6; y: 2 }, | |
|
45 | XyPoint { x: 7; y: 1 }, | |
|
46 | XyPoint { x: 8; y: 2 }, | |
|
47 | XyPoint { x: 9; y: 1 }, | |
|
48 | XyPoint { x: 10; y: 3 }, | |
|
49 | XyPoint { x: 11; y: 3 } | |
|
50 | ] | |
|
51 | lowerPoints: [ | |
|
52 | XyPoint { x: 0; y: 0 }, | |
|
53 | XyPoint { x: 1; y: 0 }, | |
|
54 | XyPoint { x: 2; y: 0 }, | |
|
55 | XyPoint { x: 3; y: 0 }, | |
|
56 | XyPoint { x: 4; y: 0 }, | |
|
57 | XyPoint { x: 5; y: 0 }, | |
|
58 | XyPoint { x: 6; y: 0 }, | |
|
59 | XyPoint { x: 7; y: 0 }, | |
|
60 | XyPoint { x: 8; y: 0 }, | |
|
61 | XyPoint { x: 9; y: 0 }, | |
|
62 | XyPoint { x: 10; y: 0 }, | |
|
63 | XyPoint { x: 11; y: 0 } | |
|
64 | ] | |
|
42 | upperModel: swedishModel | |
|
43 | lowerModel: zerosModel | |
|
65 | 44 | } |
|
66 | ||
|
67 | 45 | AreaSeries { |
|
68 |
name: " |
|
|
69 | points: [ | |
|
70 | XyPoint { x: 0; y: 1 }, | |
|
71 | XyPoint { x: 1; y: 1 }, | |
|
72 | XyPoint { x: 2; y: 1 }, | |
|
73 | XyPoint { x: 3; y: 1 }, | |
|
74 | XyPoint { x: 4; y: 1 }, | |
|
75 | XyPoint { x: 5; y: 0 }, | |
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
|
82 | ] | |
|
83 | lowerPoints: [ | |
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
|
87 | XyPoint { x: 3; y: 0 }, | |
|
88 | XyPoint { x: 4; y: 0 }, | |
|
89 | XyPoint { x: 5; y: 0 }, | |
|
90 | XyPoint { x: 6; y: 0 }, | |
|
91 | XyPoint { x: 7; y: 0 }, | |
|
92 | XyPoint { x: 8; y: 0 }, | |
|
93 | XyPoint { x: 9; y: 0 }, | |
|
94 | XyPoint { x: 10; y: 0 }, | |
|
46 | name: "Finnish" | |
|
47 | upperModel: finnishModel | |
|
48 | lowerModel: zerosModel | |
|
49 | } | |
|
50 | } | |
|
51 | ||
|
52 | XYModel { | |
|
53 | id: zerosModel | |
|
54 | XyPoint { x: 0; y: 0 } | |
|
55 | XyPoint { x: 1; y: 0 } | |
|
56 | XyPoint { x: 2; y: 0 } | |
|
57 | XyPoint { x: 3; y: 0 } | |
|
58 | XyPoint { x: 4; y: 0 } | |
|
59 | XyPoint { x: 5; y: 0 } | |
|
60 | XyPoint { x: 6; y: 0 } | |
|
61 | XyPoint { x: 7; y: 0 } | |
|
62 | XyPoint { x: 8; y: 0 } | |
|
63 | XyPoint { x: 9; y: 0 } | |
|
64 | XyPoint { x: 10; y: 0 } | |
|
95 | 65 |
|
|
96 | ] | |
|
97 | 66 |
|
|
98 | 67 | |
|
99 | AreaSeries { | |
|
100 | name: "Finnish" | |
|
101 | points: [ | |
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 | XyPoint { x: 10; y: 0 }, | |
|
68 | XYModel { | |
|
69 | id: russianModel | |
|
70 | XyPoint { x: 0; y: 1 } | |
|
71 | XyPoint { x: 1; y: 1 } | |
|
72 | XyPoint { x: 2; y: 1 } | |
|
73 | XyPoint { x: 3; y: 1 } | |
|
74 | XyPoint { x: 4; y: 1 } | |
|
75 | XyPoint { x: 5; y: 0 } | |
|
76 | XyPoint { x: 6; y: 1 } | |
|
77 | XyPoint { x: 7; y: 1 } | |
|
78 | XyPoint { x: 8; y: 4 } | |
|
79 | XyPoint { x: 9; y: 3 } | |
|
80 | XyPoint { x: 10; y: 2 } | |
|
113 | 81 |
|
|
114 | ] | |
|
115 | lowerPoints: [ | |
|
116 | XyPoint { x: 0; y: 0 }, | |
|
117 | XyPoint { x: 1; y: 0 }, | |
|
118 | XyPoint { x: 2; y: 0 }, | |
|
119 | XyPoint { x: 3; y: 0 }, | |
|
120 | XyPoint { x: 4; y: 0 }, | |
|
121 | XyPoint { x: 5; y: 0 }, | |
|
122 | XyPoint { x: 6; y: 0 }, | |
|
123 | XyPoint { x: 7; y: 0 }, | |
|
124 | XyPoint { x: 8; y: 0 }, | |
|
125 | XyPoint { x: 9; y: 0 }, | |
|
126 | XyPoint { x: 10; y: 0 }, | |
|
127 | XyPoint { x: 11; y: 0 } | |
|
128 | ] | |
|
129 | 82 |
|
|
83 | ||
|
84 | XYModel { | |
|
85 | id: swedishModel | |
|
86 | XyPoint { x: 0; y: 1 } | |
|
87 | XyPoint { x: 1; y: 1 } | |
|
88 | XyPoint { x: 2; y: 3 } | |
|
89 | XyPoint { x: 3; y: 3 } | |
|
90 | XyPoint { x: 4; y: 2 } | |
|
91 | XyPoint { x: 5; y: 0 } | |
|
92 | XyPoint { x: 6; y: 2 } | |
|
93 | XyPoint { x: 7; y: 1 } | |
|
94 | XyPoint { x: 8; y: 2 } | |
|
95 | XyPoint { x: 9; y: 1 } | |
|
96 | XyPoint { x: 10; y: 3 } | |
|
97 | XyPoint { x: 11; y: 3 } | |
|
98 | } | |
|
99 | ||
|
100 | XYModel { | |
|
101 | id: finnishModel | |
|
102 | XyPoint { x: 0; y: 0 } | |
|
103 | XyPoint { x: 1; y: 0 } | |
|
104 | XyPoint { x: 2; y: 0 } | |
|
105 | XyPoint { x: 3; y: 0 } | |
|
106 | XyPoint { x: 4; y: 0 } | |
|
107 | XyPoint { x: 5; y: 0 } | |
|
108 | XyPoint { x: 6; y: 1 } | |
|
109 | XyPoint { x: 7; y: 0 } | |
|
110 | XyPoint { x: 8; y: 0 } | |
|
111 | XyPoint { x: 9; y: 0 } | |
|
112 | XyPoint { x: 10; y: 0 } | |
|
113 | XyPoint { x: 11; y: 1 } | |
|
130 | 114 | } |
|
131 | 115 | } |
@@ -21,7 +21,6 | |||
|
21 | 21 | #include "declarativeareaseries.h" |
|
22 | 22 | #include "declarativechart.h" |
|
23 | 23 | #include "qchart.h" |
|
24 | #include "qlineseries.h" | |
|
25 | 24 | |
|
26 | 25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | 26 | |
@@ -30,34 +29,40 DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) : | |||
|
30 | 29 | { |
|
31 | 30 | } |
|
32 | 31 | |
|
33 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeAreaSeries::points() | |
|
32 | bool DeclarativeAreaSeries::setDeclarativeUpperModel(DeclarativeXyModel *model) | |
|
34 | 33 | { |
|
35 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeAreaSeries::appendPoints); | |
|
34 | QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model); | |
|
35 | bool value(false); | |
|
36 | if (m) { | |
|
37 | upperSeries()->setModel(m); | |
|
38 | upperSeries()->setModelMapping(0, 1, Qt::Vertical); | |
|
39 | } else { | |
|
40 | qWarning("DeclarativeAreaSeries: Illegal model"); | |
|
41 | } | |
|
42 | return value; | |
|
36 | 43 | } |
|
37 | 44 | |
|
38 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeAreaSeries::lowerPoints() | |
|
45 | DeclarativeXyModel *DeclarativeAreaSeries::declarativeUpperModel() | |
|
39 | 46 | { |
|
40 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeAreaSeries::appendLowerPoints); | |
|
47 | return qobject_cast<DeclarativeXyModel *>(upperSeries()->model()); | |
|
41 | 48 | } |
|
42 | 49 | |
|
43 |
|
|
|
44 | DeclarativeXyPoint *element) | |
|
50 | bool DeclarativeAreaSeries::setDeclarativeLowerModel(DeclarativeXyModel *model) | |
|
45 | 51 | { |
|
46 | QAreaSeries *series = qobject_cast<QAreaSeries *>(list->object); | |
|
47 | if (series) { | |
|
48 | QLineSeries *upper = series->upperSeries(); | |
|
49 | upper->append(element->x(), element->y()); | |
|
52 | QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model); | |
|
53 | bool value(false); | |
|
54 | if (m) { | |
|
55 | lowerSeries()->setModel(m); | |
|
56 | lowerSeries()->setModelMapping(0, 1, Qt::Vertical); | |
|
57 | } else { | |
|
58 | qWarning("DeclarativeAreaSeries: Illegal model"); | |
|
50 | 59 | } |
|
60 | return value; | |
|
51 | 61 | } |
|
52 | 62 | |
|
53 | void DeclarativeAreaSeries::appendLowerPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
|
54 | DeclarativeXyPoint *element) | |
|
63 | DeclarativeXyModel *DeclarativeAreaSeries::declarativeLowerModel() | |
|
55 | 64 | { |
|
56 | QAreaSeries *series = qobject_cast<QAreaSeries *>(list->object); | |
|
57 | if (series) { | |
|
58 | QLineSeries *lower = series->lowerSeries(); | |
|
59 | lower->append(element->x(), element->y()); | |
|
60 | } | |
|
65 | return qobject_cast<DeclarativeXyModel *>(lowerSeries()->model()); | |
|
61 | 66 | } |
|
62 | 67 | |
|
63 | 68 | #include "moc_declarativeareaseries.cpp" |
@@ -23,6 +23,7 | |||
|
23 | 23 | |
|
24 | 24 | #include "qchartglobal.h" |
|
25 | 25 | #include "qareaseries.h" |
|
26 | #include "declarativelineseries.h" | |
|
26 | 27 | #include "declarativexyseries.h" |
|
27 | 28 | |
|
28 | 29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
@@ -30,21 +31,17 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
30 | 31 | class DeclarativeAreaSeries : public QAreaSeries, public DeclarativeXySeries |
|
31 | 32 | { |
|
32 | 33 | Q_OBJECT |
|
33 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points) | |
|
34 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> lowerPoints READ lowerPoints) | |
|
34 | Q_PROPERTY(DeclarativeXyModel *upperModel READ declarativeUpperModel WRITE setDeclarativeUpperModel) | |
|
35 | Q_PROPERTY(DeclarativeXyModel *lowerModel READ declarativeLowerModel WRITE setDeclarativeLowerModel) | |
|
35 | 36 | |
|
36 | 37 | public: |
|
37 | 38 | explicit DeclarativeAreaSeries(QObject *parent = 0); |
|
38 | 39 | |
|
39 | 40 | public: |
|
40 |
|
|
|
41 | QDeclarativeListProperty<DeclarativeXyPoint> lowerPoints(); | |
|
42 | ||
|
43 | public Q_SLOTS: | |
|
44 | static void appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
|
45 | DeclarativeXyPoint *element); | |
|
46 | static void appendLowerPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
|
47 | DeclarativeXyPoint *element); | |
|
41 | bool setDeclarativeUpperModel(DeclarativeXyModel *model); | |
|
42 | DeclarativeXyModel *declarativeUpperModel(); | |
|
43 | bool setDeclarativeLowerModel(DeclarativeXyModel *model); | |
|
44 | DeclarativeXyModel *declarativeLowerModel(); | |
|
48 | 45 | }; |
|
49 | 46 | |
|
50 | 47 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -91,19 +91,16 DeclarativePieModel::DeclarativePieModel(QObject *parent) : | |||
|
91 | 91 | |
|
92 | 92 | void DeclarativePieModel::append(QPieSlice* slice) |
|
93 | 93 | { |
|
94 | qDebug() << "DeclarativePieModel::append:" << slice->label() << " " << slice->value(); | |
|
95 | qDebug() << "rowCount:" << rowCount(); | |
|
96 | qDebug() << "coolCount:" << columnCount(); | |
|
94 | // qDebug() << "DeclarativePieModel::append:" << slice->label() << " " << slice->value(); | |
|
97 | 95 | insertRow(rowCount()); |
|
98 | qDebug() << "new rowCount:" << rowCount(); | |
|
99 | 96 | |
|
100 |
|
|
|
101 |
|
|
|
97 | setData(createIndex(rowCount() - 1, 0), slice->value()); | |
|
98 | setData(createIndex(rowCount() - 1, 1), slice->label()); | |
|
102 | 99 | } |
|
103 | 100 | |
|
104 | 101 | void DeclarativePieModel::append(QVariantList slices) |
|
105 | 102 | { |
|
106 | qDebug() << "append:" << slices; | |
|
103 | // qDebug() << "append:" << slices; | |
|
107 | 104 | QString label = ""; |
|
108 | 105 | for (int i(0); i < slices.count(); i++) { |
|
109 | 106 | if (i % 2) { |
General Comments 0
You need to be logged in to leave comments.
Login now