summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/quick2/plugins.qmltypes59
-rw-r--r--src/areachart/areachartitem.cpp62
-rw-r--r--src/areachart/areachartitem_p.h5
-rw-r--r--src/areachart/qareaseries.cpp178
-rw-r--r--src/areachart/qareaseries.h24
-rw-r--r--src/areachart/qareaseries_p.h4
-rw-r--r--src/barchart/abstractbarchartitem.cpp46
-rw-r--r--src/barchart/abstractbarchartitem_p.h2
-rw-r--r--src/barchart/horizontal/percent/horizontalpercentbarchartitem.cpp10
-rw-r--r--src/barchart/qabstractbarseries.cpp103
-rw-r--r--src/barchart/qabstractbarseries.h21
-rw-r--r--src/barchart/qabstractbarseries_p.h2
-rw-r--r--src/barchart/vertical/bar/barchartitem.cpp30
-rw-r--r--src/barchart/vertical/bar/barchartitem_p.h4
-rw-r--r--src/barchart/vertical/percent/percentbarchartitem.cpp39
-rw-r--r--src/barchart/vertical/percent/percentbarchartitem_p.h4
-rw-r--r--src/barchart/vertical/stacked/stackedbarchartitem.cpp29
-rw-r--r--src/barchart/vertical/stacked/stackedbarchartitem_p.h4
-rw-r--r--src/linechart/linechartitem.cpp24
-rw-r--r--src/linechart/linechartitem_p.h5
-rw-r--r--src/linechart/qlineseries.cpp5
-rw-r--r--src/scatterchart/qscatterseries.cpp5
-rw-r--r--src/scatterchart/scatterchartitem.cpp27
-rw-r--r--src/scatterchart/scatterchartitem_p.h5
-rw-r--r--src/splinechart/qsplineseries.cpp5
-rw-r--r--src/splinechart/splinechartitem.cpp19
-rw-r--r--src/splinechart/splinechartitem_p.h5
-rw-r--r--src/xychart/qxyseries.cpp198
-rw-r--r--src/xychart/qxyseries.h24
-rw-r--r--src/xychart/qxyseries_p.h6
-rw-r--r--tests/auto/qbarseries/tst_qbarseries.cpp58
-rw-r--r--tests/auto/qhorizontalbarseries/tst_qhorizontalbarseries.cpp58
-rw-r--r--tests/auto/qhorizontalpercentbarseries/tst_qhorizontalpercentbarseries.cpp58
-rw-r--r--tests/auto/qhorizontalstackedbarseries/tst_qhorizontalstackedbarseries.cpp58
-rw-r--r--tests/auto/qlineseries/tst_qlineseries.cpp5
-rw-r--r--tests/auto/qml-qtquicktest/tst_barseries.qml12
-rw-r--r--tests/auto/qpercentbarseries/tst_qpercentbarseries.cpp58
-rw-r--r--tests/auto/qstackedbarseries/tst_qstackedbarseries.cpp58
-rw-r--r--tests/auto/qxyseries/tst_qxyseries.cpp72
-rw-r--r--tests/auto/qxyseries/tst_qxyseries.h4
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/AreaChart.qml12
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml26
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml12
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml13
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/HorizontalBarChart.qml14
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/HorizontalPercentBarChart.qml15
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/HorizontalStackedBarChart.qml16
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/LineChart.qml12
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml26
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml14
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/ScatterChart.qml12
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml26
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/SplineChart.qml12
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml14
-rw-r--r--tests/quick2chartproperties/qml/quick2chartproperties/AreaChart.qml12
-rw-r--r--tests/quick2chartproperties/qml/quick2chartproperties/AreaEditor.qml26
-rw-r--r--tests/quick2chartproperties/qml/quick2chartproperties/BarChart.qml12
-rw-r--r--tests/quick2chartproperties/qml/quick2chartproperties/BarEditor.qml13
-rw-r--r--tests/quick2chartproperties/qml/quick2chartproperties/HorizontalBarChart.qml14
-rw-r--r--tests/quick2chartproperties/qml/quick2chartproperties/HorizontalPercentBarChart.qml16
-rw-r--r--tests/quick2chartproperties/qml/quick2chartproperties/HorizontalStackedBarChart.qml16
-rw-r--r--tests/quick2chartproperties/qml/quick2chartproperties/LineChart.qml12
-rw-r--r--tests/quick2chartproperties/qml/quick2chartproperties/LineEditor.qml26
-rw-r--r--tests/quick2chartproperties/qml/quick2chartproperties/PercentBarChart.qml14
-rw-r--r--tests/quick2chartproperties/qml/quick2chartproperties/ScatterChart.qml12
-rw-r--r--tests/quick2chartproperties/qml/quick2chartproperties/ScatterEditor.qml26
-rw-r--r--tests/quick2chartproperties/qml/quick2chartproperties/SplineChart.qml12
-rw-r--r--tests/quick2chartproperties/qml/quick2chartproperties/StackedBarChart.qml14
68 files changed, 1808 insertions, 36 deletions
diff --git a/plugins/quick2/plugins.qmltypes b/plugins/quick2/plugins.qmltypes
index 4233d815..6b8dfc88 100644
--- a/plugins/quick2/plugins.qmltypes
+++ b/plugins/quick2/plugins.qmltypes
@@ -1561,9 +1561,20 @@ Module {
prototype: "QtCommercialChart::QAbstractSeries"
exports: ["QtCommercial.Chart/AbstractBarSeries 1.0"]
exportMetaObjectRevisions: [0]
+ Enum {
+ name: "LabelsPosition"
+ values: {
+ "LabelsCenter": 0,
+ "LabelsInsideEnd": 1,
+ "LabelsInsideBase": 2,
+ "LabelsOutsideEnd": 3
+ }
+ }
Property { name: "barWidth"; type: "double" }
Property { name: "count"; type: "int"; isReadonly: true }
Property { name: "labelsVisible"; type: "bool" }
+ Property { name: "labelsFormat"; type: "string" }
+ Property { name: "labelsPosition"; type: "LabelsPosition" }
Signal {
name: "clicked"
Parameter { name: "index"; type: "int" }
@@ -1581,6 +1592,14 @@ Module {
Parameter { name: "barset"; type: "QBarSet"; isPointer: true }
}
Signal {
+ name: "labelsFormatChanged"
+ Parameter { name: "format"; type: "string" }
+ }
+ Signal {
+ name: "labelsPositionChanged"
+ Parameter { name: "position"; type: "QAbstractBarSeries::LabelsPosition" }
+ }
+ Signal {
name: "barsetsAdded"
Parameter { name: "sets"; type: "QList<QBarSet*>" }
}
@@ -1623,6 +1642,10 @@ Module {
Property { name: "lowerSeries"; type: "QLineSeries"; isReadonly: true; isPointer: true }
Property { name: "color"; type: "QColor" }
Property { name: "borderColor"; type: "QColor" }
+ Property { name: "pointLabelsFormat"; type: "string" }
+ Property { name: "pointLabelsVisible"; type: "bool" }
+ Property { name: "pointLabelsFont"; type: "QFont" }
+ Property { name: "pointLabelsColor"; type: "QColor" }
Signal {
name: "clicked"
Parameter { name: "point"; type: "QPointF" }
@@ -1641,6 +1664,22 @@ Module {
name: "borderColorChanged"
Parameter { name: "color"; type: "QColor" }
}
+ Signal {
+ name: "pointLabelsFormatChanged"
+ Parameter { name: "format"; type: "string" }
+ }
+ Signal {
+ name: "pointLabelsVisibilityChanged"
+ Parameter { name: "visible"; type: "bool" }
+ }
+ Signal {
+ name: "pointLabelsFontChanged"
+ Parameter { name: "font"; type: "QFont" }
+ }
+ Signal {
+ name: "pointLabelsColorChanged"
+ Parameter { name: "color"; type: "QColor" }
+ }
}
Component {
name: "QtCommercialChart::QBarCategoryAxis"
@@ -2140,6 +2179,10 @@ Module {
exportMetaObjectRevisions: [0]
Property { name: "pointsVisible"; type: "bool" }
Property { name: "color"; type: "QColor" }
+ Property { name: "pointLabelsFormat"; type: "string" }
+ Property { name: "pointLabelsVisible"; type: "bool" }
+ Property { name: "pointLabelsFont"; type: "QFont" }
+ Property { name: "pointLabelsColor"; type: "QColor" }
Signal {
name: "clicked"
Parameter { name: "point"; type: "QPointF" }
@@ -2166,5 +2209,21 @@ Module {
Parameter { name: "color"; type: "QColor" }
}
Signal { name: "pointsReplaced" }
+ Signal {
+ name: "pointLabelsFormatChanged"
+ Parameter { name: "format"; type: "string" }
+ }
+ Signal {
+ name: "pointLabelsVisibilityChanged"
+ Parameter { name: "visible"; type: "bool" }
+ }
+ Signal {
+ name: "pointLabelsFontChanged"
+ Parameter { name: "font"; type: "QFont" }
+ }
+ Signal {
+ name: "pointLabelsColorChanged"
+ Parameter { name: "color"; type: "QColor" }
+ }
}
}
diff --git a/src/areachart/areachartitem.cpp b/src/areachart/areachartitem.cpp
index 46dacd93..225cab78 100644
--- a/src/areachart/areachartitem.cpp
+++ b/src/areachart/areachartitem.cpp
@@ -36,7 +36,11 @@ AreaChartItem::AreaChartItem(QAreaSeries *areaSeries, QGraphicsItem* item)
m_series(areaSeries),
m_upper(0),
m_lower(0),
- m_pointsVisible(false)
+ m_pointsVisible(false),
+ m_pointLabelsFormat(areaSeries->pointLabelsFormat()),
+ m_pointLabelsVisible(false),
+ m_pointLabelsFont(areaSeries->pointLabelsFont()),
+ m_pointLabelsColor(areaSeries->pointLabelsColor())
{
setAcceptHoverEvents(true);
setZValue(ChartPresenter::LineChartZValue);
@@ -50,6 +54,14 @@ AreaChartItem::AreaChartItem(QAreaSeries *areaSeries, QGraphicsItem* item)
QObject::connect(m_series, SIGNAL(opacityChanged()), this, SLOT(handleUpdated()));
QObject::connect(this, SIGNAL(clicked(QPointF)), areaSeries, SIGNAL(clicked(QPointF)));
QObject::connect(this, SIGNAL(hovered(QPointF,bool)), areaSeries, SIGNAL(hovered(QPointF,bool)));
+ QObject::connect(areaSeries, SIGNAL(pointLabelsFormatChanged(QString)),
+ this, SLOT(handleUpdated()));
+ QObject::connect(areaSeries, SIGNAL(pointLabelsVisibilityChanged(bool)),
+ this, SLOT(handleUpdated()));
+ QObject::connect(areaSeries, SIGNAL(pointLabelsFontChanged(QFont)),
+ this, SLOT(handleUpdated()));
+ QObject::connect(areaSeries, SIGNAL(pointLabelsColorChanged(QColor)),
+ this, SLOT(handleUpdated()));
handleUpdated();
}
@@ -131,6 +143,10 @@ void AreaChartItem::handleUpdated()
m_pointPen = m_series->pen();
m_pointPen.setWidthF(2 * m_pointPen.width());
setOpacity(m_series->opacity());
+ m_pointLabelsFormat = m_series->pointLabelsFormat();
+ m_pointLabelsVisible = m_series->pointLabelsVisible();
+ m_pointLabelsFont = m_series->pointLabelsFont();
+ m_pointLabelsColor = m_series->pointLabelsColor();
update();
}
@@ -170,6 +186,50 @@ void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
if (m_lower)
painter->drawPoints(m_lower->geometryPoints());
}
+
+ // Draw series point label
+ if (m_pointLabelsVisible) {
+ static const QString xPointTag(QLatin1String("@xPoint"));
+ static const QString yPointTag(QLatin1String("@yPoint"));
+ const int labelOffset = 2;
+
+ painter->setFont(m_pointLabelsFont);
+ painter->setPen(QPen(m_pointLabelsColor));
+ QFontMetrics fm(painter->font());
+
+ QString pointLabel = m_pointLabelsFormat;
+
+ if (m_series->upperSeries()) {
+ for (int i(0); i < m_series->upperSeries()->count(); i++) {
+ pointLabel.replace(xPointTag, QString::number(m_series->upperSeries()->at(i).x()));
+ pointLabel.replace(yPointTag, QString::number(m_series->upperSeries()->at(i).y()));
+
+ // Position text in relation to the point
+ int pointLabelWidth = fm.width(pointLabel);
+ QPointF position(m_upper->geometryPoints().at(i));
+ position.setX(position.x() - pointLabelWidth / 2);
+ position.setY(position.y() - m_series->upperSeries()->pen().width() / 2 - labelOffset);
+
+ painter->drawText(position, pointLabel);
+ }
+ }
+
+ if (m_series->lowerSeries()) {
+ for (int i(0); i < m_series->lowerSeries()->count(); i++) {
+ pointLabel.replace(xPointTag, QString::number(m_series->lowerSeries()->at(i).x()));
+ pointLabel.replace(yPointTag, QString::number(m_series->lowerSeries()->at(i).y()));
+
+ // Position text in relation to the point
+ int pointLabelWidth = fm.width(pointLabel);
+ QPointF position(m_lower->geometryPoints().at(i));
+ position.setX(position.x() - pointLabelWidth / 2);
+ position.setY(position.y() - m_series->lowerSeries()->pen().width() / 2 - labelOffset);
+
+ painter->drawText(position, pointLabel);
+ }
+ }
+ }
+
painter->restore();
}
diff --git a/src/areachart/areachartitem_p.h b/src/areachart/areachartitem_p.h
index 2a16a6f6..25ef8916 100644
--- a/src/areachart/areachartitem_p.h
+++ b/src/areachart/areachartitem_p.h
@@ -83,6 +83,11 @@ private:
QBrush m_brush;
bool m_pointsVisible;
+ bool m_pointLabelsVisible;
+ QString m_pointLabelsFormat;
+ QFont m_pointLabelsFont;
+ QColor m_pointLabelsColor;
+
};
class AreaBoundItem : public LineChartItem
diff --git a/src/areachart/qareaseries.cpp b/src/areachart/qareaseries.cpp
index 37d2edf4..92d7be2f 100644
--- a/src/areachart/qareaseries.cpp
+++ b/src/areachart/qareaseries.cpp
@@ -182,6 +182,110 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE
*/
/*!
+ \property QAreaSeries::pointLabelsFormat
+ The \a format used for showing labels with series points.
+
+ QAreaSeries supports the following format tags:
+ \table
+ \row
+ \li @xPoint \li The x value of the data point
+ \row
+ \li @yPoint \li The y value of the data point
+ \endtable
+
+ For example, the following usage of the format tags would produce labels that have the data
+ point (x, y) shown inside brackets separated by a comma:
+ \code
+ series->setPointLabelsFormat("(@xPoint, @yPoint)");
+ \endcode
+
+ By default, the labels format is set to '@xPoint, @yPoint'. The labels are shown on the plot
+ area, labels on the edge of the plot area are cut. If the points are close to each other the
+ labels may overlap.
+
+ \sa QAreaSeries::pointLabelsVisible, QAreaSeries::pointLabelsFont, QAreaSeries::pointLabelsColor
+*/
+/*!
+ \qmlproperty string AreaSeries::pointLabelsFormat
+ The \a format used for showing labels with series points.
+
+ \sa QAreaSeries::pointLabelsFormat, pointLabelsVisible, pointLabelsFont, pointLabelsColor
+*/
+/*!
+ \fn void QAreaSeries::pointLabelsFormatChanged(const QString &format)
+ Signal is emitted when the \a format of data point labels is changed.
+*/
+/*!
+ \qmlsignal AreaSeries::onPointLabelsFormatChanged(string format)
+ Signal is emitted when the \a format of data point labels is changed.
+*/
+
+/*!
+ \property QAreaSeries::pointLabelsVisible
+ Defines the visibility for data point labels. False by default.
+
+ \sa QAreaSeries::pointLabelsFormat
+*/
+/*!
+ \qmlproperty bool AreaSeries::pointLabelsVisible
+ Defines the visibility for data point labels.
+
+ \sa pointLabelsFormat
+*/
+/*!
+ \fn void QAreaSeries::pointLabelsVisibilityChanged(bool visible)
+ The visibility of the data point labels is changed to \a visible.
+*/
+/*!
+ \qmlsignal AreaSeries::onPointLabelsVisibilityChanged(bool visible)
+ The visibility of the data point labels is changed to \a visible.
+*/
+
+/*!
+ \property QAreaSeries::pointLabelsFont
+ Defines the font used for data point labels.
+
+ \sa QAreaSeries::pointLabelsFormat
+*/
+/*!
+ \qmlproperty font AreaSeries::pointLabelsFont
+ Defines the font used for data point labels.
+
+ \sa pointLabelsFormat
+*/
+/*!
+ \fn void QAreaSeries::pointLabelsFontChanged(const QFont &font);
+ The font used for data point labels is changed to \a font.
+*/
+/*!
+ \qmlsignal AreaSeries::onPointLabelsFontChanged(Font font)
+ The font used for data point labels is changed to \a font.
+*/
+
+/*!
+ \property QAreaSeries::pointLabelsColor
+ Defines the color used for data point labels. By default, the color is the color of the brush
+ defined in theme for labels.
+
+ \sa QAreaSeries::pointLabelsFormat
+*/
+/*!
+ \qmlproperty font AreaSeries::pointLabelsColor
+ Defines the color used for data point labels. By default, the color is the color of the brush
+ defined in theme for labels.
+
+ \sa pointLabelsFormat
+*/
+/*!
+ \fn void QAreaSeries::pointLabelsColorChanged(const QColor &color);
+ The color used for data point labels is changed to \a color.
+*/
+/*!
+ \qmlsignal AreaSeries::onPointLabelsColorChanged(Color color)
+ The color used for data point labels is changed to \a color.
+*/
+
+/*!
Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a
upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead.
When series object is added to QChartView or QChart instance ownerships is transferred.
@@ -344,6 +448,69 @@ bool QAreaSeries::pointsVisible() const
return d->m_pointsVisible;
}
+void QAreaSeries::setPointLabelsFormat(const QString &format)
+{
+ Q_D(QAreaSeries);
+ if (d->m_pointLabelsFormat != format) {
+ d->m_pointLabelsFormat = format;
+ emit pointLabelsFormatChanged(format);
+ }
+}
+
+QString QAreaSeries::pointLabelsFormat() const
+{
+ Q_D(const QAreaSeries);
+ return d->m_pointLabelsFormat;
+}
+
+void QAreaSeries::setPointLabelsVisible(bool visible)
+{
+ Q_D(QAreaSeries);
+ if (d->m_pointLabelsVisible != visible) {
+ d->m_pointLabelsVisible = visible;
+ emit pointLabelsVisibilityChanged(visible);
+ }
+}
+
+bool QAreaSeries::pointLabelsVisible() const
+{
+ Q_D(const QAreaSeries);
+ return d->m_pointLabelsVisible;
+}
+
+void QAreaSeries::setPointLabelsFont(const QFont &font)
+{
+ Q_D(QAreaSeries);
+ if (d->m_pointLabelsFont != font) {
+ d->m_pointLabelsFont = font;
+ emit pointLabelsFontChanged(font);
+ }
+}
+
+QFont QAreaSeries::pointLabelsFont() const
+{
+ Q_D(const QAreaSeries);
+ return d->m_pointLabelsFont;
+}
+
+void QAreaSeries::setPointLabelsColor(const QColor &color)
+{
+ Q_D(QAreaSeries);
+ if (d->m_pointLabelsColor != color) {
+ d->m_pointLabelsColor = color;
+ emit pointLabelsColorChanged(color);
+ }
+}
+
+QColor QAreaSeries::pointLabelsColor() const
+{
+ Q_D(const QAreaSeries);
+ if (d->m_pointLabelsColor == QChartPrivate::defaultPen().color())
+ return QPen().color();
+ else
+ return d->m_pointLabelsColor;
+}
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries, QAreaSeries *q)
@@ -352,7 +519,11 @@ QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lo
m_pen(QChartPrivate::defaultPen()),
m_upperSeries(upperSeries),
m_lowerSeries(lowerSeries),
- m_pointsVisible(false)
+ m_pointsVisible(false),
+ m_pointLabelsFormat(QLatin1String("@xPoint, @yPoint")),
+ m_pointLabelsVisible(false),
+ m_pointLabelsFont(QChartPrivate::defaultFont()),
+ m_pointLabelsColor(QChartPrivate::defaultPen().color())
{
}
@@ -470,6 +641,11 @@ void QAreaSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forc
QBrush brush(colors.at(index % colors.size()));
q->setBrush(brush);
}
+
+ if (forced || QChartPrivate::defaultPen().color() == m_pointLabelsColor) {
+ QColor color = theme->labelBrush().color();
+ q->setPointLabelsColor(color);
+ }
}
diff --git a/src/areachart/qareaseries.h b/src/areachart/qareaseries.h
index 9f29903c..034c5fc0 100644
--- a/src/areachart/qareaseries.h
+++ b/src/areachart/qareaseries.h
@@ -37,6 +37,14 @@ class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QAbstractSeries
Q_PROPERTY(QLineSeries *lowerSeries READ lowerSeries)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
+ Q_PROPERTY(QString pointLabelsFormat READ pointLabelsFormat WRITE setPointLabelsFormat
+ NOTIFY pointLabelsFormatChanged)
+ Q_PROPERTY(bool pointLabelsVisible READ pointLabelsVisible WRITE setPointLabelsVisible
+ NOTIFY pointLabelsVisibilityChanged)
+ Q_PROPERTY(QFont pointLabelsFont READ pointLabelsFont WRITE setPointLabelsFont
+ NOTIFY pointLabelsFontChanged)
+ Q_PROPERTY(QColor pointLabelsColor READ pointLabelsColor WRITE setPointLabelsColor
+ NOTIFY pointLabelsColorChanged)
public:
explicit QAreaSeries(QObject *parent = 0);
@@ -66,12 +74,28 @@ public:
void setPointsVisible(bool visible = true);
bool pointsVisible() const;
+ void setPointLabelsFormat(const QString &format);
+ QString pointLabelsFormat() const;
+
+ void setPointLabelsVisible(bool visible = true);
+ bool pointLabelsVisible() const;
+
+ void setPointLabelsFont(const QFont &font);
+ QFont pointLabelsFont() const;
+
+ void setPointLabelsColor(const QColor &color);
+ QColor pointLabelsColor() const;
+
Q_SIGNALS:
void clicked(const QPointF &point);
void hovered(const QPointF &point, bool state);
void selected();
void colorChanged(QColor color);
void borderColorChanged(QColor color);
+ void pointLabelsFormatChanged(const QString &format);
+ void pointLabelsVisibilityChanged(bool visible);
+ void pointLabelsFontChanged(const QFont &font);
+ void pointLabelsColorChanged(const QColor &color);
private:
Q_DECLARE_PRIVATE(QAreaSeries)
diff --git a/src/areachart/qareaseries_p.h b/src/areachart/qareaseries_p.h
index 11ebacb2..4efe7a98 100644
--- a/src/areachart/qareaseries_p.h
+++ b/src/areachart/qareaseries_p.h
@@ -63,6 +63,10 @@ protected:
QLineSeries *m_upperSeries;
QLineSeries *m_lowerSeries;
bool m_pointsVisible;
+ QString m_pointLabelsFormat;
+ bool m_pointLabelsVisible;
+ QFont m_pointLabelsFont;
+ QColor m_pointLabelsColor;
private:
Q_DECLARE_PUBLIC(QAreaSeries);
};
diff --git a/src/barchart/abstractbarchartitem.cpp b/src/barchart/abstractbarchartitem.cpp
index 5ca6da6a..70c647ca 100644
--- a/src/barchart/abstractbarchartitem.cpp
+++ b/src/barchart/abstractbarchartitem.cpp
@@ -47,6 +47,10 @@ AbstractBarChartItem::AbstractBarChartItem(QAbstractBarSeries *series, QGraphics
connect(series->d_func(), SIGNAL(restructuredBars()), this, SLOT(handleDataStructureChanged()));
connect(series, SIGNAL(visibleChanged()), this, SLOT(handleVisibleChanged()));
connect(series, SIGNAL(opacityChanged()), this, SLOT(handleOpacityChanged()));
+ connect(series, SIGNAL(labelsFormatChanged(QString)), this, SLOT(handleUpdatedBars()));
+ connect(series, SIGNAL(labelsFormatChanged(QString)), this, SLOT(positionLabels()));
+ connect(series, SIGNAL(labelsPositionChanged(QAbstractBarSeries::LabelsPosition)),
+ this, SLOT(handleLabelsPositionChanged()));
setZValue(ChartPresenter::BarSeriesZValue);
handleDataStructureChanged();
handleVisibleChanged();
@@ -99,12 +103,10 @@ void AbstractBarChartItem::setLayout(const QVector<QRectF> &layout)
m_layout = layout;
- for (int i = 0; i < m_bars.count(); i++) {
+ for (int i = 0; i < m_bars.count(); i++)
m_bars.at(i)->setRect(layout.at(i));
- QGraphicsTextItem *label = m_labels.at(i);
- label->setPos(layout.at(i).center() - label->boundingRect().center());
- }
+ positionLabels();
}
//handlers
@@ -203,6 +205,7 @@ void AbstractBarChartItem::handleUpdatedBars()
int categoryCount = m_series->d_func()->categoryCount();
int setCount = m_series->count();
int itemIndex(0);
+ static const QString valueTag(QLatin1String("@value"));
for (int category = 0; category < categoryCount; category++) {
for (int set = 0; set < setCount; set++) {
@@ -213,7 +216,14 @@ void AbstractBarChartItem::handleUpdatedBars()
bar->update();
QGraphicsTextItem *label = m_labels.at(itemIndex);
- label->setHtml(QString("%1").arg(barSet->value(category)));
+ QString valueLabel;
+ if (m_series->labelsFormat().isEmpty()) {
+ valueLabel = QString("%1").arg(barSet->value(category));
+ } else {
+ valueLabel = m_series->labelsFormat();
+ valueLabel.replace(valueTag, QString::number(barSet->value(category)));
+ }
+ label->setHtml(valueLabel);
label->setFont(barSet->m_labelFont);
label->setDefaultTextColor(barSet->m_labelBrush.color());
label->update();
@@ -223,6 +233,32 @@ void AbstractBarChartItem::handleUpdatedBars()
}
}
+void AbstractBarChartItem::handleLabelsPositionChanged()
+{
+ positionLabels();
+}
+
+void AbstractBarChartItem::positionLabels()
+{
+ for (int i = 0; i < m_layout.count(); i++) {
+ QGraphicsTextItem *label = m_labels.at(i);
+ qreal xPos = 0;
+ qreal yPos = m_layout.at(i).center().y() - label->boundingRect().center().y();
+
+ if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
+ xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
+ else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd)
+ xPos = m_layout.at(i).right() - label->boundingRect().width();
+ else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase)
+ xPos = m_layout.at(i).left();
+ else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd)
+ xPos = m_layout.at(i).right();
+
+ label->setPos(xPos, yPos);
+ label->setZValue(zValue() + 1);
+ }
+}
+
#include "moc_abstractbarchartitem_p.cpp"
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/abstractbarchartitem_p.h b/src/barchart/abstractbarchartitem_p.h
index 87a80b33..2aa00ac4 100644
--- a/src/barchart/abstractbarchartitem_p.h
+++ b/src/barchart/abstractbarchartitem_p.h
@@ -70,6 +70,8 @@ public Q_SLOTS:
void handleVisibleChanged();
void handleOpacityChanged();
virtual void handleUpdatedBars();
+ void handleLabelsPositionChanged();
+ virtual void positionLabels();
protected:
diff --git a/src/barchart/horizontal/percent/horizontalpercentbarchartitem.cpp b/src/barchart/horizontal/percent/horizontalpercentbarchartitem.cpp
index c6ed34c4..775bfba6 100644
--- a/src/barchart/horizontal/percent/horizontalpercentbarchartitem.cpp
+++ b/src/barchart/horizontal/percent/horizontalpercentbarchartitem.cpp
@@ -97,6 +97,7 @@ void HorizontalPercentBarChartItem::handleUpdatedBars()
int categoryCount = m_series->d_func()->categoryCount();
int setCount = m_series->count();
int itemIndex(0);
+ static const QString valueTag(QLatin1String("@value"));
for (int category = 0; category < categoryCount; category++) {
for (int set = 0; set < setCount; set++) {
@@ -111,7 +112,14 @@ void HorizontalPercentBarChartItem::handleUpdatedBars()
QString vString(QString::number(p));
vString.truncate(3);
vString.append("%");
- label->setHtml(vString);
+ QString valueLabel;
+ if (m_series->labelsFormat().isEmpty()) {
+ valueLabel = vString;
+ } else {
+ valueLabel = m_series->labelsFormat();
+ valueLabel.replace(valueTag, QString::number(barSet->value(category)));
+ }
+ label->setHtml(valueLabel);
label->setFont(barSet->m_labelFont);
label->setDefaultTextColor(barSet->m_labelBrush.color());
label->update();
diff --git a/src/barchart/qabstractbarseries.cpp b/src/barchart/qabstractbarseries.cpp
index 2c2db60a..6b40197e 100644
--- a/src/barchart/qabstractbarseries.cpp
+++ b/src/barchart/qabstractbarseries.cpp
@@ -129,6 +129,75 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE
*/
/*!
+ \property QAbstractBarSeries::labelsFormat
+ The \a format used for showing labels in series.
+
+ QAbstractBarSeries supports the following format tag:
+ \table
+ \row
+ \li @value \li The value of the bar
+ \endtable
+
+ For example, the following usage of the format tags would produce labels that show the value
+ followed by unit ('u'):
+ \code
+ series->setLabelsFormat("@value u");
+ \endcode
+
+ By default, the labels shows the value of the bar. For percent bar series '%' is added after
+ the value. The labels are shown on the plot area, labels on the edge of the plot area are cut.
+ If the bars are close to each other the labels may overlap.
+
+ \sa QAbstractBarSeries::labelsVisible, QAbstractBarSeries::labelsPosition
+*/
+/*!
+ \qmlproperty string AbstractBarSeries::labelsFormat
+ The format used for showing labels in series.
+
+ \sa QAbstractBarSeries::labelsFormat, labelsVisible, labelsPosition
+*/
+/*!
+ \fn void QAbstractBarSeries::labelsFormatChanged(const QString &format)
+ Signal is emitted when the \a format of data value labels is changed.
+*/
+/*!
+ \qmlsignal XYSeries::onLabelsFormatChanged(string format)
+ Signal is emitted when the \a format of data value labels is changed.
+*/
+
+/*!
+ \enum QAbstractBarSeries::LabelsPosition
+
+ This enum describes the position of the data value labels.
+
+ \value LabelsCenter Label is in the center of the bar.
+ \value LabelsInsideEnd Label is inside the bar at the high end of it.
+ \value LabelsInsideBase Label is inside the bar at the low end of it.
+ \value LabelsOutsideEnd Label is outside the bar at the high end of it.
+ */
+
+/*!
+ \property QAbstractBarSeries::labelsPosition
+ Defines the \a position of value labels.
+
+ \sa QAbstractBarSeries::labelsVisible, QAbstractBarSeries::labelsFormat
+*/
+/*!
+ \qmlproperty string AbstractBarSeries::labelsPosition
+ Defines the \a position of value labels.
+
+ \sa labelsVisible, labelsFormat
+*/
+/*!
+ \fn void QAbstractBarSeries::labelsPositionChanged(QAbstractBarSeries::LabelsPosition position)
+ Signal is emitted when the \a position of value labels is changed.
+*/
+/*!
+ \qmlsignal AbstractBarSeries::onLabelsPositionChanged(LabelsPosition position)
+ Signal is emitted when the \a position of value labels is changed.
+*/
+
+/*!
\fn void QAbstractBarSeries::clicked(int index, QBarSet *barset)
The signal is emitted if the user clicks with a mouse on top of QBarSet \a barset.
Clicked bar inside set is indexed by \a index
@@ -421,6 +490,36 @@ bool QAbstractBarSeries::isLabelsVisible() const
return d->m_labelsVisible;
}
+void QAbstractBarSeries::setLabelsFormat(const QString &format)
+{
+ Q_D(QAbstractBarSeries);
+ if (d->m_labelsFormat != format) {
+ d->m_labelsFormat = format;
+ emit labelsFormatChanged(format);
+ }
+}
+
+QString QAbstractBarSeries::labelsFormat() const
+{
+ Q_D(const QAbstractBarSeries);
+ return d->m_labelsFormat;
+}
+
+void QAbstractBarSeries::setLabelsPosition(QAbstractBarSeries::LabelsPosition position)
+{
+ Q_D(QAbstractBarSeries);
+ if (d->m_labelsPosition != position) {
+ d->m_labelsPosition = position;
+ emit labelsPositionChanged(position);
+ }
+}
+
+QAbstractBarSeries::LabelsPosition QAbstractBarSeries::labelsPosition() const
+{
+ Q_D(const QAbstractBarSeries);
+ return d->m_labelsPosition;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
QAbstractBarSeriesPrivate::QAbstractBarSeriesPrivate(QAbstractBarSeries *q) :
@@ -428,7 +527,9 @@ QAbstractBarSeriesPrivate::QAbstractBarSeriesPrivate(QAbstractBarSeries *q) :
m_barWidth(0.5), // Default value is 50% of category width
m_labelsVisible(false),
m_visible(true),
- m_blockBarUpdate(false)
+ m_blockBarUpdate(false),
+ m_labelsFormat(),
+ m_labelsPosition(QAbstractBarSeries::LabelsCenter)
{
}
diff --git a/src/barchart/qabstractbarseries.h b/src/barchart/qabstractbarseries.h
index 6d35ce34..93627f6f 100644
--- a/src/barchart/qabstractbarseries.h
+++ b/src/barchart/qabstractbarseries.h
@@ -36,6 +36,19 @@ class QTCOMMERCIALCHART_EXPORT QAbstractBarSeries : public QAbstractSeries
Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
+ Q_PROPERTY(QString labelsFormat READ labelsFormat WRITE setLabelsFormat
+ NOTIFY labelsFormatChanged)
+ Q_PROPERTY(LabelsPosition labelsPosition READ labelsPosition
+ WRITE setLabelsPosition NOTIFY labelsPositionChanged)
+ Q_ENUMS(LabelsPosition)
+
+public:
+ enum LabelsPosition {
+ LabelsCenter = 0,
+ LabelsInsideEnd,
+ LabelsInsideBase,
+ LabelsOutsideEnd
+ };
public:
virtual ~QAbstractBarSeries();
@@ -55,6 +68,12 @@ public:
void setLabelsVisible(bool visible = true);
bool isLabelsVisible() const;
+ void setLabelsFormat(const QString &format);
+ QString labelsFormat() const;
+
+ void setLabelsPosition(QAbstractBarSeries::LabelsPosition position);
+ QAbstractBarSeries::LabelsPosition labelsPosition() const;
+
protected:
explicit QAbstractBarSeries(QAbstractBarSeriesPrivate &d, QObject *parent = 0);
@@ -64,6 +83,8 @@ Q_SIGNALS:
void hovered(bool status, int index, QBarSet *barset);
void countChanged();
void labelsVisibleChanged();
+ void labelsFormatChanged(const QString &format);
+ void labelsPositionChanged(QAbstractBarSeries::LabelsPosition position);
void barsetsAdded(QList<QBarSet *> sets);
void barsetsRemoved(QList<QBarSet *> sets);
diff --git a/src/barchart/qabstractbarseries_p.h b/src/barchart/qabstractbarseries_p.h
index f2bd2ce0..0cedc331 100644
--- a/src/barchart/qabstractbarseries_p.h
+++ b/src/barchart/qabstractbarseries_p.h
@@ -104,6 +104,8 @@ protected:
bool m_labelsVisible;
bool m_visible;
bool m_blockBarUpdate;
+ QString m_labelsFormat;
+ QAbstractBarSeries::LabelsPosition m_labelsPosition;
private:
Q_DECLARE_PUBLIC(QAbstractBarSeries)
diff --git a/src/barchart/vertical/bar/barchartitem.cpp b/src/barchart/vertical/bar/barchartitem.cpp
index e9258ae0..eae5be18 100644
--- a/src/barchart/vertical/bar/barchartitem.cpp
+++ b/src/barchart/vertical/bar/barchartitem.cpp
@@ -29,6 +29,9 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE
BarChartItem::BarChartItem(QAbstractBarSeries *series, QGraphicsItem* item) :
AbstractBarChartItem(series, item)
{
+ connect(series, SIGNAL(labelsPositionChanged(QAbstractBarSeries::LabelsPosition)),
+ this, SLOT(handleLabelsPositionChanged()));
+ connect(series, SIGNAL(labelsFormatChanged(QString)), this, SLOT(positionLabels()));
}
void BarChartItem::initializeLayout()
@@ -86,9 +89,36 @@ QVector<QRectF> BarChartItem::calculateLayout()
layout.append(rect.normalized());
}
}
+
return layout;
}
+void BarChartItem::handleLabelsPositionChanged()
+{
+ positionLabels();
+}
+
+void BarChartItem::positionLabels()
+{
+ for (int i = 0; i < m_layout.count(); i++) {
+ QGraphicsTextItem *label = m_labels.at(i);
+ qreal xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
+ qreal yPos = 0;
+
+ if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
+ yPos = m_layout.at(i).center().y() - label->boundingRect().center().y();
+ else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd)
+ yPos = m_layout.at(i).top();
+ else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase)
+ yPos = m_layout.at(i).bottom() - label->boundingRect().height();
+ else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd)
+ yPos = m_layout.at(i).top() - label->boundingRect().height();
+
+ label->setPos(xPos, yPos);
+ label->setZValue(zValue() + 1);
+ }
+}
+
#include "moc_barchartitem_p.cpp"
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/vertical/bar/barchartitem_p.h b/src/barchart/vertical/bar/barchartitem_p.h
index 7d37fd17..b94e9c34 100644
--- a/src/barchart/vertical/bar/barchartitem_p.h
+++ b/src/barchart/vertical/bar/barchartitem_p.h
@@ -43,6 +43,10 @@ class BarChartItem : public AbstractBarChartItem
public:
BarChartItem(QAbstractBarSeries *series, QGraphicsItem* item = 0);
+private slots:
+ void handleLabelsPositionChanged();
+ void positionLabels();
+
private:
virtual QVector<QRectF> calculateLayout();
void initializeLayout();
diff --git a/src/barchart/vertical/percent/percentbarchartitem.cpp b/src/barchart/vertical/percent/percentbarchartitem.cpp
index 45875e22..1c595e9d 100644
--- a/src/barchart/vertical/percent/percentbarchartitem.cpp
+++ b/src/barchart/vertical/percent/percentbarchartitem.cpp
@@ -29,6 +29,9 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE
PercentBarChartItem::PercentBarChartItem(QAbstractBarSeries *series, QGraphicsItem* item) :
AbstractBarChartItem(series, item)
{
+ connect(series, SIGNAL(labelsPositionChanged(QAbstractBarSeries::LabelsPosition)),
+ this, SLOT(handleLabelsPositionChanged()));
+ connect(series, SIGNAL(labelsFormatChanged(QString)), this, SLOT(positionLabels()));
}
void PercentBarChartItem::initializeLayout()
@@ -99,6 +102,7 @@ void PercentBarChartItem::handleUpdatedBars()
int categoryCount = m_series->d_func()->categoryCount();
int setCount = m_series->count();
int itemIndex(0);
+ static const QString valueTag(QLatin1String("@value"));
for (int category = 0; category < categoryCount; category++) {
for (int set = 0; set < setCount; set++) {
@@ -113,7 +117,14 @@ void PercentBarChartItem::handleUpdatedBars()
QString vString(QString::number(p));
vString.truncate(3);
vString.append("%");
- label->setHtml(vString);
+ QString valueLabel;
+ if (m_series->labelsFormat().isEmpty()) {
+ valueLabel = vString;
+ } else {
+ valueLabel = m_series->labelsFormat();
+ valueLabel.replace(valueTag, QString::number(barSet->value(category)));
+ }
+ label->setHtml(valueLabel);
label->setFont(barSet->m_labelFont);
label->setDefaultTextColor(barSet->m_labelBrush.color());
label->update();
@@ -122,6 +133,32 @@ void PercentBarChartItem::handleUpdatedBars()
}
}
+void PercentBarChartItem::handleLabelsPositionChanged()
+{
+ positionLabels();
+}
+
+void PercentBarChartItem::positionLabels()
+{
+ for (int i = 0; i < m_layout.count(); i++) {
+ QGraphicsTextItem *label = m_labels.at(i);
+ qreal xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
+ qreal yPos = 0;
+
+ if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
+ yPos = m_layout.at(i).center().y() - label->boundingRect().center().y();
+ else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd)
+ yPos = m_layout.at(i).top();
+ else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase)
+ yPos = m_layout.at(i).bottom() - label->boundingRect().height();
+ else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd)
+ yPos = m_layout.at(i).top() - label->boundingRect().height();
+
+ label->setPos(xPos, yPos);
+ label->setZValue(zValue() + 1);
+ }
+}
+
#include "moc_percentbarchartitem_p.cpp"
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/vertical/percent/percentbarchartitem_p.h b/src/barchart/vertical/percent/percentbarchartitem_p.h
index 2656c3a1..da9fb897 100644
--- a/src/barchart/vertical/percent/percentbarchartitem_p.h
+++ b/src/barchart/vertical/percent/percentbarchartitem_p.h
@@ -45,6 +45,10 @@ public:
PercentBarChartItem(QAbstractBarSeries *series, QGraphicsItem* item = 0);
void handleUpdatedBars();
+private slots:
+ void handleLabelsPositionChanged();
+ void positionLabels();
+
private:
virtual QVector<QRectF> calculateLayout();
void initializeLayout();
diff --git a/src/barchart/vertical/stacked/stackedbarchartitem.cpp b/src/barchart/vertical/stacked/stackedbarchartitem.cpp
index 7c118709..82329194 100644
--- a/src/barchart/vertical/stacked/stackedbarchartitem.cpp
+++ b/src/barchart/vertical/stacked/stackedbarchartitem.cpp
@@ -29,6 +29,9 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE
StackedBarChartItem::StackedBarChartItem(QAbstractBarSeries *series, QGraphicsItem* item) :
AbstractBarChartItem(series, item)
{
+ connect(series, SIGNAL(labelsPositionChanged(QAbstractBarSeries::LabelsPosition)),
+ this, SLOT(handleLabelsPositionChanged()));
+ connect(series, SIGNAL(labelsFormatChanged(QString)), this, SLOT(positionLabels()));
}
void StackedBarChartItem::initializeLayout()
@@ -102,6 +105,32 @@ QVector<QRectF> StackedBarChartItem::calculateLayout()
return layout;
}
+void StackedBarChartItem::handleLabelsPositionChanged()
+{
+ positionLabels();
+}
+
+void StackedBarChartItem::positionLabels()
+{
+ for (int i = 0; i < m_layout.count(); i++) {
+ QGraphicsTextItem *label = m_labels.at(i);
+ qreal xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
+ qreal yPos = 0;
+
+ if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
+ yPos = m_layout.at(i).center().y() - label->boundingRect().center().y();
+ else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd)
+ yPos = m_layout.at(i).top();
+ else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase)
+ yPos = m_layout.at(i).bottom() - label->boundingRect().height();
+ else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd)
+ yPos = m_layout.at(i).top() - label->boundingRect().height();
+
+ label->setPos(xPos, yPos);
+ label->setZValue(zValue() + 1);
+ }
+}
+
#include "moc_stackedbarchartitem_p.cpp"
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/vertical/stacked/stackedbarchartitem_p.h b/src/barchart/vertical/stacked/stackedbarchartitem_p.h
index a85b98cf..f6f645a0 100644
--- a/src/barchart/vertical/stacked/stackedbarchartitem_p.h
+++ b/src/barchart/vertical/stacked/stackedbarchartitem_p.h
@@ -43,6 +43,10 @@ class StackedBarChartItem : public AbstractBarChartItem
public:
StackedBarChartItem(QAbstractBarSeries *series, QGraphicsItem* item =0);
+private slots:
+ void handleLabelsPositionChanged();
+ void positionLabels();
+
private:
virtual QVector<QRectF> calculateLayout();
void initializeLayout();
diff --git a/src/linechart/linechartitem.cpp b/src/linechart/linechartitem.cpp
index ad942c9d..4aa154e3 100644
--- a/src/linechart/linechartitem.cpp
+++ b/src/linechart/linechartitem.cpp
@@ -23,6 +23,8 @@
#include "qlineseries_p.h"
#include "chartpresenter_p.h"
#include "polardomain_p.h"
+#include "chartthememanager_p.h"
+#include "charttheme_p.h"
#include <QPainter>
#include <QGraphicsSceneMouseEvent>
@@ -34,13 +36,23 @@ LineChartItem::LineChartItem(QLineSeries *series, QGraphicsItem *item)
: XYChart(series,item),
m_series(series),
m_pointsVisible(false),
- m_chartType(QChart::ChartTypeUndefined)
+ m_chartType(QChart::ChartTypeUndefined),
+ m_pointLabelsFormat(series->pointLabelsFormat()),
+ m_pointLabelsVisible(false),
+ m_pointLabelsFont(series->pointLabelsFont()),
+ m_pointLabelsColor(series->pointLabelsColor())
{
setAcceptHoverEvents(true);
setZValue(ChartPresenter::LineChartZValue);
QObject::connect(series->d_func(), SIGNAL(updated()), this, SLOT(handleUpdated()));
QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated()));
QObject::connect(series, SIGNAL(opacityChanged()), this, SLOT(handleUpdated()));
+ QObject::connect(series, SIGNAL(pointLabelsFormatChanged(QString)),
+ this, SLOT(handleUpdated()));
+ QObject::connect(series, SIGNAL(pointLabelsVisibilityChanged(bool)),
+ this, SLOT(handleUpdated()));
+ QObject::connect(series, SIGNAL(pointLabelsFontChanged(QFont)), this, SLOT(handleUpdated()));
+ QObject::connect(series, SIGNAL(pointLabelsColorChanged(QColor)), this, SLOT(handleUpdated()));
handleUpdated();
}
@@ -300,7 +312,7 @@ void LineChartItem::updateGeometry()
void LineChartItem::handleUpdated()
{
- // If points visiblity has changed, a geometry update is needed.
+ // If points visibility has changed, a geometry update is needed.
// Also, if pen changes when points are visible, geometry update is needed.
bool doGeometryUpdate =
(m_pointsVisible != m_series->pointsVisible())
@@ -309,6 +321,10 @@ void LineChartItem::handleUpdated()
setOpacity(m_series->opacity());
m_pointsVisible = m_series->pointsVisible();
m_linePen = m_series->pen();
+ m_pointLabelsFormat = m_series->pointLabelsFormat();
+ m_pointLabelsVisible = m_series->pointLabelsVisible();
+ m_pointLabelsFont = m_series->pointLabelsFont();
+ m_pointLabelsColor = m_series->pointLabelsColor();
if (doGeometryUpdate)
updateGeometry();
update();
@@ -357,7 +373,11 @@ void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
}
}
+ if (m_pointLabelsVisible)
+ m_series->d_func()->drawSeriesPointLabels(painter, m_points);
+
painter->restore();
+
}
void LineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
diff --git a/src/linechart/linechartitem_p.h b/src/linechart/linechartitem_p.h
index b7ba7315..f1272478 100644
--- a/src/linechart/linechartitem_p.h
+++ b/src/linechart/linechartitem_p.h
@@ -79,6 +79,11 @@ private:
QPen m_linePen;
bool m_pointsVisible;
QChart::ChartType m_chartType;
+
+ bool m_pointLabelsVisible;
+ QString m_pointLabelsFormat;
+ QFont m_pointLabelsFont;
+ QColor m_pointLabelsColor;
};
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/linechart/qlineseries.cpp b/src/linechart/qlineseries.cpp
index 4d4f0f12..6fe7719d 100644
--- a/src/linechart/qlineseries.cpp
+++ b/src/linechart/qlineseries.cpp
@@ -160,6 +160,11 @@ void QLineSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forc
pen.setWidthF(2);
q->setPen(pen);
}
+
+ if (forced || QChartPrivate::defaultPen().color() == m_pointLabelsColor) {
+ QColor color = theme->labelBrush().color();
+ q->setPointLabelsColor(color);
+ }
}
#include "moc_qlineseries.cpp"
diff --git a/src/scatterchart/qscatterseries.cpp b/src/scatterchart/qscatterseries.cpp
index ea62f123..f5805e22 100644
--- a/src/scatterchart/qscatterseries.cpp
+++ b/src/scatterchart/qscatterseries.cpp
@@ -306,6 +306,11 @@ void QScatterSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool f
QBrush brush(colors.at(index % colors.size()));
q->setBrush(brush);
}
+
+ if (forced || QChartPrivate::defaultPen().color() == m_pointLabelsColor) {
+ QColor color = theme->labelBrush().color();
+ q->setPointLabelsColor(color);
+ }
}
void QScatterSeriesPrivate::initializeAnimations(QChart::AnimationOptions options)
diff --git a/src/scatterchart/scatterchartitem.cpp b/src/scatterchart/scatterchartitem.cpp
index d9d637dc..cb7ebc6c 100644
--- a/src/scatterchart/scatterchartitem.cpp
+++ b/src/scatterchart/scatterchartitem.cpp
@@ -37,11 +37,21 @@ ScatterChartItem::ScatterChartItem(QScatterSeries *series, QGraphicsItem *item)
m_items(this),
m_visible(true),
m_shape(QScatterSeries::MarkerShapeRectangle),
- m_size(15)
+ m_size(15),
+ m_pointLabelsFormat(series->pointLabelsFormat()),
+ m_pointLabelsVisible(false),
+ m_pointLabelsFont(series->pointLabelsFont()),
+ m_pointLabelsColor(series->pointLabelsColor())
{
QObject::connect(m_series->d_func(), SIGNAL(updated()), this, SLOT(handleUpdated()));
QObject::connect(m_series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated()));
QObject::connect(m_series, SIGNAL(opacityChanged()), this, SLOT(handleUpdated()));
+ QObject::connect(series, SIGNAL(pointLabelsFormatChanged(QString)),
+ this, SLOT(handleUpdated()));
+ QObject::connect(series, SIGNAL(pointLabelsVisibilityChanged(bool)),
+ this, SLOT(handleUpdated()));
+ QObject::connect(series, SIGNAL(pointLabelsFontChanged(QFont)), this, SLOT(handleUpdated()));
+ QObject::connect(series, SIGNAL(pointLabelsColorChanged(QColor)), this, SLOT(handleUpdated()));
setZValue(ChartPresenter::ScatterSeriesZValue);
setFlags(QGraphicsItem::ItemClipsChildrenToShape);
@@ -160,9 +170,18 @@ void ScatterChartItem::updateGeometry()
void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
- Q_UNUSED(painter)
Q_UNUSED(option)
Q_UNUSED(widget)
+
+ QRectF clipRect = QRectF(QPointF(0, 0), domain()->size());
+
+ painter->save();
+ painter->setClipRect(clipRect);
+
+ if (m_pointLabelsVisible)
+ m_series->d_func()->drawSeriesPointLabels(painter, m_points);
+
+ painter->restore();
}
void ScatterChartItem::setPen(const QPen &pen)
@@ -192,6 +211,10 @@ void ScatterChartItem::handleUpdated()
m_size = m_series->markerSize();
m_shape = m_series->markerShape();
setOpacity(m_series->opacity());
+ m_pointLabelsFormat = m_series->pointLabelsFormat();
+ m_pointLabelsVisible = m_series->pointLabelsVisible();
+ m_pointLabelsFont = m_series->pointLabelsFont();
+ m_pointLabelsColor = m_series->pointLabelsColor();
if (recreate) {
deletePoints(count);
diff --git a/src/scatterchart/scatterchartitem_p.h b/src/scatterchart/scatterchartitem_p.h
index b08bfa65..4c5e9f2f 100644
--- a/src/scatterchart/scatterchartitem_p.h
+++ b/src/scatterchart/scatterchartitem_p.h
@@ -75,6 +75,11 @@ private:
int m_size;
QRectF m_rect;
QMap<QGraphicsItem *, QPointF> m_markerMap;
+
+ bool m_pointLabelsVisible;
+ QString m_pointLabelsFormat;
+ QFont m_pointLabelsFont;
+ QColor m_pointLabelsColor;
};
class CircleMarker: public QGraphicsEllipseItem
diff --git a/src/splinechart/qsplineseries.cpp b/src/splinechart/qsplineseries.cpp
index a4b65438..b8c9d584 100644
--- a/src/splinechart/qsplineseries.cpp
+++ b/src/splinechart/qsplineseries.cpp
@@ -137,6 +137,11 @@ void QSplineSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool fo
pen.setWidthF(2);
q->setPen(pen);
}
+
+ if (forced || QChartPrivate::defaultPen().color() == m_pointLabelsColor) {
+ QColor color = theme->labelBrush().color();
+ q->setPointLabelsColor(color);
+ }
}
void QSplineSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options)
diff --git a/src/splinechart/splinechartitem.cpp b/src/splinechart/splinechartitem.cpp
index 5e244e78..11554c3c 100644
--- a/src/splinechart/splinechartitem.cpp
+++ b/src/splinechart/splinechartitem.cpp
@@ -32,13 +32,23 @@ SplineChartItem::SplineChartItem(QSplineSeries *series, QGraphicsItem *item)
: XYChart(series,item),
m_series(series),
m_pointsVisible(false),
- m_animation(0)
+ m_animation(0),
+ m_pointLabelsFormat(series->pointLabelsFormat()),
+ m_pointLabelsVisible(false),
+ m_pointLabelsFont(series->pointLabelsFont()),
+ m_pointLabelsColor(series->pointLabelsColor())
{
setAcceptHoverEvents(true);
setZValue(ChartPresenter::SplineChartZValue);
QObject::connect(m_series->d_func(), SIGNAL(updated()), this, SLOT(handleUpdated()));
QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated()));
QObject::connect(series, SIGNAL(opacityChanged()), this, SLOT(handleUpdated()));
+ QObject::connect(series, SIGNAL(pointLabelsFormatChanged(QString)),
+ this, SLOT(handleUpdated()));
+ QObject::connect(series, SIGNAL(pointLabelsVisibilityChanged(bool)),
+ this, SLOT(handleUpdated()));
+ QObject::connect(series, SIGNAL(pointLabelsFontChanged(QFont)), this, SLOT(handleUpdated()));
+ QObject::connect(series, SIGNAL(pointLabelsColorChanged(QColor)), this, SLOT(handleUpdated()));
handleUpdated();
}
@@ -400,6 +410,10 @@ void SplineChartItem::handleUpdated()
m_linePen = m_series->pen();
m_pointPen = m_series->pen();
m_pointPen.setWidthF(2 * m_pointPen.width());
+ m_pointLabelsFormat = m_series->pointLabelsFormat();
+ m_pointLabelsVisible = m_series->pointLabelsVisible();
+ m_pointLabelsFont = m_series->pointLabelsFont();
+ m_pointLabelsColor = m_series->pointLabelsColor();
update();
}
@@ -442,6 +456,9 @@ void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
painter->drawPoints(geometryPoints());
}
+ if (m_pointLabelsVisible)
+ m_series->d_func()->drawSeriesPointLabels(painter, m_points);
+
painter->restore();
}
diff --git a/src/splinechart/splinechartitem_p.h b/src/splinechart/splinechartitem_p.h
index c8fa558d..e171f26d 100644
--- a/src/splinechart/splinechartitem_p.h
+++ b/src/splinechart/splinechartitem_p.h
@@ -81,6 +81,11 @@ private:
QVector<QPointF> m_visiblePoints;
SplineAnimation *m_animation;
+ bool m_pointLabelsVisible;
+ QString m_pointLabelsFormat;
+ QFont m_pointLabelsFont;
+ QColor m_pointLabelsColor;
+
friend class SplineAnimation;
};
diff --git a/src/xychart/qxyseries.cpp b/src/xychart/qxyseries.cpp
index a879805e..6c56a7b1 100644
--- a/src/xychart/qxyseries.cpp
+++ b/src/xychart/qxyseries.cpp
@@ -26,6 +26,7 @@
#include "qxylegendmarker.h"
#include "charthelpers_p.h"
#include "qchart_p.h"
+#include <QPainter>
QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -124,6 +125,110 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE
*/
/*!
+ \property QXYSeries::pointLabelsFormat
+ The \a format used for showing labels with series points.
+
+ QXYSeries supports the following format tags:
+ \table
+ \row
+ \li @xPoint \li The x value of the data point
+ \row
+ \li @yPoint \li The y value of the data point
+ \endtable
+
+ For example, the following usage of the format tags would produce labels that have the data
+ point (x, y) shown inside brackets separated by a comma:
+ \code
+ series->setPointLabelsFormat("(@xPoint, @yPoint)");
+ \endcode
+
+ By default, the labels format is set to '@xPoint, @yPoint'. The labels are shown on the plot
+ area, labels on the edge of the plot area are cut. If the points are close to each other the
+ labels may overlap.
+
+ \sa QXYSeries::pointLabelsVisible, QXYSeries::pointLabelsFont, QXYSeries::pointLabelsColor
+*/
+/*!
+ \qmlproperty string XYSeries::pointLabelsFormat
+ The \a format used for showing labels with series points.
+
+ \sa QXYSeries::pointLabelsFormat, pointLabelsVisible, pointLabelsFont, pointLabelsColor
+*/
+/*!
+ \fn void QXYSeries::pointLabelsFormatChanged(const QString &format)
+ Signal is emitted when the \a format of data point labels is changed.
+*/
+/*!
+ \qmlsignal XYSeries::onPointLabelsFormatChanged(string format)
+ Signal is emitted when the \a format of data point labels is changed.
+*/
+
+/*!
+ \property QXYSeries::pointLabelsVisible
+ Defines the visibility for data point labels. False by default.
+
+ \sa QXYSeries::pointLabelsFormat
+*/
+/*!
+ \qmlproperty bool XYSeries::pointLabelsVisible
+ Defines the visibility for data point labels.
+
+ \sa pointLabelsFormat
+*/
+/*!
+ \fn void QXYSeries::pointLabelsVisibilityChanged(bool visible)
+ The visibility of the data point labels is changed to \a visible.
+*/
+/*!
+ \qmlsignal XYSeries::onPointLabelsVisibilityChanged(bool visible)
+ The visibility of the data point labels is changed to \a visible.
+*/
+
+/*!
+ \property QXYSeries::pointLabelsFont
+ Defines the font used for data point labels.
+
+ \sa QXYSeries::pointLabelsFormat
+*/
+/*!
+ \qmlproperty font XYSeries::pointLabelsFont
+ Defines the font used for data point labels.
+
+ \sa pointLabelsFormat
+*/
+/*!
+ \fn void QXYSeries::pointLabelsFontChanged(const QFont &font);
+ The font used for data point labels is changed to \a font.
+*/
+/*!
+ \qmlsignal XYSeries::onPointLabelsFontChanged(Font font)
+ The font used for data point labels is changed to \a font.
+*/
+
+/*!
+ \property QXYSeries::pointLabelsColor
+ Defines the color used for data point labels. By default, the color is the color of the brush
+ defined in theme for labels.
+
+ \sa QXYSeries::pointLabelsFormat
+*/
+/*!
+ \qmlproperty font XYSeries::pointLabelsColor
+ Defines the color used for data point labels. By default, the color is the color of the brush
+ defined in theme for labels.
+
+ \sa pointLabelsFormat
+*/
+/*!
+ \fn void QXYSeries::pointLabelsColorChanged(const QColor &color);
+ The color used for data point labels is changed to \a color.
+*/
+/*!
+ \qmlsignal XYSeries::onPointLabelsColorChanged(Color color)
+ The color used for data point labels is changed to \a color.
+*/
+
+/*!
\fn void QXYSeries::clicked(const QPointF& point)
\brief Signal is emitted when user clicks the \a point on chart.
*/
@@ -499,6 +604,68 @@ bool QXYSeries::pointsVisible() const
return d->m_pointsVisible;
}
+void QXYSeries::setPointLabelsFormat(const QString &format)
+{
+ Q_D(QXYSeries);
+ if (d->m_pointLabelsFormat != format) {
+ d->m_pointLabelsFormat = format;
+ emit pointLabelsFormatChanged(format);
+ }
+}
+
+QString QXYSeries::pointLabelsFormat() const
+{
+ Q_D(const QXYSeries);
+ return d->m_pointLabelsFormat;
+}
+
+void QXYSeries::setPointLabelsVisible(bool visible)
+{
+ Q_D(QXYSeries);
+ if (d->m_pointLabelsVisible != visible) {
+ d->m_pointLabelsVisible = visible;
+ emit pointLabelsVisibilityChanged(visible);
+ }
+}
+
+bool QXYSeries::pointLabelsVisible() const
+{
+ Q_D(const QXYSeries);
+ return d->m_pointLabelsVisible;
+}
+
+void QXYSeries::setPointLabelsFont(const QFont &font)
+{
+ Q_D(QXYSeries);
+ if (d->m_pointLabelsFont != font) {
+ d->m_pointLabelsFont = font;
+ emit pointLabelsFontChanged(font);
+ }
+}
+
+QFont QXYSeries::pointLabelsFont() const
+{
+ Q_D(const QXYSeries);
+ return d->m_pointLabelsFont;
+}
+
+void QXYSeries::setPointLabelsColor(const QColor &color)
+{
+ Q_D(QXYSeries);
+ if (d->m_pointLabelsColor != color) {
+ d->m_pointLabelsColor = color;
+ emit pointLabelsColorChanged(color);
+ }
+}
+
+QColor QXYSeries::pointLabelsColor() const
+{
+ Q_D(const QXYSeries);
+ if (d->m_pointLabelsColor == QChartPrivate::defaultPen().color())
+ return QPen().color();
+ else
+ return d->m_pointLabelsColor;
+}
/*!
Stream operator for adding a data \a point to the series.
@@ -529,7 +696,11 @@ QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q)
: QAbstractSeriesPrivate(q),
m_pen(QChartPrivate::defaultPen()),
m_brush(QChartPrivate::defaultBrush()),
- m_pointsVisible(false)
+ m_pointsVisible(false),
+ m_pointLabelsFormat(QLatin1String("@xPoint, @yPoint")),
+ m_pointLabelsVisible(false),
+ m_pointLabelsFont(QChartPrivate::defaultFont()),
+ m_pointLabelsColor(QChartPrivate::defaultPen().color())
{
}
@@ -601,6 +772,31 @@ void QXYSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::Animation
QAbstractSeriesPrivate::initializeAnimations(options);
}
+void QXYSeriesPrivate::drawSeriesPointLabels(QPainter *painter, const QVector<QPointF> &points)
+{
+ static const QString xPointTag(QLatin1String("@xPoint"));
+ static const QString yPointTag(QLatin1String("@yPoint"));
+ const int labelOffset = 2;
+
+ painter->setFont(m_pointLabelsFont);
+ painter->setPen(QPen(m_pointLabelsColor));
+ QFontMetrics fm(painter->font());
+
+ for (int i(0); i < m_points.size(); i++) {
+ QString pointLabel = m_pointLabelsFormat;
+ pointLabel.replace(xPointTag, QString::number(m_points.at(i).x()));
+ pointLabel.replace(yPointTag, QString::number(m_points.at(i).y()));
+
+ // Position text in relation to the point
+ int pointLabelWidth = fm.width(pointLabel);
+ QPointF position(points.at(i));
+ position.setX(position.x() - pointLabelWidth / 2);
+ position.setY(position.y() - painter->pen().width() / 2 - labelOffset);
+
+ painter->drawText(position, pointLabel);
+ }
+}
+
#include "moc_qxyseries.cpp"
#include "moc_qxyseries_p.cpp"
diff --git a/src/xychart/qxyseries.h b/src/xychart/qxyseries.h
index 47739ba2..1e8a7210 100644
--- a/src/xychart/qxyseries.h
+++ b/src/xychart/qxyseries.h
@@ -38,6 +38,14 @@ class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries
Q_OBJECT
Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+ Q_PROPERTY(QString pointLabelsFormat READ pointLabelsFormat WRITE setPointLabelsFormat
+ NOTIFY pointLabelsFormatChanged)
+ Q_PROPERTY(bool pointLabelsVisible READ pointLabelsVisible WRITE setPointLabelsVisible
+ NOTIFY pointLabelsVisibilityChanged)
+ Q_PROPERTY(QFont pointLabelsFont READ pointLabelsFont WRITE setPointLabelsFont
+ NOTIFY pointLabelsFontChanged)
+ Q_PROPERTY(QColor pointLabelsColor READ pointLabelsColor WRITE setPointLabelsColor
+ NOTIFY pointLabelsColorChanged)
protected:
explicit QXYSeries(QXYSeriesPrivate &d, QObject *parent = 0);
@@ -76,6 +84,18 @@ public:
void setPointsVisible(bool visible = true);
bool pointsVisible() const;
+ void setPointLabelsFormat(const QString &format);
+ QString pointLabelsFormat() const;
+
+ void setPointLabelsVisible(bool visible = true);
+ bool pointLabelsVisible() const;
+
+ void setPointLabelsFont(const QFont &font);
+ QFont pointLabelsFont() const;
+
+ void setPointLabelsColor(const QColor &color);
+ QColor pointLabelsColor() const;
+
void replace(QList<QPointF> points);
Q_SIGNALS:
@@ -86,6 +106,10 @@ Q_SIGNALS:
void pointAdded(int index);
void colorChanged(QColor color);
void pointsReplaced();
+ void pointLabelsFormatChanged(const QString &format);
+ void pointLabelsVisibilityChanged(bool visible);
+ void pointLabelsFontChanged(const QFont &font);
+ void pointLabelsColorChanged(const QColor &color);
private:
Q_DECLARE_PRIVATE(QXYSeries)
diff --git a/src/xychart/qxyseries_p.h b/src/xychart/qxyseries_p.h
index 9086e46c..64dec648 100644
--- a/src/xychart/qxyseries_p.h
+++ b/src/xychart/qxyseries_p.h
@@ -53,6 +53,8 @@ public:
QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const;
QAbstractAxis* createDefaultAxis(Qt::Orientation orientation) const;
+ void drawSeriesPointLabels(QPainter *painter, const QVector<QPointF> &points);
+
Q_SIGNALS:
void updated();
@@ -61,6 +63,10 @@ protected:
QPen m_pen;
QBrush m_brush;
bool m_pointsVisible;
+ QString m_pointLabelsFormat;
+ bool m_pointLabelsVisible;
+ QFont m_pointLabelsFont;
+ QColor m_pointLabelsColor;
private:
Q_DECLARE_PUBLIC(QXYSeries)
diff --git a/tests/auto/qbarseries/tst_qbarseries.cpp b/tests/auto/qbarseries/tst_qbarseries.cpp
index 3dcc30d3..f2c056a0 100644
--- a/tests/auto/qbarseries/tst_qbarseries.cpp
+++ b/tests/auto/qbarseries/tst_qbarseries.cpp
@@ -29,6 +29,7 @@ QTCOMMERCIALCHART_USE_NAMESPACE
Q_DECLARE_METATYPE(QBarSet*)
Q_DECLARE_METATYPE(QList<QBarSet*>)
+Q_DECLARE_METATYPE(QAbstractBarSeries::LabelsPosition)
class tst_QBarSeries : public QObject
{
@@ -59,6 +60,8 @@ private slots:
void barSets();
void setLabelsVisible_data();
void setLabelsVisible();
+ void setLabelsFormat();
+ void setLabelsPosition();
void opacity();
void mouseclicked_data();
void mouseclicked();
@@ -79,6 +82,7 @@ void tst_QBarSeries::initTestCase()
{
qRegisterMetaType<QBarSet*>("QBarSet*");
qRegisterMetaType<QList<QBarSet*> >("QList<QBarSet*>");
+ qRegisterMetaType<QAbstractBarSeries::LabelsPosition>("QAbstractBarSeries::LabelsPosition");
}
void tst_QBarSeries::cleanupTestCase()
@@ -343,6 +347,60 @@ void tst_QBarSeries::setLabelsVisible()
QVERIFY(m_barseries_with_sets->isLabelsVisible() == true);
}
+void tst_QBarSeries::setLabelsFormat()
+{
+ QSignalSpy labelsFormatSpy(m_barseries, SIGNAL(labelsFormatChanged(QString)));
+ QCOMPARE(m_barseries->labelsFormat(), QString());
+
+ QString format("(@value)");
+ m_barseries->setLabelsFormat(format);
+ TRY_COMPARE(labelsFormatSpy.count(), 1);
+ QList<QVariant> arguments = labelsFormatSpy.takeFirst();
+ QVERIFY(arguments.at(0).toString() == format);
+ QCOMPARE(m_barseries->labelsFormat(), format);
+
+ m_barseries->setLabelsFormat(QString());
+ TRY_COMPARE(labelsFormatSpy.count(), 1);
+ arguments = labelsFormatSpy.takeFirst();
+ QVERIFY(arguments.at(0).toString() == QString());
+ QCOMPARE(m_barseries->labelsFormat(), QString());
+}
+
+void tst_QBarSeries::setLabelsPosition()
+{
+ QSignalSpy labelsPositionSpy(m_barseries,
+ SIGNAL(labelsPositionChanged(QAbstractBarSeries::LabelsPosition)));
+ QCOMPARE(m_barseries->labelsPosition(), QBarSeries::LabelsCenter);
+
+ m_barseries->setLabelsPosition(QBarSeries::LabelsInsideEnd);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ QList<QVariant> arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QBarSeries::LabelsInsideEnd);
+ QCOMPARE(m_barseries->labelsPosition(), QBarSeries::LabelsInsideEnd);
+
+ m_barseries->setLabelsPosition(QBarSeries::LabelsInsideBase);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QBarSeries::LabelsInsideBase);
+ QCOMPARE(m_barseries->labelsPosition(), QBarSeries::LabelsInsideBase);
+
+ m_barseries->setLabelsPosition(QBarSeries::LabelsOutsideEnd);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QBarSeries::LabelsOutsideEnd);
+ QCOMPARE(m_barseries->labelsPosition(), QBarSeries::LabelsOutsideEnd);
+
+ m_barseries->setLabelsPosition(QBarSeries::LabelsCenter);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QBarSeries::LabelsCenter);
+ QCOMPARE(m_barseries->labelsPosition(), QBarSeries::LabelsCenter);
+}
+
void tst_QBarSeries::opacity()
{
QSignalSpy opacitySpy(m_barseries, SIGNAL(opacityChanged()));
diff --git a/tests/auto/qhorizontalbarseries/tst_qhorizontalbarseries.cpp b/tests/auto/qhorizontalbarseries/tst_qhorizontalbarseries.cpp
index fc6c4977..de5b868f 100644
--- a/tests/auto/qhorizontalbarseries/tst_qhorizontalbarseries.cpp
+++ b/tests/auto/qhorizontalbarseries/tst_qhorizontalbarseries.cpp
@@ -28,6 +28,7 @@
QTCOMMERCIALCHART_USE_NAMESPACE
Q_DECLARE_METATYPE(QBarSet*)
+Q_DECLARE_METATYPE(QAbstractBarSeries::LabelsPosition)
class tst_QHorizontalBarSeries : public QObject
{
@@ -56,6 +57,8 @@ private slots:
void barSets();
void setLabelsVisible_data();
void setLabelsVisible();
+ void setLabelsFormat();
+ void setLabelsPosition();
void mouseclicked_data();
void mouseclicked();
void mousehovered_data();
@@ -73,6 +76,7 @@ private:
void tst_QHorizontalBarSeries::initTestCase()
{
qRegisterMetaType<QBarSet*>("QBarSet*");
+ qRegisterMetaType<QAbstractBarSeries::LabelsPosition>("QAbstractBarSeries::LabelsPosition");
}
void tst_QHorizontalBarSeries::cleanupTestCase()
@@ -308,6 +312,60 @@ void tst_QHorizontalBarSeries::setLabelsVisible()
QVERIFY(m_barseries_with_sets->isLabelsVisible() == true);
}
+void tst_QHorizontalBarSeries::setLabelsFormat()
+{
+ QSignalSpy labelsFormatSpy(m_barseries, SIGNAL(labelsFormatChanged(QString)));
+ QCOMPARE(m_barseries->labelsFormat(), QString());
+
+ QString format("(@value)");
+ m_barseries->setLabelsFormat(format);
+ TRY_COMPARE(labelsFormatSpy.count(), 1);
+ QList<QVariant> arguments = labelsFormatSpy.takeFirst();
+ QVERIFY(arguments.at(0).toString() == format);
+ QCOMPARE(m_barseries->labelsFormat(), format);
+
+ m_barseries->setLabelsFormat(QString());
+ TRY_COMPARE(labelsFormatSpy.count(), 1);
+ arguments = labelsFormatSpy.takeFirst();
+ QVERIFY(arguments.at(0).toString() == QString());
+ QCOMPARE(m_barseries->labelsFormat(), QString());
+}
+
+void tst_QHorizontalBarSeries::setLabelsPosition()
+{
+ QSignalSpy labelsPositionSpy(m_barseries,
+ SIGNAL(labelsPositionChanged(QAbstractBarSeries::LabelsPosition)));
+ QCOMPARE(m_barseries->labelsPosition(), QHorizontalBarSeries::LabelsCenter);
+
+ m_barseries->setLabelsPosition(QHorizontalBarSeries::LabelsInsideEnd);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ QList<QVariant> arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QHorizontalBarSeries::LabelsInsideEnd);
+ QCOMPARE(m_barseries->labelsPosition(), QHorizontalBarSeries::LabelsInsideEnd);
+
+ m_barseries->setLabelsPosition(QHorizontalBarSeries::LabelsInsideBase);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QHorizontalBarSeries::LabelsInsideBase);
+ QCOMPARE(m_barseries->labelsPosition(), QHorizontalBarSeries::LabelsInsideBase);
+
+ m_barseries->setLabelsPosition(QHorizontalBarSeries::LabelsOutsideEnd);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QHorizontalBarSeries::LabelsOutsideEnd);
+ QCOMPARE(m_barseries->labelsPosition(), QHorizontalBarSeries::LabelsOutsideEnd);
+
+ m_barseries->setLabelsPosition(QHorizontalBarSeries::LabelsCenter);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QHorizontalBarSeries::LabelsCenter);
+ QCOMPARE(m_barseries->labelsPosition(), QHorizontalBarSeries::LabelsCenter);
+}
+
void tst_QHorizontalBarSeries::mouseclicked_data()
{
diff --git a/tests/auto/qhorizontalpercentbarseries/tst_qhorizontalpercentbarseries.cpp b/tests/auto/qhorizontalpercentbarseries/tst_qhorizontalpercentbarseries.cpp
index 1812196d..7ff2181a 100644
--- a/tests/auto/qhorizontalpercentbarseries/tst_qhorizontalpercentbarseries.cpp
+++ b/tests/auto/qhorizontalpercentbarseries/tst_qhorizontalpercentbarseries.cpp
@@ -28,6 +28,7 @@
QTCOMMERCIALCHART_USE_NAMESPACE
Q_DECLARE_METATYPE(QBarSet*)
+Q_DECLARE_METATYPE(QAbstractBarSeries::LabelsPosition)
class tst_QHorizontalPercentBarSeries : public QObject
{
@@ -44,6 +45,8 @@ private slots:
void qhorizontalpercentbarseries();
void type_data();
void type();
+ void setLabelsFormat();
+ void setLabelsPosition();
void mouseclicked_data();
void mouseclicked();
void mousehovered_data();
@@ -56,6 +59,7 @@ private:
void tst_QHorizontalPercentBarSeries::initTestCase()
{
qRegisterMetaType<QBarSet*>("QBarSet*");
+ qRegisterMetaType<QAbstractBarSeries::LabelsPosition>("QAbstractBarSeries::LabelsPosition");
}
void tst_QHorizontalPercentBarSeries::cleanupTestCase()
@@ -93,6 +97,60 @@ void tst_QHorizontalPercentBarSeries::type()
QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeHorizontalPercentBar);
}
+void tst_QHorizontalPercentBarSeries::setLabelsFormat()
+{
+ QSignalSpy labelsFormatSpy(m_barseries, SIGNAL(labelsFormatChanged(QString)));
+ QCOMPARE(m_barseries->labelsFormat(), QString());
+
+ QString format("(@value)");
+ m_barseries->setLabelsFormat(format);
+ TRY_COMPARE(labelsFormatSpy.count(), 1);
+ QList<QVariant> arguments = labelsFormatSpy.takeFirst();
+ QVERIFY(arguments.at(0).toString() == format);
+ QCOMPARE(m_barseries->labelsFormat(), format);
+
+ m_barseries->setLabelsFormat(QString());
+ TRY_COMPARE(labelsFormatSpy.count(), 1);
+ arguments = labelsFormatSpy.takeFirst();
+ QVERIFY(arguments.at(0).toString() == QString());
+ QCOMPARE(m_barseries->labelsFormat(), QString());
+}
+
+void tst_QHorizontalPercentBarSeries::setLabelsPosition()
+{
+ QSignalSpy labelsPositionSpy(m_barseries,
+ SIGNAL(labelsPositionChanged(QAbstractBarSeries::LabelsPosition)));
+ QCOMPARE(m_barseries->labelsPosition(), QHorizontalPercentBarSeries::LabelsCenter);
+
+ m_barseries->setLabelsPosition(QHorizontalPercentBarSeries::LabelsInsideEnd);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ QList<QVariant> arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QHorizontalPercentBarSeries::LabelsInsideEnd);
+ QCOMPARE(m_barseries->labelsPosition(), QHorizontalPercentBarSeries::LabelsInsideEnd);
+
+ m_barseries->setLabelsPosition(QHorizontalPercentBarSeries::LabelsInsideBase);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QHorizontalPercentBarSeries::LabelsInsideBase);
+ QCOMPARE(m_barseries->labelsPosition(), QHorizontalPercentBarSeries::LabelsInsideBase);
+
+ m_barseries->setLabelsPosition(QHorizontalPercentBarSeries::LabelsOutsideEnd);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QHorizontalPercentBarSeries::LabelsOutsideEnd);
+ QCOMPARE(m_barseries->labelsPosition(), QHorizontalPercentBarSeries::LabelsOutsideEnd);
+
+ m_barseries->setLabelsPosition(QHorizontalPercentBarSeries::LabelsCenter);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QHorizontalPercentBarSeries::LabelsCenter);
+ QCOMPARE(m_barseries->labelsPosition(), QHorizontalPercentBarSeries::LabelsCenter);
+}
+
void tst_QHorizontalPercentBarSeries::mouseclicked_data()
{
diff --git a/tests/auto/qhorizontalstackedbarseries/tst_qhorizontalstackedbarseries.cpp b/tests/auto/qhorizontalstackedbarseries/tst_qhorizontalstackedbarseries.cpp
index f1940c6d..b25df764 100644
--- a/tests/auto/qhorizontalstackedbarseries/tst_qhorizontalstackedbarseries.cpp
+++ b/tests/auto/qhorizontalstackedbarseries/tst_qhorizontalstackedbarseries.cpp
@@ -28,6 +28,7 @@
QTCOMMERCIALCHART_USE_NAMESPACE
Q_DECLARE_METATYPE(QBarSet*)
+Q_DECLARE_METATYPE(QAbstractBarSeries::LabelsPosition)
class tst_QHorizontalStackedBarSeries : public QObject
{
@@ -44,6 +45,8 @@ private slots:
void qhorizontalstackedbarseries();
void type_data();
void type();
+ void setLabelsFormat();
+ void setLabelsPosition();
void mouseclicked_data();
void mouseclicked();
void mousehovered_data();
@@ -56,6 +59,7 @@ private:
void tst_QHorizontalStackedBarSeries::initTestCase()
{
qRegisterMetaType<QBarSet*>("QBarSet*");
+ qRegisterMetaType<QAbstractBarSeries::LabelsPosition>("QAbstractBarSeries::LabelsPosition");
}
void tst_QHorizontalStackedBarSeries::cleanupTestCase()
@@ -93,6 +97,60 @@ void tst_QHorizontalStackedBarSeries::type()
QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeHorizontalStackedBar);
}
+void tst_QHorizontalStackedBarSeries::setLabelsFormat()
+{
+ QSignalSpy labelsFormatSpy(m_barseries, SIGNAL(labelsFormatChanged(QString)));
+ QCOMPARE(m_barseries->labelsFormat(), QString());
+
+ QString format("(@value)");
+ m_barseries->setLabelsFormat(format);
+ TRY_COMPARE(labelsFormatSpy.count(), 1);
+ QList<QVariant> arguments = labelsFormatSpy.takeFirst();
+ QVERIFY(arguments.at(0).toString() == format);
+ QCOMPARE(m_barseries->labelsFormat(), format);
+
+ m_barseries->setLabelsFormat(QString());
+ TRY_COMPARE(labelsFormatSpy.count(), 1);
+ arguments = labelsFormatSpy.takeFirst();
+ QVERIFY(arguments.at(0).toString() == QString());
+ QCOMPARE(m_barseries->labelsFormat(), QString());
+}
+
+void tst_QHorizontalStackedBarSeries::setLabelsPosition()
+{
+ QSignalSpy labelsPositionSpy(m_barseries,
+ SIGNAL(labelsPositionChanged(QAbstractBarSeries::LabelsPosition)));
+ QCOMPARE(m_barseries->labelsPosition(), QHorizontalStackedBarSeries::LabelsCenter);
+
+ m_barseries->setLabelsPosition(QHorizontalStackedBarSeries::LabelsInsideEnd);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ QList<QVariant> arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QHorizontalStackedBarSeries::LabelsInsideEnd);
+ QCOMPARE(m_barseries->labelsPosition(), QHorizontalStackedBarSeries::LabelsInsideEnd);
+
+ m_barseries->setLabelsPosition(QHorizontalStackedBarSeries::LabelsInsideBase);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QHorizontalStackedBarSeries::LabelsInsideBase);
+ QCOMPARE(m_barseries->labelsPosition(), QHorizontalStackedBarSeries::LabelsInsideBase);
+
+ m_barseries->setLabelsPosition(QHorizontalStackedBarSeries::LabelsOutsideEnd);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QHorizontalStackedBarSeries::LabelsOutsideEnd);
+ QCOMPARE(m_barseries->labelsPosition(), QHorizontalStackedBarSeries::LabelsOutsideEnd);
+
+ m_barseries->setLabelsPosition(QHorizontalStackedBarSeries::LabelsCenter);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QHorizontalStackedBarSeries::LabelsCenter);
+ QCOMPARE(m_barseries->labelsPosition(), QHorizontalStackedBarSeries::LabelsCenter);
+}
+
void tst_QHorizontalStackedBarSeries::mouseclicked_data()
{
diff --git a/tests/auto/qlineseries/tst_qlineseries.cpp b/tests/auto/qlineseries/tst_qlineseries.cpp
index 0781932c..4d270619 100644
--- a/tests/auto/qlineseries/tst_qlineseries.cpp
+++ b/tests/auto/qlineseries/tst_qlineseries.cpp
@@ -75,6 +75,8 @@ void tst_QLineSeries::qlineseries()
QCOMPARE(series.points(), QList<QPointF>());
QCOMPARE(series.pen(), QPen());
QCOMPARE(series.pointsVisible(), false);
+ QCOMPARE(series.pointLabelsVisible(), false);
+ QCOMPARE(series.pointLabelsFormat(), QLatin1String("@xPoint, @yPoint"));
series.append(QList<QPointF>());
series.append(0.0,0.0);
@@ -91,6 +93,9 @@ void tst_QLineSeries::qlineseries()
series.setPen(QPen());
series.setPointsVisible(false);
+ series.setPointLabelsVisible(false);
+ series.setPointLabelsFormat(QString());
+
m_chart->addSeries(&series);
m_view->show();
QTest::qWaitForWindowShown(m_view);
diff --git a/tests/auto/qml-qtquicktest/tst_barseries.qml b/tests/auto/qml-qtquicktest/tst_barseries.qml
index 169a749f..c5a5cfb7 100644
--- a/tests/auto/qml-qtquicktest/tst_barseries.qml
+++ b/tests/auto/qml-qtquicktest/tst_barseries.qml
@@ -34,6 +34,7 @@ Rectangle {
function test_properties() {
compare(barSeries.barWidth, 0.5);
compare(barSeries.labelsVisible, false);
+ compare(barSeries.labelsPosition, BarSeries.LabelsCenter);
}
function test_setproperties() {
@@ -92,6 +93,12 @@ Rectangle {
compare(barSeries.count, 0);
}
+ function test_signals() {
+ labelsPositionSpy.clear();
+ barSeries.labelsPosition = BarSeries.LabelsOutsideEnd;
+ compare(labelsPositionSpy.count, 1, "onLabelsPositionChanged")
+ }
+
function test_remove() {
var setCount = 5;
var valueCount = 50;
@@ -136,6 +143,11 @@ Rectangle {
target: barSeries
signalName: "barsetsRemoved"
}
+ SignalSpy {
+ id: labelsPositionSpy
+ target: barSeries
+ signalName: "labelsPositionChanged"
+ }
}
StackedBarSeries {
diff --git a/tests/auto/qpercentbarseries/tst_qpercentbarseries.cpp b/tests/auto/qpercentbarseries/tst_qpercentbarseries.cpp
index 569e72e1..2d0cef96 100644
--- a/tests/auto/qpercentbarseries/tst_qpercentbarseries.cpp
+++ b/tests/auto/qpercentbarseries/tst_qpercentbarseries.cpp
@@ -28,6 +28,7 @@
QTCOMMERCIALCHART_USE_NAMESPACE
Q_DECLARE_METATYPE(QBarSet*)
+Q_DECLARE_METATYPE(QAbstractBarSeries::LabelsPosition)
class tst_QPercentBarSeries : public QObject
{
@@ -44,6 +45,8 @@ private slots:
void qpercentbarseries();
void type_data();
void type();
+ void setLabelsFormat();
+ void setLabelsPosition();
void mouseclicked_data();
void mouseclicked();
void mousehovered_data();
@@ -56,6 +59,7 @@ private:
void tst_QPercentBarSeries::initTestCase()
{
qRegisterMetaType<QBarSet*>("QBarSet*");
+ qRegisterMetaType<QAbstractBarSeries::LabelsPosition>("QAbstractBarSeries::LabelsPosition");
}
void tst_QPercentBarSeries::cleanupTestCase()
@@ -98,6 +102,60 @@ void tst_QPercentBarSeries::mouseclicked_data()
}
+void tst_QPercentBarSeries::setLabelsFormat()
+{
+ QSignalSpy labelsFormatSpy(m_barseries, SIGNAL(labelsFormatChanged(QString)));
+ QCOMPARE(m_barseries->labelsFormat(), QString());
+
+ QString format("(@value)");
+ m_barseries->setLabelsFormat(format);
+ TRY_COMPARE(labelsFormatSpy.count(), 1);
+ QList<QVariant> arguments = labelsFormatSpy.takeFirst();
+ QVERIFY(arguments.at(0).toString() == format);
+ QCOMPARE(m_barseries->labelsFormat(), format);
+
+ m_barseries->setLabelsFormat(QString());
+ TRY_COMPARE(labelsFormatSpy.count(), 1);
+ arguments = labelsFormatSpy.takeFirst();
+ QVERIFY(arguments.at(0).toString() == QString());
+ QCOMPARE(m_barseries->labelsFormat(), QString());
+}
+
+void tst_QPercentBarSeries::setLabelsPosition()
+{
+ QSignalSpy labelsPositionSpy(m_barseries,
+ SIGNAL(labelsPositionChanged(QAbstractBarSeries::LabelsPosition)));
+ QCOMPARE(m_barseries->labelsPosition(), QPercentBarSeries::LabelsCenter);
+
+ m_barseries->setLabelsPosition(QPercentBarSeries::LabelsInsideEnd);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ QList<QVariant> arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QPercentBarSeries::LabelsInsideEnd);
+ QCOMPARE(m_barseries->labelsPosition(), QPercentBarSeries::LabelsInsideEnd);
+
+ m_barseries->setLabelsPosition(QPercentBarSeries::LabelsInsideBase);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QPercentBarSeries::LabelsInsideBase);
+ QCOMPARE(m_barseries->labelsPosition(), QPercentBarSeries::LabelsInsideBase);
+
+ m_barseries->setLabelsPosition(QPercentBarSeries::LabelsOutsideEnd);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QPercentBarSeries::LabelsOutsideEnd);
+ QCOMPARE(m_barseries->labelsPosition(), QPercentBarSeries::LabelsOutsideEnd);
+
+ m_barseries->setLabelsPosition(QPercentBarSeries::LabelsCenter);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QPercentBarSeries::LabelsCenter);
+ QCOMPARE(m_barseries->labelsPosition(), QPercentBarSeries::LabelsCenter);
+}
+
void tst_QPercentBarSeries::mouseclicked()
{
SKIP_IF_CANNOT_TEST_MOUSE_EVENTS();
diff --git a/tests/auto/qstackedbarseries/tst_qstackedbarseries.cpp b/tests/auto/qstackedbarseries/tst_qstackedbarseries.cpp
index 6e848a24..6285aaa1 100644
--- a/tests/auto/qstackedbarseries/tst_qstackedbarseries.cpp
+++ b/tests/auto/qstackedbarseries/tst_qstackedbarseries.cpp
@@ -28,6 +28,7 @@
QTCOMMERCIALCHART_USE_NAMESPACE
Q_DECLARE_METATYPE(QBarSet*)
+Q_DECLARE_METATYPE(QAbstractBarSeries::LabelsPosition)
class tst_QStackedBarSeries : public QObject
{
@@ -44,6 +45,8 @@ private slots:
void qstackedbarseries();
void type_data();
void type();
+ void setLabelsFormat();
+ void setLabelsPosition();
void mouseclicked_data();
void mouseclicked();
void mousehovered_data();
@@ -56,6 +59,7 @@ private:
void tst_QStackedBarSeries::initTestCase()
{
qRegisterMetaType<QBarSet*>("QBarSet*");
+ qRegisterMetaType<QAbstractBarSeries::LabelsPosition>("QAbstractBarSeries::LabelsPosition");
}
void tst_QStackedBarSeries::cleanupTestCase()
@@ -93,6 +97,60 @@ void tst_QStackedBarSeries::type()
QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeStackedBar);
}
+void tst_QStackedBarSeries::setLabelsFormat()
+{
+ QSignalSpy labelsFormatSpy(m_barseries, SIGNAL(labelsFormatChanged(QString)));
+ QCOMPARE(m_barseries->labelsFormat(), QString());
+
+ QString format("(@value)");
+ m_barseries->setLabelsFormat(format);
+ TRY_COMPARE(labelsFormatSpy.count(), 1);
+ QList<QVariant> arguments = labelsFormatSpy.takeFirst();
+ QVERIFY(arguments.at(0).toString() == format);
+ QCOMPARE(m_barseries->labelsFormat(), format);
+
+ m_barseries->setLabelsFormat(QString());
+ TRY_COMPARE(labelsFormatSpy.count(), 1);
+ arguments = labelsFormatSpy.takeFirst();
+ QVERIFY(arguments.at(0).toString() == QString());
+ QCOMPARE(m_barseries->labelsFormat(), QString());
+}
+
+void tst_QStackedBarSeries::setLabelsPosition()
+{
+ QSignalSpy labelsPositionSpy(m_barseries,
+ SIGNAL(labelsPositionChanged(QAbstractBarSeries::LabelsPosition)));
+ QCOMPARE(m_barseries->labelsPosition(), QStackedBarSeries::LabelsCenter);
+
+ m_barseries->setLabelsPosition(QStackedBarSeries::LabelsInsideEnd);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ QList<QVariant> arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QStackedBarSeries::LabelsInsideEnd);
+ QCOMPARE(m_barseries->labelsPosition(), QStackedBarSeries::LabelsInsideEnd);
+
+ m_barseries->setLabelsPosition(QStackedBarSeries::LabelsInsideBase);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QStackedBarSeries::LabelsInsideBase);
+ QCOMPARE(m_barseries->labelsPosition(), QStackedBarSeries::LabelsInsideBase);
+
+ m_barseries->setLabelsPosition(QStackedBarSeries::LabelsOutsideEnd);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QStackedBarSeries::LabelsOutsideEnd);
+ QCOMPARE(m_barseries->labelsPosition(), QStackedBarSeries::LabelsOutsideEnd);
+
+ m_barseries->setLabelsPosition(QStackedBarSeries::LabelsCenter);
+ TRY_COMPARE(labelsPositionSpy.count(), 1);
+ arguments = labelsPositionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QAbstractBarSeries::LabelsPosition>()
+ == QStackedBarSeries::LabelsCenter);
+ QCOMPARE(m_barseries->labelsPosition(), QStackedBarSeries::LabelsCenter);
+}
+
void tst_QStackedBarSeries::mouseclicked_data()
{
diff --git a/tests/auto/qxyseries/tst_qxyseries.cpp b/tests/auto/qxyseries/tst_qxyseries.cpp
index 34c4f5fe..c0721a35 100644
--- a/tests/auto/qxyseries/tst_qxyseries.cpp
+++ b/tests/auto/qxyseries/tst_qxyseries.cpp
@@ -81,6 +81,78 @@ void tst_QXYSeries::seriesOpacity()
QCOMPARE(opacitySpy.count(), 3);
}
+void tst_QXYSeries::pointLabelsFormat()
+{
+ QSignalSpy labelsFormatSpy(m_series, SIGNAL(pointLabelsFormatChanged(QString)));
+ QCOMPARE(m_series->pointLabelsFormat(), QLatin1String("@xPoint, @yPoint"));
+
+ QString format("@yPoint");
+ m_series->setPointLabelsFormat(format);
+ TRY_COMPARE(labelsFormatSpy.count(), 1);
+ QList<QVariant> arguments = labelsFormatSpy.takeFirst();
+ QVERIFY(arguments.at(0).toString() == format);
+
+ m_series->setPointLabelsFormat(QString());
+ TRY_COMPARE(labelsFormatSpy.count(), 1);
+ arguments = labelsFormatSpy.takeFirst();
+ QVERIFY(arguments.at(0).toString() == QString());
+
+}
+
+void tst_QXYSeries::pointLabelsVisible()
+{
+ QSignalSpy labelsVisibleSpy(m_series, SIGNAL(pointLabelsVisibilityChanged(bool)));
+ QCOMPARE(m_series->pointLabelsVisible(), false);
+
+ m_series->setPointLabelsVisible();
+ QCOMPARE(m_series->pointLabelsVisible(), true);
+ TRY_COMPARE(labelsVisibleSpy.count(), 1);
+ QList<QVariant> arguments = labelsVisibleSpy.takeFirst();
+ QVERIFY(arguments.at(0).toBool() == true);
+
+ m_series->setPointLabelsVisible(false);
+ QCOMPARE(m_series->pointLabelsVisible(), false);
+ TRY_COMPARE(labelsVisibleSpy.count(), 1);
+ arguments = labelsVisibleSpy.takeFirst();
+ QVERIFY(arguments.at(0).toBool() == false);
+}
+
+void tst_QXYSeries::pointLabelsFont()
+{
+ QFont defaultFont(m_series->pointLabelsFont());
+ QSignalSpy labelsFontSpy(m_series, SIGNAL(pointLabelsFontChanged(QFont)));
+
+ QFont font("Times", 10);
+ m_series->setPointLabelsFont(font);
+ TRY_COMPARE(labelsFontSpy.count(), 1);
+ QList<QVariant> arguments = labelsFontSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QFont>() == font);
+
+ m_series->setPointLabelsFont(defaultFont);
+ TRY_COMPARE(labelsFontSpy.count(), 1);
+ arguments = labelsFontSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QFont>() == defaultFont);
+
+}
+
+void tst_QXYSeries::pointLabelsColor()
+{
+ QColor defaultColor(QPen().color());
+ QSignalSpy labelsColorSpy(m_series, SIGNAL(pointLabelsColorChanged(QColor)));
+ QCOMPARE(m_series->pointLabelsColor(), defaultColor);
+
+ QColor color(Qt::blue);
+ m_series->setPointLabelsColor(color);
+ TRY_COMPARE(labelsColorSpy.count(), 1);
+ QList<QVariant> arguments = labelsColorSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QColor>() == color);
+
+ m_series->setPointLabelsColor(defaultColor);
+ TRY_COMPARE(labelsColorSpy.count(), 1);
+ arguments = labelsColorSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<QColor>() == defaultColor);
+}
+
void tst_QXYSeries::append_data()
{
QTest::addColumn< QList<QPointF> >("points");
diff --git a/tests/auto/qxyseries/tst_qxyseries.h b/tests/auto/qxyseries/tst_qxyseries.h
index 701f6829..0fad782c 100644
--- a/tests/auto/qxyseries/tst_qxyseries.h
+++ b/tests/auto/qxyseries/tst_qxyseries.h
@@ -42,6 +42,10 @@ public slots:
private slots:
void seriesName();
void seriesVisible();
+ void pointLabelsFormat();
+ void pointLabelsVisible();
+ void pointLabelsFont();
+ void pointLabelsColor();
void seriesOpacity();
void oper_data();
void oper();
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/AreaChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/AreaChart.qml
index 51c37caa..46959f7d 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/AreaChart.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/AreaChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 1.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "area series"
@@ -61,6 +61,8 @@ ChartView {
XYPoint { x: 11; y: 0 }
}
+ pointLabelsFormat: "@xPoint, @yPoint";
+
onNameChanged: console.log(name + ".onNameChanged: " + name);
onVisibleChanged: console.log(name + ".onVisibleChanged: " + visible);
onOpacityChanged: console.log(name + ".onOpacityChanged: " + opacity);
@@ -71,6 +73,14 @@ ChartView {
onBorderWidthChanged: console.log(name + ".onBorderChanged: " + borderWidth);
// onCountChanged: console.log(name + ".onCountChanged: " + count);
onHovered: console.log("lineSeries.onHovered:" + point.x + "," + point.y + " " + state);
+ onPointLabelsVisibilityChanged: console.log(name + ".onPointLabelsVisibilityChanged: "
+ + visible);
+ onPointLabelsFormatChanged: console.log(name + ".onPointLabelsFormatChanged: "
+ + format);
+ onPointLabelsFontChanged: console.log(name + ".onPointLabelsFontChanged: "
+ + font.family);
+ onPointLabelsColorChanged: console.log(name + ".onPointLabelsColorChanged: "
+ + color);
}
AreaSeries {
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml
index d7b34787..69b2761a 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml
@@ -55,6 +55,32 @@ Flow {
onClicked: series.borderWidth -= 0.5;
}
Button {
+ text: "point labels visible"
+ onClicked: series.pointLabelsVisible = !series.pointLabelsVisible;
+ }
+ Button {
+ text: "point labels format"
+ onClicked: {
+ if (series.pointLabelsFormat === "@xPoint, @yPoint")
+ series.pointLabelsFormat = "(@xPoint)"
+ else
+ series.pointLabelsFormat = "@xPoint, @yPoint"
+ }
+ }
+ Button {
+ text: "point labels font"
+ onClicked: {
+ if (series.pointLabelsFont.family === "Times")
+ series.pointLabelsFont.family = "Courier";
+ else
+ series.pointLabelsFont.family = "Times";
+ }
+ }
+ Button {
+ text: "point labels color"
+ onClicked: series.pointLabelsColor = main.nextColor();
+ }
+ Button {
id: upperButton
text: "upper series"
unpressedColor: "#79bd8f"
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml
index a7fc4895..d0e34326 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 1.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "Bar series"
@@ -34,6 +34,7 @@ ChartView {
BarSeries {
id: mySeries
name: "bar"
+ labelsFormat: "@value";
axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6]
onClicked: console.log("barset.onClicked: " + index);
@@ -62,5 +63,14 @@ ChartView {
+ " " + index);
onLabelsVisibleChanged: console.log("barSeries.onLabelsVisibleChanged: " + series.labelsVisible);
onCountChanged: console.log("barSeries.onCountChanged: " + count);
+ onLabelsFormatChanged: console.log("barSeries.onLabelsFormatChanged: " + format);
+ onLabelsPositionChanged: console.log("barSeries.onLabelsPositionChanged: " + series.labelsPosition);
+
+ function changeLabelsPosition() {
+ if (labelsPosition === BarSeries.LabelsCenter)
+ labelsPosition = BarSeries.LabelsInsideEnd;
+ else
+ labelsPosition = BarSeries.LabelsCenter;
+ }
}
}
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml
index 1a4cad6c..439d7f9e 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml
@@ -172,6 +172,19 @@ Row {
onClicked: series.labelsVisible = !series.labelsVisible;
}
Button {
+ text: "labels format"
+ onClicked: {
+ if (series.labelsFormat === "@value")
+ series.labelsFormat = "@value%"
+ else
+ series.labelsFormat = "@value"
+ }
+ }
+ Button {
+ text: "labels position"
+ onClicked: series.changeLabelsPosition();
+ }
+ Button {
text: "set 1 label color"
onClicked: series.at(0).labelColor = main.nextColor();
}
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalBarChart.qml
index 7ceaa96d..7d24d2e6 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalBarChart.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalBarChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 1.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "Bar series"
@@ -33,6 +33,7 @@ ChartView {
HorizontalBarSeries {
id: mySeries
name: "bar"
+ labelsFormat: "@value";
axisY: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6]
onClicked: console.log("barset.onClicked: " + index);
@@ -61,5 +62,16 @@ ChartView {
+ status + " " + index);
onLabelsVisibleChanged: console.log("horizontalBarSeries.onLabelsVisibleChanged: " + series.labelsVisible);
onCountChanged: console.log("horizontalBarSeries.onCountChanged: " + count);
+ onLabelsFormatChanged: console.log("horizontalBarSeries.onLabelsFormatChanged: "
+ + format);
+ onLabelsPositionChanged: console.log("horizontalBarSeries.onLabelsPositionChanged: "
+ + series.labelsPosition);
+
+ function changeLabelsPosition() {
+ if (labelsPosition === BarSeries.LabelsCenter)
+ labelsPosition = BarSeries.LabelsInsideEnd;
+ else
+ labelsPosition = BarSeries.LabelsCenter;
+ }
}
}
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalPercentBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalPercentBarChart.qml
index 2ea99639..70324888 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalPercentBarChart.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalPercentBarChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 1.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "Percent bar series"
@@ -61,5 +61,18 @@ ChartView {
+ " " + status + " " + index);
onLabelsVisibleChanged: console.log("horizontalPercentBarSeries.onLabelsVisibleChanged: " + series.labelsVisible);
onCountChanged: console.log("horizontalPercentBarSeries.onCountChanged: " + count);
+ onLabelsFormatChanged: console.log(
+ "horizontalPercentBarSeries.onLabelsFormatChanged: "
+ + format);
+ onLabelsPositionChanged: console.log(
+ "horizontalPercentBarSeries.onLabelsPositionChanged: "
+ + series.labelsPosition);
+
+ function changeLabelsPosition() {
+ if (labelsPosition === BarSeries.LabelsCenter)
+ labelsPosition = BarSeries.LabelsInsideEnd;
+ else
+ labelsPosition = BarSeries.LabelsCenter;
+ }
}
}
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalStackedBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalStackedBarChart.qml
index fc651866..0367037b 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalStackedBarChart.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalStackedBarChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 1.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "Stacked bar series"
@@ -33,6 +33,7 @@ ChartView {
HorizontalStackedBarSeries {
id: mySeries
name: "bar"
+ labelsFormat: "@value";
axisY: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6]
onClicked: console.log("barset.onClicked: " + index);
@@ -61,5 +62,18 @@ ChartView {
+ " " + status + " " + index);
onLabelsVisibleChanged: console.log("horizontalStackedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible);
onCountChanged: console.log("horizontalStackedBarSeries.onCountChanged: " + count);
+ onLabelsFormatChanged: console.log(
+ "horizontalStackedBarSeries.onLabelsFormatChanged: "
+ + format);
+ onLabelsPositionChanged: console.log(
+ "horizontalStackedBarSeries.onLabelsPositionChanged: "
+ + series.labelsPosition);
+
+ function changeLabelsPosition() {
+ if (labelsPosition === BarSeries.LabelsCenter)
+ labelsPosition = BarSeries.LabelsInsideEnd;
+ else
+ labelsPosition = BarSeries.LabelsCenter;
+ }
}
}
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/LineChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/LineChart.qml
index 0402498a..dedeebcb 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/LineChart.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/LineChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 1.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
property variant series: lineSeries
@@ -39,6 +39,8 @@ ChartView {
XYPoint { x: 3.4; y: 3.0 }
XYPoint { x: 4.1; y: 3.3 }
+ pointLabelsFormat: "@xPoint, @yPoint";
+
onNameChanged: console.log("lineSeries.onNameChanged: " + name);
onVisibleChanged: console.log("lineSeries.onVisibleChanged: " + visible);
onOpacityChanged: console.log(name + ".onOpacityChanged: " + opacity);
@@ -52,6 +54,14 @@ ChartView {
onCapStyleChanged: console.log("lineSeries.onCapStyleChanged: " + capStyle);
onCountChanged: console.log("lineSeries.onCountChanged: " + count);
onHovered: console.log("lineSeries.onHovered:" + point.x + "," + point.y + " " + state);
+ onPointLabelsVisibilityChanged: console.log("lineSeries.onPointLabelsVisibilityChanged: "
+ + visible);
+ onPointLabelsFormatChanged: console.log("lineSeries.onPointLabelsFormatChanged: "
+ + format);
+ onPointLabelsFontChanged: console.log("lineSeries.onPointLabelsFontChanged: "
+ + font.family);
+ onPointLabelsColorChanged: console.log("lineSeries.onPointLabelsColorChanged: "
+ + color);
}
LineSeries {
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml
index 526bffc7..f49dddcc 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml
@@ -72,6 +72,32 @@ Flow {
onClicked: series.pointsVisible = !series.pointsVisible;
}
Button {
+ text: "point labels visible"
+ onClicked: series.pointLabelsVisible = !series.pointLabelsVisible;
+ }
+ Button {
+ text: "point labels format"
+ onClicked: {
+ if (series.pointLabelsFormat === "@xPoint, @yPoint")
+ series.pointLabelsFormat = "(@xPoint)"
+ else
+ series.pointLabelsFormat = "@xPoint, @yPoint"
+ }
+ }
+ Button {
+ text: "point labels font"
+ onClicked: {
+ if (series.pointLabelsFont.family === "Times")
+ series.pointLabelsFont.family = "Courier";
+ else
+ series.pointLabelsFont.family = "Times";
+ }
+ }
+ Button {
+ text: "point labels color"
+ onClicked: series.pointLabelsColor = main.nextColor();
+ }
+ Button {
text: "append point"
onClicked: series.append(series.count - 1, series.count - 1);
}
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml
index ce138c3a..a9879c59 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 1.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "Percent bar series"
@@ -33,6 +33,7 @@ ChartView {
PercentBarSeries {
id: mySeries
name: "bar"
+ labelsFormat: "@value";
axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6]
@@ -62,5 +63,16 @@ ChartView {
+ " " + status + " " + index);
onLabelsVisibleChanged: console.log("percentBarSeries.onLabelsVisibleChanged: " + series.labelsVisible);
onCountChanged: console.log("percentBarSeries.onCountChanged: " + count);
+ onLabelsFormatChanged: console.log("percentBarSeries.onLabelsFormatChanged: "
+ + format);
+ onLabelsPositionChanged: console.log("percentBarSeries.onLabelsPositionChanged: "
+ + series.labelsPosition);
+
+ function changeLabelsPosition() {
+ if (labelsPosition === BarSeries.LabelsCenter)
+ labelsPosition = BarSeries.LabelsInsideEnd;
+ else
+ labelsPosition = BarSeries.LabelsCenter;
+ }
}
}
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterChart.qml
index ebb34066..cd898914 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterChart.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 1.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "scatter series"
@@ -37,6 +37,8 @@ ChartView {
XYPoint { x: 2.1; y: 1.3 }
XYPoint { x: 2.5; y: 2.1 }
+ pointLabelsFormat: "@xPoint, @yPoint";
+
onNameChanged: console.log("scatterSeries.onNameChanged: " + name);
onVisibleChanged: console.log("scatterSeries.onVisibleChanged: " + visible);
onOpacityChanged: console.log(name + ".onOpacityChanged: " + opacity);
@@ -48,6 +50,14 @@ ChartView {
onBorderColorChanged: console.log("scatterSeries.onBorderColorChanged: " + borderColor);
onBorderWidthChanged: console.log("scatterSeries.onBorderChanged: " + borderWidth);
onCountChanged: console.log("scatterSeries.onCountChanged: " + count);
+ onPointLabelsVisibilityChanged: console.log("lineSeries.onPointLabelsVisibilityChanged: "
+ + visible);
+ onPointLabelsFormatChanged: console.log("lineSeries.onPointLabelsFormatChanged: "
+ + format);
+ onPointLabelsFontChanged: console.log("lineSeries.onPointLabelsFontChanged: "
+ + font.family);
+ onPointLabelsColorChanged: console.log("lineSeries.onPointLabelsColorChanged: "
+ + color);
}
ScatterSeries {
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml
index 75ae9465..753ab197 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml
@@ -67,6 +67,32 @@ Flow {
onClicked: series.markerShape = ((series.markerShape + 1) % 2);
}
Button {
+ text: "point labels visible"
+ onClicked: series.pointLabelsVisible = !series.pointLabelsVisible;
+ }
+ Button {
+ text: "point labels format"
+ onClicked: {
+ if (series.pointLabelsFormat === "@xPoint, @yPoint")
+ series.pointLabelsFormat = "(@xPoint)"
+ else
+ series.pointLabelsFormat = "@xPoint, @yPoint"
+ }
+ }
+ Button {
+ text: "point labels font"
+ onClicked: {
+ if (series.pointLabelsFont.family === "Times")
+ series.pointLabelsFont.family = "Courier";
+ else
+ series.pointLabelsFont.family = "Times";
+ }
+ }
+ Button {
+ text: "point labels color"
+ onClicked: series.pointLabelsColor = main.nextColor();
+ }
+ Button {
text: "append point"
onClicked: series.append(series.count - 1, series.count - 1);
}
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/SplineChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/SplineChart.qml
index 87d6fb55..5f534b97 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/SplineChart.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/SplineChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 1.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "spline series"
@@ -38,6 +38,8 @@ ChartView {
XYPoint { x: 3.4; y: 3.0 }
XYPoint { x: 4.1; y: 3.3 }
+ pointLabelsFormat: "@xPoint, @yPoint";
+
onNameChanged: console.log("splineSeries.onNameChanged: " + name);
onVisibleChanged: console.log("splineSeries.onVisibleChanged: " + visible);
onOpacityChanged: console.log(name + ".onOpacityChanged: " + opacity);
@@ -50,6 +52,14 @@ ChartView {
onStyleChanged: console.log("splineSeries.onStyleChanged: " + style);
onCapStyleChanged: console.log("splineSeries.onCapStyleChanged: " + capStyle);
onCountChanged: console.log("splineSeries.onCountChanged: " + count);
+ onPointLabelsVisibilityChanged: console.log("splineSeries.onPointLabelsVisibilityChanged: "
+ + visible);
+ onPointLabelsFormatChanged: console.log("splineSeries.onPointLabelsFormatChanged: "
+ + format);
+ onPointLabelsFontChanged: console.log("splineSeries.onPointLabelsFontChanged: "
+ + font.family);
+ onPointLabelsColorChanged: console.log("splineSeries.onPointLabelsColorChanged: "
+ + color);
}
SplineSeries {
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml
index 26d156b2..5757a95c 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 1.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "Stacked bar series"
@@ -33,6 +33,7 @@ ChartView {
StackedBarSeries {
id: mySeries
name: "bar"
+ labelsFormat: "@value";
axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6]
onClicked: console.log("barset.onClicked: " + index);
@@ -61,5 +62,16 @@ ChartView {
+ " " + status + " " + index);
onLabelsVisibleChanged: console.log("stackedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible);
onCountChanged: console.log("stackedBarSeries.onCountChanged: " + count);
+ onLabelsFormatChanged: console.log("stackedBarSeries.onLabelsFormatChanged: "
+ + format);
+ onLabelsPositionChanged: console.log("stackedBarSeries.onLabelsPositionChanged: "
+ + series.labelsPosition);
+
+ function changeLabelsPosition() {
+ if (labelsPosition === BarSeries.LabelsCenter)
+ labelsPosition = BarSeries.LabelsInsideEnd;
+ else
+ labelsPosition = BarSeries.LabelsCenter;
+ }
}
}
diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/AreaChart.qml b/tests/quick2chartproperties/qml/quick2chartproperties/AreaChart.qml
index f502fe80..c942b288 100644
--- a/tests/quick2chartproperties/qml/quick2chartproperties/AreaChart.qml
+++ b/tests/quick2chartproperties/qml/quick2chartproperties/AreaChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "area series"
@@ -61,6 +61,8 @@ ChartView {
XYPoint { x: 11; y: 0 }
}
+ pointLabelsFormat: "@xPoint, @yPoint";
+
onNameChanged: console.log(name + ".onNameChanged: " + name);
onVisibleChanged: console.log(name + ".onVisibleChanged: " + visible);
onOpacityChanged: console.log(name + ".onOpacityChanged: " + opacity);
@@ -71,6 +73,14 @@ ChartView {
onBorderWidthChanged: console.log(name + ".onBorderChanged: " + borderWidth);
// onCountChanged: console.log(name + ".onCountChanged: " + count);
onHovered: console.log("lineSeries.onHovered:" + point.x + "," + point.y + " " + state);
+ onPointLabelsVisibilityChanged: console.log(name + ".onPointLabelsVisibilityChanged: "
+ + visible);
+ onPointLabelsFormatChanged: console.log(name + ".onPointLabelsFormatChanged: "
+ + format);
+ onPointLabelsFontChanged: console.log(name + ".onPointLabelsFontChanged: "
+ + font.family);
+ onPointLabelsColorChanged: console.log(name + ".onPointLabelsColorChanged: "
+ + color);
}
AreaSeries {
diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/AreaEditor.qml b/tests/quick2chartproperties/qml/quick2chartproperties/AreaEditor.qml
index 249c7c28..168dc957 100644
--- a/tests/quick2chartproperties/qml/quick2chartproperties/AreaEditor.qml
+++ b/tests/quick2chartproperties/qml/quick2chartproperties/AreaEditor.qml
@@ -55,6 +55,32 @@ Flow {
onClicked: series.borderWidth -= 0.5;
}
Button {
+ text: "point labels visible"
+ onClicked: series.pointLabelsVisible = !series.pointLabelsVisible;
+ }
+ Button {
+ text: "point labels format"
+ onClicked: {
+ if (series.pointLabelsFormat === "@xPoint, @yPoint")
+ series.pointLabelsFormat = "(@xPoint)"
+ else
+ series.pointLabelsFormat = "@xPoint, @yPoint"
+ }
+ }
+ Button {
+ text: "point labels font"
+ onClicked: {
+ if (series.pointLabelsFont.family === "Times")
+ series.pointLabelsFont.family = "Courier";
+ else
+ series.pointLabelsFont.family = "Times";
+ }
+ }
+ Button {
+ text: "point labels color"
+ onClicked: series.pointLabelsColor = main.nextColor();
+ }
+ Button {
id: upperButton
text: "upper series"
unpressedColor: "#79bd8f"
diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/BarChart.qml b/tests/quick2chartproperties/qml/quick2chartproperties/BarChart.qml
index 1774ef41..8a91cdb8 100644
--- a/tests/quick2chartproperties/qml/quick2chartproperties/BarChart.qml
+++ b/tests/quick2chartproperties/qml/quick2chartproperties/BarChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "Bar series"
@@ -34,6 +34,7 @@ ChartView {
BarSeries {
id: mySeries
name: "bar"
+ labelsFormat: "@value";
axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6]
onClicked: console.log("barset.onClicked: " + index);
@@ -62,5 +63,14 @@ ChartView {
+ " " + index);
onLabelsVisibleChanged: console.log("barSeries.onLabelsVisibleChanged: " + series.labelsVisible);
onCountChanged: console.log("barSeries.onCountChanged: " + count);
+ onLabelsFormatChanged: console.log("barSeries.onLabelsFormatChanged: " + format);
+ onLabelsPositionChanged: console.log("barSeries.onLabelsPositionChanged: " + series.labelsPosition);
+
+ function changeLabelsPosition() {
+ if (labelsPosition === BarSeries.LabelsCenter)
+ labelsPosition = BarSeries.LabelsInsideEnd;
+ else
+ labelsPosition = BarSeries.LabelsCenter;
+ }
}
}
diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/BarEditor.qml b/tests/quick2chartproperties/qml/quick2chartproperties/BarEditor.qml
index 38b2e4b3..cdd847a5 100644
--- a/tests/quick2chartproperties/qml/quick2chartproperties/BarEditor.qml
+++ b/tests/quick2chartproperties/qml/quick2chartproperties/BarEditor.qml
@@ -172,6 +172,19 @@ Row {
onClicked: series.labelsVisible = !series.labelsVisible;
}
Button {
+ text: "labels format"
+ onClicked: {
+ if (series.labelsFormat === "@value")
+ series.labelsFormat = "@value%"
+ else
+ series.labelsFormat = "@value"
+ }
+ }
+ Button {
+ text: "labels position"
+ onClicked: series.changeLabelsPosition();
+ }
+ Button {
text: "set 1 label color"
onClicked: series.at(0).labelColor = main.nextColor();
}
diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/HorizontalBarChart.qml b/tests/quick2chartproperties/qml/quick2chartproperties/HorizontalBarChart.qml
index 42ba0c88..342995cf 100644
--- a/tests/quick2chartproperties/qml/quick2chartproperties/HorizontalBarChart.qml
+++ b/tests/quick2chartproperties/qml/quick2chartproperties/HorizontalBarChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "Bar series"
@@ -33,6 +33,7 @@ ChartView {
HorizontalBarSeries {
id: mySeries
name: "bar"
+ labelsFormat: "@value";
axisY: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6]
onClicked: console.log("barset.onClicked: " + index);
@@ -61,5 +62,16 @@ ChartView {
+ status + " " + index);
onLabelsVisibleChanged: console.log("horizontalBarSeries.onLabelsVisibleChanged: " + series.labelsVisible);
onCountChanged: console.log("horizontalBarSeries.onCountChanged: " + count);
+ onLabelsFormatChanged: console.log("horizontalBarSeries.onLabelsFormatChanged: "
+ + format);
+ onLabelsPositionChanged: console.log("horizontalBarSeries.onLabelsPositionChanged: "
+ + series.labelsPosition);
+
+ function changeLabelsPosition() {
+ if (labelsPosition === BarSeries.LabelsCenter)
+ labelsPosition = BarSeries.LabelsInsideEnd;
+ else
+ labelsPosition = BarSeries.LabelsCenter;
+ }
}
}
diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/HorizontalPercentBarChart.qml b/tests/quick2chartproperties/qml/quick2chartproperties/HorizontalPercentBarChart.qml
index 8d00b762..0ef7e17a 100644
--- a/tests/quick2chartproperties/qml/quick2chartproperties/HorizontalPercentBarChart.qml
+++ b/tests/quick2chartproperties/qml/quick2chartproperties/HorizontalPercentBarChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "Percent bar series"
@@ -33,6 +33,7 @@ ChartView {
HorizontalPercentBarSeries {
id: mySeries
name: "bar"
+ labelsFormat: "@value";
axisY: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6]
onClicked: console.log("barset.onClicked: " + index);
@@ -61,5 +62,18 @@ ChartView {
+ " " + status + " " + index);
onLabelsVisibleChanged: console.log("horizontalPercentBarSeries.onLabelsVisibleChanged: " + series.labelsVisible);
onCountChanged: console.log("horizontalPercentBarSeries.onCountChanged: " + count);
+ onLabelsFormatChanged: console.log(
+ "horizontalPercentBarSeries.onLabelsFormatChanged: "
+ + format);
+ onLabelsPositionChanged: console.log(
+ "horizontalPercentBarSeries.onLabelsPositionChanged: "
+ + series.labelsPosition);
+
+ function changeLabelsPosition() {
+ if (labelsPosition === BarSeries.LabelsCenter)
+ labelsPosition = BarSeries.LabelsInsideEnd;
+ else
+ labelsPosition = BarSeries.LabelsCenter;
+ }
}
}
diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/HorizontalStackedBarChart.qml b/tests/quick2chartproperties/qml/quick2chartproperties/HorizontalStackedBarChart.qml
index e468259d..c1ef51b8 100644
--- a/tests/quick2chartproperties/qml/quick2chartproperties/HorizontalStackedBarChart.qml
+++ b/tests/quick2chartproperties/qml/quick2chartproperties/HorizontalStackedBarChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "Stacked bar series"
@@ -33,6 +33,7 @@ ChartView {
HorizontalStackedBarSeries {
id: mySeries
name: "bar"
+ labelsFormat: "@value";
axisY: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6]
onClicked: console.log("barset.onClicked: " + index);
@@ -61,5 +62,18 @@ ChartView {
+ " " + status + " " + index);
onLabelsVisibleChanged: console.log("horizontalStackedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible);
onCountChanged: console.log("horizontalStackedBarSeries.onCountChanged: " + count);
+ onLabelsFormatChanged: console.log(
+ "horizontalStackedBarSeries.onLabelsFormatChanged: "
+ + format);
+ onLabelsPositionChanged: console.log(
+ "horizontalStackedBarSeries.onLabelsPositionChanged: "
+ + series.labelsPosition);
+
+ function changeLabelsPosition() {
+ if (labelsPosition === BarSeries.LabelsCenter)
+ labelsPosition = BarSeries.LabelsInsideEnd;
+ else
+ labelsPosition = BarSeries.LabelsCenter;
+ }
}
}
diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/LineChart.qml b/tests/quick2chartproperties/qml/quick2chartproperties/LineChart.qml
index 3545c66b..3190ac35 100644
--- a/tests/quick2chartproperties/qml/quick2chartproperties/LineChart.qml
+++ b/tests/quick2chartproperties/qml/quick2chartproperties/LineChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
property variant series: lineSeries
@@ -39,6 +39,8 @@ ChartView {
XYPoint { x: 3.4; y: 3.0 }
XYPoint { x: 4.1; y: 3.3 }
+ pointLabelsFormat: "@xPoint, @yPoint";
+
onNameChanged: console.log("lineSeries.onNameChanged: " + name);
onVisibleChanged: console.log("lineSeries.onVisibleChanged: " + visible);
onOpacityChanged: console.log(name + ".onOpacityChanged: " + opacity);
@@ -52,6 +54,14 @@ ChartView {
onCapStyleChanged: console.log("lineSeries.onCapStyleChanged: " + capStyle);
onCountChanged: console.log("lineSeries.onCountChanged: " + count);
onHovered: console.log("lineSeries.onHovered:" + point.x + "," + point.y + " " + state);
+ onPointLabelsVisibilityChanged: console.log("lineSeries.onPointLabelsVisibilityChanged: "
+ + visible);
+ onPointLabelsFormatChanged: console.log("lineSeries.onPointLabelsFormatChanged: "
+ + format);
+ onPointLabelsFontChanged: console.log("lineSeries.onPointLabelsFontChanged: "
+ + font.family);
+ onPointLabelsColorChanged: console.log("lineSeries.onPointLabelsColorChanged: "
+ + color);
}
LineSeries {
diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/LineEditor.qml b/tests/quick2chartproperties/qml/quick2chartproperties/LineEditor.qml
index f9eafed6..7960b4a1 100644
--- a/tests/quick2chartproperties/qml/quick2chartproperties/LineEditor.qml
+++ b/tests/quick2chartproperties/qml/quick2chartproperties/LineEditor.qml
@@ -72,6 +72,32 @@ Flow {
onClicked: series.pointsVisible = !series.pointsVisible;
}
Button {
+ text: "point labels visible"
+ onClicked: series.pointLabelsVisible = !series.pointLabelsVisible;
+ }
+ Button {
+ text: "point labels format"
+ onClicked: {
+ if (series.pointLabelsFormat === "@xPoint, @yPoint")
+ series.pointLabelsFormat = "(@xPoint)"
+ else
+ series.pointLabelsFormat = "@xPoint, @yPoint"
+ }
+ }
+ Button {
+ text: "point labels font"
+ onClicked: {
+ if (series.pointLabelsFont.family === "Times")
+ series.pointLabelsFont.family = "Courier";
+ else
+ series.pointLabelsFont.family = "Times";
+ }
+ }
+ Button {
+ text: "point labels color"
+ onClicked: series.pointLabelsColor = main.nextColor();
+ }
+ Button {
text: "append point"
onClicked: series.append(series.count - 1, series.count - 1);
}
diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/PercentBarChart.qml b/tests/quick2chartproperties/qml/quick2chartproperties/PercentBarChart.qml
index d2aa8812..822a1839 100644
--- a/tests/quick2chartproperties/qml/quick2chartproperties/PercentBarChart.qml
+++ b/tests/quick2chartproperties/qml/quick2chartproperties/PercentBarChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "Percent bar series"
@@ -33,6 +33,7 @@ ChartView {
PercentBarSeries {
id: mySeries
name: "bar"
+ labelsFormat: "@value";
axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6]
@@ -62,5 +63,16 @@ ChartView {
+ " " + status + " " + index);
onLabelsVisibleChanged: console.log("percentBarSeries.onLabelsVisibleChanged: " + series.labelsVisible);
onCountChanged: console.log("percentBarSeries.onCountChanged: " + count);
+ onLabelsFormatChanged: console.log("percentBarSeries.onLabelsFormatChanged: "
+ + format);
+ onLabelsPositionChanged: console.log("percentBarSeries.onLabelsPositionChanged: "
+ + series.labelsPosition);
+
+ function changeLabelsPosition() {
+ if (labelsPosition === BarSeries.LabelsCenter)
+ labelsPosition = BarSeries.LabelsInsideEnd;
+ else
+ labelsPosition = BarSeries.LabelsCenter;
+ }
}
}
diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/ScatterChart.qml b/tests/quick2chartproperties/qml/quick2chartproperties/ScatterChart.qml
index cd39a5c3..64785d2b 100644
--- a/tests/quick2chartproperties/qml/quick2chartproperties/ScatterChart.qml
+++ b/tests/quick2chartproperties/qml/quick2chartproperties/ScatterChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "scatter series"
@@ -37,6 +37,8 @@ ChartView {
XYPoint { x: 2.1; y: 1.3 }
XYPoint { x: 2.5; y: 2.1 }
+ pointLabelsFormat: "@xPoint, @yPoint";
+
onNameChanged: console.log("scatterSeries.onNameChanged: " + name);
onVisibleChanged: console.log("scatterSeries.onVisibleChanged: " + visible);
onOpacityChanged: console.log(name + ".onOpacityChanged: " + opacity);
@@ -49,6 +51,14 @@ ChartView {
onBorderColorChanged: console.log("scatterSeries.onBorderColorChanged: " + borderColor);
onBorderWidthChanged: console.log("scatterSeries.onBorderChanged: " + borderWidth);
onCountChanged: console.log("scatterSeries.onCountChanged: " + count);
+ onPointLabelsVisibilityChanged: console.log("lineSeries.onPointLabelsVisibilityChanged: "
+ + visible);
+ onPointLabelsFormatChanged: console.log("lineSeries.onPointLabelsFormatChanged: "
+ + format);
+ onPointLabelsFontChanged: console.log("lineSeries.onPointLabelsFontChanged: "
+ + font.family);
+ onPointLabelsColorChanged: console.log("lineSeries.onPointLabelsColorChanged: "
+ + color);
}
ScatterSeries {
diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/ScatterEditor.qml b/tests/quick2chartproperties/qml/quick2chartproperties/ScatterEditor.qml
index 23690c1c..23afdb75 100644
--- a/tests/quick2chartproperties/qml/quick2chartproperties/ScatterEditor.qml
+++ b/tests/quick2chartproperties/qml/quick2chartproperties/ScatterEditor.qml
@@ -67,6 +67,32 @@ Flow {
onClicked: series.markerShape = ((series.markerShape + 1) % 2);
}
Button {
+ text: "point labels visible"
+ onClicked: series.pointLabelsVisible = !series.pointLabelsVisible;
+ }
+ Button {
+ text: "point labels format"
+ onClicked: {
+ if (series.pointLabelsFormat === "@xPoint, @yPoint")
+ series.pointLabelsFormat = "(@xPoint)"
+ else
+ series.pointLabelsFormat = "@xPoint, @yPoint"
+ }
+ }
+ Button {
+ text: "point labels font"
+ onClicked: {
+ if (series.pointLabelsFont.family === "Times")
+ series.pointLabelsFont.family = "Courier";
+ else
+ series.pointLabelsFont.family = "Times";
+ }
+ }
+ Button {
+ text: "point labels color"
+ onClicked: series.pointLabelsColor = main.nextColor();
+ }
+ Button {
text: "append point"
onClicked: series.append(series.count - 1, series.count - 1);
}
diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/SplineChart.qml b/tests/quick2chartproperties/qml/quick2chartproperties/SplineChart.qml
index 840055bc..e7c8793d 100644
--- a/tests/quick2chartproperties/qml/quick2chartproperties/SplineChart.qml
+++ b/tests/quick2chartproperties/qml/quick2chartproperties/SplineChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "spline series"
@@ -38,6 +38,8 @@ ChartView {
XYPoint { x: 3.4; y: 3.0 }
XYPoint { x: 4.1; y: 3.3 }
+ pointLabelsFormat: "@xPoint, @yPoint";
+
onNameChanged: console.log("splineSeries.onNameChanged: " + name);
onVisibleChanged: console.log("splineSeries.onVisibleChanged: " + visible);
onOpacityChanged: console.log(name + ".onOpacityChanged: " + opacity);
@@ -51,6 +53,14 @@ ChartView {
onStyleChanged: console.log("splineSeries.onStyleChanged: " + style);
onCapStyleChanged: console.log("splineSeries.onCapStyleChanged: " + capStyle);
onCountChanged: console.log("splineSeries.onCountChanged: " + count);
+ onPointLabelsVisibilityChanged: console.log("splineSeries.onPointLabelsVisibilityChanged: "
+ + visible);
+ onPointLabelsFormatChanged: console.log("splineSeries.onPointLabelsFormatChanged: "
+ + format);
+ onPointLabelsFontChanged: console.log("splineSeries.onPointLabelsFontChanged: "
+ + font.family);
+ onPointLabelsColorChanged: console.log("splineSeries.onPointLabelsColorChanged: "
+ + color);
}
SplineSeries {
diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/StackedBarChart.qml b/tests/quick2chartproperties/qml/quick2chartproperties/StackedBarChart.qml
index 50adedad..0890884c 100644
--- a/tests/quick2chartproperties/qml/quick2chartproperties/StackedBarChart.qml
+++ b/tests/quick2chartproperties/qml/quick2chartproperties/StackedBarChart.qml
@@ -19,7 +19,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtCommercial.Chart 1.1
+import QtCommercial.Chart 1.4
ChartView {
title: "Stacked bar series"
@@ -33,6 +33,7 @@ ChartView {
StackedBarSeries {
id: mySeries
name: "bar"
+ labelsFormat: "@value";
axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6]
onClicked: console.log("barset.onClicked: " + index);
@@ -61,5 +62,16 @@ ChartView {
+ " " + status + " " + index);
onLabelsVisibleChanged: console.log("stackedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible);
onCountChanged: console.log("stackedBarSeries.onCountChanged: " + count);
+ onLabelsFormatChanged: console.log("stackedBarSeries.onLabelsFormatChanged: "
+ + format);
+ onLabelsPositionChanged: console.log("stackedBarSeries.onLabelsPositionChanged: "
+ + series.labelsPosition);
+
+ function changeLabelsPosition() {
+ if (labelsPosition === BarSeries.LabelsCenter)
+ labelsPosition = BarSeries.LabelsInsideEnd;
+ else
+ labelsPosition = BarSeries.LabelsCenter;
+ }
}
}