-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathkline.html
109 lines (98 loc) · 2.92 KB
/
kline.html
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html lang="en">
<link href="https://fonts.googleapis.com/css?family=Cousine|Roboto+Mono" rel="stylesheet">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>ClChat Demo</title>
<link rel="stylesheet" href="../css/client.css">
</head>
<body>
<div id="container" class="container">
</div>
<script src="../ClChart.js"></script>
<script src="../SisClient.js"></script>
<script src="./config.js"></script>
<script>
const container = document.getElementById('container')
const syscfg = {
scale: window.devicePixelRatio,
axisPlatform: 'web', // 'phone' | 'web'
container: container
}
const mainCanvas ={
width: container.offsetWidth * window.devicePixelRatio,
height: container.offsetHeight * window.devicePixelRatio,
}
// Create a single stock Chart instance
const Chart = ClChart.createSingleChart(syscfg)
let isInited = false;
function initLayout() {
if (isInited) return;
isInited = true;
Chart.clearLayout();
let mainHeight = mainCanvas.height * 2 / 3
const mainLayoutCfg = {
layout: {
offset: {
left: 5,
right: 10
}
},
buttons: ClChart.DEF_CHART.CHART_BUTTONS,
config: ClChart.DEF_CHART.CHART_KBAR,
rectMain: {
left: 0,
top: 0,
width: mainCanvas.width,
height: mainHeight
}
}
Chart.createChart('user.kbar', 'system.chart', mainLayoutCfg, function (result) {
// console.log(result)
})
const volumeLayoutCfg = {
layout: {
offset: {
left: 5,
right: 10
}
},
config: ClChart.DEF_CHART.CHART_VBAR,
rectMain: {
left: 0,
top: mainHeight,
width: mainCanvas.width,
height: mainCanvas.height - mainHeight
}
}
Chart.createChart('user.vbar', 'system.chart', volumeLayoutCfg, function (result) {
// console.log(result)
})
}
function paintDrawline() {
const code = sisdb.code
const peroid = 'DAY'
let infoData
Promise.all([
sisClient.getData(code, 'info'),
sisClient.getData(code, peroid, { search:{ start:-3000,stop:-1 } })
])
.then(([infoData, dayData]) => {
Chart.clear()
Chart.initData(sisdb.tradeDate, ClChart.DEF_DATA.STOCK_TRADETIME)
Chart.setData('INFO', ClChart.DEF_DATA.FIELD_INFO, infoData.values)
Chart.setData(peroid, ClChart.DEF_DATA.FIELD_DAY, dayData.values)
Chart.bindData(Chart.getChart('user.kbar'), peroid)
Chart.bindData(Chart.getChart('user.vbar'), peroid)
Chart.onPaint()
})
}
window.onload = () => {
initLayout()
paintDrawline()
}
</script>
</body>
</html>