@@ -96,7 +96,7 Rectangle { | |||||
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | AreaSeries { |
|
98 | AreaSeries { | |
99 |
name: " |
|
99 | name: "Finnish" | |
100 | upperSeries: LineSeries { |
|
100 | upperSeries: LineSeries { | |
101 | XyPoint { x: 0; y: 0 } |
|
101 | XyPoint { x: 0; y: 0 } | |
102 | XyPoint { x: 1; y: 0 } |
|
102 | XyPoint { x: 1; y: 0 } |
@@ -30,10 +30,10 Rectangle { | |||||
30 | theme: ChartView.ChartThemeLight |
|
30 | theme: ChartView.ChartThemeLight | |
31 | legend: ChartView.LegendBottom |
|
31 | legend: ChartView.LegendBottom | |
32 | // TODO: labels defined by x-axis, not by bar series |
|
32 | // TODO: labels defined by x-axis, not by bar series | |
33 |
|
|
33 | axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"] | |
34 |
|
|
34 | axisX.max: 10 | |
35 |
|
35 | |||
36 | BarSeries { |
|
36 | GroupedBarSeries { | |
37 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] |
|
37 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] | |
38 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
38 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
39 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
39 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
@@ -90,12 +90,54 DeclarativeTableModel *DeclarativeBarSeries::declarativeModel() | |||||
90 | return qobject_cast<DeclarativeTableModel *>(model()); |
|
90 | return qobject_cast<DeclarativeTableModel *>(model()); | |
91 | } |
|
91 | } | |
92 |
|
92 | |||
93 | void DeclarativeBarSeries::setBarCategories(QStringList categories) |
|
93 | DeclarativeGroupedBarSeries::DeclarativeGroupedBarSeries(QDeclarativeItem *parent) : | |
|
94 | QGroupedBarSeries(parent) | |||
|
95 | { | |||
|
96 | } | |||
|
97 | ||||
|
98 | void DeclarativeGroupedBarSeries::classBegin() | |||
|
99 | { | |||
|
100 | } | |||
|
101 | ||||
|
102 | void DeclarativeGroupedBarSeries::componentComplete() | |||
|
103 | { | |||
|
104 | foreach(QObject *child, children()) { | |||
|
105 | if (qobject_cast<QBarSet *>(child)) { | |||
|
106 | QBarSeries::append(qobject_cast<QBarSet *>(child)); | |||
|
107 | } | |||
|
108 | } | |||
|
109 | } | |||
|
110 | ||||
|
111 | QDeclarativeListProperty<DeclarativeBarSet> DeclarativeGroupedBarSeries::initialBarSets() | |||
|
112 | { | |||
|
113 | return QDeclarativeListProperty<DeclarativeBarSet>(this, 0, &DeclarativeGroupedBarSeries::appendInitialBarSets); | |||
|
114 | } | |||
|
115 | ||||
|
116 | bool DeclarativeGroupedBarSeries::setDeclarativeModel(DeclarativeTableModel *model) | |||
|
117 | { | |||
|
118 | QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model); | |||
|
119 | bool value(false); | |||
|
120 | if (m) { | |||
|
121 | setModel(m); | |||
|
122 | //setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); | |||
|
123 | // setModelMapping(0, 1, 1, Qt::Vertical); | |||
|
124 | } else { | |||
|
125 | qWarning("DeclarativeGroupedBarSeries: Illegal model"); | |||
|
126 | } | |||
|
127 | return value; | |||
|
128 | } | |||
|
129 | ||||
|
130 | DeclarativeTableModel *DeclarativeGroupedBarSeries::declarativeModel() | |||
|
131 | { | |||
|
132 | return qobject_cast<DeclarativeTableModel *>(model()); | |||
|
133 | } | |||
|
134 | ||||
|
135 | void DeclarativeGroupedBarSeries::setBarCategories(QStringList categories) | |||
94 | { |
|
136 | { | |
95 | setCategories(categories); |
|
137 | setCategories(categories); | |
96 | } |
|
138 | } | |
97 |
|
139 | |||
98 | QStringList DeclarativeBarSeries::barCategories() |
|
140 | QStringList DeclarativeGroupedBarSeries::barCategories() | |
99 | { |
|
141 | { | |
100 | return categories(); |
|
142 | return categories(); | |
101 | } |
|
143 | } |
@@ -48,7 +48,6 class DeclarativeBarSeries : public QGroupedBarSeries, public QDeclarativeParser | |||||
48 | Q_OBJECT |
|
48 | Q_OBJECT | |
49 | Q_INTERFACES(QDeclarativeParserStatus) |
|
49 | Q_INTERFACES(QDeclarativeParserStatus) | |
50 | Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel) |
|
50 | Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel) | |
51 | Q_PROPERTY(QStringList barCategories READ barCategories WRITE setBarCategories) |
|
|||
52 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeBarSet> initialBarSets READ initialBarSets) |
|
51 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeBarSet> initialBarSets READ initialBarSets) | |
53 | Q_CLASSINFO("DefaultProperty", "initialBarSets") |
|
52 | Q_CLASSINFO("DefaultProperty", "initialBarSets") | |
54 |
|
53 | |||
@@ -63,8 +62,33 public: // from QDeclarativeParserStatus | |||||
63 | public: |
|
62 | public: | |
64 | bool setDeclarativeModel(DeclarativeTableModel *model); |
|
63 | bool setDeclarativeModel(DeclarativeTableModel *model); | |
65 | DeclarativeTableModel *declarativeModel(); |
|
64 | DeclarativeTableModel *declarativeModel(); | |
|
65 | ||||
|
66 | public Q_SLOTS: | |||
|
67 | static void appendInitialBarSets(QDeclarativeListProperty<DeclarativeBarSet> */*list*/, DeclarativeBarSet */*element*/) {} | |||
|
68 | }; | |||
|
69 | ||||
|
70 | class DeclarativeGroupedBarSeries : public QGroupedBarSeries, public QDeclarativeParserStatus | |||
|
71 | { | |||
|
72 | Q_OBJECT | |||
|
73 | Q_INTERFACES(QDeclarativeParserStatus) | |||
|
74 | Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel) | |||
|
75 | Q_PROPERTY(QStringList barCategories READ barCategories WRITE setBarCategories) | |||
|
76 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeBarSet> initialBarSets READ initialBarSets) | |||
|
77 | Q_CLASSINFO("DefaultProperty", "initialBarSets") | |||
|
78 | ||||
|
79 | public: | |||
|
80 | explicit DeclarativeGroupedBarSeries(QDeclarativeItem *parent = 0); | |||
|
81 | QDeclarativeListProperty<DeclarativeBarSet> initialBarSets(); | |||
|
82 | ||||
|
83 | public: // from QDeclarativeParserStatus | |||
|
84 | void classBegin(); | |||
|
85 | void componentComplete(); | |||
|
86 | ||||
|
87 | public: | |||
66 | void setBarCategories(QStringList categories); |
|
88 | void setBarCategories(QStringList categories); | |
67 | QStringList barCategories(); |
|
89 | QStringList barCategories(); | |
|
90 | bool setDeclarativeModel(DeclarativeTableModel *model); | |||
|
91 | DeclarativeTableModel *declarativeModel(); | |||
68 |
|
92 | |||
69 | public Q_SLOTS: |
|
93 | public Q_SLOTS: | |
70 | static void appendInitialBarSets(QDeclarativeListProperty<DeclarativeBarSet> */*list*/, DeclarativeBarSet */*element*/) {} |
|
94 | static void appendInitialBarSets(QDeclarativeListProperty<DeclarativeBarSet> */*list*/, DeclarativeBarSet */*element*/) {} |
@@ -39,11 +39,9 void DeclarativeLineSeries::appendDeclarativeChildren(QDeclarativeListProperty<Q | |||||
39 | { |
|
39 | { | |
40 | QXYSeries *series = qobject_cast<QXYSeries*>(list->object); |
|
40 | QXYSeries *series = qobject_cast<QXYSeries*>(list->object); | |
41 | DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element); |
|
41 | DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element); | |
42 |
if (series && point) |
|
42 | if (series && point) | |
43 | qDebug() << "DeclarativeScatterSeries::appendDeclarativeChildren:" << *point; |
|
|||
44 | series->append(*point); |
|
43 | series->append(*point); | |
45 | } |
|
44 | } | |
46 | } |
|
|||
47 |
|
45 | |||
48 | #include "moc_declarativelineseries.cpp" |
|
46 | #include "moc_declarativelineseries.cpp" | |
49 |
|
47 |
@@ -38,11 +38,10 void DeclarativeSplineSeries::appendDeclarativeChildren(QDeclarativeListProperty | |||||
38 | { |
|
38 | { | |
39 | QXYSeries *series = qobject_cast<QXYSeries*>(list->object); |
|
39 | QXYSeries *series = qobject_cast<QXYSeries*>(list->object); | |
40 | DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element); |
|
40 | DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element); | |
41 |
if (series && point) |
|
41 | if (series && point) | |
42 | qDebug() << "DeclarativeScatterSeries::appendDeclarativeChildren:" << *point; |
|
|||
43 | series->append(*point); |
|
42 | series->append(*point); | |
44 | } |
|
43 | } | |
45 | } |
|
44 | ||
46 | #include "moc_declarativesplineseries.cpp" |
|
45 | #include "moc_declarativesplineseries.cpp" | |
47 |
|
46 | |||
48 | QTCOMMERCIALCHART_END_NAMESPACE |
|
47 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -47,23 +47,21 public: | |||||
47 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); |
|
47 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); | |
48 | qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis", |
|
48 | qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis", | |
49 | QLatin1String("Trying to create uncreatable: Axis.")); |
|
49 | QLatin1String("Trying to create uncreatable: Axis.")); | |
50 | //qmlRegisterType<DeclarativeAxisCategory>(uri, 1, 0, "AxisCategory"); |
|
|||
51 | qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint"); |
|
50 | qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint"); | |
52 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); |
|
51 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); | |
53 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); |
|
52 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); | |
54 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); |
|
53 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); | |
55 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); |
|
54 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); | |
56 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
55 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); | |
|
56 | qmlRegisterType<DeclarativeGroupedBarSeries>(uri, 1, 0, "GroupedBarSeries"); | |||
57 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
57 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); | |
58 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); |
|
58 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); | |
59 | qmlRegisterType<DeclarativeTableModel>(uri, 1, 0, "ChartModel"); |
|
59 | qmlRegisterType<DeclarativeTableModel>(uri, 1, 0, "ChartModel"); | |
60 | qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "ChartModelElement"); |
|
60 | qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "ChartModelElement"); | |
61 | //qmlRegisterType<DeclarativePieMapping>(uri, 1, 0, "PieMapping"); |
|
|||
62 | //qmlRegisterType<QPieModelMapper>(uri, 1, 0, "PieModelMapper"); |
|
|||
63 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
61 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", | |
64 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
62 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
65 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", |
|
63 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", | |
66 |
QLatin1String("Trying to create uncreatable: |
|
64 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); | |
67 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
65 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); | |
68 | } |
|
66 | } | |
69 | }; |
|
67 | }; |
@@ -353,9 +353,6 QColor ChartTheme::colorAt(const QGradient &gradient, qreal pos) | |||||
353 | { |
|
353 | { | |
354 | Q_ASSERT(pos >= 0 && pos <= 1.0); |
|
354 | Q_ASSERT(pos >= 0 && pos <= 1.0); | |
355 |
|
355 | |||
356 | // another possibility: |
|
|||
357 | // http://stackoverflow.com/questions/3306786/get-intermediate-color-from-a-gradient |
|
|||
358 |
|
||||
359 | QGradientStops stops = gradient.stops(); |
|
356 | QGradientStops stops = gradient.stops(); | |
360 | int count = stops.count(); |
|
357 | int count = stops.count(); | |
361 |
|
358 |
General Comments 0
You need to be logged in to leave comments.
Login now