resident-analysis-charts.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. var labelBottom = {
  2. normal: {
  3. label: {
  4. show: false,
  5. },
  6. labelLine: {
  7. show: false
  8. }
  9. }
  10. };
  11. var jiaoFeiChart = null,
  12. healthChart = null,
  13. serviceChart = null,
  14. sexChart = null,
  15. ageChart = null;
  16. //缴费情况
  17. function jiaoFeiData(yiJiaoFeiData, weiJiaoFeiData) {
  18. jiaoFeiChart = echarts.init(document.getElementById('jiaoFeiChart'));
  19. var jiaoFeiOptions = {
  20. color: ['#12b7f5', '#FFC800'],
  21. series: [{
  22. type: 'pie',
  23. legendHoverLink: false,
  24. hoverAnimation: false,
  25. avoidLabelOverlap: false,
  26. radius: ['50%', '70%'],
  27. center: ['50%', '50%'], //饼图的位置
  28. data: [{
  29. name: '已缴费人数',
  30. value: yiJiaoFeiData,
  31. itemStyle: {
  32. normal: {
  33. label: {
  34. show: false,
  35. },
  36. labelLine: {
  37. show: false
  38. }
  39. }
  40. }
  41. },
  42. {
  43. name: '未缴费人数',
  44. value: weiJiaoFeiData,
  45. itemStyle: {
  46. normal: {
  47. label: {
  48. show: true,
  49. position: 'center',
  50. color: '#666',
  51. formatter: function(params) {
  52. return '缴费情况\n分析';
  53. }
  54. },
  55. labelLine: {
  56. show: false
  57. }
  58. }
  59. }
  60. }
  61. ]
  62. }]
  63. };
  64. jiaoFeiChart.clear();
  65. jiaoFeiChart.setOption(jiaoFeiOptions);
  66. }
  67. //健康分布
  68. function healthData(jkrqdata, hbrqdata, gwrqdata, hfqrqdata, wbzdata) {
  69. healthChart = echarts.init(document.getElementById('healthChart'));
  70. var healthOptions = {
  71. color: ['#12B7F5', '#FB5DAB', '#CD67FD', '#FFC800', '#61EB41'],
  72. series: [{
  73. type: 'pie',
  74. legendHoverLink: false,
  75. hoverAnimation: false,
  76. avoidLabelOverlap: false,
  77. radius: ['50%', '70%'],
  78. center: ['25%', '50%'], //饼图的位置
  79. data: [{
  80. name: '健康人群',
  81. value: jkrqdata,
  82. itemStyle: {
  83. normal: {
  84. label: {
  85. show: true,
  86. position: 'center',
  87. color: '#666',
  88. formatter: function(params) {
  89. return '健康分布\n分析';
  90. }
  91. },
  92. labelLine: {
  93. show: false
  94. }
  95. }
  96. }
  97. },
  98. {
  99. name: '患病人群',
  100. value: hbrqdata,
  101. itemStyle: labelBottom
  102. },
  103. {
  104. name: '高危人群',
  105. value: gwrqdata,
  106. itemStyle: labelBottom
  107. },
  108. {
  109. name: '恢复期人群',
  110. value: hfqrqdata,
  111. itemStyle: labelBottom
  112. },
  113. {
  114. name: '未标注',
  115. value: wbzdata,
  116. itemStyle: labelBottom
  117. }
  118. ]
  119. }]
  120. };
  121. healthChart.clear();
  122. healthChart.setOption(healthOptions);
  123. }
  124. //服务分布
  125. function serviceData(arr) {
  126. serviceChart = echarts.init(document.getElementById('serviceChart'));
  127. var serviceOptions = option = {
  128. calculable: true,
  129. grid: {
  130. y: 25,
  131. y2: 30,
  132. x: 20,
  133. x2: 20,
  134. borderColor: '#ffffff'
  135. },
  136. xAxis: [{
  137. type: 'category',
  138. axisLine: {
  139. show: true,
  140. lineStyle: {
  141. color: '#dcdcdc',
  142. width: 1
  143. }
  144. },
  145. axisTick: {
  146. show: false
  147. },
  148. axisLabel: {
  149. show: true,
  150. color: '#666'
  151. },
  152. splitArea: {
  153. show: false
  154. },
  155. splitLine: {
  156. show: false
  157. },
  158. data: ['普通人群', '老年人', '高血压', '糖尿病']
  159. }],
  160. yAxis: [{
  161. type: 'value',
  162. axisLine: {
  163. show: true,
  164. lineStyle: {
  165. color: '#dcdcdc',
  166. width: 1
  167. }
  168. },
  169. axisTick: {
  170. show: false
  171. },
  172. axisLabel: {
  173. show: false
  174. },
  175. splitArea: {
  176. show: false
  177. },
  178. splitLine: {
  179. show: false
  180. },
  181. axisLabel: {
  182. show: false
  183. }
  184. }],
  185. series: [{
  186. name: '服务分布比例',
  187. type: 'bar',
  188. barWidth: 20,
  189. itemStyle: {
  190. normal: {
  191. color: function(params) {
  192. var colorList = ['#12B7F5', '#61eb41', '#CD67FD', '#fb5dab'];
  193. return colorList[params.dataIndex]
  194. },
  195. label: {
  196. show: true,
  197. position: 'top',
  198. color: '#666',
  199. formatter: function(params) {
  200. return params.value + '%';
  201. }
  202. },
  203. barBorderRadius: 0
  204. }
  205. },
  206. data: arr
  207. }]
  208. };
  209. serviceChart.clear();
  210. serviceChart.setOption(serviceOptions);
  211. }
  212. //性别情况
  213. function sexData(femaleData, maleData) {
  214. sexChart = echarts.init(document.getElementById('sexChart'));
  215. var sexOptions = {
  216. color: ['#12B7F5', '#FB5DAB'],
  217. series: [{
  218. type: 'pie',
  219. legendHoverLink: false,
  220. hoverAnimation: false,
  221. avoidLabelOverlap: false,
  222. radius: ['50%', '70%'],
  223. center: ['50%', '50%'], //饼图的位置
  224. data: [{
  225. name: '男性',
  226. value: maleData,
  227. itemStyle: {
  228. normal: {
  229. label: {
  230. show: true,
  231. position: 'center',
  232. color: '#666',
  233. formatter: function(params) {
  234. return '性别情况\n分析';
  235. }
  236. },
  237. labelLine: {
  238. show: false
  239. }
  240. }
  241. }
  242. },
  243. {
  244. name: '女性',
  245. value: femaleData,
  246. itemStyle: labelBottom
  247. }
  248. ]
  249. }]
  250. };
  251. sexChart.clear();
  252. sexChart.setOption(sexOptions);
  253. }
  254. //年龄分布
  255. function ageData(arr) {
  256. ageChart = echarts.init(document.getElementById('ageChart'));
  257. var ageOptions = {
  258. calculable: true,
  259. grid: {
  260. y: 25,
  261. y2: 30,
  262. x: 20,
  263. x2: 20,
  264. borderColor: '#ffffff'
  265. },
  266. xAxis: [{
  267. type: 'category',
  268. axisLine: {
  269. show: true,
  270. lineStyle: {
  271. color: '#dcdcdc',
  272. width: 1
  273. }
  274. },
  275. axisTick: {
  276. show: false
  277. },
  278. axisLabel: {
  279. show: true,
  280. color: '#666'
  281. },
  282. splitArea: {
  283. show: false
  284. },
  285. splitLine: {
  286. show: false
  287. },
  288. data: ['0-6岁', '7-18岁', '19-30岁', '31-50岁', '51-64岁', '65岁以上']
  289. }],
  290. yAxis: [{
  291. type: 'value',
  292. axisLine: {
  293. show: true,
  294. lineStyle: {
  295. color: '#dcdcdc',
  296. width: 1
  297. }
  298. },
  299. axisTick: {
  300. show: false
  301. },
  302. axisLabel: {
  303. show: false
  304. },
  305. splitArea: {
  306. show: false
  307. },
  308. splitLine: {
  309. show: false
  310. },
  311. axisLabel: {
  312. show: false
  313. }
  314. }],
  315. series: [{
  316. name: '年龄分布比例',
  317. type: 'bar',
  318. barWidth: 40,
  319. itemStyle: {
  320. normal: {
  321. color: function(params) {
  322. var colorList = ['#12B7F5', '#FB5DAB', '#CD67FD', '#FFC800', '#61EB41', '#909090'];
  323. return colorList[params.dataIndex]
  324. },
  325. label: {
  326. show: true,
  327. position: 'top',
  328. formatter: function(params) {
  329. return params.value;
  330. }
  331. },
  332. barBorderRadius: 0
  333. }
  334. },
  335. data: arr
  336. }]
  337. };
  338. ageChart.clear();
  339. ageChart.setOption(ageOptions);
  340. }
  341. window.onresize = function() {
  342. jiaoFeiChart.resize();
  343. healthChart.resize();
  344. serviceChart.resize();
  345. sexChart.resize();
  346. ageChart.resize();
  347. }