-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic.html
57 lines (53 loc) · 1.73 KB
/
basic.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
<!DOCTYPE html>
<html lang="en" style="background: #FFFFFF;height: 100%">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="description"
content="KLineChart example"/>
<title>KLineChart + js</title>
<!--
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/klinecharts/dist/klinecharts.min.js"></script>
<script type="text/javascript" src="./kline.js"></script>
-->
<!--
<script type="module" src=/src/klinecharts/index.js></script>
-->
</head>
<body style="margin: 0;height: 100%">
<div id="chart" style="height: 100%"></div>
<script type="module">
import * as klinecharts from '/src/klinecharts/index.ts';
import {kLineDataList} from '/src/kline.ts';
console.log(document.querySelector('#chart').clientHeight);
let chart = null;
window.onload = function () {
//const dummy = function () {
// 初始化图表
chart = klinecharts.init('chart')
// 创建一个主图技术指标
chart.createIndicator('MA', false, { id: 'candle_pane' })
// 创建一个副图技术指标VOL
chart.createIndicator('VOL')
// 创建一个副图技术指标MACD
chart.createIndicator('MACD')
// 加载数据
var chartDataList = kLineDataList.map(function (data) {
return {
timestamp: new Date(data[0]).getTime(),
open: +data[1],
high: +data[2],
low: +data[3],
close: +data[4],
volume: Math.ceil(+data[5]),
}
})
chart.applyNewData(chartDataList)
window.addEventListener('resize', () => {
chart?.resize();
});
}
</script>
</body>
</html>