diff --git a/demos/qmlchart/qml/qmlchart/View4.qml b/demos/qmlchart/qml/qmlchart/View4.qml index 940f8e5..e3e25bc 100644 --- a/demos/qmlchart/qml/qmlchart/View4.qml +++ b/demos/qmlchart/qml/qmlchart/View4.qml @@ -29,15 +29,26 @@ Rectangle { title: "NHL All-Star Team Players" anchors.fill: parent - BarCategoriesAxis { - id: catergoriesAxis - categories: ["2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", - "2009", "2010", "2011" ] + CategoryAxis { + id: categoriesAxis + startValue: -0.5 + CategoryRange { endValue: 0.5; label: "2000" } + CategoryRange { endValue: 1.5; label: "2001" } + CategoryRange { endValue: 2.5; label: "2002" } + CategoryRange { endValue: 3.5; label: "2003" } + CategoryRange { endValue: 4.5; label: "2004" } + CategoryRange { endValue: 5.5; label: "2005" } + CategoryRange { endValue: 6.5; label: "2006" } + CategoryRange { endValue: 7.5; label: "2007" } + CategoryRange { endValue: 8.5; label: "2008" } + CategoryRange { endValue: 9.5; label: "2009" } + CategoryRange { endValue: 10.5; label: "2010" } + CategoryRange { endValue: 11.5; label: "2011" } } AreaSeries { name: "Russian" - axisX: catergoriesAxis + axisX: categoriesAxis upperSeries: LineSeries { XYPoint { x: 0; y: 1 } XYPoint { x: 1; y: 1 } @@ -58,7 +69,7 @@ Rectangle { AreaSeries { name: "Swedish" - axisX: catergoriesAxis + axisX: categoriesAxis upperSeries: LineSeries { XYPoint { x: 0; y: 1 } XYPoint { x: 1; y: 1 } @@ -77,7 +88,7 @@ Rectangle { AreaSeries { name: "Finnish" - axisX: catergoriesAxis + axisX: categoriesAxis upperSeries: LineSeries { XYPoint { x: 0; y: 0 } XYPoint { x: 1; y: 0 } diff --git a/doc/src/qml.qdoc b/doc/src/qml.qdoc index dc8cf39..089565a 100644 --- a/doc/src/qml.qdoc +++ b/doc/src/qml.qdoc @@ -20,6 +20,8 @@
  • ChartView
  • AbstractAxis
  • ValueAxis
  • +
  • CategoryAxis
  • +
  • CategoryRange
  • BarCategoryAxis
  • Legend
  • AbstractSeries
  • diff --git a/plugins/declarative/declarative.pro b/plugins/declarative/declarative.pro index b0f9577..b8fa2d6 100644 --- a/plugins/declarative/declarative.pro +++ b/plugins/declarative/declarative.pro @@ -26,8 +26,9 @@ SOURCES += \ declarativeareaseries.cpp \ declarativescatterseries.cpp \ declarativepieseries.cpp \ - declarativebarseries.cpp - + declarativebarseries.cpp \ + declarativecategoryaxis.cpp + HEADERS += \ declarativechart.h \ declarativexypoint.h \ @@ -37,7 +38,8 @@ HEADERS += \ declarativeareaseries.h \ declarativescatterseries.h \ declarativepieseries.h \ - declarativebarseries.h + declarativebarseries.h \ + declarativecategoryaxis.h TARGETPATH = QtCommercial/Chart target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH diff --git a/plugins/declarative/plugin.cpp b/plugins/declarative/plugin.cpp index 2aace60..15af067 100644 --- a/plugins/declarative/plugin.cpp +++ b/plugins/declarative/plugin.cpp @@ -23,6 +23,8 @@ #include "qchart.h" #include "qabstractaxis.h" #include "qvalueaxis.h" +#include "qdatetimeaxis.h" +#include "declarativecategoryaxis.h" #include "qbarcategoryaxis.h" #include "declarativechart.h" #include "declarativexypoint.h" @@ -113,6 +115,9 @@ public: qmlRegisterType(uri, 1, 1, "HBarModelMapper"); qmlRegisterType(uri, 1, 1, "VBarModelMapper"); qmlRegisterType(uri, 1, 1, "ValueAxis"); + qmlRegisterType(uri, 1, 1, "DateTimeAxis"); + qmlRegisterType(uri, 1, 1, "CategoryAxis"); + qmlRegisterType(uri, 1, 1, "CategoryRange"); qmlRegisterType(uri, 1, 1, "BarCategoryAxis"); qmlRegisterUncreatableType(uri, 1, 1, "Legend", QLatin1String("Trying to create uncreatable: Legend.")); diff --git a/src/axis/categoryaxis/qcategoryaxis.cpp b/src/axis/categoryaxis/qcategoryaxis.cpp index 38776e1..fc8a606 100644 --- a/src/axis/categoryaxis/qcategoryaxis.cpp +++ b/src/axis/categoryaxis/qcategoryaxis.cpp @@ -34,18 +34,26 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE This class can be used when the underlying data needs to be given extra meaning. Unlike with the QBarCategoryAxis the QCategoryAxis allows the categories ranges widths to be specified freely. */ - /*! \qmlclass CategoryAxis QCategoryAxis \inherits AbstractAxis - \brief The QCategoryAxis class allows putting a named ranges on the axis. + \brief CategoryAxis allows putting a named ranges on the axis. + + For example: + \code + CategoryAxis { + startValue: 0.0 + CategoryRange { endValue: 1.0; label: "min (0-1)" } + CategoryRange { endValue: 3.0; label: "standard (1-3)" } + CategoryRange { endValue: 4.0; label: "high (3-4)" } + } + \endcode */ /*! \property QCategoryAxis::startValue Defines the low end of the first category on the axis. */ - /*! \qmlproperty int CategoryAxis::startValue Defines the low end of the first category on the axis. @@ -79,6 +87,13 @@ QCategoryAxis::QCategoryAxis(QCategoryAxisPrivate &d,QObject *parent):QValueAxis } /*! + \qmlmethod CategoryAxis::append(string label, real endValue) + Appends new category to the axis with an \a label. Category label has to be unique. + Parameter \a endValue specifies the high end limit of the category. + It has to be greater than the high end limit of the previous category. + Otherwise the method returns without adding a new category. +*/ +/*! Appends new category to the axis with an \a categoryLabel. Category label has to be unique. Parameter \a categoryEndValue specifies the high end limit of the category. @@ -142,6 +157,10 @@ qreal QCategoryAxis::endValue(const QString& categoryLabel) const } /*! + \qmlmethod CategoryAxis::remove(string label) + Removes a category specified by the \a label from the axis +*/ +/*! Removes an interval specified by the \a categoryLabel from the axis */ void QCategoryAxis::remove(const QString &categoryLabel) @@ -173,6 +192,11 @@ void QCategoryAxis::remove(const QString &categoryLabel) } /*! + \qmlmethod CategoryAxis::replace(string oldLabel, string newLabel) + Replaces \a oldLabel of an existing category with a \a newLabel. + If the old label does not exist the method returns without making any changes. +*/ +/*! Replaces \a oldLabel of an existing category with a \a newLabel If the old label does not exist the method returns without making any changes. */