1 | <style>
|
---|
2 | .flex-wrapper {
|
---|
3 | display: flex;
|
---|
4 | flex-flow: row nowrap;
|
---|
5 | }
|
---|
6 |
|
---|
7 | .single-chart {
|
---|
8 | width: 100%;
|
---|
9 | justify-content: space-around;
|
---|
10 | }
|
---|
11 |
|
---|
12 | .circular-chart {
|
---|
13 | display: block;
|
---|
14 | margin: 10px auto;
|
---|
15 | max-width: 50%;
|
---|
16 | /*max-height: 250px;*/
|
---|
17 | }
|
---|
18 |
|
---|
19 | .circle-bg {
|
---|
20 | fill: none;
|
---|
21 | stroke: #eee;
|
---|
22 | stroke-width: 3.8;
|
---|
23 | }
|
---|
24 |
|
---|
25 | .circle {
|
---|
26 | fill: none;
|
---|
27 | stroke-width: 2.8;
|
---|
28 | stroke-linecap: round;
|
---|
29 | animation: progress 1s ease-out forwards;
|
---|
30 | }
|
---|
31 |
|
---|
32 | @keyframes progress {
|
---|
33 | 0% {
|
---|
34 | stroke-dasharray: 0 100;
|
---|
35 | }
|
---|
36 | }
|
---|
37 |
|
---|
38 | .circular-chart.blue .circle {
|
---|
39 | stroke: #1982d5;
|
---|
40 | }
|
---|
41 |
|
---|
42 | .percentage {
|
---|
43 | fill: #666;
|
---|
44 | font-family: sans-serif;
|
---|
45 | font-size: 0.5em;
|
---|
46 | text-anchor: middle;
|
---|
47 | }
|
---|
48 | </style>
|
---|
49 |
|
---|
50 | <nav class="navbar bg-secondary bg-gradient container-fluid px-0">
|
---|
51 | <div class="container-fluid">
|
---|
52 | <span class="navbar-brand mb-0 h1">Податоци за излезноста</span>
|
---|
53 | </div>
|
---|
54 | </nav>
|
---|
55 |
|
---|
56 | <nav class="navbar navbar-expand-lg navbar-light bg-light">
|
---|
57 | <div class="container-fluid">
|
---|
58 | <div class="container-fluid" id="navbarSupportedContent">
|
---|
59 | <form class="d-flex row gx-3" method="GET" action="/turnout">
|
---|
60 | <div class="col-xl-2 dropdown">
|
---|
61 | <label for="realizacija" class="m-0 me-2">Реализација</label>
|
---|
62 | <select class="form-select" id="realizacija" name="realizationId">
|
---|
63 | <option th:each="realization : ${realizations}" th:value="${realization.id}" th:text="${realization.name}"></option>
|
---|
64 | </select>
|
---|
65 | </div>
|
---|
66 | <div class="col-xl-2 dropdown">
|
---|
67 | <label for="opshtina" class="m-0 me-2">Општина</label>
|
---|
68 | <select class="form-select" id="opshtina" name="opshtinaId">
|
---|
69 | <option th:each="municipality : ${municipalities}" th:value="${municipality.mapId}" th:text="${municipality.name}"></option>
|
---|
70 | </select>
|
---|
71 | </div>
|
---|
72 | <div class="col-xl-2 dropdown">
|
---|
73 | <label for="izbirachko" class="m-0 me-2">Избирачко место</label>
|
---|
74 | <select class="form-select" id="izbirachko" name="izbirachkoMestoId">
|
---|
75 | <option th:each="pollingStation : ${pollingStations}" th:value="${pollingStation.id}" th:text="${pollingStation.name}"></option>
|
---|
76 | </select>
|
---|
77 | </div>
|
---|
78 | <div class="col-xl-2 dropdown">
|
---|
79 | <label for="chas" class="m-0 me-2">Час</label>
|
---|
80 | <select class="form-select" id="chas" name="time">
|
---|
81 | </select>
|
---|
82 | </div>
|
---|
83 | <div class="col-xl-2 d-flex flex-col align-items-center justify-content-center">
|
---|
84 | <!-- <label></label>-->
|
---|
85 | <button class="btn h-100 w-75 p-auto btn-outline-success" type="submit">Пребарај</button>
|
---|
86 | </div>
|
---|
87 | </form>
|
---|
88 | </div>
|
---|
89 | </div>
|
---|
90 | </nav>
|
---|
91 |
|
---|
92 | <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
|
---|
93 | <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.min.js"></script>
|
---|
94 |
|
---|
95 | <nav class="navbar bg-secondary-subtle container-fluid px-0 my-5">
|
---|
96 | <div class="container-fluid">
|
---|
97 | <span class="navbar-brand m-auto mb-0 h1" th:text="|Податоци за излезноста на: ${realization.name}|"></span>
|
---|
98 | </div>
|
---|
99 | </nav>
|
---|
100 |
|
---|
101 | <div class="container mt-5">
|
---|
102 | <div class="row mt-5">
|
---|
103 | <div class="col col-xl-6 col-md-12 d-flex flex-col justify-content-center align-items-center">
|
---|
104 | <div class="single-chart">
|
---|
105 | <svg viewBox="0 0 36 36" class="circular-chart blue">
|
---|
106 | <path class="circle-bg"
|
---|
107 | d="M18 2.0845
|
---|
108 | a 15.9155 15.9155 0 0 1 0 31.831
|
---|
109 | a 15.9155 15.9155 0 0 1 0 -31.831"
|
---|
110 | />
|
---|
111 | <path class="circle"
|
---|
112 | th:stroke-dasharray="|${turnoutPercentage}, 100|"
|
---|
113 | d="M18 2.0845
|
---|
114 | a 15.9155 15.9155 0 0 1 0 31.831
|
---|
115 |
|
---|
116 | a 15.9155 15.9155 0 0 1 0 -31.831"></path><text x="18" y="20.35" class="percentage" th:text="|${#numbers.formatDecimal(turnoutPercentage, 1, 2, 'COMMA')}%|">30%</text>
|
---|
117 |
|
---|
118 | </svg>
|
---|
119 | </div>
|
---|
120 | </div>
|
---|
121 | <div class="col col-xl-6 col-md-12 d-flex flex-col justify-content-center align-items-center">
|
---|
122 | <div id="map"></div>
|
---|
123 | </div>
|
---|
124 | </div>
|
---|
125 | </div>
|
---|
126 | <div class="flex-wrapper">
|
---|
127 |
|
---|
128 | </div>
|
---|
129 |
|
---|
130 |
|
---|
131 |
|
---|
132 | <script>
|
---|
133 | // Function to generate a random color
|
---|
134 | function getRandomColor() {
|
---|
135 | var letters = '0123456789ABCDEF';
|
---|
136 | var color = '#';
|
---|
137 | for (var i = 0; i < 6; i++) {
|
---|
138 | color += letters[Math.floor(Math.random() * 16)];
|
---|
139 | }
|
---|
140 | return color;
|
---|
141 | }
|
---|
142 |
|
---|
143 | function getRandomRedColor() {
|
---|
144 | function getRandomLowValue() {
|
---|
145 | return Math.floor(Math.random() * 56); // Random value between 0 and 55
|
---|
146 | }
|
---|
147 |
|
---|
148 | function componentToHex(c) {
|
---|
149 | const hex = c.toString(16);
|
---|
150 | return hex.length == 1 ? "0" + hex : hex;
|
---|
151 | }
|
---|
152 |
|
---|
153 | const red = 200 + Math.floor(Math.random() * 56); // Random value between 200 and 255
|
---|
154 | const green = getRandomLowValue();
|
---|
155 | const blue = getRandomLowValue();
|
---|
156 | return `#${componentToHex(red)}${componentToHex(green)}${componentToHex(blue)}`;
|
---|
157 | }
|
---|
158 | var selectedId = 2;
|
---|
159 | // Set random color for elements with class .circular-chart.blue .circle
|
---|
160 | document.addEventListener('DOMContentLoaded', function() {
|
---|
161 | var elements = document.querySelectorAll('.circular-chart.blue .circle');
|
---|
162 | elements.forEach(function(element) {
|
---|
163 | element.style.stroke = getRandomColor();
|
---|
164 | });
|
---|
165 |
|
---|
166 |
|
---|
167 | selectElement = document.getElementById("realizacija")
|
---|
168 |
|
---|
169 | selectElement.addEventListener('change', function() {
|
---|
170 | console.log(
|
---|
171 | 'dsdsd'
|
---|
172 | )
|
---|
173 | selectedOption = selectElement.options[selectElement.selectedIndex];
|
---|
174 | selectedId = selectedOption.value;
|
---|
175 | console.log('Realizacija ID:', selectedId);
|
---|
176 | updateMunicipalitiesUrls();
|
---|
177 | });
|
---|
178 |
|
---|
179 | simplemaps_countrymap.hooks.click_state = (id) => {
|
---|
180 | window.location.href = 'http://localhost:8080/turnout?opshtinaId=' + id + '&realizationId=' + selectedId;
|
---|
181 | console.log(id)
|
---|
182 | }
|
---|
183 |
|
---|
184 | const updateMunicipalitiesUrls = () => {
|
---|
185 | console.log("VO UPDATE")
|
---|
186 | Object.keys(simplemaps_countrymap_mapdata.state_specific).forEach(x => {
|
---|
187 | // selectElement = document.getElementById("realizacija") ?? 2
|
---|
188 | // selectedOption = selectElement.options[selectElement.selectedIndex];
|
---|
189 | // selectedId = selectedOption.value ?? 2;
|
---|
190 | console.log(selectedId)
|
---|
191 |
|
---|
192 | simplemaps_countrymap_mapdata.state_specific[x].url = 'http://localhost:8080/turnout?opshtinaId=' + x + '&realizationId=' + selectedId;
|
---|
193 | // simplemaps_countrymap_mapdata.state_specific[x].color = getRandomRedColor();
|
---|
194 | console.log(simplemaps_countrymap_mapdata.state_specific[x])
|
---|
195 | })
|
---|
196 | }
|
---|
197 |
|
---|
198 | updateMunicipalitiesUrls();
|
---|
199 |
|
---|
200 | });
|
---|
201 |
|
---|
202 | </script>
|
---|
203 |
|
---|
204 | <script src="mapdata.js"></script>
|
---|
205 | <script src="countrymap.js"></script> |
---|