Warning, /frameworks/kquickcharts/examples/charts/LineChart.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * This file is part of KQuickCharts 0003 * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiemstra@heimr.nl> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 import QtQuick 2.9 0009 import QtQuick.Controls 2.2 0010 import QtQuick.Layouts 1.2 0011 0012 import org.kde.kirigami 2.4 as Kirigami 0013 import org.kde.kquickcontrols 2.0 0014 0015 import org.kde.quickcharts 1.0 as Charts 0016 import org.kde.quickcharts.controls 1.0 as ChartsControls 0017 0018 Kirigami.Page { 0019 title: "Line Chart" 0020 0021 ListModel { 0022 id: lineModel; 0023 dynamicRoles: true; 0024 0025 Component.onCompleted: { 0026 append({label: "Item 1", value1: 10, value2: 15, value3: 20}) 0027 append({label: "Item 2", value1: 15, value2: 25, value3: 25}) 0028 append({label: "Item 3", value1: 15, value2: 20, value3: 30}) 0029 append({label: "Item 4", value1: 10, value2: 10, value3: 35}) 0030 append({label: "Item 5", value1: 20, value2: 5, value3: 40}) 0031 } 0032 } 0033 0034 ColumnLayout { 0035 anchors.fill: parent 0036 anchors.margins: Kirigami.Units.largeSpacing 0037 spacing: Kirigami.Units.largeSpacing 0038 0039 Kirigami.AbstractCard { 0040 Layout.fillHeight: false 0041 Layout.preferredHeight: 400 0042 Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter 0043 0044 ChartsControls.LineChartControl { 0045 id: lineChart 0046 0047 anchors.fill: parent 0048 0049 valueSources: [ 0050 Charts.ModelSource { roleName: "value1"; model: lineModel }, 0051 Charts.ModelSource { roleName: "value2"; model: lineModel }, 0052 Charts.ModelSource { roleName: "value3"; model: lineModel } 0053 ] 0054 0055 names: ["Example 1", "Example 2", "Example 3"] 0056 0057 pointDelegate: Item { 0058 Rectangle { 0059 anchors.centerIn: parent 0060 width: lineChart.lineWidth + Kirigami.Units.smallSpacing; 0061 height: width 0062 radius: width / 2; 0063 color: parent.Charts.LineChart.color 0064 0065 MouseArea { 0066 id: mouse 0067 anchors.fill: parent 0068 hoverEnabled: true 0069 } 0070 0071 ToolTip.visible: mouse.containsMouse 0072 ToolTip.text: "%1: %2".arg(parent.Charts.LineChart.name).arg(parent.Charts.LineChart.value) 0073 } 0074 } 0075 } 0076 } 0077 0078 RangeEditor { label: "X Axis"; range: lineChart.xRange } 0079 RangeEditor { label: "Y Axis"; range: lineChart.yRange } 0080 0081 RowLayout { 0082 Button { text: "Add Item"; onClicked: lineModel.append({label: "New", value1: 0, value2: 0, value3: 0}) } 0083 Button { text: "Remove Item"; onClicked: lineModel.remove(lineModel.count - 1)} 0084 Label { text: "Line Width" } 0085 SpinBox { from: 0; to: 1000; value: lineChart.lineWidth; onValueModified: lineChart.lineWidth = value; } 0086 Label { text: "Fill Opacity" } 0087 SpinBox { from: 0; to: 100; value: lineChart.fillOpacity * 100; onValueModified: lineChart.fillOpacity = value / 100; } 0088 CheckBox { text: "Stacked"; checked: lineChart.stacked; onToggled: lineChart.stacked = checked } 0089 CheckBox { text: "Smooth"; checked: lineChart.chart.smooth; onToggled: lineChart.chart.smooth = checked } 0090 } 0091 0092 Frame { 0093 Layout.fillWidth: true 0094 Layout.fillHeight: true 0095 0096 ScrollView { 0097 anchors.fill: parent 0098 ListView { 0099 model: lineModel; 0100 delegate: Kirigami.BasicListItem { 0101 width: ListView.view.width 0102 height: Kirigami.Units.gridUnit * 2 + Kirigami.Units.smallSpacing 0103 contentItem: RowLayout { 0104 Label { text: "Label" } 0105 TextField { 0106 Layout.preferredWidth: 75 0107 text: model.label; 0108 onEditingFinished: lineModel.setProperty(index, "label", text) 0109 } 0110 Label { text: "Value 1" } 0111 SpinBox { 0112 Layout.preferredWidth: 75 0113 from: -10000; to: 10000; 0114 stepSize: 1; 0115 value: model.value1; 0116 onValueModified: lineModel.setProperty(index, "value1", value) 0117 } 0118 Label { text: "Value 2" } 0119 SpinBox { 0120 Layout.preferredWidth: 75 0121 from: -10000; to: 10000; 0122 stepSize: 1; 0123 value: model.value2; 0124 onValueModified: lineModel.setProperty(index, "value2", value) 0125 } 0126 Label { text: "Value 3" } 0127 SpinBox { 0128 Layout.preferredWidth: 75 0129 from: -10000; to: 10000; 0130 stepSize: 1; 0131 value: model.value3; 0132 onValueModified: lineModel.setProperty(index, "value3", value) 0133 } 0134 } 0135 } 0136 } 0137 } 0138 } 0139 } 0140 }