summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKari Oikarinen <kari.oikarinen@qt.io>2017-12-21 09:35:19 +0200
committerKari Oikarinen <kari.oikarinen@qt.io>2017-12-21 11:21:35 +0000
commit146e375210f406e62fd952d150bc1bcd926d60cb (patch)
tree291b363d277d8d57c0450cace788ea97e8431818 /tests
parent6b3a1a975e1f0237e78c3d329411c15f00577b01 (diff)
Add labelsPrecision property to bar charts
Allow choosing the number of significant digits in the value labels for the bars. Before this this has been hardcoded to 6, so the default value stays as 6 for backward compatibility. Task-number: QTBUG-64370 Change-Id: I022bdad21aca7a7750ed46181b4ec97726bd9dc5 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qbarseries/tst_qbarseries.cpp14
-rw-r--r--tests/manual/qmlchartproperties/qml/qmlchartproperties/BarChart.qml3
-rw-r--r--tests/manual/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml10
-rw-r--r--tests/manual/qmlchartproperties/qml/qmlchartproperties/HorizontalBarChart.qml3
-rw-r--r--tests/manual/qmlchartproperties/qml/qmlchartproperties/HorizontalPercentBarChart.qml3
-rw-r--r--tests/manual/qmlchartproperties/qml/qmlchartproperties/HorizontalStackedBarChart.qml3
-rw-r--r--tests/manual/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml3
-rw-r--r--tests/manual/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml3
8 files changed, 41 insertions, 1 deletions
diff --git a/tests/auto/qbarseries/tst_qbarseries.cpp b/tests/auto/qbarseries/tst_qbarseries.cpp
index 5fe2808c..ef49b1ca 100644
--- a/tests/auto/qbarseries/tst_qbarseries.cpp
+++ b/tests/auto/qbarseries/tst_qbarseries.cpp
@@ -72,6 +72,7 @@ private slots:
void setLabelsFormat();
void setLabelsPosition();
void setLabelsAngle();
+ void setLabelsPrecision();
void opacity();
void mouseclicked_data();
void mouseclicked();
@@ -430,6 +431,19 @@ void tst_QBarSeries::setLabelsAngle()
QCOMPARE(m_barseries->labelsAngle(), 55.0);
}
+void tst_QBarSeries::setLabelsPrecision()
+{
+ QSignalSpy labelsPrecisionSpy(m_barseries,
+ SIGNAL(labelsPrecisionChanged(int)));
+ QCOMPARE(m_barseries->labelsPrecision(), 6);
+
+ m_barseries->setLabelsPrecision(9);
+ TRY_COMPARE(labelsPrecisionSpy.count(), 1);
+ QList<QVariant> arguments = labelsPrecisionSpy.takeFirst();
+ QVERIFY(arguments.at(0).value<int>() == 9);
+ QCOMPARE(m_barseries->labelsPrecision(), 9);
+}
+
void tst_QBarSeries::opacity()
{
QSignalSpy opacitySpy(m_barseries, SIGNAL(opacityChanged()));
diff --git a/tests/manual/qmlchartproperties/qml/qmlchartproperties/BarChart.qml b/tests/manual/qmlchartproperties/qml/qmlchartproperties/BarChart.qml
index a0d9fa92..b987d4fc 100644
--- a/tests/manual/qmlchartproperties/qml/qmlchartproperties/BarChart.qml
+++ b/tests/manual/qmlchartproperties/qml/qmlchartproperties/BarChart.qml
@@ -45,7 +45,7 @@ ChartView {
name: "bar"
labelsFormat: "@value";
axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
- BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6]
+ BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6.567889]
onClicked: console.log("barset.onClicked: " + index);
onHovered: console.log("barset.onHovered: " + status + " " + index);
onPenChanged: console.log("barset.onPenChanged: " + pen);
@@ -78,6 +78,7 @@ ChartView {
onCountChanged: console.log("barSeries.onCountChanged: " + count);
onLabelsFormatChanged: console.log("barSeries.onLabelsFormatChanged: " + format);
onLabelsPositionChanged: console.log("barSeries.onLabelsPositionChanged: " + series.labelsPosition);
+ onLabelsPrecisionChanged: console.log("barSeries.onLabelsPrecisionChanged: " + series.labelsPrecision);
onPressed: console.log("barSeries.onPressed: " + barset + " " + index);
onReleased: console.log("barSeries.onReleased: " + barset + " " + index);
onDoubleClicked: console.log("barSeries.onDoubleClicked: " + barset + " " + index);
diff --git a/tests/manual/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml b/tests/manual/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml
index 14fd991c..8292b5c6 100644
--- a/tests/manual/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml
+++ b/tests/manual/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml
@@ -205,6 +205,16 @@ Row {
text: "labels angle -"
onClicked: series.labelsAngle = series.labelsAngle - 5;
}
+ Button {
+ text: "labels precision"
+ onClicked: {
+ if (series.labelsPrecision == 2)
+ series.labelsPrecision = 4;
+ else
+ series.labelsPrecision = 2;
+ }
+ }
+
FontEditor {
id: fontEditor
fontDescription: "label"
diff --git a/tests/manual/qmlchartproperties/qml/qmlchartproperties/HorizontalBarChart.qml b/tests/manual/qmlchartproperties/qml/qmlchartproperties/HorizontalBarChart.qml
index 368ab78e..b2932a0c 100644
--- a/tests/manual/qmlchartproperties/qml/qmlchartproperties/HorizontalBarChart.qml
+++ b/tests/manual/qmlchartproperties/qml/qmlchartproperties/HorizontalBarChart.qml
@@ -78,6 +78,9 @@ ChartView {
+ format);
onLabelsPositionChanged: console.log("horizontalBarSeries.onLabelsPositionChanged: "
+ series.labelsPosition);
+ onLabelsPrecisionChanged: console.log(
+ "horizontalBarSeries.onLabelsPrecisionChanged: "
+ + series.labelsPrecision);
onPressed: console.log("horizontalBarSeries.onPressed: " + barset + " " + index);
onReleased: console.log("horizontalBarSeries.onReleased: " + barset + " " + index);
onDoubleClicked: console.log("horizontalBarSeries.onDoubleClicked: " + barset + " " + index);
diff --git a/tests/manual/qmlchartproperties/qml/qmlchartproperties/HorizontalPercentBarChart.qml b/tests/manual/qmlchartproperties/qml/qmlchartproperties/HorizontalPercentBarChart.qml
index 9f230d06..6e23dba4 100644
--- a/tests/manual/qmlchartproperties/qml/qmlchartproperties/HorizontalPercentBarChart.qml
+++ b/tests/manual/qmlchartproperties/qml/qmlchartproperties/HorizontalPercentBarChart.qml
@@ -80,6 +80,9 @@ ChartView {
onLabelsPositionChanged: console.log(
"horizontalPercentBarSeries.onLabelsPositionChanged: "
+ series.labelsPosition);
+ onLabelsPrecisionChanged: console.log(
+ "horizontalPercentBarSeries.onLabelsPrecisionChanged: "
+ + series.labelsPrecision);
onPressed: console.log("horizontalPercentBarSeries.onPressed: " + barset + " " + index);
onReleased: console.log("horizontalPercentBarSeries.onReleased: " + barset + " " + index);
onDoubleClicked: console.log("horizontalPercentBarSeries.onDoubleClicked: " + barset + " " + index);
diff --git a/tests/manual/qmlchartproperties/qml/qmlchartproperties/HorizontalStackedBarChart.qml b/tests/manual/qmlchartproperties/qml/qmlchartproperties/HorizontalStackedBarChart.qml
index 3a728c24..00f1ff39 100644
--- a/tests/manual/qmlchartproperties/qml/qmlchartproperties/HorizontalStackedBarChart.qml
+++ b/tests/manual/qmlchartproperties/qml/qmlchartproperties/HorizontalStackedBarChart.qml
@@ -80,6 +80,9 @@ ChartView {
onLabelsPositionChanged: console.log(
"horizontalStackedBarSeries.onLabelsPositionChanged: "
+ series.labelsPosition);
+ onLabelsPrecisionChanged: console.log(
+ "horizontalPercentBarSeries.onLabelsPrecisionChanged: "
+ + series.labelsPrecision);
onPressed: console.log("horizontalStackedBarSeries.onPressed: " + barset + " " + index);
onReleased: console.log("horizontalStackedBarSeries.onReleased: " + barset + " " + index);
onDoubleClicked: console.log("horizontalStackedBarSeries.onDoubleClicked: " + barset + " " + index);
diff --git a/tests/manual/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml b/tests/manual/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml
index 2c7fb574..d9eb78dd 100644
--- a/tests/manual/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml
+++ b/tests/manual/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml
@@ -79,6 +79,9 @@ ChartView {
+ format);
onLabelsPositionChanged: console.log("percentBarSeries.onLabelsPositionChanged: "
+ series.labelsPosition);
+ onLabelsPrecisionChanged: console.log(
+ "percentBarSeries.onLabelsPrecisionChanged: "
+ + series.labelsPrecision);
onPressed: console.log("percentBarSeries.onPressed: " + barset + " " + index);
onReleased: console.log("percentBarSeries.onReleased: " + barset + " " + index);
onDoubleClicked: console.log("percentBarSeries.onDoubleClicked: " + barset + " " + index);
diff --git a/tests/manual/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml b/tests/manual/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml
index 266d49dc..ec3595b7 100644
--- a/tests/manual/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml
+++ b/tests/manual/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml
@@ -78,6 +78,9 @@ ChartView {
+ format);
onLabelsPositionChanged: console.log("stackedBarSeries.onLabelsPositionChanged: "
+ series.labelsPosition);
+ onLabelsPrecisionChanged: console.log(
+ "stackedBarSeries.onLabelsPrecisionChanged: "
+ + series.labelsPrecision);
onPressed: console.log("stackedBarSeries.onPressed: " + barset + " " + index);
onReleased: console.log("stackedBarSeries.onReleased: " + barset + " " + index);
onDoubleClicked: console.log("stackedBarSeries.onDoubleClicked: " + barset + " " + index);