summaryrefslogtreecommitdiffstats
path: root/examples/qmlbarchart/qml/qmlbarchart/main.qml
blob: 9c19aeb79ab8c7d58ce8cb1b84c63d5d677cdadb (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
/****************************************************************************
**
** Copyright (C) 2013 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 QtDataVis3D module.
**
** $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 2.1
import QtQuick.Window 2.1
import QtQuick.Controls 1.0
import com.digia.QtDataVis3D 1.0

Item {
    id: mainview
    //title: "My MainWindow"
    width: 640
    height: 480
    visible: true

    Item {
        id: dataView
        width: parent.width - shadowToggle.width
        height: parent.height
        anchors.right: parent.right;
        DataItem {
            id: testitem1
            label: "Test"
            value: 10
        }
        DataItem {
            id: testitem2
            label: "Test2"
            value: -10
        }
        DataItem {
            id: testitem3
            label: "Test3"
            value: 5
        }
        DataItem {
            id: testitem4
            label: "Test4"
            value: -7
        }
        DataItem {
            id: testitem5
            label: "Test5"
            value: 8
        }
        DataItem {
            id: testitem6
            label: "Test6"
            value: 1
        }
        DataItem {
            id: testitem7
            label: "Test7"
            value: 3
        }
        DataItem {
            id: testitem8
            label: "Test8"
            value: -2
        }

        DataRow {
            id: testrow1
        }
        DataRow {
            id: testrow2
        }

        DataSet {
            id: testset1
        }

    //    ListModel {
    //        id: testdata1
    //        ListElement{ column1: "test" ; column2: "test" ; column3: "test" }
    //        ListElement{ column1: "test" ; column2: "test" ; column3: "test" }
    //        ListElement{ column1: testitem1 ; column2: testitem2 ; column3: testitem3 }
    //        ListElement{ column1: testitem4 ; column2: testitem6 ; column3: testitem6 }
    //    }

        Bars3D {
            id: testchart
            width: dataView.width
            height: dataView.height

            Component.onCompleted: {
                //data = testdata1
            }

            gridVisible: true
            shadowQuality: Bars3D.ShadowNone
            selectionMode: Bars3D.ModeNone
            labelTransparency: Bars3D.TransparencyNone
        }
    }


    Component.onCompleted: {
        testrow1.addItem(testitem1);
        testrow1.addItem(testitem2);
        testrow1.addItem(testitem3);
        testrow1.addItem(testitem4);
        testrow2.addItem(testitem5);
        testrow2.addItem(testitem6);
        testrow2.addItem(testitem7);
        testrow2.addItem(testitem8);
        testset1.addRow(testrow1);
        testset1.addRow(testrow2)

        testchart.setupSampleSpace(4, 2);
        testchart.addDataSet(testset1);
    }

    Rectangle {
        id: shadowToggle
        color: "#FFFFFF"
        x: 0
        y: 0
        width: 160
        height: 80

        TextArea {
            id: buttonText
            text: "Toggle Shadows"
            anchors.fill: parent
            textColor: "#000000"
        }

        MouseArea {
            anchors.fill: parent
            onClicked: {
                if (testchart.shadowQuality == Bars3D.ShadowNone) {
                    testchart.shadowQuality = Bars3D.ShadowLow;
                    buttonText.textColor = "#FFFFFF";
                    shadowToggle.color = "#000000";
                } else {
                    testchart.shadowQuality = Bars3D.ShadowNone;
                    buttonText.textColor = "#000000";
                    shadowToggle.color = "#FFFFFF";
                }
            }
        }
    }
}