File size: 13,519 Bytes
82f07ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Crime Dashboard</title>
    <style>

        body {

            font-family: Arial, sans-serif;

            background-color: #121212;

            color: white;

            margin: 0;

            padding: 0;

        }



        .container {

            display: flex;

            min-height: 100vh;

        }



        .sidebar {

            width: 300px;

            background-color: #2A2A2A;

            padding: 20px;

            box-sizing: border-box;

        }



        .sidebar h2, .sidebar h1, .sidebar label {

            color: #1E90FF; /* Changed color */

        }



        .sidebar form {

            margin-top: 20px;

        }



        .sidebar .form-group {

            margin-bottom: 20px;

        }



        .sidebar .form-control {

            background-color: #121212;

            color: white;

            border: 1px solid #444;

            width: 100%;

        }



        .sidebar .btn-primary {

            background-color: #1E90FF; /* Changed color */

            border: none;

            width: 100%;

        }



        .main-content {

            flex: 1;

            padding: 20px;

            box-sizing: border-box;

        }



        .header h1 {

            color: #1E90FF; /* Changed color */

        }



          .sidebar .btn-back {

            background-color: #FF4747;

            border: none;

            width: 100%;

            margin-bottom: 20px;

        }



        .content {

            display: flex;

            flex-wrap: wrap;

            gap: 20px;

        }



        .chart {

            background-color: #1E1E1E;

            padding: 20px;

            border-radius: 8px;

            box-sizing: border-box;

            width: calc(50% - 10px); /* Adjusted to fit two charts in a row */

            height: 300px; /* Reduced height */

        }



        .pie-charts {

            display: flex;

            gap: 20px;

            width: 100%;

            flex-wrap: wrap;

        }



        .pie-chart {

            background-color: #1E1E1E;

            padding: 20px;

            border-radius: 8px;

            box-sizing: border-box;

            width: calc(50% - 10px); /* Adjusted to fit two charts in a row */

            height: 300px; /* Reduced height */

        }



        .live-data {

            background-color: #1E1E1E;

            padding: 20px;

            border-radius: 8px;

            box-sizing: border-box;

            width: 100%;

            height: 300px; /* Reduced height */

            margin-bottom: 20px;

        }



        .statistics {

            background-color: #1E1E1E;

            padding: 20px;

            border-radius: 8px;

            box-sizing: border-box;

            width: 100%;

            margin-bottom: 20px;

        }



        .statistics h3 {

            color: #1E90FF; /* Changed color */

            margin: 10px 0;

        }



        .statistics p {

            color: #1E90FF; /* Changed color */

        }



        .forecast-container {

            display: flex;

            flex-direction: column;

            align-items: center;

            width: 100%;

            margin-bottom: 20px;

        }



        .forecast {

            background-color: #1E1E1E;

            padding: 20px;

            border-radius: 8px;

            box-sizing: border-box;

            width: 100%;

            text-align: center;

        }



        .forecast h2 {

            color: #1E90FF; /* Changed color */

        }



        .forecast img {

            max-width: 100%;

            height: auto;

        }



        .forecast ul {

            list-style: none;

            padding: 0;

        }



        .forecast ul li {

            margin: 5px 0;

        }



        canvas {

            height: 100% !important; /* Ensures the canvas elements take the full height of their container */

        }

    </style>
</head>
<body>
    <div class="container">
        <div class="sidebar">
            <button class="btn-back" onclick="goBack()">Back</button>
            <h2>Dashboard</h2>
            <h1>Future Crime Pattern Prediction</h1>
            <!-- Form to input forecasting details -->
            <form method="post">
                <div class="form-group">
                    <label for="future_steps">Enter number of months to forecast:</label>
                    <input type="number" id="future_steps" name="future_steps" class="form-control" min="1" value="{{ future_steps }}">
                </div>
                <div class="form-group">
                    <label for="start_date">Enter start date for the forecast:</label>
                    <input type="date" id="start_date" name="start_date" class="form-control">
                </div>
                <button type="submit" class="btn btn-primary">Forecast</button>
            </form>
            <!-- Forecasted Values Result -->
            <div class="forecasted-values">
                <h2>Forecasted Values</h2>
                {% if forecast_results %}
                    <ul>
                        {% for value in forecast_results %}
                            <li>{{ value }}</li>
                        {% endfor %}
                    </ul>
                {% endif %}
            </div>
        </div>
        <div class="main-content">
            <div class="header">
                <h1>Analysis</h1>
            </div>
            <div class="content">
                <div class="chart">
                    <canvas id="barChart"></canvas>
                </div>
                <div class="chart">
                    <canvas id="crimeRateChart"></canvas>
                </div>
                <div class="forecast-container">
                    <!-- Forecast result section -->
                    <div class="forecast">
                        <h2>Forecast Plot</h2>
                        {% if forecast_plot %}
                            <img src="data:image/png;base64,{{ forecast_plot }}" alt="Forecast Plot" class="img-fluid">
                        {% endif %}
                    </div>
                </div>
                <div class="chart">
                    <canvas id="waterfallChart"></canvas>
                </div>
                <div class="chart">
                    <canvas id="radarChart"></canvas>
                </div>
                <div class="live-data">
                    <canvas id="liveDataChart"></canvas>
                </div>
                <div class="statistics">
                    <h3>Live Data</h3>
                    <p>A Murder every min</p>
                    <p>A Suicide every 40 sec</p>
                    <p>7812 Sexual Assaults every day</p>
                    <p>More than 100,000 pending rape cases in India. Close to 90 Rapes are reported every day in India.</p>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <script>

         function goBack() {

            window.location.href = 'http://127.0.0.1:5000/index';

        }

        document.addEventListener("DOMContentLoaded", function() {

            // Bar Chart

            const barCtx = document.getElementById('barChart').getContext('2d');

            new Chart(barCtx, {

                type: 'bar',

                data: {

                    labels: ['Cyber Crime', 'Violent Crime', 'Sexual Harassment', 'Rape', 'Kidnapping', 'Property', 'Fraud', 'Childhood Abuse', 'Robbery', 'Under Age Activities'],

                    datasets: [{

                        label: 'Crime Analysis 2003-2018',

                        data: [2300, 1000, 1000, 624, 500, 431, 430, 355, 329.5, 246.5],

                        backgroundColor: [

                            '#00BFFF', '#7CFC00', '#FF69B4', '#FF4500', '#FFD700', '#ADFF2F', '#00FFFF', '#BA55D3', '#32CD32', '#FF6347'

                        ],

                        borderColor: [

                            '#00BFFF', '#7CFC00', '#FF69B4', '#FF4500', '#FFD700', '#ADFF2F', '#00FFFF', '#BA55D3', '#32CD32', '#FF6347'

                        ],

                        borderWidth: 1

                    }]

                },

                options: {

                    scales: {

                        y: {

                            beginAtZero: true

                        }

                    }

                }

            });



            // Crime Rate Pie Chart

            const crimeRateCtx = document.getElementById('crimeRateChart').getContext('2d');

            new Chart(crimeRateCtx, {

                type: 'pie',

                data: {

                    labels: ['Bengaluru City ', 'Bengaluru District', 'Tumakuru', 'Shivamogga', 'Mandya', 'Bagalkot'],

                    datasets: [{

                        label: 'Crime Rate',

                        data: [23.2, 20.5, 14.7, 17.8, 12.4, 11.4],

                        backgroundColor: [

                            'rgba(75, 192, 192, 0.8)',

                            'rgba(153, 102, 255, 0.8)',

                            'rgba(255, 159, 64, 0.8)',

                            'rgba(255, 206, 86, 0.8)',

                            'rgba(54, 162, 235, 0.8)',

                            'rgba(255, 99, 132, 0.8)'

                        ]

                    }]

                },

                options: {

                    responsive: true

                }

            });



            // Live Data Chart

            const liveDataCtx = document.getElementById('liveDataChart').getContext('2d');

            new Chart(liveDataCtx, {

                type: 'line',

                data: {

                    labels: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00'],

                    datasets: [{

                        label: 'Live Data',

                        data: [10, 20, 30, 25, 20, 15, 10, 15, 20, 25, 30, 35],

                        backgroundColor: 'rgba(255, 71, 71, 0.2)',

                        borderColor: 'rgba(255, 71, 71, 1)',

                        borderWidth: 1

                    }]

                },

                options: {

                    scales: {

                        y: {

                            beginAtZero: true

                        }

                    }

                }

            });

        });

        // Waterfall Chart

            const crimessolved = document.getElementById('waterfallChart').getContext('2d');

            new Chart(crimessolved, {

                type: 'bar',

                data: {

                    labels: ['Bengalurucity', 'Mandya', 'Shivamogga', 'Bagalkot', 'Tumakuru', 'Mysuru'],

                    datasets: [{

                        label: 'Crimes Solved',

                        data: [60,50 , 40, 30, 35, 10],

                        backgroundColor: 'rgba(75, 192, 192, 0.8)',

                        borderColor: 'rgba(75, 192, 192, 1)',

                        borderWidth: 1

                    }]

                },

                options: {

                    plugins: {

                        datalabels: {

                            display: true,

                            color: 'black',

                            align: 'top'

                        }

                    },

                    scales: {

                        y: {

                            beginAtZero: true

                        }

                    }

                }

            });



            // Radar Chart

            const radarCtx = document.getElementById('radarChart').getContext('2d');

            new Chart(radarCtx, {

                type: 'bar',

            data: {

                labels: ['accident non-fatal', 'Theft', 'CrPc', 'Cases of hurd', 'Missing persion'],

                datasets: [{

                    label: 'Crime Rate',

                    data: [6500, 6000,5600 , 4900, 3200, 2500,],

                    backgroundColor: [

                        'rgba(255, 99, 132, 0.2)',

                        'rgba(54, 162, 235, 0.2)',

                        'rgba(255, 206, 86, 0.2)',

                        'rgba(75, 192, 192, 0.2)',

                        'rgba(153, 102, 255, 0.2)',

                        'rgba(255, 159, 64, 0.2)',

                        'rgba(201, 203, 207, 0.2)'

                    ],

                    borderColor: [

                        'rgba(255, 99, 132, 1)',

                        'rgba(54, 162, 235, 1)',

                        'rgba(255, 206, 86, 1)',

                        'rgba(75, 192, 192, 1)',

                        'rgba(153, 102, 255, 1)',

                        'rgba(255, 159, 64, 1)',

                        'rgba(201, 203, 207, 1)'

                    ],

                    borderWidth: 1

                }]

            },

            options: {

                responsive: true,

                scales: {

                    y: {

                        beginAtZero: true

                    }

                }

            }

        });

    </script>
</body>
</html>