DmitrMakeev commited on
Commit
287a81b
·
verified ·
1 Parent(s): 4e98c77

Update plot_ph_week.html

Browse files
Files changed (1) hide show
  1. plot_ph_week.html +38 -89
plot_ph_week.html CHANGED
@@ -55,108 +55,56 @@
55
  </div>
56
 
57
  {% if data %}
58
- <div class="graph-container">
59
- <!-- График pH -->
60
- <div class="graph" id="ph_chart"></div>
61
- </div>
62
-
63
- <div class="graph-container">
64
- <!-- График EC -->
65
- <div class="graph" id="ec_chart"></div>
66
- </div>
67
-
68
- <div class="graph-container">
69
- <!-- График насосов -->
70
- <div class="graph" id="pump_chart"></div>
71
- </div>
72
 
73
  <script>
74
- const data = {{ data | tojson }}; // Данные из Flask
75
-
76
- // Рендерим графики с использованием Plotly.js
77
- Plotly.newPlot("ph_chart", [{
78
- x: data.dates,
79
- y: data.ph,
80
- type: "scatter",
81
- mode: "lines+markers",
82
- name: "pH",
83
- line: { color: "blue" },
84
- hovertemplate: data.days_of_week.map((day, index) =>
85
- `День недели: ${day}<br>pH: %{y}<br>Дата: ${data.dates[index]}`
86
- )
87
- }], {
88
- title: `График pH за ${data.week}-ю неделю`,
89
- xaxis: { title: "Дата" },
90
- yaxis: {
91
- title: "Уровень pH",
92
- titlefont: { size: 14 }
93
- },
94
- hovermode: "closest",
95
- showlegend: false
96
- });
97
-
98
- Plotly.newPlot("ec_chart", [{
99
- x: data.dates,
100
- y: data.ec,
101
- type: "scatter",
102
- mode: "lines+markers",
103
- name: "EC",
104
- line: { color: "blue" },
105
- hovertemplate: data.days_of_week.map((day, index) =>
106
- `День недели: ${day}<br>EC: %{y}<br>Дата: ${data.dates[index]}`
107
- )
108
- }], {
109
- title: `График EC за ${data.week}-ю неделю`,
110
- xaxis: { title: "Дата" },
111
- yaxis: {
112
- title: "Уровень EC",
113
- titlefont: { size: 14 }
114
- },
115
- hovermode: "closest",
116
- showlegend: false
117
- });
118
-
119
- Plotly.newPlot("pump_chart", [
120
- {
121
  x: data.dates,
122
- y: data.onA,
123
  type: "scatter",
124
  mode: "lines+markers",
125
- name: "Насос A",
126
- line: { color: "green" },
127
  hovertemplate: data.days_of_week.map((day, index) =>
128
- `День недели: ${day}<br>Насос A: %{y}сек.<br>Дата: ${data.dates[index]}`
129
  )
130
- },
131
- {
132
- x: data.dates,
133
- y: data.onB,
134
- type: "scatter",
135
- mode: "lines+markers",
136
- name: "Насос B",
137
- line: { color: "brown" },
138
- hovertemplate: data.days_of_week.map((day, index) =>
139
- `День недели: ${day}<br>Насос B: %{y}сек.<br>Дата: ${data.dates[index]}`
140
- )
141
- },
142
- {
143
- x: data.dates,
144
- y: data.onC,
145
- type: "scatter",
146
- mode: "lines+markers",
147
- name: "Насос C",
148
- line: { color: "orange" },
149
- hovertemplate: data.days_of_week.map((day, index) =>
150
- `День недели: ${day}<br>Насос C: %{y}сек.<br>Дата: ${data.dates[index]}`
151
- )
152
- }
153
  ], {
154
  title: `График работы насосов за ${data.week}-ю неделю`,
155
  xaxis: { title: "Дата" },
156
  yaxis: { title: "Состояние насосов" },
157
  hovermode: "closest",
158
- showlegend: false
159
  });
 
160
  </script>
161
 
162
  {% else %}
@@ -177,4 +125,5 @@
177
 
178
  </body>
179
 
 
180
  </html>
 
55
  </div>
56
 
57
  {% if data %}
58
+ <div class="graph-container"><div class="graph" id="ph_chart"></div></div>
59
+ <div class="graph-container"><div class="graph" id="ec_chart"></div></div>
60
+ <div class="graph-container"><div class="graph" id="pump_chart"></div></div>
61
+ <div class="graph-container"><div class="graph" id="ts_chart"></div></div>
62
+ <div class="graph-container"><div class="graph" id="ta_chart"></div></div>
63
+ <div class="graph-container"><div class="graph" id="hdm_chart"></div></div>
64
+ <div class="graph-container"><div class="graph" id="sven_chart"></div></div>
 
 
 
 
 
 
 
65
 
66
  <script>
67
+ const data = {{ data | tojson }};
68
+
69
+ function renderPlot(id, yData, title, yTitle, color) {
70
+ Plotly.newPlot(id, [{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  x: data.dates,
72
+ y: yData,
73
  type: "scatter",
74
  mode: "lines+markers",
75
+ name: title,
76
+ line: { color: color },
77
  hovertemplate: data.days_of_week.map((day, index) =>
78
+ `День недели: ${day}<br>${title}: %{y}<br>Дата: ${data.dates[index]}`
79
  )
80
+ }], {
81
+ title: `График ${title} за ${data.week}-ю неделю`,
82
+ xaxis: { title: "Дата" },
83
+ yaxis: { title: yTitle, titlefont: { size: 14 } },
84
+ hovermode: "closest",
85
+ showlegend: false
86
+ });
87
+ }
88
+
89
+ renderPlot("ph_chart", data.ph, "pH", "Уровень pH", "blue");
90
+ renderPlot("ec_chart", data.ec, "EC", "Уровень EC", "red");
91
+ renderPlot("ts_chart", data.tS, "Температура раствора", "Температура (°C)", "purple");
92
+ renderPlot("ta_chart", data.tA, "Температура воздуха", "Температура (°C)", "orange");
93
+ renderPlot("hdm_chart", data.hDm, "Влажность воздуха", "Влажность (%)", "green");
94
+ renderPlot("sven_chart", data.sVen, "Обороты вентилятора", "Обороты", "brown");
95
+
96
+ Plotly.newPlot("pump_chart", [
97
+ { x: data.dates, y: data.onA, type: "scatter", mode: "lines+markers", name: "Насос A", line: { color: "green" } },
98
+ { x: data.dates, y: data.onB, type: "scatter", mode: "lines+markers", name: "Насос B", line: { color: "brown" } },
99
+ { x: data.dates, y: data.onC, type: "scatter", mode: "lines+markers", name: "Насос C", line: { color: "orange" } }
 
 
 
100
  ], {
101
  title: `График работы насосов за ${data.week}-ю неделю`,
102
  xaxis: { title: "Дата" },
103
  yaxis: { title: "Состояние насосов" },
104
  hovermode: "closest",
105
+ showlegend: true
106
  });
107
+
108
  </script>
109
 
110
  {% else %}
 
125
 
126
  </body>
127
 
128
+
129
  </html>