|
<!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> |
|
<style> |
|
|
|
body { |
|
display: flex; |
|
flex-direction: column; |
|
align-items: center; |
|
margin: 0; |
|
padding: 0; |
|
height: 100vh; |
|
justify-content: flex-start; |
|
} |
|
h1 { |
|
margin-top: 20px; |
|
font-size: 24px; |
|
} |
|
.buttons { |
|
margin: 20px 0; |
|
} |
|
button { |
|
margin: 0 10px; |
|
padding: 10px 20px; |
|
font-size: 16px; |
|
} |
|
.graph-container { |
|
width: 90%; |
|
max-width: 1200px; |
|
margin-bottom: 30px; |
|
} |
|
.graph { |
|
width: 100%; |
|
height: 500px; |
|
} |
|
.no-data-message { |
|
font-size: 18px; |
|
color: red; |
|
text-align: center; |
|
margin-top: 20px; |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
|
|
<h1>Графики за <span id="week_number">{{ week_number }}</span>-ю неделю</h1> |
|
|
|
<div class="buttons"> |
|
<button id="prev_week" onclick="navigateWeek(-1)">Предыдущая неделя</button> |
|
<button id="next_week" onclick="navigateWeek(1)">Следующая неделя</button> |
|
</div> |
|
|
|
{% if data %} |
|
<div class="graph-container"><div class="graph" id="ph_chart"></div></div> |
|
<div class="graph-container"><div class="graph" id="ec_chart"></div></div> |
|
<div class="graph-container"><div class="graph" id="pump_chart"></div></div> |
|
<div class="graph-container"><div class="graph" id="tS_chart"></div></div> |
|
<div class="graph-container"><div class="graph" id="tA_chart"></div></div> |
|
<div class="graph-container"><div class="graph" id="hDm_chart"></div></div> |
|
<div class="graph-container"><div class="graph" id="sVen_chart"></div></div> |
|
|
|
<script> |
|
const data = {{ data | tojson }}; |
|
|
|
Plotly.newPlot("ph_chart", [{ |
|
x: data.dates, |
|
y: data.ph, |
|
type: "scatter", |
|
mode: "lines+markers", |
|
name: "pH", |
|
line: { color: "blue" }, |
|
hovertemplate: data.days_of_week.map((day, index) => |
|
`День недели: ${day}<br>pH: %{y}<br>Дата: ${data.dates[index]}` |
|
) |
|
}], { |
|
title: `График pH за ${data.week}-ю неделю`, |
|
xaxis: { title: "Дата" }, |
|
yaxis: { title: "Уровень pH" }, |
|
hovermode: "closest" |
|
}); |
|
|
|
Plotly.newPlot("ec_chart", [{ |
|
x: data.dates, |
|
y: data.ec, |
|
type: "scatter", |
|
mode: "lines+markers", |
|
name: "EC", |
|
line: { color: "blue" }, |
|
hovertemplate: data.days_of_week.map((day, index) => |
|
`День недели: ${day}<br>EC: %{y}<br>Дата: ${data.dates[index]}` |
|
) |
|
}], { |
|
title: `График EC за ${data.week}-ю неделю`, |
|
xaxis: { title: "Дата" }, |
|
yaxis: { title: "Уровень EC" }, |
|
hovermode: "closest" |
|
}); |
|
|
|
Plotly.newPlot("pump_chart", [ |
|
{ x: data.dates, y: data.onA, type: "scatter", mode: "lines+markers", name: "Насос A", line: { color: "green" }}, |
|
{ x: data.dates, y: data.onB, type: "scatter", mode: "lines+markers", name: "Насос B", line: { color: "brown" }}, |
|
{ x: data.dates, y: data.onC, type: "scatter", mode: "lines+markers", name: "Насос C", line: { color: "orange" }} |
|
], { |
|
title: `График работы насосов за ${data.week}-ю неделю`, |
|
xaxis: { title: "Дата" }, |
|
yaxis: { title: "Состояние насосов" }, |
|
hovermode: "closest" |
|
}); |
|
|
|
Plotly.newPlot("tS_chart", [{ |
|
x: data.dates, |
|
y: data.tS, |
|
type: "scatter", |
|
mode: "lines+markers", |
|
name: "Температура раствора", |
|
line: { color: "red" } |
|
}], { |
|
title: `График температуры раствора за ${data.week}-ю неделю`, |
|
xaxis: { title: "Дата" }, |
|
yaxis: { title: "Температура (°C)" }, |
|
hovermode: "closest" |
|
}); |
|
|
|
Plotly.newPlot("tA_chart", [{ |
|
x: data.dates, |
|
y: data.tA, |
|
type: "scatter", |
|
mode: "lines+markers", |
|
name: "Температура воздуха", |
|
line: { color: "purple" } |
|
}], { |
|
title: `График температуры воздуха за ${data.week}-ю неделю`, |
|
xaxis: { title: "Дата" }, |
|
yaxis: { title: "Температура (°C)" }, |
|
hovermode: "closest" |
|
}); |
|
|
|
Plotly.newPlot("hDm_chart", [{ |
|
x: data.dates, |
|
y: data.hDm, |
|
type: "scatter", |
|
mode: "lines+markers", |
|
name: "Влажность воздуха", |
|
line: { color: "blue" } |
|
}], { |
|
title: `График влажности воздуха за ${data.week}-ю неделю`, |
|
xaxis: { title: "Дата" }, |
|
yaxis: { title: "Влажность (%)" }, |
|
hovermode: "closest" |
|
}); |
|
|
|
Plotly.newPlot("sVen_chart", [{ |
|
x: data.dates, |
|
y: data.sVen, |
|
type: "scatter", |
|
mode: "lines+markers", |
|
name: "Обороты вентилятора", |
|
line: { color: "gray" } |
|
}], { |
|
title: `График оборотов вентилятора за ${data.week}-ю неделю`, |
|
xaxis: { title: "Дата" }, |
|
yaxis: { title: "Обороты" }, |
|
hovermode: "closest" |
|
}); |
|
|
|
</script> |
|
|
|
{% else %} |
|
<div class="no-data-message">Данных за эту неделю нет в базе данных.</div> |
|
{% endif %} |
|
|
|
<script> |
|
const weekNumber = {{ week_number }}; |
|
function navigateWeek(change) { |
|
const newWeek = weekNumber + change; |
|
if (newWeek >= 1 && newWeek <= 30) { |
|
window.location.href = `/plot_ph_week?week=${newWeek}`; |
|
} |
|
} |
|
</script> |
|
|
|
</body> |
|
|
|
|
|
|
|
</html> |