-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharts.html
291 lines (216 loc) · 11.3 KB
/
charts.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="css/bootstrap-theme.min.css" crossorigin="anonymous">
<link href="../css/style.css" rel="stylesheet" media="screen, print">
<link href="../css/navcustom.css" rel="stylesheet">
<link rel="stylesheet" href="css/starter-template.css">
<!-- Latest compiled and minified JavaScript -->
<script src="js/bootstrap.min.js" crossorigin="anonymous"></script>
<script>
var dataPop = [["Country", "Population"]];
var dataAr = [["Country", "Population"]];
var bubbleChart = [['Country', 'Rank', 'PercentageOfWorld', 'Country', 'Population']];
var comboChart = [['CustName', 'Q1', 'Q2', 'Q3', 'Q4', 'TotalOrder']];
$(document).ready(function () {
$("button").click(function () {
var SendInfo = {"limit": 5};
//call customer
$.ajax({
url: 'http://api.masterdatanode.com/demo-prod/customer/find/',
type: 'get',
data: {},
headers: {
"access_token": '2QElaypzKUgiroyYIMu8oIXNy3ZPateI',
"Content-Type": 'application/json'
},
dataType: 'json',
success: function (data) {
// console.info(JSON.stringify(data));
// $("#test_div").html(JSON.stringify(data));
var population = data['result'];
// var myStringArray = ["Hello", "World"];
var obj = {a: 1, b: 2};
for (var key in population) {
if (population.hasOwnProperty(key)) {
var val = population[key];
// alert(JSON.stringify(val['Country']));
comboChart.push([val['CustName'], val['Q1'], val['Q2'], val['Q3'], val['Q4'], val['CustomerOrder']])
// alert(JSON.stringify(dataPop));
}
}
// Load the Visualization API and the corechart package.
// google.charts.load('current', {'packages': ['corechart']});
// google.charts.setOnLoadCallback(drawComboChart);
}
});
//call population
$.ajax({
url: 'http://api.masterdatanode.com/demo-prod/population/find/',
type: 'get',
data: {},
headers: {
"access_token": '2QElaypzKUgiroyYIMu8oIXNy3ZPateI',
"Content-Type": 'application/json'
},
dataType: 'json',
success: function (data) {
// console.info(JSON.stringify(data));
// $("#test_div").html(JSON.stringify(data));
var population = data['result'];
// var myStringArray = ["Hello", "World"];
var obj = {a: 1, b: 2};
for (var key in population) {
if (population.hasOwnProperty(key)) {
var val = population[key];
// alert(JSON.stringify(val['Country']));
dataPop.push([val['Country'], val['Population']]);
dataAr.push([val['Country'], val['Population']]);
bubbleChart.push([val['Country'], val['Rank'], val['PercentageOfWorld'], val['Country'], val['Population']])
// alert(JSON.stringify(dataPop));
}
}
// Load the Visualization API and the corechart package.
google.charts.load('current', {'packages': ['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(drawChart);
google.charts.setOnLoadCallback(drawBar);
google.charts.setOnLoadCallback(drawSeriesChart);
google.charts.setOnLoadCallback(drawColumnChart);
google.charts.setOnLoadCallback(drawDonutChart);
google.charts.setOnLoadCallback(draw3dChart);
google.charts.setOnLoadCallback(drawComboChart);
}
});
});
});
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
var data = google.visualization.arrayToDataTable(dataPop);
// Set chart options
var options = {'title': 'World population Pie chart',
'width': 400,
'height': 300};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawBar() {
// Create the data table.
var data = google.visualization.arrayToDataTable(dataPop);
// Set chart options
var options = {'title': 'World Population Bar chart',
'width': 400,
'height': 300};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.BarChart(document.getElementById('bar_div'));
chart.draw(data, options);
}
function drawSeriesChart() {
var data = google.visualization.arrayToDataTable(bubbleChart);
var options = {
title: 'World population Bubble chart',
hAxis: {title: 'Rank'},
vAxis: {title: 'PercentageOfWorld'},
bubble: {textStyle: {fontSize: 11}}
};
var chart = new google.visualization.BubbleChart(document.getElementById('bubble_div'));
chart.draw(data, options);
}
function drawColumnChart() {
var data = google.visualization.arrayToDataTable(dataAr);
var view = new google.visualization.DataView(data);
var options = {
title: "World Population Column chart",
};
var chart = new google.visualization.ColumnChart(document.getElementById("columnchart_div"));
chart.draw(view, options);
}
function drawComboChart() {
// Some raw data (not necessarily accurate)
var data = google.visualization.arrayToDataTable(comboChart);
var options = {
title: 'Monthly Coffee Production by Company',
vAxis: {title: 'Order'},
hAxis: {title: 'CustName'},
seriesType: 'bars',
series: {5: {type: 'line'}}
};
var chart = new google.visualization.ComboChart(document.getElementById('combochart_div'));
chart.draw(data, options);
}
function drawDonutChart() {
var data = google.visualization.arrayToDataTable(dataPop);
var options = {
title: 'World Population Donut chart',
pieHole: 0.4,
// slices: {1: {offset: 0.2},
// 2: {offset: 0.3},
// 4: {offset: 0.4},
// 7: {offset: 0.5},
// },
};
var chart = new google.visualization.PieChart(document.getElementById('donutchart_div'));
chart.draw(data, options);
}
function draw3dChart() {
var data = google.visualization.arrayToDataTable(dataPop);
var options = {
title: 'World Population 3d chart',
is3D: true,
// slices: {1: {offset: 0.2},
// 2: {offset: 0.3},
// 4: {offset: 0.4},
// 7: {offset: 0.5},
// },
};
var chart = new google.visualization.PieChart(document.getElementById('3dchart_div'));
chart.draw(data, options);
}
</script>
</head>
<body >
<!-- Navigation -->
<div class="intro-header">
<!--Div that will hold the pie chart-->
<div class="container" style="text-align: center">
<div >
<h1>Dashboard charts</h1>
<p class="lead">With MasterDataNode you don't require server<br> A standalone html page with CSS and JS, suffice to build Chart application</p>
</div>
<div >
<button class="btn btn-info">Click Button to create charts</button>
<a href="https://github.com/MasterDataNode/HTMLExample/blob/master/charts.html" target="blank" > <button class="btn btn-info">See Code</button> </a>
</div>
<div class="col-lg-12">
<div id="chart_div" class="col-lg-6"></div>
<div id="bar_div" class="col-lg-6"></div>
<div id="donutchart_div" class="col-lg-6" style="width: 500px; height: 500px;"></div>
<div id="3dchart_div" class="col-lg-6" style="width: 500px; height: 500px;"></div>
</div>
<div class="col-lg-12">
<div id="bubble_div" ></div>
</div>
<div class="col-lg-12">
<div id="columnchart_div" ></div>
</div>
<div class="col-lg-12">
<div id="combochart_div" ></div>
</div>
</div>
</div>
</body>
</html>