From 2325cc247e94e22bf531963bc63a0aff128381ef 2012-08-30 07:29:59 From: Tero Ahola Date: 2012-08-30 07:29:59 Subject: [PATCH] Added horizontal bar series to qml tester --- diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml index c8cb694..70b0913 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml @@ -39,11 +39,11 @@ Flow { onClicked: series.borderColor = main.nextColor(); } Button { - text: "borderWidth + (" + series.borderWidth + ")" + text: series != undefined ? "borderWidth + (" + series.borderWidth + ")" : "" onClicked: series.borderWidth += 0.5; } Button { - text: "borderWidth - (" + series.borderWidth + ")" + text: series != undefined ? "borderWidth - (" + series.borderWidth + ")" : "" onClicked: series.borderWidth -= 0.5; } Button { diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml index 68396c2..15d68c5 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml @@ -143,11 +143,11 @@ Row { onClicked: series.at(0).borderColor = main.nextColor(); } Button { - text: "set 1 borderWidth + (" + series.at(0).borderWidth + ")" + text: "set 1 borderWidth +" onClicked: series.at(0).borderWidth += 0.5; } Button { - text: "set 1 borderWidth - (" + series.at(0).borderWidth + ")" + text: "set 1 borderWidth -" onClicked: series.at(0).borderWidth -= 0.5; } } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalBarChart.qml new file mode 100644 index 0000000..a0652cf --- /dev/null +++ b/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalBarChart.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import QtCommercial.Chart 1.1 + +ChartView { + title: "Bar series" + anchors.fill: parent + theme: ChartView.ChartThemeLight + legend.alignment: Qt.AlignBottom + animationOptions: ChartView.SeriesAnimations + + property variant series: mySeries + + + HorizontalBarSeries { + id: mySeries + name: "bar" + 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); + onHovered: console.log("barset.onHovered: " + status); + onPenChanged: console.log("barset.onPenChanged: " + pen); + onBrushChanged: console.log("barset.onBrushChanged: " + brush); + onLabelChanged: console.log("barset.onLabelChanged: " + label); + onLabelBrushChanged: console.log("barset.onLabelBrushChanged: " + labelBrush); + onLabelFontChanged: console.log("barset.onLabelFontChanged: " + labelFont); + onColorChanged: console.log("barset.onColorChanged: " + color); + onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); + onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); + onCountChanged: console.log("barset.onCountChanged: " + count); + onValuesAdded: console.log("barset.onValuesAdded: " + index + ", " + count); + onValuesRemoved: console.log("barset.onValuesRemoved: " + index + ", " + count); + onValueChanged: console.log("barset.onValuesChanged: " + index); + } + BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } + BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } + + onNameChanged: console.log("groupedBarSeries.onNameChanged: " + series.name); + onVisibleChanged: console.log("groupedBarSeries.onVisibleChanged: " + series.visible); + onClicked: console.log("groupedBarSeries.onClicked: " + barset + " " + index); + onHovered: console.log("groupedBarSeries.onHovered: " + barset + " " + status); + onLabelsVisibleChanged: console.log("groupedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); + onCountChanged: console.log("groupedBarSeries.onCountChanged: " + count); + } +} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalPercentBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalPercentBarChart.qml new file mode 100644 index 0000000..365d6d8 --- /dev/null +++ b/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalPercentBarChart.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import QtCommercial.Chart 1.1 + +ChartView { + title: "Percent bar series" + anchors.fill: parent + theme: ChartView.ChartThemeLight + legend.alignment: Qt.AlignBottom + animationOptions: ChartView.SeriesAnimations + + property variant series: mySeries + + HorizontalPercentBarSeries { + id: mySeries + name: "bar" + 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); + onHovered: console.log("barset.onHovered: " + status); + onPenChanged: console.log("barset.onPenChanged: " + pen); + onBrushChanged: console.log("barset.onBrushChanged: " + brush); + onLabelChanged: console.log("barset.onLabelChanged: " + label); + onLabelBrushChanged: console.log("barset.onLabelBrushChanged: " + labelBrush); + onLabelFontChanged: console.log("barset.onLabelFontChanged: " + labelFont); + onColorChanged: console.log("barset.onColorChanged: " + color); + onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); + onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); + onCountChanged: console.log("barset.onCountChanged: " + count); + onValuesAdded: console.log("barset.onValuesAdded: " + index + ", " + count); + onValuesRemoved: console.log("barset.onValuesRemoved: " + index + ", " + count); + onValueChanged: console.log("barset.onValuesChanged: " + index); + } + BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } + BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } + + onNameChanged: console.log("percentBarSeries.onNameChanged: " + series.name); + onVisibleChanged: console.log("percentBarSeries.onVisibleChanged: " + series.visible); + onClicked: console.log("percentBarSeries.onClicked: " + barset + " " + index); + onHovered: console.log("percentBarSeries.onHovered: " + barset + " " + status); + onLabelsVisibleChanged: console.log("percentBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); + onCountChanged: console.log("percentBarSeries.onCountChanged: " + count); + } +} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalStackedBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalStackedBarChart.qml new file mode 100644 index 0000000..1e10724 --- /dev/null +++ b/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalStackedBarChart.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import QtCommercial.Chart 1.1 + +ChartView { + title: "Stacked bar series" + anchors.fill: parent + theme: ChartView.ChartThemeLight + legend.alignment: Qt.AlignBottom + animationOptions: ChartView.SeriesAnimations + + property variant series: mySeries + + HorizontalStackedBarSeries { + id: mySeries + name: "bar" + 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); + onHovered: console.log("barset.onHovered: " + status); + onPenChanged: console.log("barset.onPenChanged: " + pen); + onBrushChanged: console.log("barset.onBrushChanged: " + brush); + onLabelChanged: console.log("barset.onLabelChanged: " + label); + onLabelBrushChanged: console.log("barset.onLabelBrushChanged: " + labelBrush); + onLabelFontChanged: console.log("barset.onLabelFontChanged: " + labelFont); + onColorChanged: console.log("barset.onColorChanged: " + color); + onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); + onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); + onCountChanged: console.log("barset.onCountChanged: " + count); + onValuesAdded: console.log("barset.onValuesAdded: " + index + ", " + count); + onValuesRemoved: console.log("barset.onValuesRemoved: " + index + ", " + count); + onValueChanged: console.log("barset.onValuesChanged: " + index); + } + BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } + BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } + + onNameChanged: console.log("stackedBarSeries.onNameChanged: " + series.name); + onVisibleChanged: console.log("stackedBarSeries.onVisibleChanged: " + series.visible); + onClicked: console.log("stackedBarSeries.onClicked: " + barset + " " + index); + onHovered: console.log("stackedBarSeries.onHovered: " + barset + " " + status); + onLabelsVisibleChanged: console.log("stackedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); + onCountChanged: console.log("stackedBarSeries.onCountChanged: " + count); + } +} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml index dbdec6d..da18917 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml @@ -36,27 +36,27 @@ Flow { onClicked: series.color = main.nextColor(); } Button { - text: "width + (" + series.width + ")" + text: series != undefined ? "width + (" + series.width + ")" : "" onClicked: series.width += 0.5; } Button { - text: "width - (" + series.width + ")" + text: series != undefined ? "width - (" + series.width + ")" : "" onClicked: series.width -= 0.5; } Button { - text: "style + (" + series.style + ")" + text: series != undefined ? "style + (" + series.style + ")" : "" onClicked: series.style++; } Button { - text: "style - (" + series.style + ")" + text: series != undefined ? "style - (" + series.style + ")" : "" onClicked: series.style--; } Button { - text: "cap style + (" + series.capStyle + ")" + text: series != undefined ? "cap style + (" + series.capStyle + ")" : "" onClicked: series.capStyle++; } Button { - text: "cap style - (" +series.capStyle + ")" + text: series != undefined ? "cap style - (" +series.capStyle + ")" : "" onClicked: series.capStyle--; } Button { diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml index b0106c5..e4b4160 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml @@ -39,11 +39,11 @@ Flow { onClicked: series.borderColor = main.nextColor(); } Button { - text: "borderWidth + (" + series.borderWidth + ")" + text: series != undefined ? "borderWidth + (" + series.borderWidth + ")" : "" onClicked: series.borderWidth += 0.5; } Button { - text: "borderWidth - (" + series.borderWidth + ")" + text: series != undefined ? "borderWidth - (" + series.borderWidth + ")" : "" onClicked: series.borderWidth -= 0.5; } Button { diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/main.qml b/tests/qmlchartproperties/qml/qmlchartproperties/main.qml index 64b86d3..4e58d44 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/main.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/main.qml @@ -24,49 +24,16 @@ Rectangle { id: main width: parent.width height: parent.height - property int viewNumber: 0 property int viewCount: 9 property variant colors: ["#637D74", "#403D3A", "#8C3B3B", "#AB6937", "#D4A960"] property int colorIndex: 0 + property int buttonWidth: 42 function nextColor() { colorIndex++; return colors[colorIndex % colors.length]; } - onViewNumberChanged: { - if (viewNumber == 0) { - chartLoader.source = "Chart.qml"; - editorLoader.source = "ChartEditor.qml"; - } else if (viewNumber == 1) { - chartLoader.source = "PieChart.qml"; - editorLoader.source = "PieEditor.qml"; - } else if (viewNumber == 2) { - chartLoader.source = "LineChart.qml"; - editorLoader.source = "LineEditor.qml"; - } else if (viewNumber == 3) { - chartLoader.source = "SplineChart.qml"; - editorLoader.source = "LineEditor.qml"; - } else if (viewNumber == 4) { - chartLoader.source = "ScatterChart.qml"; - editorLoader.source = "ScatterEditor.qml"; - } else if (viewNumber == 5) { - chartLoader.source = "AreaChart.qml"; - editorLoader.source = "AreaEditor.qml"; - } else if (viewNumber == 6) { - chartLoader.source = "BarChart.qml"; - editorLoader.source = "BarEditor.qml"; - } else if (viewNumber == 7) { - chartLoader.source = "StackedBarChart.qml"; - editorLoader.source = "BarEditor.qml"; - } else if (viewNumber == 8) { - chartLoader.source = "PercentBarChart.qml"; - editorLoader.source = "BarEditor.qml"; - } else { - console.log("Illegal view number"); - } - } - Row { anchors.top: parent.top anchors.bottom: buttonRow.top @@ -105,16 +72,99 @@ Rectangle { spacing: 10 Button { - text: "previous" + text: "chart" + width: buttonWidth onClicked: { - viewNumber = (viewNumber + viewCount - 1) % viewCount; + chartLoader.source = "Chart.qml"; + editorLoader.source = "ChartEditor.qml"; + } + } + Button { + text: "pie" + width: buttonWidth + onClicked: { + chartLoader.source = "PieChart.qml"; + editorLoader.source = "PieEditor.qml"; + } + } + Button { + text: "line" + width: buttonWidth + onClicked: { + chartLoader.source = "LineChart.qml"; + editorLoader.source = "PieEditor.qml"; + } + } + Button { + text: "spline" + width: buttonWidth + onClicked: { + chartLoader.source = "SplineChart.qml"; + editorLoader.source = "PieEditor.qml"; + } + } + Button { + text: "scatter" + width: buttonWidth + onClicked: { + chartLoader.source = "ScatterChart.qml"; + editorLoader.source = "ScatterEditor.qml"; + } + } + Button { + text: "area" + width: buttonWidth + onClicked: { + chartLoader.source = "AreaChart.qml"; + editorLoader.source = "AreaEditor.qml"; + } + } + Button { + text: "bar" + width: buttonWidth + onClicked: { + chartLoader.source = "BarChart.qml"; + editorLoader.source = "BarEditor.qml"; + } + } + Button { + text: "sbar" + width: buttonWidth + onClicked: { + chartLoader.source = "StackedBarChart.qml"; + editorLoader.source = "BarEditor.qml"; + } + } + Button { + text: "pbar" + width: buttonWidth + onClicked: { + chartLoader.source = "PercentBarChart.qml"; + editorLoader.source = "BarEditor.qml"; + } + } + Button { + text: "hbar" + width: buttonWidth + onClicked: { + chartLoader.source = "HorizontalBarChart.qml"; + editorLoader.source = "BarEditor.qml"; + } + } + Button { + text: "hsbar" + width: buttonWidth + onClicked: { + chartLoader.source = "HorizontalStackedBarChart.qml"; + editorLoader.source = "BarEditor.qml"; } } - Button { - text: "next" + text: "hpbar" + width: buttonWidth onClicked: { - viewNumber = (viewNumber + 1) % viewCount; + chartLoader.source = "HorizontalPercentBarChart.qml"; + editorLoader.source = "BarEditor.qml"; } } } diff --git a/tests/qmlchartproperties/resources.qrc b/tests/qmlchartproperties/resources.qrc index 56e0f35..212c4b1 100644 --- a/tests/qmlchartproperties/resources.qrc +++ b/tests/qmlchartproperties/resources.qrc @@ -22,5 +22,8 @@ qml/qmlchartproperties/ChartEditor2.qml qml/qmlchartproperties/ChartEditor3.qml qml/qmlchartproperties/FontEditor.qml + qml/qmlchartproperties/HorizontalBarChart.qml + qml/qmlchartproperties/HorizontalPercentBarChart.qml + qml/qmlchartproperties/HorizontalStackedBarChart.qml