-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreally_dumb_stats.php
162 lines (141 loc) · 4.4 KB
/
really_dumb_stats.php
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
<?php
require_once('common.php');
template('header');
?>
<div class="album py-5 bg-light">
<div class="container">
<div class="row mt-3 mb-3">
<div class="col">
<p class="display-6 text-center ">Really Dumb Stats</p>
<p class="lead text-center mb-5">I don't know what you're trying to prove except maybe that you need something more constructive to do with your time...</p>
<div class="card mb-3">
<div class="card-header">
<h3>Who put the most movies on each wedge?</h3>
</div>
<div class="card-body">
<p>Pie charts to illustrate who dominated each wedge.</p>
<div class="row">
<?php for($i = 1; $i <= 12; $i++):?>
<div class="col-2">
<?php
$wedge_number = $i;
$this_wedge = get_moviegoers_from_this_wedge($pdo, $wedge_number);
asort($this_wedge);
//print_r($this_wedge);
$the_colors = Array();
$the_names = Array();
unset($this_wedge[0]);
foreach($this_wedge as $key => $value){
$the_colors[] = getMoviegoerColorById($key);
$the_names[] = getMoviegoerById($key);
}
?>
<strong>Wedge <?php echo $i;?></strong>
<canvas id="wedge<?php echo $i;?>" width="250" height="250" style="position:relative; !important"></canvas>
<script>
var ctx = document.getElementById('wedge<?php echo $i;?>').getContext('2d');
var myChart = new Chart(ctx, {
type: 'pie',
data: {
labels: ['<?php echo implode("','", $the_names); ?>'],
datasets: [{
data: [<?php echo implode(',',$this_wedge); ?>],
backgroundColor: ['#<?php echo implode("','#", $the_colors); ?>'],
hoverOffset: 10
}]
},
options: {
layout: {
padding: {
left: 5,
right: 5,
top: 0
}
},
plugins: {
legend: {
display: false
}
}
}
});
</script>
</div>
<?php endfor;?>
</div>
</div>
</div>
<div class="card mb-3">
<div class="card-header">
<h3>How many minutes of content has been put on each wedge?</h3>
</div>
<div class="card-body">
<div class="chart" style="height:25rem;">
<table id="wedge_time" class="charts-css column show-labels show-data">
<thead>
<tr>
<th scope="col">Wedge</th>
<th scope="col">Minutes</th>
</tr>
</thead>
<tbody>
<?php
$max = 0;
for($ii = 1; $ii <= 12; $ii++): ?>
<?php
$wedge_number = $ii;
$wedge = get_movies_from_this_wedge($pdo,$wedge_number);
$total_runtime = 0;
foreach($wedge as $film_id){
$total_runtime += get_movie_runtime($pdo, $film_id);
}
if($total_runtime > $max){
$max = $total_runtime;
}?>
<tr>
<th scope="row"> <?php echo $ii; ?> </th>
<td style="--size:<?php echo round($total_runtime/$max,2); ?>; "><span class="data data_padding"><?php echo $total_runtime; ?></span></td>
</tr>
<?php endfor;?>
</tbody>
</table>
</div>
</div>
</div>
<div class="card mb-3">
<div class="card-header">
<h3>How many minutes of content has each viewer put on the wheel?</h3>
</div>
<div class="card-body">
<div class="">
<?php $viewer_time = get_viewers_time($pdo);
arsort($viewer_time);
unset($viewer_time[0]);
$max = max($viewer_time);
?>
<div class="chart "style="height:25rem;">
<table id="columns" class="charts-css column show-labels">
<thead>
<tr>
<th scope="col">Person</th>
<th scope="col">Minutes</th>
</tr>
</thead>
<tbody>
<?php foreach($viewer_time as $key => $value):?>
<tr>
<th scope="row"> <?php echo getMoviegoerById($key); ?> </th>
<td style="--size:<?php echo round($value/$max,2); ?>; --color:#<?php echo getMoviegoerColorById($key); ?>"><span class="data data_padding"><?php echo $value; ?></span></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php template('footer');?>