-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest2.jsp
159 lines (111 loc) · 3.48 KB
/
test2.jsp
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
<%@include file ='header.jsp' %>
<%@page import = "java.util.*"%>
</div>
</div>
</div>
<br/><br/><br/><br/><br/><br/><br/><br/>
<title>Chart</title>
<% if(request.getAttribute("graph")==null){ %>
<p>Something is wrong, may be nothing is there in database.</p>
<%} %>
<%ArrayList<String> carlist = (ArrayList<String>) request.getAttribute("graph");%>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
<script>
google.charts.load('current', {packages: ['corechart', 'bar']});
google.charts.setOnLoadCallback(drawBasic);
function drawBasic() {
var data = google.visualization.arrayToDataTable([
['City', 'Available Cars',],
<%
int i =0;
%>
<%while (i<carlist.size()){%>
['<%out.print(carlist.get(i));%>',<%out.print(carlist.get(i+1));%>],
<%i=i+2;}%>
]);
var options = {
title: 'Available cars in U.S. Cities',
chartArea: {width: '70%'},
hAxis: {
title: 'Total Cars',
minValue: 0
},
vAxis: {
title: 'City'
}
};
var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
<br>
<hr>
<div id="chart_div2"></div>
<% if(request.getAttribute("graph2")==null){ %>
<p>Something is wrong, may be nothing is there in database.</p>
<%} %>
<%ArrayList<String> orderlist = (ArrayList<String>) request.getAttribute("graph2");%>
<script>
google.charts.load('current', {packages: ['corechart', 'bar']});
google.charts.setOnLoadCallback(drawBasic);
function drawBasic() {
var data = google.visualization.arrayToDataTable([
['Cars', 'Total Amounnt',],
<%
int j =0;
%>
<%while (j<orderlist.size()){%>
['<%out.print(orderlist.get(j));%>',<%out.print(orderlist.get(j+1));%>],
<%j=j+2;}%>
]);
var options = {
title: 'Total sales of disparate cars',
chartArea: {width: '70%'},
hAxis: {
title: 'Amount',
minValue: 0
},
vAxis: {
title: 'Cars'
}
};
var chart = new google.visualization.BarChart(document.getElementById('chart_div2'));
chart.draw(data, options);
}
</script>
<br>
<hr>
<div id="chart_div3"></div>
<% if(request.getAttribute("graph3")==null){ %>
<p>Something is wrong, may be nothing is there in database.</p>
<%} %>
<%ArrayList<String> saleslist = (ArrayList<String>) request.getAttribute("graph3");%>
<script>
google.charts.load('current', {packages: ['corechart', 'bar']});
google.charts.setOnLoadCallback(drawBasic);
function drawBasic() {
var data = google.visualization.arrayToDataTable([
['Cars', 'Count of cars sold',],
<%
int k =0;
%>
<%while (k<saleslist.size()){%>
['<%out.print(saleslist.get(k));%>',<%out.print(saleslist.get(k+1));%>],
<%k=k+2;}%>
]);
var options = {
title: 'Total times cars were sold',
chartArea: {width: '70%'},
hAxis: {
title: 'Count',
minValue: 0
},
vAxis: {
title: 'Cars'
}
};
var chart = new google.visualization.BarChart(document.getElementById('chart_div3'));
chart.draw(data, options);
}
</script>