flask_inference_api_g / plot_ph_week.html
DmitrMakeev's picture
Create plot_ph_week.html
dfaa01c verified
raw
history blame
2.5 kB
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Графики pH и EC</title>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
<h1>Графики за <span id="week_number">{{ data.week }}</span>-ю неделю</h1>
<button id="prev_week" onclick="navigateWeek(-1)">Предыдущая неделя</button>
<button id="next_week" onclick="navigateWeek(1)">Следующая неделя</button>
<div id="ph_chart"></div>
<div id="ec_chart"></div>
<div id="pump_chart"></div>
<script>
const weekNumber = {{ data.week }};
const data = {{ data | tojson }}; // Данные из Flask
function navigateWeek(change) {
const newWeek = weekNumber + change;
if (newWeek >= 1 && newWeek <= 30) {
window.location.href = `/plot_ph_week?week=${newWeek}`;
}
}
// Рендерим графики с использованием Plotly.js
Plotly.newPlot("ph_chart", [{
x: data.dates,
y: data.ph,
type: "scatter",
mode: "lines",
name: "pH"
}], {
title: `График pH за ${data.week}-ю неделю`,
xaxis: { title: "Дата" },
yaxis: { title: "pH" }
});
Plotly.newPlot("ec_chart", [{
x: data.dates,
y: data.ec,
type: "scatter",
mode: "lines",
name: "EC",
line: { color: "green" }
}], {
title: `График EC за ${data.week}-ю неделю`,
xaxis: { title: "Дата" },
yaxis: { title: "EC" }
});
Plotly.newPlot("pump_chart", [
{ x: data.dates, y: data.onA, type: "scatter", mode: "lines", name: "Насос A", line: { color: "blue" } },
{ x: data.dates, y: data.onB, type: "scatter", mode: "lines", name: "Насос B", line: { color: "brown" } },
{ x: data.dates, y: data.onC, type: "scatter", mode: "lines", name: "Насос C", line: { color: "orange" } }
], {
title: `График работы насосов за ${data.week}-ю неделю`,
xaxis: { title: "Дата" },
yaxis: { title: "Состояние насосов" }
});
</script>
</body>
</html>