visualization-dashboard.html 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637
  1. <!DOCTYPE html>
  2. <html lang="zh-CN" class="iframe-content">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>数据统计图表 - 爱智农</title>
  7. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css">
  8. <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.0/dist/echarts.min.js"></script>
  9. <script src="https://cdn.jsdelivr.net/npm/chart.js@3.9.1/dist/chart.min.js"></script>
  10. <style>
  11. body {
  12. font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  13. background-color: #f5f7f9;
  14. color: #333;
  15. margin: 0;
  16. padding: 0;
  17. overflow-x: hidden;
  18. }
  19. .dashboard-container {
  20. padding: 20px;
  21. min-height: 100vh; width: 100%; max-width: 100%; box-sizing: border-box;
  22. }
  23. .dashboard-header {
  24. margin-bottom: 24px;
  25. position: relative;
  26. }
  27. .dashboard-title {
  28. font-size: 24px;
  29. font-weight: bold;
  30. color: #1e293b;
  31. position: relative;
  32. display: inline-block;
  33. }
  34. .card {
  35. background: #ffffff;
  36. border-radius: 8px;
  37. box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  38. padding: 20px;
  39. position: relative;
  40. overflow: hidden;
  41. height: 100%;
  42. transition: all 0.3s ease;
  43. }
  44. .card:hover {
  45. box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  46. }
  47. .card-title {
  48. font-size: 16px;
  49. font-weight: bold;
  50. margin-bottom: 16px;
  51. color: #1e293b;
  52. display: flex;
  53. align-items: center;
  54. }
  55. .card-title::before {
  56. content: "";
  57. display: block;
  58. width: 3px;
  59. height: 16px;
  60. background: #4CAF50;
  61. margin-right: 8px;
  62. border-radius: 2px;
  63. }
  64. .chart-container {
  65. height: 300px;
  66. width: 100%;
  67. }
  68. .number-card {
  69. text-align: center;
  70. padding: 16px;
  71. transition: transform 0.2s;
  72. }
  73. .number-card:hover {
  74. transform: translateY(-5px);
  75. }
  76. .number-value {
  77. font-size: 28px;
  78. font-weight: bold;
  79. margin-bottom: 5px;
  80. color: #4CAF50;
  81. }
  82. .number-label {
  83. font-size: 14px;
  84. color: #64748b;
  85. }
  86. .btn {
  87. display: inline-flex;
  88. align-items: center;
  89. justify-content: center;
  90. padding: 8px 16px;
  91. border-radius: 6px;
  92. font-weight: 500;
  93. cursor: pointer;
  94. transition: all 0.2s;
  95. }
  96. .btn-primary {
  97. background-color: #4CAF50;
  98. color: white;
  99. }
  100. .btn-primary:hover {
  101. background-color: #388E3C;
  102. }
  103. .btn-default {
  104. background-color: white;
  105. border: 1px solid #d1d5db;
  106. color: #374151;
  107. }
  108. .btn-default:hover {
  109. background-color: #f9fafb;
  110. }
  111. .tab-button {
  112. padding: 8px 16px;
  113. border-radius: 6px;
  114. font-weight: 500;
  115. cursor: pointer;
  116. transition: all 0.2s;
  117. background-color: transparent;
  118. }
  119. .tab-button.active {
  120. background-color: #4CAF50;
  121. color: white;
  122. }
  123. .tab-button:not(.active):hover {
  124. background-color: #f0fdf4;
  125. }
  126. .time-range-selector {
  127. display: flex;
  128. gap: 8px;
  129. margin-bottom: 16px;
  130. }
  131. .time-range-button {
  132. padding: 6px 12px;
  133. border-radius: 4px;
  134. font-size: 14px;
  135. cursor: pointer;
  136. background-color: #f1f5f9;
  137. color: #64748b;
  138. transition: all 0.2s;
  139. }
  140. .time-range-button.active {
  141. background-color: #4CAF50;
  142. color: white;
  143. }
  144. .data-selector {
  145. display: flex;
  146. flex-wrap: wrap;
  147. gap: 8px;
  148. margin-bottom: 16px;
  149. }
  150. .data-selector-item {
  151. display: flex;
  152. align-items: center;
  153. padding: 6px 12px;
  154. border-radius: 4px;
  155. font-size: 14px;
  156. cursor: pointer;
  157. background-color: #f1f5f9;
  158. color: #64748b;
  159. transition: all 0.2s;
  160. }
  161. .data-selector-item.active {
  162. background-color: #4CAF50;
  163. color: white;
  164. }
  165. .data-selector-item input[type="checkbox"] {
  166. margin-right: 6px;
  167. }
  168. .data-table {
  169. width: 100%;
  170. border-collapse: collapse;
  171. }
  172. .data-table th,
  173. .data-table td {
  174. padding: 12px 16px;
  175. text-align: left;
  176. border-bottom: 1px solid #e5e7eb;
  177. }
  178. .data-table th {
  179. background-color: #f8fafc;
  180. font-weight: 600;
  181. color: #475569;
  182. }
  183. .data-table tbody tr:hover {
  184. background-color: #f1f5f9;
  185. }
  186. </style>
  187. </head>
  188. <body>
  189. <div class="dashboard-container">
  190. <header class="dashboard-header flex justify-between items-center">
  191. <h1 class="dashboard-title">数据统计图表</h1>
  192. <div class="flex gap-3">
  193. <button class="btn btn-default">
  194. <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  195. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
  196. </svg>
  197. 导出数据
  198. </button>
  199. <button class="btn btn-primary">
  200. <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  201. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
  202. </svg>
  203. 刷新数据
  204. </button>
  205. </div>
  206. </header>
  207. <div class="mb-6">
  208. <div class="flex gap-4 mb-6">
  209. <button class="tab-button active" data-tab="environment">环境数据</button>
  210. <button class="tab-button" data-tab="crop">作物数据</button>
  211. <button class="tab-button" data-tab="device">设备数据</button>
  212. <button class="tab-button" data-tab="yield">产量数据</button>
  213. </div>
  214. </div>
  215. <div class="tab-content" id="environment-tab">
  216. <div class="grid grid-cols-4 gap-4 mb-6">
  217. <div class="number-card card">
  218. <div class="number-value">26.5°C</div>
  219. <div class="number-label">平均气温</div>
  220. </div>
  221. <div class="number-card card">
  222. <div class="number-value">68%</div>
  223. <div class="number-label">平均湿度</div>
  224. </div>
  225. <div class="number-card card">
  226. <div class="number-value">35mm</div>
  227. <div class="number-label">月降水量</div>
  228. </div>
  229. <div class="number-card card">
  230. <div class="number-value">7.2</div>
  231. <div class="number-label">土壤pH值</div>
  232. </div>
  233. </div>
  234. <div class="card mb-6">
  235. <div class="flex justify-between items-center mb-4">
  236. <h3 class="card-title">环境数据趋势</h3>
  237. <div class="flex gap-2">
  238. <select class="px-3 py-2 bg-white border border-gray-300 rounded-md text-sm">
  239. <option>全部区域</option>
  240. <option>东区</option>
  241. <option>西区</option>
  242. <option>南区</option>
  243. <option>北区</option>
  244. </select>
  245. </div>
  246. </div>
  247. <div class="data-selector">
  248. <label class="data-selector-item active">
  249. <input type="checkbox" checked> 气温
  250. </label>
  251. <label class="data-selector-item active">
  252. <input type="checkbox" checked> 湿度
  253. </label>
  254. <label class="data-selector-item">
  255. <input type="checkbox"> 降水量
  256. </label>
  257. <label class="data-selector-item">
  258. <input type="checkbox"> 光照强度
  259. </label>
  260. <label class="data-selector-item">
  261. <input type="checkbox"> 土壤湿度
  262. </label>
  263. <label class="data-selector-item">
  264. <input type="checkbox"> 土壤温度
  265. </label>
  266. </div>
  267. <div class="time-range-selector">
  268. <button class="time-range-button">今日</button>
  269. <button class="time-range-button active">本周</button>
  270. <button class="time-range-button">本月</button>
  271. <button class="time-range-button">季度</button>
  272. <button class="time-range-button">年度</button>
  273. <div class="ml-auto flex gap-2">
  274. <input type="date" class="px-3 py-1 bg-white border border-gray-300 rounded-md text-sm">
  275. <span class="self-center">至</span>
  276. <input type="date" class="px-3 py-1 bg-white border border-gray-300 rounded-md text-sm">
  277. </div>
  278. </div>
  279. <div class="chart-container">
  280. <canvas id="environmentChart"></canvas>
  281. </div>
  282. </div>
  283. <div class="grid grid-cols-2 gap-6">
  284. <div class="card">
  285. <h3 class="card-title">区域环境对比</h3>
  286. <div id="environmentComparisonChart" class="chart-container"></div>
  287. </div>
  288. <div class="card">
  289. <h3 class="card-title">环境异常记录</h3>
  290. <div class="overflow-x-auto">
  291. <table class="data-table">
  292. <thead>
  293. <tr>
  294. <th>时间</th>
  295. <th>区域</th>
  296. <th>异常类型</th>
  297. <th>数值</th>
  298. <th>状态</th>
  299. </tr>
  300. </thead>
  301. <tbody>
  302. <tr>
  303. <td>2023-08-15 14:30</td>
  304. <td>东区</td>
  305. <td>高温预警</td>
  306. <td>38.5°C</td>
  307. <td><span class="px-2 py-1 bg-yellow-100 text-yellow-800 rounded-full text-xs">已处理</span></td>
  308. </tr>
  309. <tr>
  310. <td>2023-08-14 09:15</td>
  311. <td>南区</td>
  312. <td>湿度过低</td>
  313. <td>25%</td>
  314. <td><span class="px-2 py-1 bg-green-100 text-green-800 rounded-full text-xs">已解决</span></td>
  315. </tr>
  316. <tr>
  317. <td>2023-08-12 16:45</td>
  318. <td>西区</td>
  319. <td>土壤pH异常</td>
  320. <td>8.9</td>
  321. <td><span class="px-2 py-1 bg-green-100 text-green-800 rounded-full text-xs">已解决</span></td>
  322. </tr>
  323. <tr>
  324. <td>2023-08-10 11:20</td>
  325. <td>北区</td>
  326. <td>降水量过大</td>
  327. <td>85mm/h</td>
  328. <td><span class="px-2 py-1 bg-red-100 text-red-800 rounded-full text-xs">未处理</span></td>
  329. </tr>
  330. </tbody>
  331. </table>
  332. </div>
  333. </div>
  334. </div>
  335. </div>
  336. <div class="tab-content hidden" id="crop-tab">
  337. <div class="grid grid-cols-4 gap-4 mb-6">
  338. <div class="number-card card">
  339. <div class="number-value">4</div>
  340. <div class="number-label">主要作物种类</div>
  341. </div>
  342. <div class="number-card card">
  343. <div class="number-value">2,560</div>
  344. <div class="number-label">总种植面积(亩)</div>
  345. </div>
  346. <div class="number-card card">
  347. <div class="number-value">85%</div>
  348. <div class="number-label">作物健康率</div>
  349. </div>
  350. <div class="number-card card">
  351. <div class="number-value">1,850</div>
  352. <div class="number-label">预计总产量(吨)</div>
  353. </div>
  354. </div>
  355. <div class="grid grid-cols-2 gap-6 mb-6">
  356. <div class="card">
  357. <div class="flex justify-between items-center mb-4">
  358. <h3 class="card-title">作物分布</h3>
  359. <select class="px-3 py-2 bg-white border border-gray-300 rounded-md text-sm">
  360. <option>按面积</option>
  361. <option>按产量</option>
  362. <option>按价值</option>
  363. </select>
  364. </div>
  365. <div id="cropDistributionChart" class="chart-container"></div>
  366. </div>
  367. <div class="card">
  368. <div class="flex justify-between items-center mb-4">
  369. <h3 class="card-title">生长阶段分布</h3>
  370. <select class="px-3 py-2 bg-white border border-gray-300 rounded-md text-sm">
  371. <option>全部作物</option>
  372. <option>水稻</option>
  373. <option>小麦</option>
  374. <option>玉米</option>
  375. </select>
  376. </div>
  377. <div id="growthStageChart" class="chart-container"></div>
  378. </div>
  379. </div>
  380. <div class="card mb-6">
  381. <div class="flex justify-between items-center mb-4">
  382. <h3 class="card-title">作物生长趋势</h3>
  383. <div class="flex gap-2">
  384. <select class="px-3 py-2 bg-white border border-gray-300 rounded-md text-sm">
  385. <option>水稻</option>
  386. <option>小麦</option>
  387. <option>玉米</option>
  388. <option>大豆</option>
  389. </select>
  390. </div>
  391. </div>
  392. <div class="data-selector">
  393. <label class="data-selector-item active">
  394. <input type="checkbox" checked> 株高
  395. </label>
  396. <label class="data-selector-item active">
  397. <input type="checkbox" checked> 叶面积指数
  398. </label>
  399. <label class="data-selector-item">
  400. <input type="checkbox"> 茎粗
  401. </label>
  402. <label class="data-selector-item">
  403. <input type="checkbox"> 叶绿素含量
  404. </label>
  405. <label class="data-selector-item">
  406. <input type="checkbox"> 穗长
  407. </label>
  408. </div>
  409. <div class="time-range-selector">
  410. <button class="time-range-button">本周</button>
  411. <button class="time-range-button active">本月</button>
  412. <button class="time-range-button">季度</button>
  413. <button class="time-range-button">全生长期</button>
  414. </div>
  415. <div class="chart-container">
  416. <canvas id="cropGrowthChart"></canvas>
  417. </div>
  418. </div>
  419. <div class="grid grid-cols-2 gap-6">
  420. <div class="card">
  421. <h3 class="card-title">作物健康状况</h3>
  422. <div id="cropHealthChart" class="chart-container"></div>
  423. </div>
  424. <div class="card">
  425. <h3 class="card-title">病虫害监测</h3>
  426. <div class="overflow-x-auto">
  427. <table class="data-table">
  428. <thead>
  429. <tr>
  430. <th>发现时间</th>
  431. <th>区域</th>
  432. <th>作物</th>
  433. <th>病虫害类型</th>
  434. <th>影响面积</th>
  435. <th>状态</th>
  436. </tr>
  437. </thead>
  438. <tbody>
  439. <tr>
  440. <td>2023-08-12</td>
  441. <td>东区</td>
  442. <td>水稻</td>
  443. <td>稻飞虱</td>
  444. <td>15亩</td>
  445. <td><span class="px-2 py-1 bg-green-100 text-green-800 rounded-full text-xs">已处理</span></td>
  446. </tr>
  447. <tr>
  448. <td>2023-08-10</td>
  449. <td>南区</td>
  450. <td>玉米</td>
  451. <td>玉米螟</td>
  452. <td>8亩</td>
  453. <td><span class="px-2 py-1 bg-yellow-100 text-yellow-800 rounded-full text-xs">处理中</span></td>
  454. </tr>
  455. <tr>
  456. <td>2023-08-08</td>
  457. <td>西区</td>
  458. <td>小麦</td>
  459. <td>白粉病</td>
  460. <td>5亩</td>
  461. <td><span class="px-2 py-1 bg-green-100 text-green-800 rounded-full text-xs">已处理</span></td>
  462. </tr>
  463. <tr>
  464. <td>2023-08-05</td>
  465. <td>北区</td>
  466. <td>大豆</td>
  467. <td>蚜虫</td>
  468. <td>3亩</td>
  469. <td><span class="px-2 py-1 bg-red-100 text-red-800 rounded-full text-xs">未处理</span></td>
  470. </tr>
  471. </tbody>
  472. </table>
  473. </div>
  474. </div>
  475. </div>
  476. </div>
  477. <div class="tab-content hidden" id="device-tab">
  478. <div class="grid grid-cols-4 gap-4 mb-6">
  479. <div class="number-card card">
  480. <div class="number-value">42</div>
  481. <div class="number-label">设备总数</div>
  482. </div>
  483. <div class="number-card card">
  484. <div class="number-value">36</div>
  485. <div class="number-label">在线设备</div>
  486. </div>
  487. <div class="number-card card">
  488. <div class="number-value">6</div>
  489. <div class="number-label">离线/故障设备</div>
  490. </div>
  491. <div class="number-card card">
  492. <div class="number-value">95%</div>
  493. <div class="number-label">设备健康率</div>
  494. </div>
  495. </div>
  496. <div class="grid grid-cols-2 gap-6 mb-6">
  497. <div class="card">
  498. <div class="flex justify-between items-center mb-4">
  499. <h3 class="card-title">设备类型分布</h3>
  500. <select class="px-3 py-2 bg-white border border-gray-300 rounded-md text-sm">
  501. <option>全部农场</option>
  502. <option>东区智慧农场</option>
  503. <option>西区智慧农场</option>
  504. <option>南区智慧农场</option>
  505. <option>中心监测农场</option>
  506. </select>
  507. </div>
  508. <div id="deviceTypeChart" class="chart-container"></div>
  509. </div>
  510. <div class="card">
  511. <div class="flex justify-between items-center mb-4">
  512. <h3 class="card-title">设备状态分布</h3>
  513. <select class="px-3 py-2 bg-white border border-gray-300 rounded-md text-sm">
  514. <option>全部类型</option>
  515. <option>传感器</option>
  516. <option>摄像头</option>
  517. <option>控制器</option>
  518. <option>气象设备</option>
  519. </select>
  520. </div>
  521. <div id="deviceStatusChart" class="chart-container"></div>
  522. </div>
  523. </div>
  524. <div class="card mb-6">
  525. <div class="flex justify-between items-center mb-4">
  526. <h3 class="card-title">设备活动趋势</h3>
  527. <div class="flex gap-2">
  528. <select class="px-3 py-2 bg-white border border-gray-300 rounded-md text-sm">
  529. <option>全部设备</option>
  530. <option>传感器</option>
  531. <option>摄像头</option>
  532. <option>控制器</option>
  533. <option>气象设备</option>
  534. </select>
  535. </div>
  536. </div>
  537. <div class="time-range-selector">
  538. <button class="time-range-button">今日</button>
  539. <button class="time-range-button active">本周</button>
  540. <button class="time-range-button">本月</button>
  541. <button class="time-range-button">季度</button>
  542. </div>
  543. <div class="chart-container">
  544. <canvas id="deviceActivityChart"></canvas>
  545. </div>
  546. </div>
  547. <div class="grid grid-cols-2 gap-6">
  548. <div class="card">
  549. <h3 class="card-title">设备告警统计</h3>
  550. <div id="deviceAlertChart" class="chart-container"></div>
  551. </div>
  552. <div class="card">
  553. <h3 class="card-title">最近告警记录</h3>
  554. <div class="overflow-x-auto">
  555. <table class="data-table">
  556. <thead>
  557. <tr>
  558. <th>时间</th>
  559. <th>设备编号</th>
  560. <th>设备名称</th>
  561. <th>告警类型</th>
  562. <th>状态</th>
  563. </tr>
  564. </thead>
  565. <tbody>
  566. <tr>
  567. <td>2023-10-15 18:30</td>
  568. <td>DEV20230004</td>
  569. <td>智能灌溉控制器-D1</td>
  570. <td>设备故障</td>
  571. <td><span class="px-2 py-1 bg-red-100 text-red-800 rounded-full text-xs">未处理</span></td>
  572. </tr>
  573. <tr>
  574. <td>2023-10-14 09:45</td>
  575. <td>DEV20230002</td>
  576. <td>土壤湿度检测仪-B1</td>
  577. <td>电量不足</td>
  578. <td><span class="px-2 py-1 bg-yellow-100 text-yellow-800 rounded-full text-xs">处理中</span></td>
  579. </tr>
  580. <tr>
  581. <td>2023-10-12 14:20</td>
  582. <td>DEV20230007</td>
  583. <td>水质监测仪-E1</td>
  584. <td>数据异常</td>
  585. <td><span class="px-2 py-1 bg-green-100 text-green-800 rounded-full text-xs">已解决</span></td>
  586. </tr>
  587. <tr>
  588. <td>2023-10-10 11:05</td>
  589. <td>DEV20230009</td>
  590. <td>光照传感器-F2</td>
  591. <td>信号弱</td>
  592. <td><span class="px-2 py-1 bg-green-100 text-green-800 rounded-full text-xs">已解决</span></td>
  593. </tr>
  594. </tbody>
  595. </table>
  596. </div>
  597. </div>
  598. </div>
  599. </div>
  600. <div class="tab-content hidden" id="yield-tab">
  601. <div class="grid grid-cols-4 gap-4 mb-6">
  602. <div class="number-card card">
  603. <div class="number-value">2,450</div>
  604. <div class="number-label">总产量(吨)</div>
  605. </div>
  606. <div class="number-card card">
  607. <div class="number-value">1.2</div>
  608. <div class="number-label">亩均产量(吨)</div>
  609. </div>
  610. <div class="number-card card">
  611. <div class="number-value">+8.5%</div>
  612. <div class="number-label">同比增长</div>
  613. </div>
  614. <div class="number-card card">
  615. <div class="number-value">¥368</div>
  616. <div class="number-label">平均亩产值(万元)</div>
  617. </div>
  618. </div>
  619. <div class="grid grid-cols-2 gap-6 mb-6">
  620. <div class="card">
  621. <div class="flex justify-between items-center mb-4">
  622. <h3 class="card-title">各作物产量占比</h3>
  623. <select class="px-3 py-2 bg-white border border-gray-300 rounded-md text-sm">
  624. <option>2023年</option>
  625. <option>2022年</option>
  626. <option>2021年</option>
  627. </select>
  628. </div>
  629. <div id="yieldDistributionChart" class="chart-container"></div>
  630. </div>
  631. <div class="card">
  632. <div class="flex justify-between items-center mb-4">
  633. <h3 class="card-title">各区域产量对比</h3>
  634. <select class="px-3 py-2 bg-white border border-gray-300 rounded-md text-sm">
  635. <option>全部作物</option>
  636. <option>水稻</option>
  637. <option>小麦</option>
  638. <option>玉米</option>
  639. <option>大豆</option>
  640. </select>
  641. </div>
  642. <div id="yieldByRegionChart" class="chart-container"></div>
  643. </div>
  644. </div>
  645. <div class="card mb-6">
  646. <div class="flex justify-between items-center mb-4">
  647. <h3 class="card-title">年度产量趋势</h3>
  648. <div class="flex gap-2">
  649. <select class="px-3 py-2 bg-white border border-gray-300 rounded-md text-sm">
  650. <option>全部作物</option>
  651. <option>水稻</option>
  652. <option>小麦</option>
  653. <option>玉米</option>
  654. <option>大豆</option>
  655. </select>
  656. </div>
  657. </div>
  658. <div class="chart-container">
  659. <canvas id="yieldTrendChart"></canvas>
  660. </div>
  661. </div>
  662. <div class="grid grid-cols-2 gap-6">
  663. <div class="card">
  664. <h3 class="card-title">产量与环境因素关系</h3>
  665. <div id="yieldFactorsChart" class="chart-container"></div>
  666. </div>
  667. <div class="card">
  668. <h3 class="card-title">产量质量分析</h3>
  669. <div class="overflow-x-auto">
  670. <table class="data-table">
  671. <thead>
  672. <tr>
  673. <th>作物类型</th>
  674. <th>优质率</th>
  675. <th>中等率</th>
  676. <th>一般率</th>
  677. <th>平均质量指数</th>
  678. </tr>
  679. </thead>
  680. <tbody>
  681. <tr>
  682. <td>水稻</td>
  683. <td>85%</td>
  684. <td>12%</td>
  685. <td>3%</td>
  686. <td>92.5</td>
  687. </tr>
  688. <tr>
  689. <td>小麦</td>
  690. <td>78%</td>
  691. <td>18%</td>
  692. <td>4%</td>
  693. <td>88.6</td>
  694. </tr>
  695. <tr>
  696. <td>玉米</td>
  697. <td>82%</td>
  698. <td>15%</td>
  699. <td>3%</td>
  700. <td>90.2</td>
  701. </tr>
  702. <tr>
  703. <td>大豆</td>
  704. <td>75%</td>
  705. <td>20%</td>
  706. <td>5%</td>
  707. <td>86.8</td>
  708. </tr>
  709. </tbody>
  710. </table>
  711. </div>
  712. </div>
  713. </div>
  714. </div>
  715. </div>
  716. <script>
  717. document.addEventListener('DOMContentLoaded', function() {
  718. // 切换标签页
  719. const tabButtons = document.querySelectorAll('.tab-button');
  720. const tabContents = document.querySelectorAll('.tab-content');
  721. tabButtons.forEach(button => {
  722. button.addEventListener('click', function() {
  723. const tabName = this.dataset.tab;
  724. // 更新按钮状态
  725. tabButtons.forEach(btn => btn.classList.remove('active'));
  726. this.classList.add('active');
  727. // 更新内容显示
  728. tabContents.forEach(content => {
  729. if (content.id === tabName + '-tab') {
  730. content.classList.remove('hidden');
  731. } else {
  732. content.classList.add('hidden');
  733. }
  734. });
  735. // 重新渲染图表以适应大小
  736. resizeAllCharts();
  737. });
  738. });
  739. // 时间范围选择器
  740. const timeRangeButtons = document.querySelectorAll('.time-range-button');
  741. timeRangeButtons.forEach(button => {
  742. button.addEventListener('click', function() {
  743. timeRangeButtons.forEach(btn => btn.classList.remove('active'));
  744. this.classList.add('active');
  745. updateCharts();
  746. });
  747. });
  748. // 数据选择器
  749. const dataSelectors = document.querySelectorAll('.data-selector-item');
  750. dataSelectors.forEach(item => {
  751. item.addEventListener('click', function() {
  752. const checkbox = this.querySelector('input[type="checkbox"]');
  753. checkbox.checked = !checkbox.checked;
  754. this.classList.toggle('active', checkbox.checked);
  755. updateCharts();
  756. });
  757. });
  758. // 初始化环境数据图表
  759. const ctx = document.getElementById('environmentChart').getContext('2d');
  760. const environmentChart = new Chart(ctx, {
  761. type: 'line',
  762. data: {
  763. labels: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
  764. datasets: [
  765. {
  766. label: '气温 (°C)',
  767. data: [22, 24, 26, 25, 23, 22, 21],
  768. borderColor: '#FF9800',
  769. backgroundColor: 'rgba(255, 152, 0, 0.1)',
  770. tension: 0.4,
  771. fill: true
  772. },
  773. {
  774. label: '湿度 (%)',
  775. data: [65, 60, 55, 58, 62, 68, 70],
  776. borderColor: '#2196F3',
  777. backgroundColor: 'rgba(33, 150, 243, 0.1)',
  778. tension: 0.4,
  779. fill: true
  780. }
  781. ]
  782. },
  783. options: {
  784. responsive: true,
  785. maintainAspectRatio: false,
  786. interaction: {
  787. mode: 'index',
  788. intersect: false,
  789. },
  790. plugins: {
  791. tooltip: {
  792. enabled: true
  793. },
  794. legend: {
  795. position: 'top',
  796. }
  797. },
  798. scales: {
  799. y: {
  800. beginAtZero: false
  801. }
  802. }
  803. }
  804. });
  805. // 区域环境对比图表
  806. const environmentComparisonChart = echarts.init(document.getElementById('environmentComparisonChart'));
  807. environmentComparisonChart.setOption({
  808. tooltip: {
  809. trigger: 'axis',
  810. axisPointer: {
  811. type: 'shadow'
  812. }
  813. },
  814. legend: {
  815. data: ['气温', '湿度', '土壤湿度', '光照']
  816. },
  817. grid: {
  818. left: '3%',
  819. right: '4%',
  820. bottom: '3%',
  821. containLabel: true
  822. },
  823. xAxis: {
  824. type: 'category',
  825. data: ['东区', '西区', '南区', '北区']
  826. },
  827. yAxis: {
  828. type: 'value'
  829. },
  830. series: [
  831. {
  832. name: '气温',
  833. type: 'bar',
  834. data: [26.5, 25.8, 27.2, 24.9],
  835. color: '#FF9800'
  836. },
  837. {
  838. name: '湿度',
  839. type: 'bar',
  840. data: [68, 72, 65, 70],
  841. color: '#2196F3'
  842. },
  843. {
  844. name: '土壤湿度',
  845. type: 'bar',
  846. data: [35, 40, 32, 38],
  847. color: '#4CAF50'
  848. },
  849. {
  850. name: '光照',
  851. type: 'bar',
  852. data: [85, 80, 90, 75],
  853. color: '#FFC107'
  854. }
  855. ]
  856. });
  857. // 响应式调整图表大小
  858. function resizeAllCharts() {
  859. environmentComparisonChart.resize();
  860. environmentChart.resize();
  861. // 如果作物选项卡的图表已初始化,则调整其大小
  862. if (typeof cropDistributionChart !== 'undefined') {
  863. cropDistributionChart.resize();
  864. growthStageChart.resize();
  865. cropHealthChart.resize();
  866. if (cropGrowthChart) {
  867. cropGrowthChart.resize();
  868. }
  869. }
  870. }
  871. // 更新图表数据
  872. function updateCharts() {
  873. // 这里可以根据选择的时间范围和数据项更新图表
  874. console.log("更新图表数据");
  875. }
  876. window.addEventListener('resize', resizeAllCharts);
  877. // 初始化作物图表的变量
  878. let cropDistributionChart, growthStageChart, cropHealthChart, cropGrowthChart;
  879. // 当切换到作物选项卡时初始化图表
  880. document.querySelector('[data-tab="crop"]').addEventListener('click', function() {
  881. if (!cropDistributionChart) {
  882. // 作物分布饼图
  883. cropDistributionChart = echarts.init(document.getElementById('cropDistributionChart'));
  884. cropDistributionChart.setOption({
  885. tooltip: {
  886. trigger: 'item',
  887. formatter: '{a} <br/>{b}: {c}亩 ({d}%)'
  888. },
  889. legend: {
  890. orient: 'vertical',
  891. right: 10,
  892. top: 'center',
  893. data: ['水稻', '小麦', '玉米', '大豆']
  894. },
  895. series: [
  896. {
  897. name: '作物分布',
  898. type: 'pie',
  899. radius: ['40%', '70%'],
  900. avoidLabelOverlap: false,
  901. itemStyle: {
  902. borderRadius: 10,
  903. borderWidth: 2
  904. },
  905. label: {
  906. show: false,
  907. position: 'center'
  908. },
  909. emphasis: {
  910. label: {
  911. show: true,
  912. fontSize: '18',
  913. fontWeight: 'bold'
  914. }
  915. },
  916. labelLine: {
  917. show: false
  918. },
  919. data: [
  920. { value: 1200, name: '水稻' },
  921. { value: 600, name: '小麦' },
  922. { value: 580, name: '玉米' },
  923. { value: 180, name: '大豆' }
  924. ],
  925. color: ['#4CAF50', '#8BC34A', '#CDDC39', '#FFC107']
  926. }
  927. ]
  928. });
  929. // 生长阶段图表
  930. growthStageChart = echarts.init(document.getElementById('growthStageChart'));
  931. growthStageChart.setOption({
  932. tooltip: {
  933. trigger: 'item',
  934. formatter: '{b}: {c}亩 ({d}%)'
  935. },
  936. legend: {
  937. bottom: '0%',
  938. left: 'center',
  939. data: ['播种期', '幼苗期', '生长期', '成熟期', '收获期']
  940. },
  941. series: [
  942. {
  943. name: '生长阶段',
  944. type: 'pie',
  945. radius: '70%',
  946. center: ['50%', '45%'],
  947. data: [
  948. { value: 350, name: '播种期' },
  949. { value: 450, name: '幼苗期' },
  950. { value: 850, name: '生长期' },
  951. { value: 650, name: '成熟期' },
  952. { value: 260, name: '收获期' }
  953. ],
  954. color: ['#E3F2FD', '#90CAF9', '#42A5F5', '#1976D2', '#0D47A1'],
  955. emphasis: {
  956. itemStyle: {
  957. shadowBlur: 10,
  958. shadowOffsetX: 0,
  959. shadowColor: 'rgba(0, 0, 0, 0.5)'
  960. }
  961. }
  962. }
  963. ]
  964. });
  965. // 作物健康状况图表
  966. cropHealthChart = echarts.init(document.getElementById('cropHealthChart'));
  967. cropHealthChart.setOption({
  968. tooltip: {
  969. trigger: 'axis',
  970. axisPointer: {
  971. type: 'shadow'
  972. }
  973. },
  974. legend: {
  975. data: ['健康', '轻度受损', '中度受损', '重度受损']
  976. },
  977. grid: {
  978. left: '3%',
  979. right: '4%',
  980. bottom: '3%',
  981. containLabel: true
  982. },
  983. xAxis: {
  984. type: 'value',
  985. boundaryGap: [0, 0.01]
  986. },
  987. yAxis: {
  988. type: 'category',
  989. data: ['水稻', '小麦', '玉米', '大豆']
  990. },
  991. series: [
  992. {
  993. name: '健康',
  994. type: 'bar',
  995. stack: 'total',
  996. data: [1020, 510, 480, 160],
  997. color: '#4CAF50'
  998. },
  999. {
  1000. name: '轻度受损',
  1001. type: 'bar',
  1002. stack: 'total',
  1003. data: [120, 60, 70, 15],
  1004. color: '#FFC107'
  1005. },
  1006. {
  1007. name: '中度受损',
  1008. type: 'bar',
  1009. stack: 'total',
  1010. data: [50, 25, 25, 5],
  1011. color: '#FF9800'
  1012. },
  1013. {
  1014. name: '重度受损',
  1015. type: 'bar',
  1016. stack: 'total',
  1017. data: [10, 5, 5, 0],
  1018. color: '#F44336'
  1019. }
  1020. ]
  1021. });
  1022. // 作物生长趋势图表
  1023. const cropGrowthCtx = document.getElementById('cropGrowthChart').getContext('2d');
  1024. cropGrowthChart = new Chart(cropGrowthCtx, {
  1025. type: 'line',
  1026. data: {
  1027. labels: ['第1周', '第2周', '第3周', '第4周', '第5周', '第6周', '第7周', '第8周'],
  1028. datasets: [
  1029. {
  1030. label: '株高 (cm)',
  1031. data: [15, 25, 38, 52, 68, 85, 95, 100],
  1032. borderColor: '#4CAF50',
  1033. backgroundColor: 'rgba(76, 175, 80, 0.1)',
  1034. tension: 0.4,
  1035. fill: true
  1036. },
  1037. {
  1038. label: '叶面积指数',
  1039. data: [0.8, 1.5, 2.3, 3.2, 4.1, 4.8, 5.2, 5.5],
  1040. borderColor: '#2196F3',
  1041. backgroundColor: 'rgba(33, 150, 243, 0.1)',
  1042. tension: 0.4,
  1043. fill: true
  1044. }
  1045. ]
  1046. },
  1047. options: {
  1048. responsive: true,
  1049. maintainAspectRatio: false,
  1050. interaction: {
  1051. mode: 'index',
  1052. intersect: false,
  1053. },
  1054. plugins: {
  1055. tooltip: {
  1056. enabled: true
  1057. },
  1058. legend: {
  1059. position: 'top',
  1060. }
  1061. },
  1062. scales: {
  1063. y: {
  1064. beginAtZero: false
  1065. }
  1066. }
  1067. }
  1068. });
  1069. }
  1070. // 调整图表大小以适应容器
  1071. setTimeout(() => {
  1072. cropDistributionChart.resize();
  1073. growthStageChart.resize();
  1074. cropHealthChart.resize();
  1075. }, 0);
  1076. });
  1077. // 当切换到设备数据选项卡时初始化图表
  1078. document.querySelector('[data-tab="device"]').addEventListener('click', function() {
  1079. if (!deviceTypeChart) {
  1080. // 设备类型分布图
  1081. deviceTypeChart = echarts.init(document.getElementById('deviceTypeChart'));
  1082. deviceTypeChart.setOption({
  1083. tooltip: {
  1084. trigger: 'item',
  1085. formatter: '{a} <br/>{b}: {c} ({d}%)'
  1086. },
  1087. legend: {
  1088. orient: 'vertical',
  1089. right: 10,
  1090. top: 'center',
  1091. data: ['传感器', '摄像头', '控制器', '气象设备']
  1092. },
  1093. series: [
  1094. {
  1095. name: '设备类型',
  1096. type: 'pie',
  1097. radius: ['50%', '70%'],
  1098. avoidLabelOverlap: false,
  1099. itemStyle: {
  1100. borderRadius: 10,
  1101. borderWidth: 2
  1102. },
  1103. label: {
  1104. show: false,
  1105. position: 'center'
  1106. },
  1107. emphasis: {
  1108. label: {
  1109. show: true,
  1110. fontSize: '18',
  1111. fontWeight: 'bold'
  1112. }
  1113. },
  1114. labelLine: {
  1115. show: false
  1116. },
  1117. data: [
  1118. { value: 24, name: '传感器' },
  1119. { value: 8, name: '摄像头' },
  1120. { value: 6, name: '控制器' },
  1121. { value: 4, name: '气象设备' }
  1122. ],
  1123. color: ['#2196F3', '#9C27B0', '#FF9800', '#4CAF50']
  1124. }
  1125. ]
  1126. });
  1127. // 设备状态分布图
  1128. deviceStatusChart = echarts.init(document.getElementById('deviceStatusChart'));
  1129. deviceStatusChart.setOption({
  1130. tooltip: {
  1131. trigger: 'item',
  1132. formatter: '{a} <br/>{b}: {c} ({d}%)'
  1133. },
  1134. legend: {
  1135. orient: 'vertical',
  1136. right: 10,
  1137. top: 'center',
  1138. data: ['在线', '离线', '故障', '维护中']
  1139. },
  1140. series: [
  1141. {
  1142. name: '设备状态',
  1143. type: 'pie',
  1144. radius: ['50%', '70%'],
  1145. avoidLabelOverlap: false,
  1146. itemStyle: {
  1147. borderRadius: 10,
  1148. borderWidth: 2
  1149. },
  1150. label: {
  1151. show: false,
  1152. position: 'center'
  1153. },
  1154. emphasis: {
  1155. label: {
  1156. show: true,
  1157. fontSize: '18',
  1158. fontWeight: 'bold'
  1159. }
  1160. },
  1161. labelLine: {
  1162. show: false
  1163. },
  1164. data: [
  1165. { value: 36, name: '在线' },
  1166. { value: 3, name: '离线' },
  1167. { value: 2, name: '故障' },
  1168. { value: 1, name: '维护中' }
  1169. ],
  1170. color: ['#4CAF50', '#FFC107', '#F44336', '#9E9E9E']
  1171. }
  1172. ]
  1173. });
  1174. // 设备告警统计图
  1175. deviceAlertChart = echarts.init(document.getElementById('deviceAlertChart'));
  1176. deviceAlertChart.setOption({
  1177. tooltip: {
  1178. trigger: 'axis',
  1179. axisPointer: {
  1180. type: 'shadow'
  1181. }
  1182. },
  1183. legend: {
  1184. data: ['设备故障', '电量不足', '数据异常', '信号弱', '其他']
  1185. },
  1186. grid: {
  1187. left: '3%',
  1188. right: '4%',
  1189. bottom: '3%',
  1190. containLabel: true
  1191. },
  1192. xAxis: {
  1193. type: 'category',
  1194. data: ['传感器', '摄像头', '控制器', '气象设备']
  1195. },
  1196. yAxis: {
  1197. type: 'value'
  1198. },
  1199. series: [
  1200. {
  1201. name: '设备故障',
  1202. type: 'bar',
  1203. stack: 'total',
  1204. data: [2, 1, 3, 0],
  1205. color: '#F44336'
  1206. },
  1207. {
  1208. name: '电量不足',
  1209. type: 'bar',
  1210. stack: 'total',
  1211. data: [5, 2, 0, 1],
  1212. color: '#FF9800'
  1213. },
  1214. {
  1215. name: '数据异常',
  1216. type: 'bar',
  1217. stack: 'total',
  1218. data: [3, 0, 2, 2],
  1219. color: '#FFC107'
  1220. },
  1221. {
  1222. name: '信号弱',
  1223. type: 'bar',
  1224. stack: 'total',
  1225. data: [2, 3, 1, 1],
  1226. color: '#2196F3'
  1227. },
  1228. {
  1229. name: '其他',
  1230. type: 'bar',
  1231. stack: 'total',
  1232. data: [1, 0, 1, 0],
  1233. color: '#9E9E9E'
  1234. }
  1235. ]
  1236. });
  1237. // 设备活动趋势图表
  1238. const deviceActivityCtx = document.getElementById('deviceActivityChart').getContext('2d');
  1239. deviceActivityChart = new Chart(deviceActivityCtx, {
  1240. type: 'line',
  1241. data: {
  1242. labels: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
  1243. datasets: [
  1244. {
  1245. label: '活动次数',
  1246. data: [125, 132, 128, 142, 135, 92, 88],
  1247. borderColor: '#4CAF50',
  1248. backgroundColor: 'rgba(76, 175, 80, 0.1)',
  1249. tension: 0.4,
  1250. fill: true
  1251. },
  1252. {
  1253. label: '数据上传量(KB)',
  1254. data: [850, 920, 880, 950, 910, 720, 680],
  1255. borderColor: '#2196F3',
  1256. backgroundColor: 'rgba(33, 150, 243, 0.1)',
  1257. tension: 0.4,
  1258. fill: true
  1259. }
  1260. ]
  1261. },
  1262. options: {
  1263. responsive: true,
  1264. maintainAspectRatio: false,
  1265. interaction: {
  1266. mode: 'index',
  1267. intersect: false,
  1268. },
  1269. plugins: {
  1270. tooltip: {
  1271. enabled: true
  1272. },
  1273. legend: {
  1274. position: 'top',
  1275. }
  1276. },
  1277. scales: {
  1278. y: {
  1279. beginAtZero: false
  1280. }
  1281. }
  1282. }
  1283. });
  1284. }
  1285. // 调整图表大小以适应容器
  1286. setTimeout(() => {
  1287. deviceTypeChart.resize();
  1288. deviceStatusChart.resize();
  1289. deviceAlertChart.resize();
  1290. }, 0);
  1291. });
  1292. // 当切换到产量数据选项卡时初始化图表
  1293. document.querySelector('[data-tab="yield"]').addEventListener('click', function() {
  1294. if (!yieldDistributionChart) {
  1295. // 产量分布饼图
  1296. yieldDistributionChart = echarts.init(document.getElementById('yieldDistributionChart'));
  1297. yieldDistributionChart.setOption({
  1298. tooltip: {
  1299. trigger: 'item',
  1300. formatter: '{a} <br/>{b}: {c}吨 ({d}%)'
  1301. },
  1302. legend: {
  1303. orient: 'vertical',
  1304. right: 10,
  1305. top: 'center',
  1306. data: ['水稻', '小麦', '玉米', '大豆']
  1307. },
  1308. series: [
  1309. {
  1310. name: '产量分布',
  1311. type: 'pie',
  1312. radius: ['50%', '70%'],
  1313. avoidLabelOverlap: false,
  1314. itemStyle: {
  1315. borderRadius: 10,
  1316. borderWidth: 2
  1317. },
  1318. label: {
  1319. show: false,
  1320. position: 'center'
  1321. },
  1322. emphasis: {
  1323. label: {
  1324. show: true,
  1325. fontSize: '18',
  1326. fontWeight: 'bold'
  1327. }
  1328. },
  1329. labelLine: {
  1330. show: false
  1331. },
  1332. data: [
  1333. { value: 1200, name: '水稻' },
  1334. { value: 580, name: '小麦' },
  1335. { value: 520, name: '玉米' },
  1336. { value: 150, name: '大豆' }
  1337. ],
  1338. color: ['#4CAF50', '#8BC34A', '#CDDC39', '#FFC107']
  1339. }
  1340. ]
  1341. });
  1342. // 区域产量对比图
  1343. yieldByRegionChart = echarts.init(document.getElementById('yieldByRegionChart'));
  1344. yieldByRegionChart.setOption({
  1345. tooltip: {
  1346. trigger: 'axis',
  1347. axisPointer: {
  1348. type: 'shadow'
  1349. }
  1350. },
  1351. legend: {
  1352. data: ['2021年', '2022年', '2023年']
  1353. },
  1354. grid: {
  1355. left: '3%',
  1356. right: '4%',
  1357. bottom: '3%',
  1358. containLabel: true
  1359. },
  1360. xAxis: {
  1361. type: 'category',
  1362. data: ['东区', '西区', '南区', '北区']
  1363. },
  1364. yAxis: {
  1365. type: 'value',
  1366. name: '产量(吨)'
  1367. },
  1368. series: [
  1369. {
  1370. name: '2021年',
  1371. type: 'bar',
  1372. data: [580, 480, 520, 420],
  1373. color: '#CDDC39'
  1374. },
  1375. {
  1376. name: '2022年',
  1377. type: 'bar',
  1378. data: [620, 520, 580, 450],
  1379. color: '#8BC34A'
  1380. },
  1381. {
  1382. name: '2023年',
  1383. type: 'bar',
  1384. data: [680, 560, 630, 480],
  1385. color: '#4CAF50'
  1386. }
  1387. ]
  1388. });
  1389. // 产量与环境因素关系图
  1390. yieldFactorsChart = echarts.init(document.getElementById('yieldFactorsChart'));
  1391. yieldFactorsChart.setOption({
  1392. tooltip: {
  1393. trigger: 'axis'
  1394. },
  1395. legend: {
  1396. data: ['产量', '温度', '降水量', '光照']
  1397. },
  1398. grid: {
  1399. left: '3%',
  1400. right: '4%',
  1401. bottom: '3%',
  1402. containLabel: true
  1403. },
  1404. xAxis: {
  1405. type: 'category',
  1406. boundaryGap: false,
  1407. data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
  1408. },
  1409. yAxis: [
  1410. {
  1411. type: 'value',
  1412. name: '产量',
  1413. position: 'left',
  1414. axisLine: {
  1415. show: true,
  1416. lineStyle: {
  1417. color: '#4CAF50'
  1418. }
  1419. }
  1420. },
  1421. {
  1422. type: 'value',
  1423. name: '环境因素',
  1424. position: 'right',
  1425. axisLine: {
  1426. show: true,
  1427. lineStyle: {
  1428. color: '#FF9800'
  1429. }
  1430. }
  1431. }
  1432. ],
  1433. series: [
  1434. {
  1435. name: '产量',
  1436. type: 'line',
  1437. data: [0, 0, 0, 120, 180, 240, 320, 420, 580, 420, 180, 0],
  1438. color: '#4CAF50',
  1439. yAxisIndex: 0
  1440. },
  1441. {
  1442. name: '温度',
  1443. type: 'line',
  1444. data: [5, 8, 12, 18, 24, 28, 32, 30, 25, 18, 12, 6],
  1445. color: '#FF9800',
  1446. yAxisIndex: 1
  1447. },
  1448. {
  1449. name: '降水量',
  1450. type: 'line',
  1451. data: [20, 25, 35, 45, 80, 120, 150, 120, 90, 60, 30, 20],
  1452. color: '#2196F3',
  1453. yAxisIndex: 1
  1454. },
  1455. {
  1456. name: '光照',
  1457. type: 'line',
  1458. data: [40, 45, 55, 65, 80, 85, 90, 85, 75, 60, 50, 40],
  1459. color: '#FFC107',
  1460. yAxisIndex: 1
  1461. }
  1462. ]
  1463. });
  1464. // 年度产量趋势图表
  1465. const yieldTrendCtx = document.getElementById('yieldTrendChart').getContext('2d');
  1466. yieldTrendChart = new Chart(yieldTrendCtx, {
  1467. type: 'bar',
  1468. data: {
  1469. labels: ['2018', '2019', '2020', '2021', '2022', '2023'],
  1470. datasets: [
  1471. {
  1472. label: '水稻',
  1473. data: [980, 1020, 1080, 1120, 1150, 1200],
  1474. backgroundColor: '#4CAF50'
  1475. },
  1476. {
  1477. label: '小麦',
  1478. data: [450, 480, 520, 550, 560, 580],
  1479. backgroundColor: '#8BC34A'
  1480. },
  1481. {
  1482. label: '玉米',
  1483. data: [420, 440, 460, 480, 500, 520],
  1484. backgroundColor: '#CDDC39'
  1485. },
  1486. {
  1487. label: '大豆',
  1488. data: [120, 130, 135, 140, 145, 150],
  1489. backgroundColor: '#FFC107'
  1490. }
  1491. ]
  1492. },
  1493. options: {
  1494. responsive: true,
  1495. maintainAspectRatio: false,
  1496. plugins: {
  1497. tooltip: {
  1498. enabled: true
  1499. },
  1500. legend: {
  1501. position: 'top',
  1502. }
  1503. },
  1504. scales: {
  1505. x: {
  1506. stacked: true,
  1507. },
  1508. y: {
  1509. stacked: true,
  1510. title: {
  1511. display: true,
  1512. text: '产量(吨)'
  1513. }
  1514. }
  1515. }
  1516. }
  1517. });
  1518. }
  1519. // 调整图表大小以适应容器
  1520. setTimeout(() => {
  1521. yieldDistributionChart.resize();
  1522. yieldByRegionChart.resize();
  1523. yieldFactorsChart.resize();
  1524. }, 0);
  1525. });
  1526. // 初始化图表变量
  1527. let deviceTypeChart, deviceStatusChart, deviceAlertChart, deviceActivityChart;
  1528. let yieldDistributionChart, yieldByRegionChart, yieldFactorsChart, yieldTrendChart;
  1529. });
  1530. </script>
  1531. </body>
  1532. </html>