-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
840 lines (746 loc) · 34.2 KB
/
Copy pathindex.html
File metadata and controls
840 lines (746 loc) · 34.2 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
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>IPL Data Visualization 2021 by PAHALAVAN R D</title>
<!-- Favicon icon -->
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon.png">
<!-- Custom Stylesheet and Scripts -->
<link href="css/style.css?2" rel="stylesheet">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
crossorigin=""></script>
<style>
/*the container must be positioned relative:*/
.autocomplete {
position: relative;
display: inline-block;
}
input {
border: 1px solid transparent;
background-color: #f1f1f1;
padding: 10px;
font-size: 16px;
}
input[type=text] {
background-color: #f1f1f1;
width: 100%;
}
#cc1 {
background-color: #5470c6;
color: #fff;
cursor: pointer;
}
#cc2 {
background-color: #91cc75;
color: #fff;
cursor: pointer;
}
#cc3 {
background-color: #ee6666;
color: #fff;
cursor: pointer;
}
.autocomplete-items {
position: absolute;
border: 1px solid #d4d4d4;
border-bottom: none;
border-top: none;
z-index: 99;
/*position the autocomplete items to be the same width as the container:*/
top: 100%;
left: 0;
right: 0;
}
.autocomplete-items div {
padding: 10px;
cursor: pointer;
background-color: #fff;
border-bottom: 1px solid #d4d4d4;
}
/*when hovering an item:*/
.autocomplete-items div:hover {
background-color: #e9e9e9;
}
/*when navigating through the items using the arrow keys:*/
.autocomplete-active {
background-color: DodgerBlue !important;
color: #ffffff;
}
#map { height: 780px; }
</style>
</head>
<body>
<!--*******************
Preloader start
********************-->
<div id="preloader">
<div class="loader">
<svg class="circular" viewBox="25 25 50 50">
<circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="3" stroke-miterlimit="10" />
</svg>
</div>
</div>
<!--*******************
Preloader end
********************-->
<!--**********************************
Main wrapper start
***********************************-->
<div id="main-wrapper">
<!--**********************************
Content body start
***********************************-->
<div class="content-body">
<div class="col">
<div class="card">
<div class="card-body">
<div class="text-center">
<img alt="" class="rounded-circle mt-4" src="images/logo.png" height=100 width=100>
<h4 class="card-widget__title text-dark mt-3">IPL Data Visualization 2021</h4>
<p class="text-muted">PAHALAVAN R D</p>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body text-center">
<h5 class="center-1">Search Batsman Name or Select using the Chart</h5>
<br>
<form autocomplete="off" action="/IPL-Data-Visualization/batsman.html" target="_blank">
<div class="autocomplete" style="width:300px;">
<input id="batsman" type="text" name="player" placeholder="Player Name" required>
</div>
<input id="cc1" type="submit" value="OPEN">
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<!--**********************************
CHART 1
***********************************-->
<div id="chart1" style="width: 100%;height:500px;"></div>
<div class='center-1'>
<div class="dropdown56">
<p id="value6">Most Runs in IPL</p>
<div class="dropdown-content56">
<a id="value7" href="javascript:changeValue('value7')"><p>Most Runs</p></a>
<a id="value8" href="javascript:changeValue('value8')"><p>Most Matches</p></a>
<a id="value9" href="javascript:changeValue('value9')"><p>Highest Strike Rate</p></a>
<a id="value10" href="javascript:changeValue('value10')"><p>Highest Average</p></a>
<a id="value11" href="javascript:changeValue('value11')"><p>Most Centuries</p></a>
<a id="value12" href="javascript:changeValue('value12')"><p>Most Half Cebturies</p></a>
<a id="value13" href="javascript:changeValue('value13')"><p>Most Sixes</p></a>
<a id="value14" href="javascript:changeValue('value14')"><p>Most Fours</p></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body text-center">
<h5 class="center-1">Search Bowler Name or Select using the Chart</h5>
<br>
<form autocomplete="off" action="/IPL-Data-Visualization/bowler.html" target="_blank">
<div class="autocomplete" style="width:300px;">
<input id="bowler" type="text" name="player" placeholder="Player Name" required>
</div>
<input id="cc2" type="submit" value="OPEN">
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<!--**********************************
CHART 2
***********************************-->
<div id="chart2" style="width: 100%;height:500px;"></div>
<div class='center-1'>
<div class="dropdown56">
<p id="value21">Most Wickets in IPL</p>
<div class="dropdown-content56">
<a id="value15" href="javascript:changeValue('value15')"><p>Most Wickets</p></a>
<a id="value16" href="javascript:changeValue('value16')"><p>Most Matches</p></a>
<a id="value17" href="javascript:changeValue('value17')"><p>Lowest Average</p></a>
<a id="value18" href="javascript:changeValue('value18')"><p>Lowest Economy</p></a>
<a id="value19" href="javascript:changeValue('value19')"><p>Most Dot Balls</p></a>
<a id="value20" href="javascript:changeValue('value20')"><p>Most Maiden Overs</p></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body text-center">
<h5 class="center-1">Comparison Between two Batsmen</h5>
<br>
<form autocomplete="off" action="/IPL-Data-Visualization/compare-batsmen.html" target="_blank">
<div class="autocomplete" style="width:300px;">
<input id="batsman1" type="text" name="player1" placeholder="Player 1" required>
</div>
<div class="autocomplete" style="width:300px;">
<input id="batsman2" type="text" name="player2" placeholder="Player 2" required>
</div>
<input id='cc3' type="submit" value="OPEN">
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body text-center">
<h5 class="center-1">Comparison Between two Bowlers</h5>
<br>
<form autocomplete="off" action="/IPL-Data-Visualization/compare-bowlers.html" target="_blank">
<div class="autocomplete" style="width:300px;">
<input id="bowler1" type="text" name="player1" placeholder="Player 1" required>
</div>
<div class="autocomplete" style="width:300px;">
<input id="bowler2" type="text" name="player2" placeholder="Player 2" required>
</div>
<input id='cc3' type="submit" value="OPEN">
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<!--**********************************
CHART 3
***********************************-->
<div id="map"></div>
</div>
</div>
</div>
</div>
</div>
<!-- #/ container -->
</div>
<!--**********************************
Content body end
***********************************-->
<!--**********************************
Footer start
***********************************-->
<div class="footer">
<div class="copyright">
<p>Copyright © Designed & Developed by Pahalavan R D</p>
</div>
</div>
<!--**********************************
Footer end
***********************************-->
</div>
<!--**********************************
Main wrapper end
***********************************-->
<!--**********************************
Scripts
***********************************-->
<script>
function autocomplete(inp, arr) {
/*the autocomplete function takes two arguments,
the text field element and an array of possible autocompleted values:*/
var currentFocus;
/*execute a function when someone writes in the text field:*/
inp.addEventListener("input", function(e) {
var a, b, i, val = this.value;
/*close any already open lists of autocompleted values*/
closeAllLists();
if (!val) { return false;}
currentFocus = -1;
/*create a DIV element that will contain the items (values):*/
a = document.createElement("DIV");
a.setAttribute("id", this.id + "autocomplete-list");
a.setAttribute("class", "autocomplete-items");
/*append the DIV element as a child of the autocomplete container:*/
this.parentNode.appendChild(a);
/*for each item in the array...*/
for (i = 0; i < arr.length; i++) {
/*check if the item starts with the same letters as the text field value:*/
if (arr[i].substr(0, val.length).toUpperCase() == val.toUpperCase()) {
/*create a DIV element for each matching element:*/
b = document.createElement("DIV");
/*make the matching letters bold:*/
b.innerHTML = "<strong>" + arr[i].substr(0, val.length) + "</strong>";
b.innerHTML += arr[i].substr(val.length);
/*insert a input field that will hold the current array item's value:*/
b.innerHTML += "<input type='hidden' value='" + arr[i] + "'>";
/*execute a function when someone clicks on the item value (DIV element):*/
b.addEventListener("click", function(e) {
/*insert the value for the autocomplete text field:*/
inp.value = this.getElementsByTagName("input")[0].value;
/*close the list of autocompleted values,
(or any other open lists of autocompleted values:*/
closeAllLists();
});
a.appendChild(b);
}
}
});
/*execute a function presses a key on the keyboard:*/
inp.addEventListener("keydown", function(e) {
var x = document.getElementById(this.id + "autocomplete-list");
if (x) x = x.getElementsByTagName("div");
if (e.keyCode == 40) {
/*If the arrow DOWN key is pressed,
increase the currentFocus variable:*/
currentFocus++;
/*and and make the current item more visible:*/
addActive(x);
} else if (e.keyCode == 38) { //up
/*If the arrow UP key is pressed,
decrease the currentFocus variable:*/
currentFocus--;
/*and and make the current item more visible:*/
addActive(x);
} else if (e.keyCode == 13) {
/*If the ENTER key is pressed, prevent the form from being submitted,*/
e.preventDefault();
if (currentFocus > -1) {
/*and simulate a click on the "active" item:*/
if (x) x[currentFocus].click();
}
}
});
function addActive(x) {
/*a function to classify an item as "active":*/
if (!x) return false;
/*start by removing the "active" class on all items:*/
removeActive(x);
if (currentFocus >= x.length) currentFocus = 0;
if (currentFocus < 0) currentFocus = (x.length - 1);
/*add class "autocomplete-active":*/
x[currentFocus].classList.add("autocomplete-active");
}
function removeActive(x) {
/*a function to remove the "active" class from all autocomplete items:*/
for (var i = 0; i < x.length; i++) {
x[i].classList.remove("autocomplete-active");
}
}
function closeAllLists(elmnt) {
/*close all autocomplete lists in the document,
except the one passed as an argument:*/
var x = document.getElementsByClassName("autocomplete-items");
for (var i = 0; i < x.length; i++) {
if (elmnt != x[i] && elmnt != inp) {
x[i].parentNode.removeChild(x[i]);
}
}
}
/*execute a function when someone clicks in the document:*/
document.addEventListener("click", function (e) {
closeAllLists(e.target);
});
}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.2.1/echarts.min.js" integrity="sha512-17GGcT5BjSbaXG+4Fk3Z1HS1ATXH5oEH060GS3WvSEqGGpkSbRV/amkIWpqOJOIwkBW13QMOBblj8DXnlN7bEA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="js/custom.min.js"></script>
<script src="js/echart.js?1"></script>
<script>
// CHART 1 INITIOALIZATION
var chartDom1 = document.getElementById('chart1');
var myChart1 = echarts.init(chartDom1);
var option1;
// CHART 2 INITIALIZATION
var chartDom2 = document.getElementById('chart2');
var myChart2 = echarts.init(chartDom2);
var option2;
var name_array = {};
var matches_array = {};
var runs_array = {};
var average_array = {};
var strike_rate_array = {};
var centuries_array = {};
var half_centuries_array = {};
var sixes_array = {};
var fours_array = {};
$.get('dataset/most_runs.json',
function (most_runs) {
name_array = Object.keys(most_runs).map(el=> el);
var m1 = Object.values(most_runs).map(el=> el['Matches All']);
name_array.forEach((key, i) => matches_array[key] = m1[i]);
matches_array = sortByValue(matches_array);
var m2 = Object.values(most_runs).map(el=> el['Runs All']);
name_array.forEach((key, i) => runs_array[key] = m2[i]);
runs_array = sortByValue(runs_array);
var m3 = Object.values(most_runs).map(el=> el['Average All']);
name_array.forEach((key, i) => average_array[key] = m3[i]);
average_array = sortByValue(average_array);
var m4 = Object.values(most_runs).map(el=> el['Strike Rate All']);
name_array.forEach((key, i) => strike_rate_array[key] = m4[i]);
strike_rate_array = sortByValue(strike_rate_array);
var m5 = Object.values(most_runs).map(el=> el['Centuries All']);
name_array.forEach((key, i) => centuries_array[key] = m5[i]);
centuries_array = sortByValue(centuries_array);
var m6 = Object.values(most_runs).map(el=> el['Half Centuries All']);
name_array.forEach((key, i) => half_centuries_array[key] = m6[i]);
half_centuries_array = sortByValue(half_centuries_array);
var m7 = Object.values(most_runs).map(el=> el['Sixes All']);
name_array.forEach((key, i) => sixes_array[key] = m7[i]);
sixes_array = sortByValue(sixes_array);
var m8 = Object.values(most_runs).map(el=> el['Fours All']);
name_array.forEach((key, i) => fours_array [key] = m8[i]);
fours_array = sortByValue(fours_array );
autocomplete(document.getElementById("batsman"), name_array);
autocomplete(document.getElementById("batsman1"), name_array);
autocomplete(document.getElementById("batsman2"), name_array);
myChart1.hideLoading();
option1 = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
label: {
show: true
}
}
},
calculable: true,
grid: {
top: '12%',
left: '1%',
right: '10%',
containLabel: true
},
xAxis: [
{
type: 'category',
data: Object.keys(runs_array)
}
],
yAxis: [
{
type: 'value',
axisLabel: {
formatter: function (a) {
a = +a;
return isFinite(a) ? echarts.format.addCommas(+a / 1) : '';
}
}
}
],
dataZoom: [
{
show: true,
start: 0,
end: 100
},
{
type: 'inside',
start: 0,
end: 100
},
{
show: true,
yAxisIndex: 0,
filterMode: 'empty',
width: 30,
height: '80%',
showDataShadow: false,
left: '93%'
}
],
series: [
{
name: 'Total Runs',
type: 'bar',
data: Object.values(runs_array),
color: '#5470c6'
}
]
};
myChart1.setOption(option1);
myChart1.on('click', function (id){
window.open("/IPL-Data-Visualization/batsman.html?player="+id.name);
});
}
);
var named_array = {};
var match_array = {};
var wickets_array = {};
var averaged_array = {};
var economy_array = {};
var dot_balls_array = {};
var maiden_overs_array = {};
$.get('dataset/most_wickets.json',
function (most_wickets) {
named_array = Object.keys(most_wickets).map(el=> el);
var m9 = Object.values(most_wickets).map(el=> el['Matches All']);
named_array.forEach((key, i) => match_array[key] = m9[i]);
match_array = sortByValue(match_array);
var m10 = Object.values(most_wickets).map(el=> el['Wickets All']);
named_array.forEach((key, i) => wickets_array[key] = m10[i]);
wickets_array = sortByValue(wickets_array);
var m11 = Object.values(most_wickets).map(el=> el['Average All']);
named_array.forEach((key, i) => averaged_array[key] = m11[i]);
averaged_array = sortByValue(averaged_array);
var m12 = Object.values(most_wickets).map(el=> el['Economy All']);
named_array.forEach((key, i) => economy_array[key] = m12[i]);
economy_array = sortByValue(economy_array);
var m13 = Object.values(most_wickets).map(el=> el['Dot Balls All']);
named_array.forEach((key, i) => dot_balls_array[key] = m13[i]);
dot_balls_array = sortByValue(dot_balls_array);
var m14 = Object.values(most_wickets).map(el=> el['Maiden Overs All']);
named_array.forEach((key, i) => maiden_overs_array[key] = m14[i]);
maiden_overs_array = sortByValue(maiden_overs_array);
autocomplete(document.getElementById("bowler"), named_array);
autocomplete(document.getElementById("bowler1"), named_array);
autocomplete(document.getElementById("bowler2"), named_array);
myChart2.hideLoading();
option2 = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
label: {
show: true
}
}
},
calculable: true,
grid: {
top: '12%',
left: '1%',
right: '10%',
containLabel: true
},
xAxis: [
{
type: 'category',
data: Object.keys(wickets_array).reverse()
}
],
yAxis: [
{
type: 'value',
axisLabel: {
formatter: function (a) {
a = +a;
return isFinite(a) ? echarts.format.addCommas(+a / 1) : '';
}
}
}
],
dataZoom: [
{
show: true,
start: 0,
end: 100
},
{
type: 'inside',
start: 0,
end: 100
},
{
show: true,
yAxisIndex: 0,
filterMode: 'empty',
width: 30,
height: '80%',
showDataShadow: false,
left: '93%'
}
],
series: [
{
name: 'Total Wickets',
type: 'bar',
data: Object.values(wickets_array).reverse(),
color: '#91cc75'
}
]
};
myChart2.setOption(option2);
myChart2.on('click', function (id){
window.open("/IPL-Data-Visualization/bowler.html?player="+id.name);
});
}
);
function changeValue(val){
switch(val){
case 'value7':
option1["series"][0]["data"]=Object.values(runs_array);
option1["xAxis"][0]["data"]=Object.keys(runs_array);
option1["series"][0]["name"]='Total Runs';
myChart1.setOption(option1);
document.getElementById("value6").innerHTML ='Most Runs in IPL';
break;
case 'value8':
option1["series"][0]["data"]=Object.values(matches_array);
option1["xAxis"][0]["data"]=Object.keys(matches_array);
option1["series"][0]["name"]='Total Matches';
myChart1.setOption(option1);
document.getElementById("value6").innerHTML ='Most Matches in IPL';
break;
case 'value9':
option1["series"][0]["data"]=Object.values(strike_rate_array);
option1["xAxis"][0]["data"]=Object.keys(strike_rate_array);
option1["series"][0]["name"]='Batting Strike Rate';
myChart1.setOption(option1);
document.getElementById("value6").innerHTML ='Highest Strike Rate in IPL';
break;
case 'value10':
option1["series"][0]["data"]=Object.values(average_array);
option1["xAxis"][0]["data"]=Object.keys(average_array);
option1["series"][0]["name"]='Batting Average';
myChart1.setOption(option1);
document.getElementById("value6").innerHTML ='Highest Average in IPL';
break;
case 'value11':
option1["series"][0]["data"]=Object.values(centuries_array);
option1["xAxis"][0]["data"]=Object.keys(centuries_array);
option1["series"][0]["name"]='Total Centuries';
myChart1.setOption(option1);
document.getElementById("value6").innerHTML ='Most Centuries in IPL';
break;
case 'value12':
option1["series"][0]["data"]=Object.values(half_centuries_array);
option1["xAxis"][0]["data"]=Object.keys(half_centuries_array);
option1["series"][0]["name"]='Total Half Centuries';
myChart1.setOption(option1);
document.getElementById("value6").innerHTML ='Most Half Centuries in IPL';
break;
case 'value13':
option1["series"][0]["data"]=Object.values(sixes_array);
option1["xAxis"][0]["data"]=Object.keys(sixes_array);
option1["series"][0]["name"]='Total Sixes';
myChart1.setOption(option1);
document.getElementById("value6").innerHTML ='Most Sixes in IPL';
break;
case 'value14':
option1["series"][0]["data"]=Object.values(fours_array);
option1["xAxis"][0]["data"]=Object.keys(fours_array);
option1["series"][0]["name"]='Total Fours';
myChart1.setOption(option1);
document.getElementById("value6").innerHTML ='Most Fours in IPL';
break;
case 'value15':
option2["series"][0]["data"]=Object.values(wickets_array).reverse();
option2["xAxis"][0]["data"]=Object.keys(wickets_array).reverse();
option2["series"][0]["name"]='Total Wickets';
myChart2.setOption(option2);
document.getElementById("value21").innerHTML ='Most Wickets in IPL';
break;
case 'value16':
option2["series"][0]["data"]=Object.values(match_array).reverse();
option2["xAxis"][0]["data"]=Object.keys(match_array).reverse();
option2["series"][0]["name"]='Total Matches';
myChart2.setOption(option2);
document.getElementById("value21").innerHTML ='Most Matches in IPL';
break;
case 'value17':
option2["series"][0]["data"]=Object.values(averaged_array).reverse();
option2["xAxis"][0]["data"]=Object.keys(averaged_array).reverse();
option2["series"][0]["name"]='Bowling Average';
myChart2.setOption(option2);
document.getElementById("value21").innerHTML ='Lowest Average in IPL';
break;
case 'value18':
option2["series"][0]["data"]=Object.values(economy_array).reverse();
option2["xAxis"][0]["data"]=Object.keys(economy_array).reverse();
option2["series"][0]["name"]='Bowling Economy';
myChart2.setOption(option2);
document.getElementById("value21").innerHTML ='Lowest Economy in IPL';
break;
case 'value19':
option2["series"][0]["data"]=Object.values(dot_balls_array).reverse();
option2["xAxis"][0]["data"]=Object.keys(dot_balls_array).reverse();
option2["series"][0]["name"]='Total Dot Balls';
myChart2.setOption(option2);
document.getElementById("value21").innerHTML ='Most Dot Balls in IPL';
break;
case 'value20':
option2["series"][0]["data"]=Object.values(maiden_overs_array).reverse();
option2["xAxis"][0]["data"]=Object.keys(maiden_overs_array).reverse();
option2["series"][0]["name"]='Total Maiden Overs';
myChart2.setOption(option2);
document.getElementById("value21").innerHTML ='Most Maiden Overs in IPL';
break;
}
}
</script>
<script>
$.get('dataset/venues.json',
function (most_runs) {
var latitude = Object.values(most_runs).map(el=> el['Latitude']);
var longitude = Object.values(most_runs).map(el=> el['Longitude']);
var stadium = Object.values(most_runs).map(el=> el['Venue']);
var city = Object.values(most_runs).map(el=> el['City']);
var stadium_unique=[];
const occurrences = stadium.reduce(function (acc, curr) {
return acc[curr] ? ++acc[curr] : acc[curr] = 1, acc
}, {});
var greenIcon = L.icon({
iconUrl: 'images/stadium.png',
iconSize:[50, 50]
});
var map = L.map('map').setView([17.387140, 78.491684], 5);
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoicmRwYWhhbGF2YW4iLCJhIjoiY2t2ZDhod3hnYjVnazJwcTZzdDR4M3dlaCJ9.fEmTKtF1J8f1iLGXd45YFQ', {
attribution: 'IPL Stadiums | Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 14,
id: 'mapbox/streets-v11',
tileSize: 512,
zoomOffset: -1
}).addTo(map);
for(i=0;i<stadium.length;i++){
if(stadium_unique.includes(stadium[i])){
continue;
}
var marker = L.marker([latitude[i], longitude[i]], {icon: greenIcon}).addTo(map);
marker.bindPopup("Stadium: "+stadium[i]+"<br>City: "+city[i]+"<br>Total Matches: "+occurrences[stadium[i]]+"<br><a href='/IPL-Data-Visualization/stadium.html?stadium="+stadium[i]+"' target='_blank'>More Information</a>");
stadium_unique.push(stadium[i]);
}
});
</script>
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>
<script>
function sortByValue(object, descending = true) {
const { max, min } = Math;
const selector = descending ? max : min;
const objects = [];
const cloned = _.clone(object);
while (!_.isEmpty(cloned)) {
const selectedValue = selector(...Object.values(cloned));
const [key, value] = Object.entries(cloned).find(([, value]) => value === selectedValue);
objects.push({ [key]: value });
delete cloned[key];
}
return _.merge(...objects);
}
</script>
</body>
</html>