| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <% layout("/sk/history/layout", { title: `história` }) %>
- <%~ include("/sk/partials/topbar") %>
- <% const backIcon = `
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
- <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m12 19l-7-7l7-7m7 7H5" />
- </svg>
- ` %>
- <div class="container-row">
- <a role="button" href="/history"><%~ backIcon %> história</a>
- <h2><%~ it?.lang?.history.properties?.[it?.property]() %></h2>
- </div>
- <div class="historyLinks">
- <a role="button" href="/history/<%= it.property %>/daily">deň</a>
- <a role="button" href="/history/<%= it.property %>/monthly">mesiac</a>
- <a role="button" href="/history/<%= it.property %>/yearly">rok</a>
- <a role="button" href="/history/<%= it.property %>/allTime">celý čas</a>
- </div>
- <% if (it?.dateMap?.years) { %>
- <form id="historyForm">
- <% if (it?.dateMap?.days) { %>
- <div>
- <label for="day">deň</label>
- <select id="day" name="day">
- <% for (const item of it?.dateMap?.days) { %>
- <option value="<%= item %>" <%= item === it?.dateMap?.days[it?.dateMap?.days.length - 1] ? `selected` : `` %> ><%= item %></option>
- <% } %>
- </select>
- </div>
- <% } %>
- <% if (it?.dateMap?.months) { %>
- <div>
- <label for="month">mesiac</label>
- <select id="month" name="month">
- <% for (const item of it?.dateMap?.months) { %>
- <option value="<%= item %>" <%= item === it?.dateMap?.months[it?.dateMap?.months.length - 1] ? `selected` : `` %> > <%= it?.lang?.history.dateFormats.months?.[item]() %></option>
- <% } %>
- </select>
- </div>
- <% } %>
- <div>
- <label for="year">rok</label>
- <select id="year" name="year">
- <% for (const item of it?.dateMap?.years) { %>
- <option value="<%= item %>" <%= item === it?.dateMap?.years[it?.dateMap?.years.length - 1] ? `selected` : `` %> > <%= item %></option>
- <% } %>
- </select>
- </div>
- <button type="submit">načítať</button>
- </form>
- <% } %>
- <% const time = [] %>
- <% const data = [] %>
- <% for (const item of it.data) { %>
- <% time.push(item.timeMark) %>
-
- <% if (it.property === "outdoorConnected") {%>
- <% data.push(item.value) %>
- <% continue %>
- <% } %>
- <% data.push(item.value / 100) %>
- <% } %>
- <div>
- <canvas id="historyChart"></canvas>
- </div>
- <script>
- const ctx = document.getElementById('historyChart');
- new Chart(ctx, {
- type: 'bar',
- data: {
- labels: <%~ JSON.stringify(time, null, 2) %>,
- datasets: [{
- label: `<%= it.property %>`,
- data: <%~ JSON.stringify(data, null, 2) %>,
- borderWidth: 1
- }]
- },
- options: {
- scales: {
- y: {
- beginAtZero: true
- }
- }
- }
- });
- </script>
|