Update plot_week.html
Browse files- plot_week.html +117 -129
plot_week.html
CHANGED
@@ -1,52 +1,33 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="ru">
|
3 |
<head>
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
<meta charset="UTF-8">
|
8 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
9 |
-
<link rel="icon" type="image/ico" href="https://huggingface.co/spaces/igs-img/stor/resolve/main/list.ico">
|
10 |
-
<title>My static Space</title>
|
11 |
-
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
12 |
-
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
<title>Графики pH и EC</title>
|
|
|
|
|
18 |
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
|
|
|
19 |
<style>
|
20 |
-
/* Центрирование и растягивание графиков */
|
21 |
body {
|
22 |
display: flex;
|
23 |
flex-direction: column;
|
24 |
align-items: center;
|
25 |
margin: 0;
|
26 |
padding: 0;
|
27 |
-
height: 100vh;
|
28 |
-
justify-content: flex-start;
|
29 |
-
}
|
30 |
-
h1 {
|
31 |
-
margin-top: 20px;
|
32 |
-
font-size: 24px;
|
33 |
}
|
34 |
-
.
|
35 |
-
margin: 20px 0;
|
36 |
-
}
|
37 |
-
button {
|
38 |
-
margin: 0 10px;
|
39 |
-
padding: 10px 20px;
|
40 |
-
font-size: 16px;
|
41 |
-
}
|
42 |
-
.graph-container {
|
43 |
width: 90%;
|
44 |
max-width: 1200px;
|
|
|
|
|
|
|
45 |
margin-bottom: 30px;
|
46 |
}
|
47 |
.graph {
|
48 |
width: 100%;
|
49 |
-
height: 500px;
|
50 |
}
|
51 |
.no-data-message {
|
52 |
font-size: 18px;
|
@@ -54,29 +35,41 @@
|
|
54 |
text-align: center;
|
55 |
margin-top: 20px;
|
56 |
}
|
|
|
|
|
|
|
|
|
|
|
57 |
</style>
|
58 |
</head>
|
59 |
<body>
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
70 |
</nav>
|
71 |
|
|
|
72 |
<h1>Графики за <span id="week_number">{{ week_number }}</span>-ю неделю</h1>
|
|
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
78 |
|
79 |
-
|
|
|
80 |
<div class="graph-container"><div class="graph" id="ph_chart"></div></div>
|
81 |
<div class="graph-container"><div class="graph" id="ec_chart"></div></div>
|
82 |
<div class="graph-container"><div class="graph" id="pump_chart"></div></div>
|
@@ -84,96 +77,91 @@
|
|
84 |
<div class="graph-container"><div class="graph" id="ta_chart"></div></div>
|
85 |
<div class="graph-container"><div class="graph" id="hdm_chart"></div></div>
|
86 |
<div class="graph-container"><div class="graph" id="sven_chart"></div></div>
|
|
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
xaxis: { title: "", showticklabels: false },
|
104 |
-
yaxis: { title: yLabel, titlefont: { size: 14 } },
|
105 |
-
hovermode: "closest",
|
106 |
-
showlegend: false
|
107 |
-
});
|
108 |
-
}
|
109 |
-
|
110 |
-
createChart("ph_chart", data.ph, `График pH за ${data.week}-ю неделю`, "Уровень pH", "blue");
|
111 |
-
createChart("ec_chart", data.ec, `График EC за ${data.week}-ю неделю`, "Уровень EC", "blue");
|
112 |
-
createChart("ts_chart", data.tS, `Температура раствора за ${data.week}-ю неделю`, "Температура (°C)", "purple");
|
113 |
-
createChart("ta_chart", data.tA, `Температура воздуха за ${data.week}-ю неделю`, "Температура (°C)", "purple");
|
114 |
-
createChart("hdm_chart", data.hDm, `Влажность воздуха за ${data.week}-ю неделю`, "Влажность (%)", "purple");
|
115 |
-
createChart("sven_chart", data.sVen, `Обороты вентилятора за ${data.week}-ю неделю`, "Обороты (%)", "purple");
|
116 |
-
|
117 |
-
// График насосов без легенды
|
118 |
-
Plotly.newPlot("pump_chart", [
|
119 |
-
{
|
120 |
-
x: data.dates,
|
121 |
-
y: data.onA,
|
122 |
-
type: "scatter",
|
123 |
-
mode: "lines+markers",
|
124 |
-
line: { color: "green" },
|
125 |
-
hovertemplate: data.days_of_week.map((day, index) =>
|
126 |
-
`Неделя: ${data.week}<br>День: ${day}<br>Насос A: %{y} сек.<br>Дата: ${data.dates[index]}`
|
127 |
-
)
|
128 |
-
},
|
129 |
-
{
|
130 |
-
x: data.dates,
|
131 |
-
y: data.onB,
|
132 |
-
type: "scatter",
|
133 |
-
mode: "lines+markers",
|
134 |
-
line: { color: "brown" },
|
135 |
-
hovertemplate: data.days_of_week.map((day, index) =>
|
136 |
-
`День: ${day}<br>Насос B: %{y} сек.<br>Дата: ${data.dates[index]}`
|
137 |
-
)
|
138 |
-
},
|
139 |
-
{
|
140 |
-
x: data.dates,
|
141 |
-
y: data.onC,
|
142 |
-
type: "scatter",
|
143 |
-
mode: "lines+markers",
|
144 |
-
line: { color: "orange" },
|
145 |
-
hovertemplate: data.days_of_week.map((day, index) =>
|
146 |
-
`День: ${day}<br>Насос C: %{y} сек.<br>Дата: ${data.dates[index]}`
|
147 |
-
)
|
148 |
-
}
|
149 |
-
], {
|
150 |
-
title: `Интервал дозирования насосов для ${data.week}-ой недели`,
|
151 |
xaxis: { title: "", showticklabels: false },
|
152 |
-
yaxis: { title:
|
153 |
hovermode: "closest",
|
154 |
-
showlegend: false
|
155 |
});
|
156 |
-
|
157 |
-
|
158 |
-
{% else %}
|
159 |
-
<div class="no-data-message">
|
160 |
-
{{ message if message else 'Данных за эту неделю нет в базе данных.' }}
|
161 |
-
</div>
|
162 |
-
{% endif %}
|
163 |
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
}
|
171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
|
174 |
</body>
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="ru">
|
3 |
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<link rel="icon" type="image/ico" href="https://huggingface.co/spaces/igs-img/stor/resolve/main/list.ico">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
<title>Графики pH и EC</title>
|
8 |
+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
9 |
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
10 |
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
|
11 |
+
|
12 |
<style>
|
|
|
13 |
body {
|
14 |
display: flex;
|
15 |
flex-direction: column;
|
16 |
align-items: center;
|
17 |
margin: 0;
|
18 |
padding: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
+
.container {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
width: 90%;
|
22 |
max-width: 1200px;
|
23 |
+
}
|
24 |
+
.graph-container {
|
25 |
+
width: 100%;
|
26 |
margin-bottom: 30px;
|
27 |
}
|
28 |
.graph {
|
29 |
width: 100%;
|
30 |
+
height: 500px;
|
31 |
}
|
32 |
.no-data-message {
|
33 |
font-size: 18px;
|
|
|
35 |
text-align: center;
|
36 |
margin-top: 20px;
|
37 |
}
|
38 |
+
.week-buttons {
|
39 |
+
display: flex;
|
40 |
+
justify-content: center;
|
41 |
+
margin: 20px 0;
|
42 |
+
}
|
43 |
</style>
|
44 |
</head>
|
45 |
<body>
|
46 |
+
|
47 |
+
<!-- Навигационная панель -->
|
48 |
+
<nav class="navbar navbar-light bg-light w-100">
|
49 |
+
<div class="container">
|
50 |
+
<a class="navbar-brand" href="/online">
|
51 |
+
<img src="https://huggingface.co/spaces/igs-img/stor/resolve/main/list.png" width="30" height="30" class="d-inline-block align-top" alt="">
|
52 |
+
MackorLab
|
53 |
+
</a>
|
54 |
+
<form class="form-inline">
|
55 |
+
<button id="st_onl" class="btn btn-success mr-2" type="button">Онлайн</button>
|
56 |
+
<button id="st_set" class="btn btn-outline-success" type="button">Настройки</button>
|
57 |
+
</form>
|
58 |
+
</div>
|
59 |
</nav>
|
60 |
|
61 |
+
<div class="container text-center mt-3">
|
62 |
<h1>Графики за <span id="week_number">{{ week_number }}</span>-ю неделю</h1>
|
63 |
+
</div>
|
64 |
|
65 |
+
<!-- Кнопки переключения недель -->
|
66 |
+
<div class="week-buttons">
|
67 |
+
<button id="prev_week" class="btn btn-success mr-2" onclick="navigateWeek(-1)">Предыдущая неделя</button>
|
68 |
+
<button id="next_week" class="btn btn-success" onclick="navigateWeek(1)">Следующая неделя</button>
|
69 |
+
</div>
|
70 |
|
71 |
+
{% if data %}
|
72 |
+
<div class="container">
|
73 |
<div class="graph-container"><div class="graph" id="ph_chart"></div></div>
|
74 |
<div class="graph-container"><div class="graph" id="ec_chart"></div></div>
|
75 |
<div class="graph-container"><div class="graph" id="pump_chart"></div></div>
|
|
|
77 |
<div class="graph-container"><div class="graph" id="ta_chart"></div></div>
|
78 |
<div class="graph-container"><div class="graph" id="hdm_chart"></div></div>
|
79 |
<div class="graph-container"><div class="graph" id="sven_chart"></div></div>
|
80 |
+
</div>
|
81 |
|
82 |
+
<script>
|
83 |
+
const data = {{ data | tojson }};
|
84 |
+
|
85 |
+
function createChart(id, yData, title, yLabel, color) {
|
86 |
+
Plotly.newPlot(id, [{
|
87 |
+
x: data.dates,
|
88 |
+
y: yData,
|
89 |
+
type: "scatter",
|
90 |
+
mode: "lines+markers",
|
91 |
+
line: { color: color },
|
92 |
+
hovertemplate: data.days_of_week.map((day, index) =>
|
93 |
+
`Неделя: ${data.week}<br>День: ${day}<br>${yLabel}: %{y}<br>Дата: ${data.dates[index]}`
|
94 |
+
)
|
95 |
+
}], {
|
96 |
+
title: title,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
xaxis: { title: "", showticklabels: false },
|
98 |
+
yaxis: { title: yLabel, titlefont: { size: 14 } },
|
99 |
hovermode: "closest",
|
100 |
+
showlegend: false
|
101 |
});
|
102 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
+
createChart("ph_chart", data.ph, `График pH за ${data.week}-ю неделю`, "Уровень pH", "blue");
|
105 |
+
createChart("ec_chart", data.ec, `График EC за ${data.week}-ю неделю`, "Уровень EC", "blue");
|
106 |
+
createChart("ts_chart", data.tS, `Температура раствора за ${data.week}-ю неделю`, "Температура (°C)", "purple");
|
107 |
+
createChart("ta_chart", data.tA, `Температура воздуха за ${data.week}-ю неделю`, "Температура (°C)", "purple");
|
108 |
+
createChart("hdm_chart", data.hDm, `Влажность воздуха за ${data.week}-ю неделю`, "Влажность (%)", "purple");
|
109 |
+
createChart("sven_chart", data.sVen, `Обороты вентилятора за ${data.week}-ю неделю`, "Обороты (%)", "purple");
|
110 |
+
|
111 |
+
Plotly.newPlot("pump_chart", [
|
112 |
+
{
|
113 |
+
x: data.dates,
|
114 |
+
y: data.onA,
|
115 |
+
type: "scatter",
|
116 |
+
mode: "lines+markers",
|
117 |
+
line: { color: "green" },
|
118 |
+
hovertemplate: data.days_of_week.map((day, index) =>
|
119 |
+
`Неделя: ${data.week}<br>День: ${day}<br>Насос A: %{y} сек.<br>Дата: ${data.dates[index]}`
|
120 |
+
)
|
121 |
+
},
|
122 |
+
{
|
123 |
+
x: data.dates,
|
124 |
+
y: data.onB,
|
125 |
+
type: "scatter",
|
126 |
+
mode: "lines+markers",
|
127 |
+
line: { color: "brown" },
|
128 |
+
hovertemplate: data.days_of_week.map((day, index) =>
|
129 |
+
`День: ${day}<br>Насос B: %{y} сек.<br>Дата: ${data.dates[index]}`
|
130 |
+
)
|
131 |
+
},
|
132 |
+
{
|
133 |
+
x: data.dates,
|
134 |
+
y: data.onC,
|
135 |
+
type: "scatter",
|
136 |
+
mode: "lines+markers",
|
137 |
+
line: { color: "orange" },
|
138 |
+
hovertemplate: data.days_of_week.map((day, index) =>
|
139 |
+
`День: ${day}<br>Насос C: %{y} сек.<br>Дата: ${data.dates[index]}`
|
140 |
+
)
|
141 |
}
|
142 |
+
], {
|
143 |
+
title: `Интервал дозирования насосов для ${data.week}-ой недели`,
|
144 |
+
xaxis: { title: "", showticklabels: false },
|
145 |
+
yaxis: { title: "Время ВКЛ(сек.)" },
|
146 |
+
hovermode: "closest",
|
147 |
+
showlegend: false
|
148 |
+
});
|
149 |
</script>
|
150 |
+
{% else %}
|
151 |
+
<div class="no-data-message">
|
152 |
+
{{ message if message else 'Данных за эту неделю нет в базе данных.' }}
|
153 |
+
</div>
|
154 |
+
{% endif %}
|
155 |
+
|
156 |
+
<script>
|
157 |
+
let weekNumber = {{ week_number }};
|
158 |
+
function navigateWeek(change) {
|
159 |
+
const newWeek = weekNumber + change;
|
160 |
+
if (newWeek >= 1 && newWeek <= 30) {
|
161 |
+
window.location.href = `/plot_week?week=${newWeek}`;
|
162 |
+
}
|
163 |
+
}
|
164 |
+
</script>
|
165 |
|
166 |
</body>
|
167 |
+
</html>
|
|
|
|
|
|
|
|