-
Notifications
You must be signed in to change notification settings - Fork 1
/
testcharts.html
53 lines (47 loc) · 1.82 KB
/
testcharts.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
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
<script type="text/javascript">
$(document).ready(function(){
google.charts.load("current", {packages:["corechart"]});
google.charts.setOnLoadCallback(drawChart);
var chart_arr = [];
$.get("https://www.quandl.com/api/v3/datasets/WGC/GOLD_DAILY_USD.json?api_key=VzZzw2s9FYGh3ampr5mg", function(res){
var arr = res.dataset['data'];
for (var i=0; i<17; i++){
var data_arr = []
x = res.dataset['data'][i][0];
y = res.dataset['data'][i][1];
data_arr.push("[x,y]");
chart_arr.push(data_arr)
}
}, 'json');
console.log("data array", data_ar)
// console.log(chart_arr,"Chart array")
function drawChart() {
var x = [['Price', 'Date'],]
for (var i=0; i<chart_arr.length; i++){
data.push([res.dataset['data'][i][0],res.dataset['data'][i][1]])
}
console.log(x, "data")
var data = google.visualization.arrayToDataTable()[
['Price', 'Date'],
[1125.7, '2016-12-20'],
[1155.7, '2016-13-20'],
[1105.7, '2016-14-20']]
};
var options = {
title: 'Lengths of dinosaurs, in meters',
legend: { position: 'none' },
};
var chart = new google.visualization.Histogram(document.getElementById('chart_div'));
chart.draw(data, options);
return false;
});
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>