resident-analysis-charts.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  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. tooltip: {
  21. trigger: 'item',
  22. },
  23. color: ['#12b7f5', '#FFC800'],
  24. series: [{
  25. type: 'pie',
  26. // legendHoverLink: false,
  27. // hoverAnimation: false,
  28. avoidLabelOverlap: false,
  29. // silent: true,
  30. radius: ['50%', '70%'],
  31. center: ['50%', '50%'], //饼图的位置
  32. labelLine: {
  33. normal: {
  34. show: false
  35. }
  36. },
  37. data: [{
  38. name: '已缴费人数',
  39. value: yiJiaoFeiData,
  40. itemStyle: {
  41. normal: {
  42. label: {
  43. show: false,
  44. },
  45. labelLine: {
  46. show: false
  47. }
  48. }
  49. }
  50. },
  51. {
  52. name: '未缴费人数',
  53. value: weiJiaoFeiData,
  54. itemStyle: {
  55. normal: {
  56. label: {
  57. show: true,
  58. position: 'center',
  59. color: '#666',
  60. formatter: function(params) {
  61. return '缴费情况\n分析';
  62. }
  63. },
  64. labelLine: {
  65. show: false
  66. }
  67. }
  68. }
  69. }
  70. ]
  71. }]
  72. };
  73. jiaoFeiChart.clear();
  74. jiaoFeiChart.setOption(jiaoFeiOptions);
  75. }
  76. //健康分布
  77. function healthData(jkrqdata, hbrqdata, gwrqdata, hfqrqdata, wbzdata) {
  78. healthChart = echarts.init(document.getElementById('healthChart'));
  79. var healthOptions = {
  80. tooltip: {
  81. trigger: 'item',
  82. },
  83. color: ['#12B7F5', '#FB5DAB', '#CD67FD', '#FFC800', '#61EB41'],
  84. series: [{
  85. type: 'pie',
  86. // legendHoverLink: false,
  87. // hoverAnimation: false,
  88. avoidLabelOverlap: false,
  89. radius: ['50%', '70%'],
  90. center: ['50%', '50%'], //饼图的位置
  91. labelLine: {
  92. normal: {
  93. show: false
  94. }
  95. },
  96. data: [{
  97. name: '健康人群',
  98. value: jkrqdata,
  99. itemStyle: {
  100. normal: {
  101. label: {
  102. show: true,
  103. position: 'center',
  104. color: '#666',
  105. formatter: function(params) {
  106. return '健康分布\n分析';
  107. }
  108. },
  109. labelLine: {
  110. show: false
  111. }
  112. }
  113. }
  114. },
  115. {
  116. name: '患病人群',
  117. value: hbrqdata,
  118. itemStyle: labelBottom
  119. },
  120. {
  121. name: '高危人群',
  122. value: gwrqdata,
  123. itemStyle: labelBottom
  124. },
  125. {
  126. name: '恢复期人群',
  127. value: hfqrqdata,
  128. itemStyle: labelBottom
  129. },
  130. {
  131. name: '未标注',
  132. value: wbzdata,
  133. itemStyle: labelBottom
  134. }
  135. ]
  136. }]
  137. };
  138. healthChart.clear();
  139. healthChart.setOption(healthOptions);
  140. }
  141. //服务分布
  142. function serviceData(nameArr, rateArr, colorList, year) {
  143. serviceChart = echarts.init(document.getElementById('serviceChart'));
  144. var serviceOptions = {
  145. // calculable: true,
  146. grid: {
  147. y: 25,
  148. y2: 30,
  149. x: 20,
  150. x2: 20,
  151. borderColor: '#ffffff'
  152. },
  153. xAxis: [{
  154. type: 'category',
  155. axisLine: {
  156. show: true,
  157. lineStyle: {
  158. color: '#dcdcdc',
  159. width: 1
  160. }
  161. },
  162. axisTick: {
  163. show: false
  164. },
  165. axisLabel: {
  166. show: true,
  167. interval: 0,
  168. textStyle: {
  169. color: '#333',
  170. fontSize: 14,
  171. },
  172. // formatter: function(val) {
  173. // if(val.length > 4) {
  174. // return val.substring(0, 4) + '…'
  175. // } else {
  176. // return val
  177. // }
  178. // },
  179. },
  180. splitArea: {
  181. show: false
  182. },
  183. splitLine: {
  184. show: false
  185. },
  186. data: nameArr
  187. }],
  188. yAxis: [{
  189. type: 'value',
  190. show: false,
  191. axisLine: {
  192. show: true,
  193. lineStyle: {
  194. color: '#dcdcdc',
  195. width: 1
  196. }
  197. },
  198. axisTick: {
  199. show: false
  200. },
  201. axisLabel: {
  202. show: false
  203. },
  204. splitArea: {
  205. show: false
  206. },
  207. splitLine: {
  208. show: false
  209. },
  210. axisLabel: {
  211. show: false
  212. }
  213. }],
  214. series: [{
  215. name: '',
  216. type: 'bar',
  217. barWidth: 20,
  218. barMinHeight: 1,
  219. label: {
  220. normal: {
  221. show: true,
  222. position: 'top',
  223. formatter: '{c}%',
  224. textStyle: {
  225. color: '#333',
  226. fontSize: 14,
  227. },
  228. }
  229. },
  230. itemStyle: {
  231. normal: {
  232. color: function(params) {
  233. return colorList[params.dataIndex];
  234. },
  235. }
  236. },
  237. data: rateArr
  238. }]
  239. };
  240. if(year != "2016") {
  241. serviceOptions.dataZoom = [{
  242. type: 'inside',
  243. orient: 'horizontal',
  244. filterMode: 'none',
  245. zoomLock: true,
  246. zoomOnMouseWheel: false,
  247. preventDefaultMouseMove: true,
  248. xAxisIndex: 0,
  249. start: 0,
  250. end: 40
  251. },{
  252. show: false,
  253. start: 0,
  254. end: 40,
  255. type: 'slider',
  256. zoomLock: true,
  257. }]
  258. }
  259. serviceChart.clear();
  260. serviceChart.setOption(serviceOptions);
  261. }
  262. //性别情况
  263. function sexData(femaleData, maleData) {
  264. sexChart = echarts.init(document.getElementById('sexChart'));
  265. var sexOptions = {
  266. tooltip: {
  267. trigger: 'item',
  268. },
  269. color: ['#12B7F5', '#FB5DAB'],
  270. series: [{
  271. type: 'pie',
  272. // legendHoverLink: false,
  273. // hoverAnimation: false,
  274. avoidLabelOverlap: false,
  275. radius: ['50%', '70%'],
  276. center: ['50%', '50%'], //饼图的位置
  277. labelLine: {
  278. normal: {
  279. show: false
  280. }
  281. },
  282. data: [{
  283. name: '男性',
  284. value: maleData,
  285. itemStyle: {
  286. normal: {
  287. label: {
  288. show: true,
  289. position: 'center',
  290. color: '#666',
  291. formatter: function(params) {
  292. return '性别情况\n分析';
  293. }
  294. },
  295. labelLine: {
  296. show: false
  297. }
  298. }
  299. }
  300. },
  301. {
  302. name: '女性',
  303. value: femaleData,
  304. itemStyle: labelBottom
  305. }
  306. ]
  307. }]
  308. };
  309. sexChart.clear();
  310. sexChart.setOption(sexOptions);
  311. }
  312. //年龄分布
  313. function ageData(arr) {
  314. ageChart = echarts.init(document.getElementById('ageChart'));
  315. var ageOptions = {
  316. calculable: true,
  317. grid: {
  318. y: 25,
  319. y2: 30,
  320. x: 20,
  321. x2: 20,
  322. borderColor: '#ffffff'
  323. },
  324. xAxis: [{
  325. type: 'category',
  326. axisLine: {
  327. show: true,
  328. lineStyle: {
  329. color: '#dcdcdc',
  330. width: 1
  331. }
  332. },
  333. axisTick: {
  334. show: false
  335. },
  336. axisLabel: {
  337. show: true,
  338. color: '#666'
  339. },
  340. splitArea: {
  341. show: false
  342. },
  343. splitLine: {
  344. show: false
  345. },
  346. data: ['0-6岁', '7-18岁', '19-30岁', '31-50岁', '51-64岁', '65岁以上']
  347. }],
  348. yAxis: [{
  349. type: 'value',
  350. axisLine: {
  351. show: true,
  352. lineStyle: {
  353. color: '#dcdcdc',
  354. width: 1
  355. }
  356. },
  357. axisTick: {
  358. show: false
  359. },
  360. axisLabel: {
  361. show: false
  362. },
  363. splitArea: {
  364. show: false
  365. },
  366. splitLine: {
  367. show: false
  368. },
  369. axisLabel: {
  370. show: false
  371. }
  372. }],
  373. series: [{
  374. name: '年龄分布比例',
  375. type: 'bar',
  376. barWidth: 40,
  377. itemStyle: {
  378. normal: {
  379. color: function(params) {
  380. var colorList = ['#12B7F5', '#FB5DAB', '#CD67FD', '#FFC800', '#61EB41', '#909090'];
  381. return colorList[params.dataIndex]
  382. },
  383. label: {
  384. show: true,
  385. position: 'top',
  386. formatter: function(params) {
  387. return params.value;
  388. }
  389. },
  390. barBorderRadius: 0
  391. }
  392. },
  393. data: arr
  394. }]
  395. };
  396. ageChart.clear();
  397. ageChart.setOption(ageOptions);
  398. }
  399. window.onresize = function() {
  400. jiaoFeiChart.resize();
  401. healthChart.resize();
  402. serviceChart.resize();
  403. sexChart.resize();
  404. ageChart.resize();
  405. }