Debian Codegraph @

examples/charts/qmlchartsgallery/qml/Main.qml

raw
1 // Copyright (C) 2023 The Qt Company Ltd.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4 import QtQuick
5
6 Rectangle {
7 id: root
8 width: 1200
9 height: 600
10
11 color: "#f0f0f0"
12
13 property bool isHorizontalView: root.width >= root.height
14
15 Item {
16 anchors.fill: parent
17 anchors.topMargin: Math.max(8, root.SafeArea.margins.top)
18 anchors.leftMargin: Math.max(8, root.SafeArea.margins.left)
19 anchors.rightMargin: Math.max(8, root.SafeArea.margins.right)
20 anchors.bottomMargin: Math.max(8, root.SafeArea.margins.bottom)
21
22 Rectangle {
23 id: listRect
24 width: isHorizontalView ? 200 : parent.width
25 height: isHorizontalView ? parent.height : parent.height / 3
26 x: 0
27 y: isHorizontalView ? 0 : parent.height - height
28 border.width: 1
29
30 ListView {
31 id: listView
32 focus: true
33 anchors.fill: parent
34 anchors.margins: 1
35 highlightMoveDuration: 250
36 highlightResizeDuration: 0
37 orientation: ListView.Vertical
38 boundsBehavior: Flickable.StopAtBounds
39 currentIndex: 0
40 clip: true
41
42 model: ListModel {
43 ListElement {
44 name: "Area Chart"
45 component: "AreaSeries.qml"
46 }
47 ListElement {
48 name: "Bar Chart"
49 component: "BarSeries.qml"
50 }
51 ListElement {
52 name: "Bar Chart Horizontal"
53 component: "BarSeriesHorizontal.qml"
54 }
55 ListElement {
56 name: "Bar Chart Percent"
57 component: "BarSeriesPercent.qml"
58 }
59 ListElement {
60 name: "Bar Chart Percent Horizontal"
61 component: "BarSeriesPercentHorizontal.qml"
62 }
63 ListElement {
64 name: "Bar Chart Stacked"
65 component: "BarSeriesStacked.qml"
66 }
67 ListElement {
68 name: "Bar Chart Stacked Horizontal"
69 component: "BarSeriesStackedHorizontal.qml"
70 }
71 ListElement {
72 name: "Box Plot Chart"
73 component: "BoxPlotSeries.qml"
74 }
75 ListElement {
76 name: "Candlestick Chart"
77 component: "CandlestickSeries.qml"
78 }
79 ListElement {
80 name: "Category Axis"
81 component: "CategoryAxis.qml"
82 }
83 ListElement {
84 name: "Category Axis Polar"
85 component: "CategoryAxisPolar.qml"
86 }
87 ListElement {
88 name: "Custom Legend"
89 component: "customlegend/Main.qml"
90 }
91 ListElement {
92 name: "Datetime Axis"
93 component: "DateTimeAxis.qml"
94 }
95 ListElement {
96 name: "Datetime Axis Polar"
97 component: "DateTimeAxisPolar.qml"
98 }
99 ListElement {
100 name: "Donut"
101 component: "Donut.qml"
102 }
103 ListElement {
104 name: "F1 Legends"
105 component: "f1legends/F1Legends.qml"
106 }
107 ListElement {
108 name: "Line Chart"
109 component: "LineSeries.qml"
110 }
111 ListElement {
112 name: "Pie Chart"
113 component: "PieChart.qml"
114 }
115 ListElement {
116 name: "Spline Chart"
117 component: "SplineSeries.qml"
118 }
119 ListElement {
120 name: "Scatter Chart"
121 component: "ScatterSeries.qml"
122 }
123 ListElement {
124 name: "Two Series in Chart"
125 component: "TwoSeries.qml"
126 }
127 ListElement {
128 name: "Two Series in Polar Chart"
129 component: "TwoSeriesPolar.qml"
130 }
131 ListElement {
132 name: "Wheel of Fortune"
133 component: "WheelOfFortune.qml"
134 }
135 }
136
137 delegate: Text {
138 property string source: component
139 text: name
140 width: listView.width
141 leftPadding: 4
142
143 MouseArea {
144 anchors.fill: parent
145 onClicked: {
146 listView.currentIndex = index
147 }
148 }
149 }
150
151 highlight: Rectangle {
152 color: "lightblue";
153 }
154 }
155 }
156
157 Rectangle {
158 width: isHorizontalView ? parent.width - listView.width - 8 : parent.width
159 height: isHorizontalView ? parent.height : parent.height - listView.height - 8
160 radius: 5
161 x: isHorizontalView ? 208 : 0
162 y: 0
163 clip: true
164
165 Loader {
166 anchors.fill: parent
167 asynchronous: true
168 source: listView.currentItem.source
169 }
170 }
171 }
172 }