summaryrefslogtreecommitdiffstats
path: root/tests/manual/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml
blob: 98b7ab8cab07652f33fab5ea69baf64bcdf7242f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd
** All rights reserved.
** For any questions to The Qt Company, please use contact form at http://qt.io
**
** This file is part of the Qt Charts module.
**
** Licensees holding valid commercial license for Qt may use this file in
** accordance with the Qt License Agreement provided with the Software
** or, alternatively, in accordance with the terms contained in a written
** agreement between you and The Qt Company.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.io
**
****************************************************************************/

import QtQuick 2.0

Row {
    anchors.fill: parent
    spacing: 5
    property variant series

    // buttons for selecting the edited object: series, barset or label
    Flow {
        spacing: 5
        flow: Flow.TopToBottom
        Button {
            id: seriesButton
            text: "series"
            unpressedColor: "#79bd8f"
            onClicked: {
                seriesFlow.visible = true;
                setFlow.visible = false;
                labelsFlow.visible = false;
                color = "#00a388";
                setButton.color = "#79bd8f";
                labelButton.color = "#79bd8f";
            }
        }
        Button {
            id: setButton
            text: "BarSet"
            unpressedColor: "#79bd8f"
            onClicked: {
                seriesFlow.visible = false;
                setFlow.visible = true;
                labelsFlow.visible = false;
                color = "#00a388";
                seriesButton.color = "#79bd8f";
                labelButton.color = "#79bd8f";
            }
        }
        Button {
            id: labelButton
            text: "label"
            unpressedColor: "#79bd8f"
            onClicked: {
                seriesFlow.visible = false;
                setFlow.visible = false;
                labelsFlow.visible = true;
                color = "#00a388";
                seriesButton.color = "#79bd8f";
                setButton.color = "#79bd8f";
            }
        }
    }

    // Buttons for editing series
    Flow {
        id: seriesFlow
        spacing: 5
        flow: Flow.TopToBottom
        visible: false

        Button {
            text: "visible"
            onClicked: series.visible = !series.visible;
        }
        Button {
            text: "opacity +"
            onClicked: series.opacity += 0.1;
        }
        Button {
            text: "opacity -"
            onClicked: series.opacity -= 0.1;
        }
        Button {
            text: "bar width +"
            onClicked: series.barWidth += 0.1;
        }
        Button {
            text: "bar width -"
            onClicked: series.barWidth -= 0.1;
        }
    }

    // Buttons for editing sets
    Flow {
        id: setFlow
        spacing: 5
        flow: Flow.TopToBottom
        visible: false

        Button {
            text: "append set"
            onClicked: {
                var count = series.count;
                series.append("set" + count, [0, 0.1 * count, 0.2 * count, 0.3 * count, 0.4 * count, 0.5 * count, 0.6 * count]);
            }
        }
        Button {
            text: "insert set"
            onClicked: {
                var count = series.count;
                series.insert(count - 1, "set" + count, [0, 0.1 * count, 0.2 * count, 0.3 * count, 0.4 * count, 0.5 * count, 0.6 * count]);
            }
        }
        Button {
            text: "remove set"
            onClicked: series.remove(series.at(series.count - 1));
        }
        Button {
            text: "clear sets"
            onClicked: series.clear();
        }

        Button {
            text: "set 1 append"
            onClicked: series.at(0).append(series.at(0).count + 1);
        }
        Button {
            text: "set 1 replace"
            onClicked: series.at(0).replace(series.at(0).count - 1, series.at(0).at(series.at(0).count - 1) + 1.5);
        }
        Button {
            text: "set 1 remove"
            onClicked: series.at(0).remove(series.at(0).count - 1);
        }

        Button {
            text: "set 1 color"
            onClicked: series.at(0).color = main.nextColor();
        }
        Button {
            text: "set 1 border color"
            onClicked: series.at(0).borderColor = main.nextColor();
        }
        Button {
            text: "set 1 borderWidth +"
            onClicked: series.at(0).borderWidth += 0.5;
        }
        Button {
            text: "set 1 borderWidth -"
            onClicked: series.at(0).borderWidth -= 0.5;
        }
    }


    Flow {
        id: labelsFlow
        spacing: 5
        flow: Flow.TopToBottom
        visible: false

        Button {
            text: "labels visible"
            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();
        }
        Button {
            text: "labels angle +"
            onClicked: series.labelsAngle = series.labelsAngle + 5;
        }
        Button {
            text: "labels angle -"
            onClicked: series.labelsAngle = series.labelsAngle - 5;
        }
        FontEditor {
            id: fontEditor
            fontDescription: "label"
            function editedFont() {
                return series.at(0).labelFont;
            }
        }
    }
}