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
year = year + 1;
32
month = 1;
33
day = 1;
34
high = 1;
35
low = 0.5;
36
open = 0.6;
37
close = 0.8;
38
console.log(Date.UTC(year, month, day));
39
data.addData([[Date.UTC(year, month, day), open, high, low, close]]);
40
}
41
42
let year = 2008;
43
let data = anychart.data.table(0);
44
45
anychart.onDocumentReady(function () {
46
// create a chart
47
chart = anychart.stock();
48
49
mapping = data.mapAs({open: 1, high: 2, low: 3, close: 4});
50
// create a japanese candlestick series and set the data
51
var series = chart.plot(0).candlestick(mapping);
52
53
// set container id
54
chart.container("container");
55
56
// initiate drawing the chart
57
chart.draw();
58
59
setInterval(requestAndTreatment, 1000);
60
})