From baa389f1ece6dcc156cccf7bdfcfa8c29e98972e 2013-05-24 16:41:03 From: Mika Salmela Date: 2013-05-24 16:41:03 Subject: [PATCH] Documentation and fix for box specific pen color Change-Id: I88919b60a17665b01bda979b576878c30abd50fd Reviewed-by: Mika Salmela --- diff --git a/examples/boxplotchart/main.cpp b/examples/boxplotchart/main.cpp index 8518401..2a179e5 100644 --- a/examples/boxplotchart/main.cpp +++ b/examples/boxplotchart/main.cpp @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) //![3] QChart *chart = new QChart(); chart->addSeries(series); - chart->setTitle("Cargotec's share deviation 2012") + chart->setTitle("Cargotec's share deviation in 2012"); chart->setAnimationOptions(QChart::SeriesAnimations); //![3] diff --git a/examples/qmlboxplot/qml/qmlboxplot/box.qml b/examples/qmlboxplot/qml/qmlboxplot/box.qml index 09726a3..cf16139 100644 --- a/examples/qmlboxplot/qml/qmlboxplot/box.qml +++ b/examples/qmlboxplot/qml/qmlboxplot/box.qml @@ -25,6 +25,12 @@ BoxSet { id: myNewBox label: "Foo" values: [5, 6, 7, 8, 9] + onPenChanged: { + console.log("onPenChanged") + } + onColorChanged: { + console.log("onColorChanged") + } Component.onCompleted: { console.log("BoxSet completed") } diff --git a/examples/qmlboxplot/qml/qmlboxplot/main.qml b/examples/qmlboxplot/qml/qmlboxplot/main.qml index e492927..4000627 100644 --- a/examples/qmlboxplot/qml/qmlboxplot/main.qml +++ b/examples/qmlboxplot/qml/qmlboxplot/main.qml @@ -38,8 +38,17 @@ ChartView { BoxSet { values: [3, 4, 4.4, 6, 7] } BoxSet { label: "Tok"; values: [5, 6, 7.5, 8, 12] } BoxSet { label: "Kol"; values: [2, 5, 5.7, 8, 9] } - BoxSet { label: "Nel"; values: [5, 6, 6.8, 7, 8] } - BoxSet { label: "Vii"; values: [4, 5, 5.2, 6, 7] } + BoxSet { id: nelBox + label: "Nel" + values: [5, 6, 6.8, 7, 8]; + onColorChanged: { + console.log("onColorChanged") + } + } + BoxSet { label: "Vii"; values: [4, 5, 5.2, 6, 7]; color: "#aa0000" } + //onClicked: console.log("series onClicked " + boxset.median) + //onHovered: console.log("series onHovered " + status + "median = " + boxset.median) + onCountChanged: console.log("onCountChanged") } //![2] @@ -51,6 +60,7 @@ ChartView { MouseArea { anchors.fill: parent onClicked: { + nelBox.color = "#0000aa" var com = Qt.createComponent("box.qml") if (com.status == Component.Ready) { var obj = com.createObject(moreButton) @@ -67,9 +77,12 @@ ChartView { obj.label = "mik" console.log("label = " + obj.label) plotSeries.append(obj) + obj.color = "#aa0000" + console.log("color = " + obj.color) + obj.borderColor = "#00aa00" } else { console.log(com.errorString()) - } + } } } } diff --git a/plugins/declarative/declarativeboxplotseries.cpp b/plugins/declarative/declarativeboxplotseries.cpp index 48097c8..86672dd 100644 --- a/plugins/declarative/declarativeboxplotseries.cpp +++ b/plugins/declarative/declarativeboxplotseries.cpp @@ -55,7 +55,7 @@ void DeclarativeBoxSet::setValues(QVariantList values) } } -// Declarative box&whiskers series ===================================================== +// ===================================================== DeclarativeBoxPlotSeries::DeclarativeBoxPlotSeries(QDeclarativeItem *parent) : QBoxPlotSeries(parent), @@ -65,6 +65,8 @@ DeclarativeBoxPlotSeries::DeclarativeBoxPlotSeries(QDeclarativeItem *parent) : connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); + connect(this, SIGNAL(hovered(bool, QBoxSet*)), this, SLOT(onHovered(bool, QBoxSet*))); + connect(this, SIGNAL(clicked(QBoxSet*)), this, SLOT(onClicked(QBoxSet*))); } void DeclarativeBoxPlotSeries::classBegin() @@ -100,7 +102,6 @@ void DeclarativeBoxPlotSeries::appendSeriesChildren(QDeclarativeListProperty setList = boxSets(); if (index >= 0 && index < setList.count()) return qobject_cast(setList[index]); @@ -118,6 +119,15 @@ DeclarativeBoxSet *DeclarativeBoxPlotSeries::insert(int index, const QString lab return 0; } +void DeclarativeBoxPlotSeries::onHovered(bool status, QBoxSet *boxset) +{ + emit hovered(status, qobject_cast(boxset)); +} + +void DeclarativeBoxPlotSeries::onClicked(QBoxSet *boxset) +{ + emit clicked(qobject_cast(boxset)); +} #include "moc_declarativeboxplotseries.cpp" diff --git a/plugins/declarative/declarativeboxplotseries.h b/plugins/declarative/declarativeboxplotseries.h index eed2ea1..21d52a8 100644 --- a/plugins/declarative/declarativeboxplotseries.h +++ b/plugins/declarative/declarativeboxplotseries.h @@ -98,9 +98,13 @@ Q_SIGNALS: Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); + void clicked(DeclarativeBoxSet *boxset); + void hovered(bool status, DeclarativeBoxSet *boxset); public Q_SLOTS: static void appendSeriesChildren(QDeclarativeListProperty *list, QObject *element); + void onHovered(bool status, QBoxSet *boxset); + void onClicked(QBoxSet *boxset); public: DeclarativeAxes *m_axes; diff --git a/src/boxplotchart/boxplotchartitem.cpp b/src/boxplotchart/boxplotchartitem.cpp index b201dff..d4fc304 100644 --- a/src/boxplotchart/boxplotchartitem.cpp +++ b/src/boxplotchart/boxplotchartitem.cpp @@ -112,8 +112,6 @@ void BoxPlotChartItem::handleDataStructureChanged() void BoxPlotChartItem::handleUpdatedBars() { - qDebug() << "BoxPlotChartItem::handleUpdatedBars()"; - foreach (BoxWhiskers *item, m_boxTable.values()) { item->setBrush(m_series->brush()); item->setPen(m_series->pen()); diff --git a/src/boxplotchart/qboxplotseries.cpp b/src/boxplotchart/qboxplotseries.cpp index 93188d2..ad65183 100644 --- a/src/boxplotchart/qboxplotseries.cpp +++ b/src/boxplotchart/qboxplotseries.cpp @@ -42,8 +42,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE \mainclass QBoxPlotSeries represents a series of data shown as box-and-whisker bars. The purpose of this class is to act as - a container for single box-and-whisker items. Each item is drawn to own slot. If chart includes multiple QBoxPlotSeries - items with the same index are drawn to same slot. + a container for single box-and-whisker items. Each item is drawn to own slot. If chart includes multiple instances of + QBoxPlotSeries then box-and-whiskers items with the same index are drawn to same slot. See the \l {Box and Whiskers Example} {box-and-whiskers chart example} to learn how to create a box-and-whiskers chart. \image examples_boxplotchart.png @@ -53,12 +53,16 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE /*! \qmlclass BoxPlotSeries QBoxPlotSeries - \inherits AbstractBarSeries + \inherits QAbstractSeries + + BoxPlotSeries represents a series of data shown as box-and-whisker bars. The purpose of this class is to act as + a container for single box-and-whisker items. Each item is drawn to own slot. If chart includes multiple instances of + BoxPlotSeries then box-and-whiskers items with the same index are drawn to same slot. The following QML shows how to create a simple box-and-whiskers chart: \snippet ../examples/qmlboxplot/qml/qmlboxplot/main.qml 1 \beginfloatleft - \image demos_qmlchart7.png + \image TODO_CREATE_IMAGE.png \endfloat \clearfloat */ @@ -87,6 +91,45 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE \fn QBoxPlotSeries::countChanged() \brief Signal is emitted when there is change in count of box-and-whiskers items in the series. */ +/*! + \qmlmethod BoxPlotSeries::append(const QString label, QVariantList values) + Appends a new box-and-whiskers set with \a label and \a values to the series. + */ +/*! + \qmlmethod BoxPlotSeries::append(BoxSet *box) + Appends the \a box to the series. +*/ +/*! + \qmlmethod BoxPlotSeries::insert(int index, const QString label, QVariantList values) + Inserts a new box-and-whiskers set with \a label and \a values at the \a index position. +*/ +/*! + \qmlmethod BoxPlotSeries::remove(QBoxSet *boxset) + Removes the \a boxset from the series. +*/ +/*! + \qmlmethod BoxPlotSeries::clear() + Removes all boxsets from the series. Deletes removed sets. +*/ + +/*! + \qmlsignal BoxPlotSeries::onClicked(BoxSet boxset); + Signal is emitted when the user clicks the \a boxset on the chart. +*/ +/*! + \qmlsignal BoxPlotSeries::onHovered(bool status, BoxSet boxset); + Signal is emitted when there is change in hover \a status over \a boxset. +*/ +/*! + \qmlsignal BoxPlotSeries::onCountChanged(); + Signal is emitted when there is change in count of box-and-whiskers items in the series. +*/ +/* + void boxsetsAdded(QList sets); +*/ +/* + void boxsetsRemoved(QList sets); +*/ /*! Constructs empty QBoxPlotSeries. diff --git a/src/boxplotchart/qboxset.cpp b/src/boxplotchart/qboxset.cpp index b219f15..e7db1a2 100644 --- a/src/boxplotchart/qboxset.cpp +++ b/src/boxplotchart/qboxset.cpp @@ -32,9 +32,9 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE QBoxSet represents one box-and-whiskers item. It takes fives values to create a graphical representation of range and three medians. There's two type of methods to give the values. The first one is with constructor - or append type of methods (append and operator <<). In these the values have to be given in order lower extreme, + or append type of methods (append and operator <<). The values have to be given in order lower extreme, lower quartile, median, upper quartile and upper extre. Second method is to create an empty QBoxSet instance and - give the values using own methods. + give the values using value specific methods. \mainclass @@ -45,11 +45,19 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE BoxSet represents one box-and-whiskers item. It takes fives values to create a graphical representation of range and three medians. There's two type of methods to give the values. The first one is with constructor - or append type of methods (append and operator <<). In these the values have to be given in order lower extreme, - lower quartile, median, upper quartile and upper extre. Second method is to create an empty BoxSet instance and - give the values using own methods. + or with append method. In these the values have to be given in order lower extreme, lower quartile, median, + upper quartile and upper extre. Second method is to create an empty QBoxSet instance and + give the values using value specific methods. \sa BoxPlotSeries */ +/*! + \qmlproperty string BoxSet::label + Defines the label of the boxSet. +*/ +/*! + \qmlproperty int BoxSet::count + The count of values on the box-and-whiskers set +*/ /*! \property QBoxSet::pen @@ -65,16 +73,52 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE \property QBoxSet::color The fill (brush) color of the box-and-whiskers set. */ - +/*! + \qmlproperty color BoxSet::color + Defines the fill (brush) color of the box-and-whiskers set. +*/ /*! \property QBoxSet::borderColor The line (pen) color of the box-and-whiskers set. */ +/*! + \qmlproperty color BoxSet::borderColor + Defines the outline color of the box-and-whiskers set. +*/ + +/*! + \qmlproperty qreal BoxSet::lowerExtreme + The lower extreme value of the box-and-whiskers set +*/ + +/*! + \qmlproperty qreal BoxSet::lowerQuartile + The lower quartile value of the box-and-whiskers set +*/ + +/*! + \qmlproperty qreal BoxSet::median + The median value of the box-and-whiskers set +*/ + +/*! + \qmlproperty qreal BoxSet::upperQuartile + The upper quartile value of the box-and-whiskers set +*/ + +/*! + \qmlproperty qreal BoxSet::upperExtreme + The upper extreme value of the box-and-whiskers set +*/ /*! \fn void QBoxSet::clicked() The signal is emitted if the user clicks with a mouse on top of box-and-whisker item. */ +/*! + \qmlsignal BoxSet::onClicked() + This signal is emitted when the user clicks with a mouse on top of box-and-whisker item. +*/ /*! \fn void QBoxSet::hovered(bool status) @@ -82,23 +126,40 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE The signal is emitted if mouse is hovered on top of box-and-whisker item. Parameter \a status is true, if mouse entered on top of item, false if mouse left from top of item. */ +/*! + \qmlsignal BoxSet::onHovered(bool status) + + The signal is emitted if mouse is hovered on top of box-and-whisker item. + Parameter \a status is true, if mouse entered on top of item, false if mouse left from top of item. +*/ /*! \fn void QBoxSet::penChanged() This signal is emitted when the pen of the box-and-whisker item has changed. \sa pen */ - +/*! + \qmlsignal BoxSet::onPenChanged() + This signal is emitted when the pen of the box-and-whisker item has changed. +*/ /*! \fn void QBoxSet::brushChanged() This signal is emitted when the brush of the box-and-whisker item has changed. \sa brush */ +/*! + \qmlsignal BoxSet::onBrushChanged() + This signal is emitted when the brush of the box-and-whisker item has changed. +*/ /*! \fn void QBoxSet::colorChanged(QColor) This signal is emitted when the fill (brush) color of the box-and-whisker item has changed to \a color. */ +/*! + \qmlsignal BoxSet::onColorChanged(QColor color) + This signal is emitted when the fill (brush) color of the box-and-whisker item has changed to \a color. +*/ /*! \fn void QBoxSet::valuesAdded(int index, int count) @@ -107,6 +168,12 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE Parameter \a count is the number of inserted values. \sa append(), insert() */ +/*! + \qmlsignal BoxSet::onValuesAdded(int index, int count) + This signal is emitted when new values have been added to the box-and-whisker item. + Parameter \a index indicates the position of the first inserted value. + Parameter \a count is the number of inserted values. +*/ /*! \fn void QBoxSet::valueChanged(int index) @@ -114,11 +181,19 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE Parameter \a index indicates the position of the modified value. \sa at() */ - +/*! + \qmlsignal BoxSet::onValueChanged(int index) + This signal is emitted values the value in the box-and-whisker item has been modified. + Parameter \a index indicates the position of the modified value. +*/ /*! \fn void QBoxSet::borderColorChanged(QColor) This signal is emitted when the line (pen) color of the box-and-whisker item has changed to \a color. */ +/*! + \qmlsignal BoxSet::onBorderColorChanged(QColor color) + This signal is emitted when the line (pen) color of the box-and-whisker item has changed to \a color. +*/ /*! Constructs QBoxSet with optional \a label and parent of \a parent @@ -425,6 +500,7 @@ void QBoxSet::setBorderColor(QColor color) QPen p = pen(); if (p.color() != color) { p.setColor(color); + p.setStyle(Qt::SolidLine); setPen(p); emit borderColorChanged(color); }