This repository was archived by the owner on Sep 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
59 lines (55 loc) · 1.74 KB
/
test.php
File metadata and controls
59 lines (55 loc) · 1.74 KB
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
<?php
/**
* Created by PhpStorm.
* User: Daniel Pfeffer
* Date: 20.04.18
*/
$api_key = "8IC1KW4FEJ2EDU3D";
$firma = "ATX";
$file = "https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=" . $firma . "&apikey=$api_key";
$dataPoints = array();
if ($file) {
$json = json_decode(file_get_contents($file));
$real = $json->{"Time Series (Daily)"};
$startDate = time();
for ($cnt = 0; $cnt < 100; $cnt++) {
$date = date("Y-m-d", strtotime("-$cnt day", $startDate));
$yaxis = $real->{$date}->{"1. open"};
if ($yaxis != null && $yaxis != 0) {
array_push($dataPoints, array("y" => $yaxis, "label" => $date));
}
}
$min = min($dataPoints);
$min = $min['y'];
//https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=MSFT&apikey=8IC1KW4FEJ2EDU3D
}
?>
<script>
window.onload = function () {
let chart = new CanvasJS.Chart("chartContainer", {
zoomEnabled: true,
title: {
text: "Stock Market of " +<?php echo "\"$firma\""?>
},
axisY: {
title: "€",
minimum: <?php echo $min - 10 ?>
},
axisX: {
title: "Date",
},
data: [{
type: "line",
color: "green",
dataPoints: <?php echo json_encode(array_reverse($dataPoints), JSON_NUMERIC_CHECK);?>
}
]
});
chart.render();
}
</script>
<body>
<div id="chartContainer" style="height: 370px; width: 90%;"></div>
<div><a>Add to Favourite</a></div>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
</body>