HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
2
3
async function requestAndTreatment() {
4
/*
5
const response = await fetch(requestURL);
6
const res = await response.json();
7
//Get date from apishka
8
let time = res.timestamp;
9
let date = new Date(time);
10
//Get prices from apishka
11
let open = res.data[0].open;
12
let high = res.data[0].high;
13
let low = res.data[0].low;
14
let close = res.data[0].close;
15
16
//Translating milliseconds into year, month...
17
18
let year = date.getFullYear();
19
let month = date.getMonth();
20
letday = date.getDate();
21
let hours = date.getHours();
22
let minutes = date.getMinutes();
23
//Add "0" in front of the number if the month is a number and not a number
24
if (month < 10) {
25
month = "0" + month;
26
}
27
*/
28
//fills the array with information.
29
30
// add into anychart data set - not simply an array
31
console.log(Date.now());
32
data.addData([[Date.now(), 1, 2, 0, 1.5]]);
33
34
}
35
36
let year = 2008;
37
let data = anychart.data.table(0);
38
39
anychart.onDocumentReady(function () {
40
// create a chart
41
chart = anychart.stock();
42
43
mapping = data.mapAs({open: 1, high: 2, low: 3, close: 4});
44
// create a japanese candlestick series and set the data
45
var series = chart.plot(0).candlestick(mapping);
46
47
// set container id
48
chart.container("container");
49
50
// initiate drawing the chart
51
chart.draw();
52
53
setInterval(requestAndTreatment, 1000);
54
})