-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathline.html
116 lines (99 loc) · 2.99 KB
/
line.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
<!doctype html>
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
<meta charset="utf-8">
<title>ESPN Cricinfo - Match Centre</title>
<link rel="stylesheet" href="./css/styles.css">
</head>
<style type="text/css" media="screen">
html{
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
}
body{
background: #f2f2f2;
}
.espn-gfx{
float:left;
padding-bottom:10px;
}
.mcr-chart-axis path, .mcr-chart-axis line {
fill: none;
stroke: #ced2d3;
}
</style>
<body>
<div id="espn-line2" class="espn-gfx"></div>
<div id="espn-line3" class="espn-gfx"></div>
<div id="espn-line" class="espn-gfx"></div>
<div id="espn-line4" class="espn-gfx"></div>
<script src="./bower_components/d3/d3.js"></script>
<script src="./bower_components/d3.chart/d3.chart.js"></script>
<script src="./js/espn.gfx.random.js"></script>
<script src="./js/espn.gfx.line.js"></script>
<script>
var cumulative = [[0,0,""],[1,2,200],[2,2,100],[3,2,66],[4,2,50],[5,3,60],[6,3,50],[7,3,42],[8,4,50],[9,5,55],[10,11,110],[11,12,109],[12,13,108],[13,14,107],[14,14,100],[15,15,100],[16,16,100],[17,20,117],[18,20,111],[19,24,126],[20,28,140],[21,29,138],[22,31,140],[23,32,139],[24,33,137],[25,34,136],[26,36,138],[27,36,133],[28,40,142],[29,41,141],[30,41,136],[31,42,135],[32,43,134],[33,44,133],[34,45,132],[35,47,134],[36,47,130],[37,48,129],[38,49,128],[39,50,128],[40,54,135],[41,55,134],[42,56,133],[43,56,130],[44,56,127]];
function getComparisons(cumulative){
var arr = [],
cur;
for (var i = 0, len = cumulative.length; i < len; i++) {
cur = cumulative[i];
arr.push({
over: Number(cur[0]),
runs: Number(cur[1]),
rate: Number(cur[2])
})
}
return arr;
}
getComparisons(cumulative);
var interval = 4000;
setInterval(function(){
// line.draw(espn.gfx.random.line(1,7));
line2.draw(espn.gfx.random.line(1,2));
line3.draw(espn.gfx.random.line(1,3));
line4.draw(espn.gfx.random.line(1,30));
},interval);
var line = d3.select("#espn-line")
.chart("line",{
width : 225,
height : 225,
keyLeftMargin : 100,
chartTitle : 'BALLS',
comparison : true,
key : ['Runs','Strike rate']
});
line.draw(getComparisons(cumulative));
var line2 = d3.select("#espn-line2")
.chart("line",{
width : 225,
height : 225,
keyLeftMargin : 100,
chartTitle : 'BALLS',
comparison : true,
key : ['Runs','Strike rate']
});
line2.draw(espn.gfx.random.line(1,2));
var line3 = d3.select("#espn-line3")
.chart("line",{
width : 225,
height : 225,
keyLeftMargin : 100,
chartTitle : 'BALLS',
comparison : true,
key : ['Runs','Strike rate']
});
line3.draw(espn.gfx.random.line(1,3));
var line4 = d3.select("#espn-line4")
.chart("line",{
width : 350,
height : 225,
keyLeftMargin : 270,
chartTitle : 'BALLS',
key : ['Runs'],
colors : ['#7dcc5f'],
strokeWidth : 3
});
line4.draw(espn.gfx.random.line(1,10));
</script>
</body>