-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
348 lines (327 loc) · 18.9 KB
/
Copy pathindex.html
File metadata and controls
348 lines (327 loc) · 18.9 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
<!doctype html>
<html lang="en" class="scroll-smooth">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ImpactMeter Dashboard</title>
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
cricketGreen: "#0B6E4F",
cricketGold: "#FFD700",
cricketOrange: "#F39C12",
lightBg: "#F5F7F6"
}
}
}
};
</script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" integrity="sha512-Evv84Mr4kqVGRNSgIGL/F/aIDqQb7xQ2vcrdIwxfjThSH8CSR7PBEakCr51Ck+w+/U6swU2Im1vVX0SVk9ABhg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body class="bg-lightBg text-slate-800 min-h-screen">
<div id="pageLoader" class="fixed inset-0 z-50 flex items-center justify-center bg-white/85 backdrop-blur-sm">
<div class="flex flex-col items-center gap-3">
<div class="w-12 h-12 border-4 border-slate-200 border-t-cricketGreen rounded-full animate-spin"></div>
<p id="pageLoaderText" class="text-sm font-medium text-slate-700">Loading dashboard data...</p>
</div>
</div>
<header class="bg-white/95 backdrop-blur border-b border-slate-200 sticky top-0 z-30">
<div class="max-w-7xl mx-auto px-4 py-3 flex flex-col md:flex-row md:items-center md:justify-between gap-3">
<div>
<p class="text-sm font-semibold text-cricketGreen">ImpactMeter</p>
<p class="text-xs text-slate-600">Context-aware cricket impact analytics</p>
</div>
<div class="flex items-center gap-2 text-xs overflow-x-auto pb-1 w-full md:w-auto">
<a href="#section-player" class="whitespace-nowrap px-2.5 py-1 rounded-full bg-slate-100 hover:bg-slate-200 text-slate-700 font-medium">Player</a>
<a href="#section-impact" class="whitespace-nowrap px-2.5 py-1 rounded-full bg-slate-100 hover:bg-slate-200 text-slate-700 font-medium">Impact</a>
<a href="#section-trend" class="whitespace-nowrap px-2.5 py-1 rounded-full bg-slate-100 hover:bg-slate-200 text-slate-700 font-medium">Trend</a>
<a href="#section-pressure" class="whitespace-nowrap px-2.5 py-1 rounded-full bg-slate-100 hover:bg-slate-200 text-slate-700 font-medium">Pressure</a>
<a href="#section-insights" class="whitespace-nowrap px-2.5 py-1 rounded-full bg-slate-100 hover:bg-slate-200 text-slate-700 font-medium">Insights</a>
<a href="#section-compare" class="whitespace-nowrap px-2.5 py-1 rounded-full bg-slate-100 hover:bg-slate-200 text-slate-700 font-medium">Compare</a>
<a href="https://github.com/mr-baraiya/ImpactMeter" target="_blank" rel="noopener noreferrer" class="whitespace-nowrap px-2.5 py-1 rounded-full bg-slate-900 hover:bg-slate-800 text-white font-medium">GitHub Repo</a>
<a href="frontend/ImpactMeter_Logic_Design_Document.html" class="whitespace-nowrap px-2.5 py-1 rounded-full bg-cricketGreen hover:opacity-90 text-white font-medium">Logic Doc</a>
</div>
</div>
</header>
<main class="max-w-7xl mx-auto px-4 py-6 md:py-8">
<header class="mb-6">
<h1 class="text-2xl md:text-3xl font-bold text-cricketGreen">ImpactMeter - Cricket Player Impact Analytics</h1>
<p class="text-sm text-slate-600 mt-1">Simple dashboard for impact score, trend, context, and rankings.</p>
</header>
<section id="section-player" class="bg-white rounded-xl shadow-sm border border-slate-200 p-4 md:p-5 mb-6 scroll-mt-24">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-4 lg:gap-6">
<div>
<label for="playerSelect" class="block text-sm font-semibold mb-2">Select Player</label>
<div class="relative w-full md:w-96 lg:w-full">
<input
id="playerSelect"
type="text"
placeholder="Search and select player (e.g. Kohli)"
autocomplete="off"
class="w-full border border-slate-300 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-cricketGreen"
/>
<ul
id="playerDropdownList"
class="hidden absolute z-20 mt-1 w-full max-h-56 overflow-y-auto rounded-lg border border-slate-200 bg-white shadow-lg text-sm"
></ul>
</div>
<p id="statusMsg" class="text-xs text-slate-500 mt-2"></p>
</div>
<div class="bg-slate-50 rounded-xl border border-slate-200 p-4">
<h2 class="text-base font-semibold mb-3">Impact Category</h2>
<div class="flex items-center gap-3 flex-wrap">
<p id="impactCategoryTitle" class="text-lg font-bold text-cricketGreen">-</p>
<p id="impactCategorySub" class="text-sm text-slate-600">-</p>
</div>
</div>
</div>
</section>
<section id="section-impact" class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6 scroll-mt-24">
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-5">
<h2 class="text-lg font-semibold mb-3">Impact Score</h2>
<div class="text-4xl font-bold text-cricketGreen mb-3">
<span id="impactScoreValue">0</span>
<span class="text-lg font-medium text-slate-600">/ 100</span>
</div>
<p class="text-xs text-slate-600 mb-3">Baseline + ML Assisted</p>
<div class="h-52 md:h-56">
<canvas id="gaugeChart"></canvas>
</div>
<div class="relative mt-2">
<div class="h-2 bg-slate-200 rounded-full overflow-hidden">
<div id="gaugeFill" class="h-full bg-gradient-to-r from-cricketOrange via-cricketGold to-cricketGreen" style="width: 0%"></div>
</div>
<div class="flex justify-between text-xs text-slate-500 mt-2">
<span>0</span>
<span>25</span>
<span>50</span>
<span>75</span>
<span>100</span>
</div>
</div>
<div class="mt-4 pt-4 border-t border-slate-200">
<div class="flex items-center justify-between mb-1">
<h3 class="text-sm font-semibold text-slate-700">ML-Assisted Impact</h3>
<span class="px-2 py-0.5 rounded-full text-xs font-semibold bg-sky-100 text-sky-700">Random Forest</span>
</div>
<div class="flex items-end justify-between mb-2">
<p class="text-2xl font-bold text-sky-700"><span id="mlImpactValue">-</span><span class="text-base text-slate-500"> / 100</span></p>
<p class="text-xs text-slate-600">vs Rule: <span id="mlDeltaValue" class="font-semibold">-</span></p>
</div>
<div class="h-2 bg-slate-200 rounded-full overflow-hidden">
<div id="mlImpactBar" class="h-full bg-sky-500" style="width: 0%"></div>
</div>
</div>
</div>
<div class="space-y-4">
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-4">
<h2 class="text-base font-semibold mb-3">Player Summary</h2>
<div class="space-y-2 text-sm">
<div class="flex justify-between"><span class="text-slate-600">Team</span><span id="summaryTeam" class="font-semibold">-</span></div>
<div class="flex justify-between"><span class="text-slate-600">Role</span><span id="summaryRole" class="font-semibold">-</span></div>
<div class="flex justify-between"><span class="text-slate-600">Matches</span><span id="summaryMatches" class="font-semibold">-</span></div>
<div class="flex justify-between"><span class="text-slate-600">Avg Impact</span><span id="summaryAvgImpact" class="font-semibold text-cricketGreen">-</span></div>
<div class="flex justify-between"><span class="text-slate-600">Recent Form (Last 10)</span><span id="summaryRecentImpact" class="font-semibold">-</span></div>
<div class="flex justify-between"><span class="text-slate-600">High-Pressure Share</span><span id="summaryHighPressure" class="font-semibold">-</span></div>
<div class="flex justify-between"><span class="text-slate-600">Primary Phase</span><span id="summaryPrimaryPhase" class="font-semibold">-</span></div>
</div>
</div>
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-5">
<div class="flex items-center justify-between mb-3">
<h2 class="text-lg font-semibold">Role-Based Snapshot</h2>
<span id="roleBadge" class="px-3 py-1 rounded-full text-xs font-semibold bg-slate-100 text-slate-700">Batter</span>
</div>
<div class="space-y-2 text-sm">
<div class="flex justify-between"><span id="roleMetric1Label">Runs</span><span id="roleMetric1Value" class="font-semibold">-</span></div>
<div class="flex justify-between"><span id="roleMetric2Label">Strike Rate</span><span id="roleMetric2Value" class="font-semibold">-</span></div>
<div class="flex justify-between"><span id="roleMetric3Label">Boundaries</span><span id="roleMetric3Value" class="font-semibold">-</span></div>
<div class="flex justify-between"><span id="roleMetric4Label">Clutch Runs</span><span id="roleMetric4Value" class="font-semibold">-</span></div>
<div class="flex justify-between"><span id="roleMetric5Label">Batting Impact</span><span id="roleMetric5Value" class="font-semibold">-</span></div>
<hr class="my-2" />
<div class="flex justify-between text-base"><span class="font-semibold">Final Impact Score</span><span id="roleFinal" class="font-bold text-cricketGreen">-</span></div>
<p id="roleMetricNote" class="text-xs text-slate-500 pt-1">Role-specific metrics are calculated from available feature data.</p>
</div>
</div>
</div>
</section>
<section id="section-trend" class="bg-white rounded-xl shadow-sm border border-slate-200 p-5 mb-6 scroll-mt-24">
<div class="flex items-center justify-between gap-3 mb-1">
<h2 class="text-lg font-semibold">Impact Trend (Last 10 Matches)</h2>
<label class="flex items-center gap-2 text-xs text-slate-600">
<input id="trendModeToggle" type="checkbox" class="accent-cricketGreen" />
Use ML trend
</label>
</div>
<p id="trendPlayerLabel" class="text-sm text-slate-600 mb-4">Player: -</p>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-4">
<div class="lg:col-span-2 h-72 md:h-80">
<canvas id="trendChart"></canvas>
</div>
<div class="border border-slate-200 rounded-lg overflow-hidden">
<table class="w-full text-sm">
<thead>
<tr class="text-left bg-slate-50 border-b border-slate-200">
<th class="py-2 px-3">Match</th>
<th class="py-2 px-3 text-right">Impact</th>
</tr>
</thead>
<tbody id="trendTableBody"></tbody>
</table>
</div>
</div>
</section>
<section id="section-pressure" class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6 scroll-mt-24">
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-5">
<h2 class="text-lg font-semibold mb-3">Pressure Index</h2>
<div class="flex items-center justify-between mb-3">
<div>
<p id="pressureIndexValue" class="text-3xl font-bold text-cricketOrange">0.0</p>
<p class="text-xs text-slate-500">Average context pressure (0-100)</p>
</div>
<span id="pressureLevelBadge" class="px-3 py-1 rounded-full text-xs font-semibold bg-slate-100 text-slate-700">Low</span>
</div>
<div class="h-2 bg-slate-200 rounded-full overflow-hidden mb-2">
<div id="pressureIndexBar" class="h-full bg-cricketOrange" style="width: 0%"></div>
</div>
<p class="text-sm text-slate-600">High-pressure scenarios: <span id="highPressureShare" class="font-semibold">0.0%</span></p>
</div>
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-5">
<h2 class="text-lg font-semibold mb-3">Clutch Performance</h2>
<div class="flex items-center justify-between mb-3">
<div>
<p id="clutchScoreValue" class="text-3xl font-bold text-cricketGreen">0.0</p>
<p class="text-xs text-slate-500">Performance under high pressure (0-100)</p>
</div>
<span id="clutchTag" class="px-3 py-1 rounded-full text-xs font-semibold bg-slate-100 text-slate-700">Developing</span>
</div>
<div class="h-2 bg-slate-200 rounded-full overflow-hidden mb-2">
<div id="clutchScoreBar" class="h-full bg-cricketGreen" style="width: 0%"></div>
</div>
<p id="clutchSummary" class="text-sm text-slate-600">No high-pressure summary available yet.</p>
</div>
</section>
<section id="section-insights" class="grid grid-cols-1 lg:grid-cols-2 gap-6 scroll-mt-24">
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-5">
<h2 class="text-lg font-semibold mb-3">Phase Contribution</h2>
<div class="space-y-3">
<div>
<div class="flex justify-between text-sm mb-1"><span>Powerplay</span><span id="phasePowerplay">0%</span></div>
<div class="h-2 bg-slate-200 rounded"><div id="phasePowerplayBar" class="h-full bg-cricketGreen rounded" style="width:0%"></div></div>
</div>
<div>
<div class="flex justify-between text-sm mb-1"><span>Middle</span><span id="phaseMiddle">0%</span></div>
<div class="h-2 bg-slate-200 rounded"><div id="phaseMiddleBar" class="h-full bg-cricketGold rounded" style="width:0%"></div></div>
</div>
<div>
<div class="flex justify-between text-sm mb-1"><span>Death Overs</span><span id="phaseDeath">0%</span></div>
<div class="h-2 bg-slate-200 rounded"><div id="phaseDeathBar" class="h-full bg-cricketOrange rounded" style="width:0%"></div></div>
</div>
</div>
<div class="mt-5 pt-4 border-t border-slate-200">
<h3 class="text-sm font-semibold text-slate-700 mb-2">Phase Role Profile</h3>
<div class="space-y-1 text-sm text-slate-700">
<p><span class="font-medium">Powerplay:</span> <span id="phaseRolePowerplay">-</span></p>
<p><span class="font-medium">Middle Overs:</span> <span id="phaseRoleMiddle">-</span></p>
<p><span class="font-medium">Death Overs:</span> <span id="phaseRoleDeath">-</span></p>
</div>
</div>
<div class="mt-4 pt-4 border-t border-slate-200">
<h3 class="text-sm font-semibold text-slate-700 mb-1">Phase Insight</h3>
<p class="text-sm text-slate-700 mb-2">Primary Phase: <span id="phaseInsightPrimary" class="font-bold">-</span></p>
<p id="phaseInsightText" class="text-sm text-slate-600">-</p>
</div>
</div>
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-5">
<h2 class="text-lg font-semibold mb-3">Top Impact Players</h2>
<div class="overflow-auto">
<table class="w-full text-sm">
<thead>
<tr class="text-left border-b border-slate-200">
<th class="py-2 pr-2">Rank</th>
<th class="py-2 pr-2">Player</th>
<th class="py-2 text-right">Impact</th>
</tr>
</thead>
<tbody id="rankingTableBody"></tbody>
</table>
</div>
</div>
</section>
<section id="section-compare" class="grid grid-cols-1 lg:grid-cols-2 gap-6 mt-6 scroll-mt-24">
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-5">
<h2 class="text-lg font-semibold mb-3">Compare Two Players</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-3 mb-4">
<div>
<label for="compareASelect" class="block text-xs font-semibold mb-1">Player A</label>
<div class="relative">
<input
id="compareASelect"
type="text"
placeholder="Search Player A"
autocomplete="off"
class="w-full border border-slate-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-cricketGreen"
/>
<ul
id="compareADropdownList"
class="hidden absolute z-20 mt-1 w-full max-h-48 overflow-y-auto rounded-lg border border-slate-200 bg-white shadow-lg text-sm"
></ul>
</div>
</div>
<div>
<label for="compareBSelect" class="block text-xs font-semibold mb-1">Player B</label>
<div class="relative">
<input
id="compareBSelect"
type="text"
placeholder="Search Player B"
autocomplete="off"
class="w-full border border-slate-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-cricketGreen"
/>
<ul
id="compareBDropdownList"
class="hidden absolute z-20 mt-1 w-full max-h-48 overflow-y-auto rounded-lg border border-slate-200 bg-white shadow-lg text-sm"
></ul>
</div>
</div>
</div>
<div class="grid grid-cols-2 gap-3 text-sm mb-3">
<div class="bg-slate-50 rounded-lg p-3 border border-slate-200">
<p class="text-slate-500">Player A Impact</p>
<p id="compareAScore" class="text-xl font-bold text-cricketGreen">-</p>
</div>
<div class="bg-slate-50 rounded-lg p-3 border border-slate-200">
<p class="text-slate-500">Player B Impact</p>
<p id="compareBScore" class="text-xl font-bold text-cricketOrange">-</p>
</div>
</div>
<div class="h-64">
<canvas id="compareTrendChart"></canvas>
</div>
</div>
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-5">
<h2 class="text-lg font-semibold mb-3">Impact Score Distribution</h2>
<div class="h-64 mb-4">
<canvas id="distributionChart"></canvas>
</div>
<h3 class="text-sm font-semibold mb-1">Feature Importance (Random Forest)</h3>
<p class="text-xs text-slate-500 mb-2">Source: <code>models/ml_feature_importance.csv</code></p>
<p class="text-xs text-slate-600 mb-2">The Random Forest model also reveals which features contribute most to impact prediction.</p>
<div id="mlFeatureImportancePanel" class="space-y-2 text-sm">
<p class="text-xs text-slate-500">Loading feature importance...</p>
</div>
</div>
</section>
</main>
<footer class="border-t border-slate-200 bg-white mt-8">
<div class="max-w-7xl mx-auto px-4 py-4 flex flex-col md:flex-row md:items-center md:justify-between gap-2 text-xs text-slate-600">
<p>ImpactMeter Dashboard | Built for context and pressure-based player evaluation</p>
<p>Data: IPL ball-by-ball | Output: IM Score (0-100)</p>
</div>
</footer>
<script src="./script.js"></script>
</body>
</html>