-
Notifications
You must be signed in to change notification settings - Fork 364
/
main.qml
54 lines (49 loc) · 1.52 KB
/
main.qml
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
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
import QtWebEngine 1.2
Window {
id: root
width: 640
height: 480
visible: true
title: qsTr("WebEngine + ECharts (By: GongJianBo1992)")
property var now: new Date(1997, 9, 3)
property var oneDay: 24 * 3600 * 1000
WebEngineView{
id: view
anchors.fill: parent
//@disable-check M7
url:"file:///./index.html"
}
Row{
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: 10
spacing: 10
Button{
text: "单个数据"
onClicked: {
now = new Date(+now + oneDay);
view.runJavaScript("window.appendData("+
JSON.stringify({
"date":now.valueOf(),
"value":Number(Math.random() * 1000 + 500)
})+")");
}
}
Button{
text: "批量数据"
onClicked: {
let datalist=[];
for(let i=0;i<100;i++)
{
now = new Date(+now + oneDay);
datalist.push({"date":now.valueOf(),"value":Number(Math.random() * 1000 + 500)});
}
view.runJavaScript("window.setData("+
JSON.stringify(datalist)+")");
}
}
}
}