index-charts.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. /*
  2. * 显示血糖图表
  3. */
  4. function showChartSugar(list) {
  5. if(list.length == 0) {
  6. return
  7. }
  8. var legendArray = ['早餐前血糖', '早餐后血糖', '午餐前血糖', '午餐后血糖', '晚餐前血糖', '晚餐后血糖', '睡前血糖'];
  9. var xAxisArray = new Array();
  10. var xAxisArray1 = new Array();
  11. var xAxisArray2 = new Array();
  12. var xAxisArray3 = new Array();
  13. var xAxisArray4 = new Array();
  14. var xAxisArray5 = new Array();
  15. var xAxisArray6 = new Array();
  16. var xAxisArray7 = new Array();
  17. var xdate = new Array();
  18. var seriesArray = new Array();
  19. var allDatas = new Array();
  20. var data1 = new Array();
  21. var data2 = new Array();
  22. var data3 = new Array();
  23. var data4 = new Array();
  24. var data5 = new Array();
  25. var data6 = new Array();
  26. var data7 = new Array();
  27. for(var i = 0; i < list.length; i++) {
  28. var data = list[i];
  29. if(!data) {
  30. continue;
  31. }
  32. xAxisArray.push(data.date.substr(5, 5));
  33. if(data.value1 != null) {
  34. xAxisArray1.push(data.date.substr(5, 5));
  35. // data1.push(buildData(data.value1, 6.1, 3.9));
  36. }
  37. if(data.value2 != null) {
  38. xAxisArray2.push(data.date.substr(5, 5));
  39. // data2.push(buildData(data.value2, 7.8, 4.4));
  40. }
  41. if(data.value3 != null) {
  42. xAxisArray3.push(data.date.substr(5, 5));
  43. // data3.push(buildData(data.value3, 6.1, 3.9));
  44. }
  45. if(data.value4 != null) {
  46. xAxisArray4.push(data.date.substr(5, 5));
  47. // data4.push(buildData(data.value4, 7.8, 4.4));
  48. }
  49. if(data.value5 != null) {
  50. xAxisArray5.push(data.date.substr(5, 5));
  51. // data5.push(buildData(data.value5, 6.1, 3.9));
  52. }
  53. if(data.value6 != null) {
  54. xAxisArray6.push(data.date.substr(5, 5));
  55. // data6.push(buildData(data.value6, 7.8, 4.4));
  56. }
  57. if(data.value7 != null) {
  58. xAxisArray7.push(data.date.substr(5, 5));
  59. // data7.push(buildData(data.value7, 7.8, 4.4));
  60. }
  61. data1.push(buildData(data.value1, 6.1, 3.9));
  62. data2.push(buildData(data.value2, 7.8, 4.4));
  63. data3.push(buildData(data.value3, 6.1, 3.9));
  64. data4.push(buildData(data.value4, 7.8, 4.4));
  65. data5.push(buildData(data.value5, 6.1, 3.9));
  66. data6.push(buildData(data.value6, 7.8, 4.4));
  67. data7.push(buildData(data.value7, 7.8, 4.4));
  68. }
  69. allDatas.push(data1);
  70. allDatas.push(data2);
  71. allDatas.push(data3);
  72. allDatas.push(data4);
  73. allDatas.push(data5);
  74. allDatas.push(data6);
  75. allDatas.push(data7);
  76. xdate.push(xAxisArray1);
  77. xdate.push(xAxisArray2);
  78. xdate.push(xAxisArray3);
  79. xdate.push(xAxisArray4);
  80. xdate.push(xAxisArray5);
  81. xdate.push(xAxisArray6);
  82. xdate.push(xAxisArray7);
  83. for(var i = 0; i < 7; i++) {
  84. var ech = echarts.init(document.getElementById('echarts' + (i * 1 + 1)));
  85. var echID = 'echarts' + (i * 1 + 1);
  86. if(xdate[i].length > 0) {
  87. $('#' + echID).css("top", "");
  88. //有数据
  89. var option = {
  90. title: {
  91. text: legendArray[i],
  92. textStyle: {
  93. color: "#17b3ec",
  94. fontWeight: "normal",
  95. fontSize: 15
  96. },
  97. x: "center"
  98. },
  99. // calculable: true,
  100. grid: {
  101. x: '8%',
  102. x2: '8%'
  103. },
  104. tooltip: {
  105. show: true,
  106. showContent: true,
  107. trigger: "axis"
  108. },
  109. xAxis: [{
  110. type: 'category',
  111. boundaryGap: false,
  112. data: xAxisArray
  113. }],
  114. yAxis: [{
  115. type: 'value',
  116. name: "mmol/L",
  117. // scale: true
  118. }],
  119. color: ['#6e7074'],
  120. series: [{
  121. name: legendArray[i],
  122. type: 'line',
  123. data: allDatas[i],
  124. markLine: {
  125. symbol: ['circle', 'circle'],
  126. precision: 1,
  127. itemStyle: {
  128. normal: {
  129. color: "#6e7074"
  130. }
  131. },
  132. data: [
  133. [{
  134. value: 4.4,
  135. xAxis: 0,
  136. yAxis: 4.4
  137. }, {
  138. value: 4.4,
  139. xAxis: 40,
  140. yAxis: 4.4
  141. }],
  142. [{
  143. value: 7.8,
  144. xAxis: 0,
  145. yAxis: 7.8
  146. }, {
  147. value: 7.8,
  148. xAxis: 40,
  149. yAxis: 7.8
  150. }]
  151. ]
  152. }
  153. }]
  154. };
  155. if(i == 0) {
  156. option.series[0].markLine.data = [
  157. [{
  158. value: 3.9,
  159. xAxis: 0,
  160. yAxis: 3.9
  161. }, {
  162. value: 3.9,
  163. xAxis: 40,
  164. yAxis: 3.9
  165. }],
  166. [{
  167. value: 6.1,
  168. xAxis: 0,
  169. yAxis: 6.1
  170. }, {
  171. value: 6.1,
  172. xAxis: 40,
  173. yAxis: 6.1
  174. }]
  175. ]
  176. }
  177. ech.setOption(option);
  178. } else {
  179. //没有血糖数据时的显示方式
  180. var no_html = "<p class='c-17b3ec' style='margin: 10px 0 45px 0;font-size:15px'>"+legendArray[i]+"</p><i class='icon-noset' ></i><p class='c-17b3ec'>暂无相关记录</p>";
  181. $('#' + echID).html(no_html);
  182. $('#' + echID).css("text-align", "center");
  183. }
  184. }
  185. plus.nativeUI.closeWaiting();
  186. }
  187. /*
  188. * 显示血压图表
  189. */
  190. function showChartPressure(list) {
  191. if(list.length == 0) {
  192. return
  193. }
  194. var xAxisArray = new Array();
  195. var seriesArray = new Array();
  196. var data1 = new Array();
  197. var data2 = new Array();
  198. for(var i = 0; i < list.length; i++) {
  199. var data = list[i];
  200. if(!data) {
  201. continue;
  202. }
  203. xAxisArray.push(data.date.substr(5, 5));
  204. // data1.push(data.value1);
  205. data1.push(buildData(data.value1, 139, 90));
  206. data2.push(buildData(data.value2, 89, 60));
  207. // data2.push(data.value2);
  208. }
  209. var ech = echarts.init(document.getElementById('echarts8'));
  210. var option = {
  211. title: {
  212. text: "血 压",
  213. textStyle: {
  214. color: "#17b3ec",
  215. fontWeight: "normal",
  216. fontSize: 15
  217. },
  218. x: "center"
  219. },
  220. grid: {
  221. x: '8%',
  222. x2: '8%'
  223. },
  224. calculable: true,
  225. tooltip: {
  226. show: true,
  227. showContent: true,
  228. trigger: "axis"
  229. },
  230. legend: {
  231. show: true,
  232. x: "right",
  233. data: ["收缩压", "舒张压"],
  234. },
  235. xAxis: [{
  236. type: 'category',
  237. boundaryGap: false,
  238. data: xAxisArray
  239. }],
  240. yAxis: [{
  241. type: 'value',
  242. name: "mmHg",
  243. // scale: true
  244. }],
  245. color: ['#d48265', '#91c7ae', '#749f83', '#ca8622', '#bda29a', '#6e7074', '#546570', '#c4ccd3'],
  246. series: [{
  247. name: "收缩压",
  248. type: 'line',
  249. data: data1,
  250. markLine: {
  251. symbol: ['circle', 'circle'],
  252. itemStyle: {
  253. normal: {
  254. color: "#d48265"
  255. }
  256. },
  257. data: [
  258. [{
  259. value: 139,
  260. xAxis: 0,
  261. yAxis: 139
  262. }, {
  263. value: 139,
  264. xAxis: 40,
  265. yAxis: 139
  266. }]
  267. ]
  268. }
  269. }, {
  270. name: "舒张压",
  271. type: 'line',
  272. data: data2,
  273. markLine: {
  274. symbol: ['circle', 'circle'],
  275. itemStyle: {
  276. normal: {
  277. color: "91c7ae"
  278. }
  279. },
  280. data: [
  281. [{
  282. value: 60,
  283. xAxis: 0,
  284. yAxis: 60
  285. }, {
  286. value: 60,
  287. xAxis: 40,
  288. yAxis: 60
  289. }],
  290. [{
  291. value: 90,
  292. xAxis: 0,
  293. yAxis: 90
  294. }, {
  295. value: 90,
  296. xAxis: 40,
  297. yAxis: 90
  298. }]
  299. ]
  300. }
  301. }]
  302. };
  303. // ech.showLoading({
  304. // text : '数据获取中',
  305. // effect: 'whirling'
  306. // });
  307. // ech.hideLoading();
  308. ech.setOption(option);
  309. plus.nativeUI.closeWaiting();
  310. }
  311. /*
  312. * 显示体重图表
  313. */
  314. function showChartWeight(list) {
  315. if(list.length == 0) {
  316. return
  317. }
  318. var xAxisArray = new Array();
  319. var seriesArray = new Array();
  320. var data1 = new Array();
  321. for(var i = 0; i < list.length; i++) {
  322. var data = list[i];
  323. if(!data) {
  324. continue;
  325. }
  326. xAxisArray.push(data.date.substr(5, 5));
  327. data1.push(data.value1);
  328. }
  329. var ech = echarts.init(document.getElementById('echarts9'));
  330. var option = {
  331. title: {
  332. text: "体 重",
  333. textStyle: {
  334. color: "#17b3ec",
  335. fontWeight: "normal",
  336. fontSize: 15
  337. },
  338. x: "center"
  339. },
  340. // calculable: true,
  341. grid: {
  342. x: '8%',
  343. x2: '8%',
  344. // width:'100%'
  345. },
  346. tooltip: {
  347. show: true,
  348. showContent: true,
  349. trigger: "axis"
  350. },
  351. xAxis: [{
  352. type: 'category',
  353. boundaryGap: false,
  354. data: xAxisArray
  355. }],
  356. yAxis: [{
  357. type: 'value',
  358. name: "Kg",
  359. scale: true
  360. }],
  361. series: [{
  362. name: "体重",
  363. type: 'line',
  364. data: data1,
  365. markPoint: {
  366. data: [{
  367. type: 'max',
  368. symbolSize: 10,
  369. name: '最大值',
  370. itemStyle: {
  371. normal: {
  372. label: {
  373. textStyle: {
  374. fontSize: '10'
  375. }
  376. }
  377. },
  378. emphasis: {
  379. label: {
  380. textStyle: {
  381. fontSize: '10'
  382. }
  383. }
  384. }
  385. }
  386. }, {
  387. type: 'min',
  388. symbolSize: 10,
  389. name: '最小值',
  390. itemStyle: {
  391. normal: {
  392. label: {
  393. textStyle: {
  394. fontSize: '10'
  395. }
  396. }
  397. },
  398. emphasis: {
  399. label: {
  400. textStyle: {
  401. fontSize: '10'
  402. }
  403. }
  404. }
  405. }
  406. }]
  407. }
  408. }]
  409. };
  410. ech.setOption(option);
  411. plus.nativeUI.closeWaiting();
  412. }
  413. /*
  414. * 显示腰围图表
  415. */
  416. function showChartWaistline(list) {
  417. if(list.length == 0) {
  418. return
  419. }
  420. var xAxisArray = new Array();
  421. var seriesArray = new Array();
  422. var data1 = new Array();
  423. for(var i = 0; i < list.length; i++) {
  424. var data = list[i];
  425. if(!data) {
  426. continue;
  427. }
  428. xAxisArray.push(data.date.substr(5, 5));
  429. data1.push(data.value1);
  430. }
  431. var ech = echarts.init(document.getElementById('echarts10'));
  432. var option = {
  433. title: {
  434. text: "腰 围",
  435. textStyle: {
  436. color: "#17b3ec",
  437. fontWeight: "normal",
  438. fontSize: 15
  439. },
  440. x: "center"
  441. },
  442. grid: {
  443. x: '8%',
  444. x2: '8%'
  445. },
  446. //calculable: true,
  447. tooltip: {
  448. show: true,
  449. showContent: true,
  450. trigger: "axis"
  451. },
  452. xAxis: [{
  453. type: 'category',
  454. boundaryGap: false,
  455. data: xAxisArray
  456. }],
  457. yAxis: [{
  458. type: 'value',
  459. name: "cm",
  460. scale: true
  461. }],
  462. series: [{
  463. name: "腰围",
  464. type: 'line',
  465. data: data1,
  466. markPoint: {
  467. data: [{
  468. type: 'max',
  469. symbolSize: 12,
  470. name: '最高值',
  471. itemStyle: {
  472. normal: {
  473. label: {
  474. textStyle: {
  475. fontSize: '10'
  476. }
  477. }
  478. },
  479. emphasis: {
  480. label: {
  481. textStyle: {
  482. fontSize: '10'
  483. }
  484. }
  485. }
  486. }
  487. }, {
  488. type: 'min',
  489. symbolSize: 12,
  490. name: '最低值',
  491. itemStyle: {
  492. normal: {
  493. label: {
  494. textStyle: {
  495. fontSize: '10'
  496. }
  497. }
  498. },
  499. emphasis: {
  500. label: {
  501. textStyle: {
  502. fontSize: '10'
  503. }
  504. }
  505. }
  506. }
  507. }]
  508. }
  509. }]
  510. };
  511. ech.setOption(option);
  512. plus.nativeUI.closeWaiting();
  513. }
  514. function buildData(value, max, min) {
  515. if((value > 0 && value < min) || value > max) {
  516. return {
  517. value: value,
  518. symbol: 'pin',
  519. // symbol: 'star6',
  520. symbolSize: 10,
  521. itemStyle: {
  522. normal: {
  523. color: "red"
  524. },
  525. emphasis: {
  526. label: {
  527. show: true,
  528. position: 'inside',
  529. textStyle: {
  530. fontSize: '10'
  531. }
  532. },
  533. color: "red"
  534. }
  535. }
  536. }
  537. } else {
  538. return value;
  539. }
  540. }