##// END OF EJS Templates
Added CategoryAxis and CategoryRange to QML API
Tero Ahola -
r1870:102af68fd8c5
parent child
Show More
@@ -29,15 +29,26 Rectangle {
29 29 title: "NHL All-Star Team Players"
30 30 anchors.fill: parent
31 31
32 BarCategoriesAxis {
33 id: catergoriesAxis
34 categories: ["2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008",
35 "2009", "2010", "2011" ]
32 CategoryAxis {
33 id: categoriesAxis
34 startValue: -0.5
35 CategoryRange { endValue: 0.5; label: "2000" }
36 CategoryRange { endValue: 1.5; label: "2001" }
37 CategoryRange { endValue: 2.5; label: "2002" }
38 CategoryRange { endValue: 3.5; label: "2003" }
39 CategoryRange { endValue: 4.5; label: "2004" }
40 CategoryRange { endValue: 5.5; label: "2005" }
41 CategoryRange { endValue: 6.5; label: "2006" }
42 CategoryRange { endValue: 7.5; label: "2007" }
43 CategoryRange { endValue: 8.5; label: "2008" }
44 CategoryRange { endValue: 9.5; label: "2009" }
45 CategoryRange { endValue: 10.5; label: "2010" }
46 CategoryRange { endValue: 11.5; label: "2011" }
36 47 }
37 48
38 49 AreaSeries {
39 50 name: "Russian"
40 axisX: catergoriesAxis
51 axisX: categoriesAxis
41 52 upperSeries: LineSeries {
42 53 XYPoint { x: 0; y: 1 }
43 54 XYPoint { x: 1; y: 1 }
@@ -58,7 +69,7 Rectangle {
58 69
59 70 AreaSeries {
60 71 name: "Swedish"
61 axisX: catergoriesAxis
72 axisX: categoriesAxis
62 73 upperSeries: LineSeries {
63 74 XYPoint { x: 0; y: 1 }
64 75 XYPoint { x: 1; y: 1 }
@@ -77,7 +88,7 Rectangle {
77 88
78 89 AreaSeries {
79 90 name: "Finnish"
80 axisX: catergoriesAxis
91 axisX: categoriesAxis
81 92 upperSeries: LineSeries {
82 93 XYPoint { x: 0; y: 0 }
83 94 XYPoint { x: 1; y: 0 }
@@ -20,6 +20,8
20 20 <li><a href="qml-chartview.html">ChartView</a></li>
21 21 <li><a href="qml-abstractaxis.html">AbstractAxis</a></li>
22 22 <li><a href="qml-valueaxis.html">ValueAxis</a></li>
23 <li><a href="qml-categoryaxis.html">CategoryAxis</a></li>
24 <li><a href="qml-categoryrange.html">CategoryRange</a></li>
23 25 <li><a href="qml-barcategoryaxis.html">BarCategoryAxis</a></li>
24 26 <li><a href="qml-legend.html">Legend</a></li>
25 27 <li><a href="qml-abstractseries.html">AbstractSeries</a></li>
@@ -26,8 +26,9 SOURCES += \
26 26 declarativeareaseries.cpp \
27 27 declarativescatterseries.cpp \
28 28 declarativepieseries.cpp \
29 declarativebarseries.cpp
30
29 declarativebarseries.cpp \
30 declarativecategoryaxis.cpp
31
31 32 HEADERS += \
32 33 declarativechart.h \
33 34 declarativexypoint.h \
@@ -37,7 +38,8 HEADERS += \
37 38 declarativeareaseries.h \
38 39 declarativescatterseries.h \
39 40 declarativepieseries.h \
40 declarativebarseries.h
41 declarativebarseries.h \
42 declarativecategoryaxis.h
41 43
42 44 TARGETPATH = QtCommercial/Chart
43 45 target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
@@ -23,6 +23,8
23 23 #include "qchart.h"
24 24 #include "qabstractaxis.h"
25 25 #include "qvalueaxis.h"
26 #include "qdatetimeaxis.h"
27 #include "declarativecategoryaxis.h"
26 28 #include "qbarcategoryaxis.h"
27 29 #include "declarativechart.h"
28 30 #include "declarativexypoint.h"
@@ -113,6 +115,9 public:
113 115 qmlRegisterType<QHBarModelMapper>(uri, 1, 1, "HBarModelMapper");
114 116 qmlRegisterType<QVBarModelMapper>(uri, 1, 1, "VBarModelMapper");
115 117 qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis");
118 qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis");
119 qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis");
120 qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange");
116 121 qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis");
117 122 qmlRegisterUncreatableType<QLegend>(uri, 1, 1, "Legend",
118 123 QLatin1String("Trying to create uncreatable: Legend."));
@@ -34,18 +34,26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
34 34 This class can be used when the underlying data needs to be given extra meaning.
35 35 Unlike with the QBarCategoryAxis the QCategoryAxis allows the categories ranges widths to be specified freely.
36 36 */
37
38 37 /*!
39 38 \qmlclass CategoryAxis QCategoryAxis
40 39 \inherits AbstractAxis
41 \brief The QCategoryAxis class allows putting a named ranges on the axis.
40 \brief CategoryAxis allows putting a named ranges on the axis.
41
42 For example:
43 \code
44 CategoryAxis {
45 startValue: 0.0
46 CategoryRange { endValue: 1.0; label: "min (0-1)" }
47 CategoryRange { endValue: 3.0; label: "standard (1-3)" }
48 CategoryRange { endValue: 4.0; label: "high (3-4)" }
49 }
50 \endcode
42 51 */
43 52
44 53 /*!
45 54 \property QCategoryAxis::startValue
46 55 Defines the low end of the first category on the axis.
47 56 */
48
49 57 /*!
50 58 \qmlproperty int CategoryAxis::startValue
51 59 Defines the low end of the first category on the axis.
@@ -79,6 +87,13 QCategoryAxis::QCategoryAxis(QCategoryAxisPrivate &d,QObject *parent):QValueAxis
79 87 }
80 88
81 89 /*!
90 \qmlmethod CategoryAxis::append(string label, real endValue)
91 Appends new category to the axis with an \a label. Category label has to be unique.
92 Parameter \a endValue specifies the high end limit of the category.
93 It has to be greater than the high end limit of the previous category.
94 Otherwise the method returns without adding a new category.
95 */
96 /*!
82 97 Appends new category to the axis with an \a categoryLabel.
83 98 Category label has to be unique.
84 99 Parameter \a categoryEndValue specifies the high end limit of the category.
@@ -142,6 +157,10 qreal QCategoryAxis::endValue(const QString& categoryLabel) const
142 157 }
143 158
144 159 /*!
160 \qmlmethod CategoryAxis::remove(string label)
161 Removes a category specified by the \a label from the axis
162 */
163 /*!
145 164 Removes an interval specified by the \a categoryLabel from the axis
146 165 */
147 166 void QCategoryAxis::remove(const QString &categoryLabel)
@@ -173,6 +192,11 void QCategoryAxis::remove(const QString &categoryLabel)
173 192 }
174 193
175 194 /*!
195 \qmlmethod CategoryAxis::replace(string oldLabel, string newLabel)
196 Replaces \a oldLabel of an existing category with a \a newLabel.
197 If the old label does not exist the method returns without making any changes.
198 */
199 /*!
176 200 Replaces \a oldLabel of an existing category with a \a newLabel
177 201 If the old label does not exist the method returns without making any changes.
178 202 */
General Comments 0
You need to be logged in to leave comments. Login now