property.eta 900 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <% layout("/sk/history/layout") %>
  2. <%~ include("/sk/partials/topbar") %>
  3. <h2>história <%= it?.property %></h2>
  4. <%= JSON.stringify(it.data[0]) %>
  5. <% const time = [] %>
  6. <% const data = [] %>
  7. <% for (const item of it.data) { %>
  8. <% time.push(item.timeMark) %>
  9. <% if (it.property === "outdoorConnected") {%>
  10. <% data.push(item.value) %>
  11. <% continue %>
  12. <% } %>
  13. <% data.push(item.value / 100) %>
  14. <% } %>
  15. <div>
  16. <canvas id="historyChart"></canvas>
  17. </div>
  18. <script>
  19. const ctx = document.getElementById('historyChart');
  20. new Chart(ctx, {
  21. type: 'bar',
  22. data: {
  23. labels: <%~ JSON.stringify(time) %>,
  24. datasets: [{
  25. label: `<%= it.property %>`,
  26. data: <%~ JSON.stringify(data) %>,
  27. borderWidth: 1
  28. }]
  29. },
  30. options: {
  31. scales: {
  32. y: {
  33. beginAtZero: true
  34. }
  35. }
  36. }
  37. });
  38. </script>