@@ -0,0 +1,48 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | import QtCommercial.Chart 1.0 | |
|
23 | ||
|
24 | Rectangle { | |
|
25 | anchors.fill: parent | |
|
26 | ||
|
27 | //![1] | |
|
28 | ChartView { | |
|
29 | title: "Horizontal Stacked Bar series" | |
|
30 | anchors.fill: parent | |
|
31 | legend.alignment: Qt.AlignBottom | |
|
32 | BarCategoriesAxis { | |
|
33 | id: myAxis; | |
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |
|
35 | } | |
|
36 | HorizontalStackedBarSeries { | |
|
37 | id: mySeries; | |
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
|
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
|
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
|
41 | } | |
|
42 | Component.onCompleted: { | |
|
43 | createDefaultAxes(); | |
|
44 | setAxisY(myAxis,mySeries); | |
|
45 | } | |
|
46 | } | |
|
47 | //![1] | |
|
48 | } |
@@ -0,0 +1,49 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | import QtCommercial.Chart 1.0 | |
|
23 | ||
|
24 | Rectangle { | |
|
25 | anchors.fill: parent | |
|
26 | ||
|
27 | //![1] | |
|
28 | ChartView { | |
|
29 | title: "Horizontal Percent Bar series" | |
|
30 | anchors.fill: parent | |
|
31 | legend.alignment: Qt.AlignBottom | |
|
32 | BarCategoriesAxis { | |
|
33 | id: myAxis | |
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |
|
35 | } | |
|
36 | HorizontalPercentBarSeries { | |
|
37 | id: mySeries | |
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
|
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
|
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
|
41 | } | |
|
42 | Component.onCompleted: { | |
|
43 | createDefaultAxes(); | |
|
44 | setAxisY(myAxis,mySeries); | |
|
45 | } | |
|
46 | } | |
|
47 | //![1] | |
|
48 | } | |
|
49 |
@@ -0,0 +1,49 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | import QtCommercial.Chart 1.0 | |
|
23 | ||
|
24 | Rectangle { | |
|
25 | anchors.fill: parent | |
|
26 | ||
|
27 | //![1] | |
|
28 | ChartView { | |
|
29 | title: "Horizontal Bar series" | |
|
30 | anchors.fill: parent | |
|
31 | legend.alignment: Qt.AlignBottom | |
|
32 | BarCategoriesAxis { | |
|
33 | id: myAxis | |
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |
|
35 | } | |
|
36 | HorizontalBarSeries { | |
|
37 | id: mySeries | |
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
|
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
|
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
|
41 | } | |
|
42 | Component.onCompleted: { | |
|
43 | createDefaultAxes(); | |
|
44 | setAxisY(myAxis,mySeries); | |
|
45 | } | |
|
46 | } | |
|
47 | //![1] | |
|
48 | } | |
|
49 |
@@ -1,90 +1,90 | |||
|
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 | Rectangle { |
|
25 | 25 | width: parent.width |
|
26 | 26 | height: parent.height |
|
27 | 27 | property int viewNumber: 1 |
|
28 | 28 | |
|
29 | 29 | Loader { |
|
30 | 30 | id: loader |
|
31 | 31 | anchors.fill: parent |
|
32 | 32 | source: "View" + viewNumber + ".qml"; |
|
33 | 33 | } |
|
34 | 34 | |
|
35 | 35 | Rectangle { |
|
36 | 36 | id: infoText |
|
37 | 37 | anchors.centerIn: parent |
|
38 | 38 | width: parent.width |
|
39 | 39 | height: 40 |
|
40 | 40 | color: "black" |
|
41 | 41 | Text { |
|
42 | 42 | color: "white" |
|
43 | 43 | anchors.centerIn: parent |
|
44 | 44 | text: "Use left and right arrow keys to navigate between chart types" |
|
45 | 45 | } |
|
46 | 46 | |
|
47 | 47 | Behavior on opacity { |
|
48 | 48 | NumberAnimation { duration: 400 } |
|
49 | 49 | } |
|
50 | 50 | } |
|
51 | 51 | |
|
52 | 52 | MouseArea { |
|
53 | 53 | focus: true |
|
54 | 54 | anchors.fill: parent |
|
55 | 55 | onClicked: { |
|
56 | 56 | if (infoText.opacity > 0) { |
|
57 | 57 | infoText.opacity = 0.0; |
|
58 | 58 | } else { |
|
59 | 59 | nextView(); |
|
60 | 60 | } |
|
61 | 61 | } |
|
62 | 62 | Keys.onPressed: { |
|
63 | 63 | if (infoText.opacity > 0) { |
|
64 | 64 | infoText.opacity = 0.0; |
|
65 | 65 | } else { |
|
66 | 66 | if (event.key == Qt.Key_Left) { |
|
67 | 67 | previousView(); |
|
68 | 68 | } else { |
|
69 | 69 | nextView(); |
|
70 | 70 | } |
|
71 | 71 | } |
|
72 | 72 | } |
|
73 | 73 | } |
|
74 | 74 | |
|
75 | 75 | function nextView() { |
|
76 | 76 | var i = viewNumber + 1; |
|
77 |
if (i > |
|
|
77 | if (i > 11) | |
|
78 | 78 | viewNumber = 1; |
|
79 | 79 | else |
|
80 | 80 | viewNumber = i; |
|
81 | 81 | } |
|
82 | 82 | |
|
83 | 83 | function previousView() { |
|
84 | 84 | var i = viewNumber - 1; |
|
85 | 85 | if (i <= 0) |
|
86 |
viewNumber = |
|
|
86 | viewNumber = 11; | |
|
87 | 87 | else |
|
88 | 88 | viewNumber = i; |
|
89 | 89 | } |
|
90 | 90 | } |
@@ -1,14 +1,17 | |||
|
1 | 1 | <RCC> |
|
2 | 2 | <qresource prefix="/"> |
|
3 | 3 | <file>qml/qmlchart/loader.qml</file> |
|
4 | 4 | <file>qml/qmlchart/main.qml</file> |
|
5 | 5 | <file>qml/qmlchart/View1.qml</file> |
|
6 | 6 | <file>qml/qmlchart/View2.qml</file> |
|
7 | 7 | <file>qml/qmlchart/View3.qml</file> |
|
8 | 8 | <file>qml/qmlchart/View4.qml</file> |
|
9 | 9 | <file>qml/qmlchart/View5.qml</file> |
|
10 | 10 | <file>qml/qmlchart/View6.qml</file> |
|
11 | 11 | <file>qml/qmlchart/View7.qml</file> |
|
12 | 12 | <file>qml/qmlchart/View8.qml</file> |
|
13 | <file>qml/qmlchart/View9.qml</file> | |
|
14 | <file>qml/qmlchart/View10.qml</file> | |
|
15 | <file>qml/qmlchart/View11.qml</file> | |
|
13 | 16 | </qresource> |
|
14 | 17 | </RCC> |
@@ -1,515 +1,524 | |||
|
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 | #include "qbarcategoryaxis.h" |
|
30 | 30 | |
|
31 | 31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | 32 | |
|
33 | 33 | /*! |
|
34 | 34 | \qmlclass ChartView DeclarativeChart |
|
35 | 35 | |
|
36 | 36 | ChartView element is the parent that is responsible for showing different chart series types. |
|
37 | 37 | |
|
38 | 38 | The following QML shows how to create a simple chart with one pie series: |
|
39 | 39 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 |
|
40 | 40 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
41 | 41 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 |
|
42 | 42 | |
|
43 | 43 | \beginfloatleft |
|
44 | 44 | \image examples_qmlpiechart.png |
|
45 | 45 | \endfloat |
|
46 | 46 | \clearfloat |
|
47 | 47 | */ |
|
48 | 48 | |
|
49 | 49 | /*! |
|
50 | 50 | \qmlproperty Theme ChartView::theme |
|
51 | 51 | Theme defines the visual appearance of the chart, including for example colors, fonts, line |
|
52 | 52 | widths and chart background. |
|
53 | 53 | */ |
|
54 | 54 | |
|
55 | 55 | /*! |
|
56 | 56 | \qmlproperty Animation ChartView::animation |
|
57 | 57 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, |
|
58 | 58 | ChartView.SeriesAnimations or ChartView.AllAnimations. |
|
59 | 59 | */ |
|
60 | 60 | |
|
61 | 61 | /*! |
|
62 | 62 | \qmlproperty Font ChartView::titleFont |
|
63 | 63 | The title font of the chart |
|
64 | 64 | |
|
65 | 65 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
66 | 66 | */ |
|
67 | 67 | |
|
68 | 68 | /*! |
|
69 | 69 | \qmlproperty string ChartView::title |
|
70 | 70 | The title of the chart, shown on top of the chart. |
|
71 | 71 | \sa ChartView::titleColor |
|
72 | 72 | */ |
|
73 | 73 | |
|
74 | 74 | /*! |
|
75 | 75 | \qmlproperty string ChartView::titleColor |
|
76 | 76 | The color of the title text. |
|
77 | 77 | */ |
|
78 | 78 | |
|
79 | 79 | /*! |
|
80 | 80 | \qmlproperty Axis ChartView::axisX |
|
81 | 81 | The x-axis of the chart. |
|
82 | 82 | */ |
|
83 | 83 | |
|
84 | 84 | /*! |
|
85 | 85 | \qmlproperty Axis ChartView::axisY |
|
86 | 86 | The default y-axis of the chart. |
|
87 | 87 | */ |
|
88 | 88 | |
|
89 | 89 | /*! |
|
90 | 90 | \qmlproperty Legend ChartView::legend |
|
91 | 91 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. |
|
92 | 92 | */ |
|
93 | 93 | |
|
94 | 94 | /*! |
|
95 | 95 | \qmlproperty int ChartView::count |
|
96 | 96 | The count of series added to the chart. |
|
97 | 97 | */ |
|
98 | 98 | |
|
99 | 99 | /*! |
|
100 | 100 | \qmlproperty color ChartView::backgroundColor |
|
101 | 101 | The color of the chart's background. By default background color is defined by chart theme. |
|
102 | 102 | \sa ChartView::theme |
|
103 | 103 | */ |
|
104 | 104 | |
|
105 | 105 | /*! |
|
106 | 106 | \qmlproperty bool ChartView::dropShadowEnabled |
|
107 | 107 | The chart's border drop shadow. Set to true to enable drop shadow. |
|
108 | 108 | */ |
|
109 | 109 | |
|
110 | 110 | /*! |
|
111 | 111 | \qmlproperty real ChartView::topMargin |
|
112 | 112 | The space between the top of chart view and the top of the plot area. The title (if non-empty) is drawn on top margin |
|
113 | 113 | area of the chart view. Top margin area is also used by legend, if aligned to top. |
|
114 | 114 | */ |
|
115 | 115 | |
|
116 | 116 | /*! |
|
117 | 117 | \qmlproperty real ChartView::bottomMargin |
|
118 | 118 | The space between the bottom of chart view and the bottom of the plot area. The bottom margin area may be used by |
|
119 | 119 | legend (if aligned to bottom), x-axis, x-axis labels and x-axis tick marks. |
|
120 | 120 | */ |
|
121 | 121 | |
|
122 | 122 | /*! |
|
123 | 123 | \qmlproperty real ChartView::leftMargin |
|
124 | 124 | The space between the left side of chart view and the left side of the plot area. The left margin area may be used by |
|
125 | 125 | legend (if aligned to left), y-axis, y-axis labels and y-axis tick marks. |
|
126 | 126 | */ |
|
127 | 127 | |
|
128 | 128 | /*! |
|
129 | 129 | \qmlproperty real ChartView::rightMargin |
|
130 | 130 | The space between the right side of chart view and the right side of the plot area. The right margin area may be used |
|
131 | 131 | by legend (if aligned to right). |
|
132 | 132 | */ |
|
133 | 133 | |
|
134 | 134 | /*! |
|
135 | 135 | \qmlmethod AbstractSeries ChartView::series(int index) |
|
136 | 136 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with |
|
137 | 137 | the count property of the chart. |
|
138 | 138 | */ |
|
139 | 139 | |
|
140 | 140 | /*! |
|
141 | 141 | \qmlmethod AbstractSeries ChartView::series(string name) |
|
142 | 142 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. |
|
143 | 143 | */ |
|
144 | 144 | |
|
145 | 145 | /*! |
|
146 | 146 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name) |
|
147 | 147 | Creates a series object of \a type to the chart. For example: |
|
148 | 148 | \code |
|
149 | 149 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series"); |
|
150 | 150 | scatter.markerSize = 22; |
|
151 | 151 | scatter.append(1.1, 2.0); |
|
152 | 152 | \endcode |
|
153 | 153 | */ |
|
154 | 154 | |
|
155 | 155 | /*! |
|
156 | 156 | \qmlmethod Axis ChartView::axisY(QAbstractSeries *series) |
|
157 | 157 | The y-axis of the series. This is the same as the default y-axis of the chart as multiple y-axes are not yet supported. |
|
158 | 158 | */ |
|
159 | 159 | |
|
160 | 160 | /*! |
|
161 | 161 | \qmlmethod ChartView::zoomY(real factor) |
|
162 | 162 | Zooms in by \a factor on the center of the chart. |
|
163 | 163 | */ |
|
164 | 164 | |
|
165 | 165 | /*! |
|
166 | 166 | \qmlmethod ChartView::scrollLeft(real pixels) |
|
167 | 167 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. |
|
168 | 168 | \sa ValuesAxis::min, ValuesAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max |
|
169 | 169 | */ |
|
170 | 170 | |
|
171 | 171 | /*! |
|
172 | 172 | \qmlmethod ChartView::scrollRight(real pixels) |
|
173 | 173 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. |
|
174 | 174 | \sa ValuesAxis::min, ValuesAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max |
|
175 | 175 | */ |
|
176 | 176 | |
|
177 | 177 | /*! |
|
178 | 178 | \qmlmethod ChartView::scrollUp(real pixels) |
|
179 | 179 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. |
|
180 | 180 | \sa ValuesAxis::min, ValuesAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max |
|
181 | 181 | */ |
|
182 | 182 | |
|
183 | 183 | /*! |
|
184 | 184 | \qmlmethod ChartView::scrollDown(real pixels) |
|
185 | 185 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. |
|
186 | 186 | \sa ValuesAxis::min, ValuesAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max |
|
187 | 187 | */ |
|
188 | 188 | |
|
189 | 189 | /*! |
|
190 | 190 | \qmlsignal ChartView::onTopMarginChanged(real margin) |
|
191 | 191 | The top margin of the chart view has changed to \a margin. This may happen for example if you modify font size |
|
192 | 192 | related properties of the legend or chart title. |
|
193 | 193 | */ |
|
194 | 194 | |
|
195 | 195 | /*! |
|
196 | 196 | \qmlsignal ChartView::onBottomMarginChanged(real margin) |
|
197 | 197 | The bottom margin of the chart view has changed to \a margin. This may happen for example if you modify font size |
|
198 | 198 | related properties of the legend or chart title. |
|
199 | 199 | */ |
|
200 | 200 | |
|
201 | 201 | /*! |
|
202 | 202 | \qmlsignal ChartView::onLeftMarginChanged(real margin) |
|
203 | 203 | The left margin of the chart view has changed to \a margin. This may happen for example if you modify font size |
|
204 | 204 | related properties of the legend or chart title. |
|
205 | 205 | */ |
|
206 | 206 | |
|
207 | 207 | /*! |
|
208 | 208 | \qmlsignal ChartView::onRightMarginChanged(real margin) |
|
209 | 209 | The right margin of the chart view has changed to \a margin. This may happen for example if you modify font size |
|
210 | 210 | related properties of the legend or chart title. |
|
211 | 211 | */ |
|
212 | 212 | |
|
213 | 213 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
|
214 | 214 | : QDeclarativeItem(parent), |
|
215 | 215 | m_chart(new QChart(this)) |
|
216 | 216 | { |
|
217 | 217 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
218 | 218 | // m_chart->axisX()->setNiceNumbersEnabled(false); |
|
219 | 219 | m_chartMargins = m_chart->margins(); |
|
220 | 220 | connect(m_chart, SIGNAL(marginsChanged(QRectF)), this, SLOT(handleMarginsChanged(QRectF))); |
|
221 | 221 | } |
|
222 | 222 | |
|
223 | 223 | void DeclarativeChart::handleMarginsChanged(QRectF newMargins) |
|
224 | 224 | { |
|
225 | 225 | if (m_chartMargins.top() != newMargins.top()) |
|
226 | 226 | topMarginChanged(m_chart->margins().top()); |
|
227 | 227 | if (m_chartMargins.bottom() != newMargins.bottom()) |
|
228 | 228 | bottomMarginChanged(m_chart->margins().bottom()); |
|
229 | 229 | if (m_chartMargins.left() != newMargins.left()) |
|
230 | 230 | leftMarginChanged(m_chart->margins().left()); |
|
231 | 231 | if (m_chartMargins.right() != newMargins.right()) |
|
232 | 232 | rightMarginChanged(m_chart->margins().right()); |
|
233 | 233 | |
|
234 | 234 | m_chartMargins = m_chart->margins(); |
|
235 | 235 | } |
|
236 | 236 | |
|
237 | 237 | DeclarativeChart::~DeclarativeChart() |
|
238 | 238 | { |
|
239 | 239 | delete m_chart; |
|
240 | 240 | } |
|
241 | 241 | |
|
242 | 242 | void DeclarativeChart::childEvent(QChildEvent *event) |
|
243 | 243 | { |
|
244 | 244 | if (event->type() == QEvent::ChildAdded) { |
|
245 | 245 | if (qobject_cast<QAbstractSeries *>(event->child())) { |
|
246 | 246 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); |
|
247 | 247 | } |
|
248 | 248 | } |
|
249 | 249 | } |
|
250 | 250 | |
|
251 | 251 | void DeclarativeChart::componentComplete() |
|
252 | 252 | { |
|
253 | 253 | foreach(QObject *child, children()) { |
|
254 | 254 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
255 | 255 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; |
|
256 | 256 | // TODO: how about optional y-axis? |
|
257 | 257 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); |
|
258 | 258 | }else if(qobject_cast<QAbstractAxis *>(child)){ |
|
259 | 259 | |
|
260 | 260 | } |
|
261 | 261 | } |
|
262 | 262 | QDeclarativeItem::componentComplete(); |
|
263 | 263 | } |
|
264 | 264 | |
|
265 | 265 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
266 | 266 | { |
|
267 | 267 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); |
|
268 | 268 | if (newGeometry.isValid()) { |
|
269 | 269 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
270 | 270 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
271 | 271 | } |
|
272 | 272 | } |
|
273 | 273 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); |
|
274 | 274 | } |
|
275 | 275 | |
|
276 | 276 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
277 | 277 | { |
|
278 | 278 | Q_UNUSED(option) |
|
279 | 279 | Q_UNUSED(widget) |
|
280 | 280 | |
|
281 | 281 | // TODO: optimized? |
|
282 | 282 | painter->setRenderHint(QPainter::Antialiasing, true); |
|
283 | 283 | } |
|
284 | 284 | |
|
285 | 285 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
|
286 | 286 | { |
|
287 | 287 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; |
|
288 | 288 | if (chartTheme != m_chart->theme()) |
|
289 | 289 | m_chart->setTheme(chartTheme); |
|
290 | 290 | } |
|
291 | 291 | |
|
292 | 292 | DeclarativeChart::Theme DeclarativeChart::theme() |
|
293 | 293 | { |
|
294 | 294 | return (DeclarativeChart::Theme) m_chart->theme(); |
|
295 | 295 | } |
|
296 | 296 | |
|
297 | 297 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) |
|
298 | 298 | { |
|
299 | 299 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; |
|
300 | 300 | if (animationOptions != m_chart->animationOptions()) |
|
301 | 301 | m_chart->setAnimationOptions(animationOptions); |
|
302 | 302 | } |
|
303 | 303 | |
|
304 | 304 | DeclarativeChart::Animation DeclarativeChart::animationOptions() |
|
305 | 305 | { |
|
306 | 306 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) |
|
307 | 307 | return DeclarativeChart::AllAnimations; |
|
308 | 308 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) |
|
309 | 309 | return DeclarativeChart::GridAxisAnimations; |
|
310 | 310 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
311 | 311 | return DeclarativeChart::SeriesAnimations; |
|
312 | 312 | else |
|
313 | 313 | return DeclarativeChart::NoAnimation; |
|
314 | 314 | } |
|
315 | 315 | |
|
316 | 316 | void DeclarativeChart::setTitle(QString title) |
|
317 | 317 | { |
|
318 | 318 | if (title != m_chart->title()) |
|
319 | 319 | m_chart->setTitle(title); |
|
320 | 320 | } |
|
321 | 321 | QString DeclarativeChart::title() |
|
322 | 322 | { |
|
323 | 323 | return m_chart->title(); |
|
324 | 324 | } |
|
325 | 325 | |
|
326 | 326 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) |
|
327 | 327 | { |
|
328 | 328 | return m_chart->axisX(series); |
|
329 | 329 | } |
|
330 | 330 | |
|
331 | 331 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) |
|
332 | 332 | { |
|
333 | 333 | return m_chart->axisY(series); |
|
334 | 334 | } |
|
335 | 335 | |
|
336 | 336 | QLegend *DeclarativeChart::legend() |
|
337 | 337 | { |
|
338 | 338 | return m_chart->legend(); |
|
339 | 339 | } |
|
340 | 340 | |
|
341 | 341 | void DeclarativeChart::setTitleColor(QColor color) |
|
342 | 342 | { |
|
343 | 343 | QBrush b = m_chart->titleBrush(); |
|
344 | 344 | if (color != b.color()) { |
|
345 | 345 | b.setColor(color); |
|
346 | 346 | m_chart->setTitleBrush(b); |
|
347 | 347 | emit titleColorChanged(color); |
|
348 | 348 | } |
|
349 | 349 | } |
|
350 | 350 | |
|
351 | 351 | QFont DeclarativeChart::titleFont() const |
|
352 | 352 | { |
|
353 | 353 | return m_chart->titleFont(); |
|
354 | 354 | } |
|
355 | 355 | |
|
356 | 356 | void DeclarativeChart::setTitleFont(const QFont& font) |
|
357 | 357 | { |
|
358 | 358 | m_chart->setTitleFont(font); |
|
359 | 359 | } |
|
360 | 360 | |
|
361 | 361 | QColor DeclarativeChart::titleColor() |
|
362 | 362 | { |
|
363 | 363 | return m_chart->titleBrush().color(); |
|
364 | 364 | } |
|
365 | 365 | |
|
366 | 366 | void DeclarativeChart::setBackgroundColor(QColor color) |
|
367 | 367 | { |
|
368 | 368 | QBrush b = m_chart->backgroundBrush(); |
|
369 | 369 | if (b.style() != Qt::SolidPattern || color != b.color()) { |
|
370 | 370 | b.setStyle(Qt::SolidPattern); |
|
371 | 371 | b.setColor(color); |
|
372 | 372 | m_chart->setBackgroundBrush(b); |
|
373 | 373 | emit backgroundColorChanged(); |
|
374 | 374 | } |
|
375 | 375 | } |
|
376 | 376 | |
|
377 | 377 | QColor DeclarativeChart::backgroundColor() |
|
378 | 378 | { |
|
379 | 379 | return m_chart->backgroundBrush().color(); |
|
380 | 380 | } |
|
381 | 381 | |
|
382 | 382 | int DeclarativeChart::count() |
|
383 | 383 | { |
|
384 | 384 | return m_chart->series().count(); |
|
385 | 385 | } |
|
386 | 386 | |
|
387 | 387 | void DeclarativeChart::setDropShadowEnabled(bool enabled) |
|
388 | 388 | { |
|
389 | 389 | if (enabled != m_chart->isDropShadowEnabled()) { |
|
390 | 390 | m_chart->setDropShadowEnabled(enabled); |
|
391 | 391 | dropShadowEnabledChanged(enabled); |
|
392 | 392 | } |
|
393 | 393 | } |
|
394 | 394 | |
|
395 | 395 | bool DeclarativeChart::dropShadowEnabled() |
|
396 | 396 | { |
|
397 | 397 | return m_chart->isDropShadowEnabled(); |
|
398 | 398 | } |
|
399 | 399 | |
|
400 | 400 | qreal DeclarativeChart::topMargin() |
|
401 | 401 | { |
|
402 | 402 | return m_chart->margins().top(); |
|
403 | 403 | } |
|
404 | 404 | |
|
405 | 405 | qreal DeclarativeChart::bottomMargin() |
|
406 | 406 | { |
|
407 | 407 | return m_chart->margins().bottom(); |
|
408 | 408 | } |
|
409 | 409 | |
|
410 | 410 | qreal DeclarativeChart::leftMargin() |
|
411 | 411 | { |
|
412 | 412 | return m_chart->margins().left(); |
|
413 | 413 | } |
|
414 | 414 | |
|
415 | 415 | qreal DeclarativeChart::rightMargin() |
|
416 | 416 | { |
|
417 | 417 | return m_chart->margins().right(); |
|
418 | 418 | } |
|
419 | 419 | |
|
420 | 420 | void DeclarativeChart::zoom(qreal factor) |
|
421 | 421 | { |
|
422 | 422 | m_chart->zoom(factor); |
|
423 | 423 | } |
|
424 | 424 | |
|
425 | 425 | void DeclarativeChart::scrollLeft(qreal pixels) |
|
426 | 426 | { |
|
427 | 427 | m_chart->scroll(pixels, 0); |
|
428 | 428 | } |
|
429 | 429 | |
|
430 | 430 | void DeclarativeChart::scrollRight(qreal pixels) |
|
431 | 431 | { |
|
432 | 432 | m_chart->scroll(-pixels, 0); |
|
433 | 433 | } |
|
434 | 434 | |
|
435 | 435 | void DeclarativeChart::scrollUp(qreal pixels) |
|
436 | 436 | { |
|
437 | 437 | m_chart->scroll(0, pixels); |
|
438 | 438 | } |
|
439 | 439 | |
|
440 | 440 | void DeclarativeChart::scrollDown(qreal pixels) |
|
441 | 441 | { |
|
442 | 442 | m_chart->scroll(0, -pixels); |
|
443 | 443 | } |
|
444 | 444 | |
|
445 | 445 | QAbstractSeries *DeclarativeChart::series(int index) |
|
446 | 446 | { |
|
447 | 447 | if (index < m_chart->series().count()) { |
|
448 | 448 | return m_chart->series().at(index); |
|
449 | 449 | } |
|
450 | 450 | return 0; |
|
451 | 451 | } |
|
452 | 452 | |
|
453 | 453 | QAbstractSeries *DeclarativeChart::series(QString seriesName) |
|
454 | 454 | { |
|
455 | 455 | foreach(QAbstractSeries *series, m_chart->series()) { |
|
456 | 456 | if (series->name() == seriesName) |
|
457 | 457 | return series; |
|
458 | 458 | } |
|
459 | 459 | return 0; |
|
460 | 460 | } |
|
461 | 461 | |
|
462 | 462 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) |
|
463 | 463 | { |
|
464 | 464 | QAbstractSeries *series = 0; |
|
465 | 465 | switch (type) { |
|
466 | 466 | case DeclarativeChart::SeriesTypeLine: |
|
467 | 467 | series = new DeclarativeLineSeries(); |
|
468 | 468 | break; |
|
469 | 469 | case DeclarativeChart::SeriesTypeArea: |
|
470 | 470 | series = new DeclarativeAreaSeries(); |
|
471 | 471 | break; |
|
472 | 472 | case DeclarativeChart::SeriesTypeStackedBar: |
|
473 | 473 | series = new DeclarativeStackedBarSeries(); |
|
474 | 474 | break; |
|
475 | 475 | case DeclarativeChart::SeriesTypePercentBar: |
|
476 | 476 | series = new DeclarativePercentBarSeries(); |
|
477 | 477 | break; |
|
478 | 478 | case DeclarativeChart::SeriesTypeBar: |
|
479 | 479 | series = new DeclarativeBarSeries(); |
|
480 | 480 | break; |
|
481 | case DeclarativeChart::SeriesTypeHorizontalBar: | |
|
482 | series = new DeclarativeHorizontalBarSeries(); | |
|
483 | break; | |
|
484 | case DeclarativeChart::SeriesTypeHorizontalPercentBar: | |
|
485 | series = new DeclarativeHorizontalPercentBarSeries(); | |
|
486 | break; | |
|
487 | case DeclarativeChart::SeriesTypeHorizontalStackedBar: | |
|
488 | series = new DeclarativeHorizontalStackedBarSeries(); | |
|
489 | break; | |
|
481 | 490 | case DeclarativeChart::SeriesTypePie: |
|
482 | 491 | series = new DeclarativePieSeries(); |
|
483 | 492 | break; |
|
484 | 493 | case DeclarativeChart::SeriesTypeScatter: |
|
485 | 494 | series = new DeclarativeScatterSeries(); |
|
486 | 495 | break; |
|
487 | 496 | case DeclarativeChart::SeriesTypeSpline: |
|
488 | 497 | series = new DeclarativeSplineSeries(); |
|
489 | 498 | break; |
|
490 | 499 | default: |
|
491 | 500 | qWarning() << "Illegal series type"; |
|
492 | 501 | } |
|
493 | 502 | series->setName(name); |
|
494 | 503 | m_chart->addSeries(series); |
|
495 | 504 | return series; |
|
496 | 505 | } |
|
497 | 506 | |
|
498 | 507 | void DeclarativeChart::setAxisX(QAbstractAxis* axis, QAbstractSeries *series) |
|
499 | 508 | { |
|
500 | 509 | m_chart->setAxisX(axis,series); |
|
501 | 510 | } |
|
502 | 511 | |
|
503 | 512 | void DeclarativeChart::setAxisY(QAbstractAxis* axis, QAbstractSeries *series) |
|
504 | 513 | { |
|
505 | 514 | m_chart->setAxisY(axis,series); |
|
506 | 515 | } |
|
507 | 516 | |
|
508 | 517 | void DeclarativeChart::createDefaultAxes() |
|
509 | 518 | { |
|
510 | 519 | m_chart->createDefaultAxes(); |
|
511 | 520 | } |
|
512 | 521 | |
|
513 | 522 | #include "moc_declarativechart.cpp" |
|
514 | 523 | |
|
515 | 524 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,155 +1,158 | |||
|
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 | |
|
28 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | 29 | |
|
30 | 30 | // TODO: Derive from QChart for easier definition of properties? |
|
31 | 31 | class DeclarativeChart : public QDeclarativeItem |
|
32 | 32 | // TODO: for QTQUICK2: extend QQuickPainterItem instead |
|
33 | 33 | //class DeclarativeChart : public QQuickPaintedItem, public Chart |
|
34 | 34 | { |
|
35 | 35 | Q_OBJECT |
|
36 | 36 | Q_PROPERTY(Theme theme READ theme WRITE setTheme) |
|
37 | 37 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) |
|
38 | 38 | Q_PROPERTY(QString title READ title WRITE setTitle) |
|
39 | 39 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) |
|
40 | 40 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) |
|
41 | 41 | Q_PROPERTY(QLegend *legend READ legend) |
|
42 | 42 | Q_PROPERTY(int count READ count) |
|
43 | 43 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) |
|
44 | 44 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) |
|
45 | 45 | Q_PROPERTY(qreal topMargin READ topMargin NOTIFY topMarginChanged) |
|
46 | 46 | Q_PROPERTY(qreal bottomMargin READ bottomMargin NOTIFY bottomMarginChanged) |
|
47 | 47 | Q_PROPERTY(qreal leftMargin READ leftMargin NOTIFY leftMarginChanged) |
|
48 | 48 | Q_PROPERTY(qreal rightMargin READ rightMargin NOTIFY rightMarginChanged) |
|
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 | SeriesTypePie, |
|
79 | 79 | SeriesTypeScatter, |
|
80 | SeriesTypeSpline | |
|
80 | SeriesTypeSpline, | |
|
81 | SeriesTypeHorizontalBar, | |
|
82 | SeriesTypeHorizontalStackedBar, | |
|
83 | SeriesTypeHorizontalPercentBar | |
|
81 | 84 | }; |
|
82 | 85 | |
|
83 | 86 | public: |
|
84 | 87 | DeclarativeChart(QDeclarativeItem *parent = 0); |
|
85 | 88 | ~DeclarativeChart(); |
|
86 | 89 | |
|
87 | 90 | public: // From QDeclarativeItem/QGraphicsItem |
|
88 | 91 | void childEvent(QChildEvent *event); |
|
89 | 92 | void componentComplete(); |
|
90 | 93 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); |
|
91 | 94 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
92 | 95 | |
|
93 | 96 | public: |
|
94 | 97 | void setTheme(DeclarativeChart::Theme theme); |
|
95 | 98 | DeclarativeChart::Theme theme(); |
|
96 | 99 | void setAnimationOptions(DeclarativeChart::Animation animations); |
|
97 | 100 | DeclarativeChart::Animation animationOptions(); |
|
98 | 101 | void setTitle(QString title); |
|
99 | 102 | QString title(); |
|
100 | 103 | QLegend *legend(); |
|
101 | 104 | QFont titleFont() const; |
|
102 | 105 | void setTitleFont(const QFont& font); |
|
103 | 106 | void setTitleColor(QColor color); |
|
104 | 107 | QColor titleColor(); |
|
105 | 108 | void setBackgroundColor(QColor color); |
|
106 | 109 | QColor backgroundColor(); |
|
107 | 110 | int count(); |
|
108 | 111 | void setDropShadowEnabled(bool enabled); |
|
109 | 112 | bool dropShadowEnabled(); |
|
110 | 113 | qreal topMargin(); |
|
111 | 114 | qreal bottomMargin(); |
|
112 | 115 | qreal leftMargin(); |
|
113 | 116 | qreal rightMargin(); |
|
114 | 117 | |
|
115 | 118 | |
|
116 | 119 | |
|
117 | 120 | public: |
|
118 | 121 | Q_INVOKABLE QAbstractSeries *series(int index); |
|
119 | 122 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); |
|
120 | 123 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); |
|
121 | 124 | Q_INVOKABLE void setAxisX(QAbstractAxis* axis, QAbstractSeries *series = 0); |
|
122 | 125 | Q_INVOKABLE void setAxisY(QAbstractAxis* axis, QAbstractSeries *series = 0); |
|
123 | 126 | Q_INVOKABLE void createDefaultAxes(); |
|
124 | 127 | Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0); |
|
125 | 128 | Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0); |
|
126 | 129 | |
|
127 | 130 | Q_INVOKABLE void zoom(qreal factor); |
|
128 | 131 | Q_INVOKABLE void scrollLeft(qreal pixels); |
|
129 | 132 | Q_INVOKABLE void scrollRight(qreal pixels); |
|
130 | 133 | Q_INVOKABLE void scrollUp(qreal pixels); |
|
131 | 134 | Q_INVOKABLE void scrollDown(qreal pixels); |
|
132 | 135 | |
|
133 | 136 | Q_SIGNALS: |
|
134 | 137 | void axisLabelsChanged(); |
|
135 | 138 | void titleColorChanged(QColor color); |
|
136 | 139 | void backgroundColorChanged(); |
|
137 | 140 | void dropShadowEnabledChanged(bool enabled); |
|
138 | 141 | void topMarginChanged(qreal margin); |
|
139 | 142 | void bottomMarginChanged(qreal margin); |
|
140 | 143 | void leftMarginChanged(qreal margin); |
|
141 | 144 | void rightMarginChanged(qreal margin); |
|
142 | 145 | |
|
143 | 146 | public Q_SLOTS: |
|
144 | 147 | void handleMarginsChanged(QRectF newMargins); |
|
145 | 148 | |
|
146 | 149 | private: |
|
147 | 150 | // Extending QChart with DeclarativeChart is not possible because QObject does not support |
|
148 | 151 | // multi inheritance, so we now have a QChart as a member instead |
|
149 | 152 | QChart *m_chart; |
|
150 | 153 | QRectF m_chartMargins; |
|
151 | 154 | }; |
|
152 | 155 | |
|
153 | 156 | QTCOMMERCIALCHART_END_NAMESPACE |
|
154 | 157 | |
|
155 | 158 | #endif // DECLARATIVECHART_H |
@@ -1,101 +1,104 | |||
|
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 <QtDeclarative/qdeclarativeextensionplugin.h> |
|
22 | 22 | #include <QtDeclarative/qdeclarative.h> |
|
23 | 23 | #include "qchart.h" |
|
24 | 24 | #include "qabstractaxis.h" |
|
25 | 25 | #include "qvalueaxis.h" |
|
26 | 26 | #include "qbarcategoryaxis.h" |
|
27 | 27 | #include "declarativechart.h" |
|
28 | 28 | #include "declarativexypoint.h" |
|
29 | 29 | #include "declarativelineseries.h" |
|
30 | 30 | #include "declarativesplineseries.h" |
|
31 | 31 | #include "declarativeareaseries.h" |
|
32 | 32 | #include "declarativescatterseries.h" |
|
33 | 33 | #include "declarativebarseries.h" |
|
34 | 34 | #include "declarativepieseries.h" |
|
35 | 35 | #include "qvxymodelmapper.h" |
|
36 | 36 | #include "qhxymodelmapper.h" |
|
37 | 37 | #include "qhpiemodelmapper.h" |
|
38 | 38 | #include "qvpiemodelmapper.h" |
|
39 | 39 | #include "qhbarmodelmapper.h" |
|
40 | 40 | #include "qvbarmodelmapper.h" |
|
41 | 41 | #include <QAbstractItemModel> |
|
42 | 42 | |
|
43 | 43 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
44 | 44 | |
|
45 | 45 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin |
|
46 | 46 | { |
|
47 | 47 | Q_OBJECT |
|
48 | 48 | public: |
|
49 | 49 | virtual void registerTypes(const char *uri) |
|
50 | 50 | { |
|
51 | 51 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); |
|
52 | 52 | |
|
53 | 53 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); |
|
54 | 54 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint"); |
|
55 | 55 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); |
|
56 | 56 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); |
|
57 | 57 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); |
|
58 | 58 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); |
|
59 | 59 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
60 | 60 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); |
|
61 | 61 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); |
|
62 | qmlRegisterType<DeclarativeHorizontalBarSeries>(uri, 1, 0, "HorizontalBarSeries"); | |
|
63 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries>(uri, 1, 0, "HorizontalStackedBarSeries"); | |
|
64 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries>(uri, 1, 0, "HorizontalPercentBarSeries"); | |
|
62 | 65 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
63 | 66 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); |
|
64 | 67 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
65 | 68 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); |
|
66 | 69 | qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); |
|
67 | 70 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); |
|
68 | 71 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); |
|
69 | 72 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); |
|
70 | 73 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); |
|
71 | 74 | qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis"); |
|
72 | 75 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis"); |
|
73 | 76 | |
|
74 | 77 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", |
|
75 | 78 | QLatin1String("Trying to create uncreatable: Legend.")); |
|
76 | 79 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", |
|
77 | 80 | QLatin1String("Trying to create uncreatable: XYSeries.")); |
|
78 | 81 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", |
|
79 | 82 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
80 | 83 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", |
|
81 | 84 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); |
|
82 | 85 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
83 | 86 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
84 | 87 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", |
|
85 | 88 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); |
|
86 | 89 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", |
|
87 | 90 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); |
|
88 | 91 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", |
|
89 | 92 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); |
|
90 | 93 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", |
|
91 | 94 | QLatin1String("Trying to create uncreatable: AbstractAxis.")); |
|
92 | 95 | } |
|
93 | 96 | }; |
|
94 | 97 | |
|
95 | 98 | #include "plugin.moc" |
|
96 | 99 | |
|
97 | 100 | QTCOMMERCIALCHART_END_NAMESPACE |
|
98 | 101 | |
|
99 | 102 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
100 | 103 | |
|
101 | 104 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
General Comments 0
You need to be logged in to leave comments.
Login now