Warning, /frameworks/kquickcharts/examples/charts/HistoryProxySource.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 0009 import QtQuick.Controls 0010 import QtQuick.Layouts 0011 0012 import org.kde.kirigami as Kirigami 0013 import org.kde.kquickcontrols 0014 0015 import org.kde.quickcharts as Charts 0016 0017 Kirigami.Page { 0018 title: "History Proxy Source" 0019 0020 ListModel { 0021 id: lineModel; 0022 dynamicRoles: true; 0023 } 0024 0025 Timer { 0026 id: updateTimer 0027 running: true 0028 repeat: true 0029 interval: 16 0030 0031 property real value 0032 0033 onTriggered: { 0034 value = Math.max(0.0, Math.min(1.0, value + (-0.05 + Math.random() / 10))); 0035 } 0036 } 0037 0038 ColumnLayout { 0039 anchors.fill: parent 0040 anchors.margins: Kirigami.Units.largeSpacing 0041 spacing: Kirigami.Units.largeSpacing 0042 0043 Kirigami.AbstractCard { 0044 Layout.fillHeight: false 0045 Layout.preferredHeight: 400 0046 Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter 0047 0048 Charts.LineChart { 0049 id: chart 0050 anchors.fill: parent 0051 0052 yRange { 0053 from: 0 0054 to: 1 0055 automatic: false 0056 } 0057 0058 valueSources: Charts.HistoryProxySource { 0059 id: historySource 0060 source: Charts.SingleValueSource { value: updateTimer.value } 0061 maximumHistory: 100 0062 } 0063 0064 colorSource: Charts.SingleValueSource { value: "darkRed" } 0065 0066 lineWidth: 2 0067 fillOpacity: 0.2 0068 } 0069 } 0070 0071 ColumnLayout { 0072 RangeEditor { label: "X Axis"; range: chart.xRange } 0073 RangeEditor { label: "Y Axis"; range: chart.yRange } 0074 RowLayout { 0075 Button { icon.name: "media-playback-start"; enabled: !updateTimer.running; onClicked: updateTimer.start() } 0076 Button { icon.name: "media-playback-stop"; enabled: updateTimer.running; onClicked: updateTimer.stop() } 0077 Label { text: "History Amount" } 0078 SpinBox { 0079 from: 0 0080 to: 99999 0081 stepSize: 1 0082 value: historySource.maximumHistory 0083 onValueModified: historySource.maximumHistory = value 0084 } 0085 CheckBox { 0086 text: "Smooth" 0087 checked: chart.smooth 0088 onToggled: chart.smooth = checked 0089 } 0090 Label { text : "Interval" } 0091 SpinBox { 0092 from: 10 0093 to: 99999 0094 stepSize: 1 0095 value: updateTimer.interval 0096 onValueModified: updateTimer.interval = value 0097 } 0098 } 0099 RowLayout { 0100 Label { text: "Direction" } 0101 ComboBox { 0102 model: [ 0103 { value: Charts.XYChart.ZeroAtStart, text: "Zero at Start" }, 0104 { value: Charts.XYChart.ZeroAtEnd, text: "Zero at End" } 0105 ] 0106 0107 textRole: "text" 0108 valueRole: "value" 0109 0110 onActivated: chart.direction = currentValue 0111 } 0112 Label { text: "Fill Mode" } 0113 ComboBox { 0114 model: [ 0115 { value: Charts.HistoryProxySource.DoNotFill, text: "Do Not Fill" }, 0116 { value: Charts.HistoryProxySource.FillFromStart, text: "Fill from Start" }, 0117 { value: Charts.HistoryProxySource.FillFromEnd, text: "Fill from End" } 0118 ] 0119 0120 textRole: "text" 0121 valueRole: "value" 0122 0123 onActivated: historySource.fillMode = currentValue 0124 } 0125 } 0126 } 0127 } 0128 }