Warning, /libraries/kqtquickcharts/demo/dynamicdata/main.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * Copyright 2014 Sebastian Gottfried <sebastiangottfried@web.de> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) version 3, or any 0008 * later version accepted by the membership of KDE e.V. (or its 0009 * successor approved by the membership of KDE e.V.), which shall 0010 * act as a proxy defined in Section 6 of version 3 of the license. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Lesser General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Lesser General Public 0018 */ 0019 0020 import QtQuick 2.2 0021 import QtQuick.Controls 1.2 0022 import org.kde.charts 0.1 0023 0024 Column { 0025 width: 1000 0026 height: 500 0027 spacing: 15 0028 0029 Component.onCompleted: { 0030 for (var i = 0; i < 25; i++) { 0031 appendRecord() 0032 } 0033 } 0034 0035 function randomizeRecord(row) { 0036 for (var column = 0; column < chart.model.columns; column++) { 0037 var value = parseInt(100 * Math.random()) / 100 0038 chart.model.setValue(row, column, value) 0039 } 0040 } 0041 0042 function appendRecord() { 0043 chart.model.appendRecord() 0044 randomizeRecord(chart.model.rows - 1) 0045 var row = chart.model.rows - 1 0046 } 0047 0048 function insertRecord() { 0049 chart.model.insertRecord(0) 0050 randomizeRecord(0) 0051 } 0052 0053 function removeRecord() { 0054 if (chart.model.rows > 0) { 0055 var row = chart.model.rows - 1 0056 chart.model.removeRecord(row) 0057 } 0058 } 0059 0060 ToolBar { 0061 id: toolbar 0062 Row { 0063 spacing: 4 0064 ToolButton { 0065 anchors.verticalCenter: parent.verticalCenter 0066 //iconSource: "edit-table-insert-row-below" 0067 text: "Append record" 0068 onClicked: appendRecord() 0069 } 0070 ToolButton { 0071 anchors.verticalCenter: parent.verticalCenter 0072 //iconSource: "edit-table-insert-row-above" 0073 text: "Insert record" 0074 onClicked: insertRecord() 0075 } 0076 ToolButton { 0077 anchors.verticalCenter: parent.verticalCenter 0078 //iconSource: "edit-table-delete-row" 0079 text: "Remove record" 0080 onClicked: removeRecord() 0081 } 0082 } 0083 } 0084 0085 Item { 0086 height: parent.height - toolbar.height - parent.spacing 0087 width: parent.width 0088 0089 Row { 0090 anchors { 0091 fill: parent 0092 margins: 20 0093 } 0094 0095 spacing: 40 0096 0097 ChartTableView { 0098 id: tableView 0099 height: parent.height 0100 chart: chart 0101 } 0102 0103 Rectangle { 0104 color: "white" 0105 width: parent.width - tableView.width - parent.spacing 0106 height: parent.height 0107 0108 Chart { 0109 id: chart 0110 anchors.fill: parent 0111 padding: 10 0112 } 0113 } 0114 } 0115 } 0116 }