resident-analysis-charts.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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(nameArr, rateArr, colorList, year) {
  126. serviceChart = echarts.init(document.getElementById('serviceChart'));
  127. var serviceOptions = {
  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. interval: 0,
  151. textStyle: {
  152. color: '#333',
  153. fontSize: 14,
  154. },
  155. formatter: function(val) {
  156. if(val.length > 4) {
  157. return val.substring(0, 4) + '…'
  158. } else {
  159. return val
  160. }
  161. },
  162. },
  163. splitArea: {
  164. show: false
  165. },
  166. splitLine: {
  167. show: false
  168. },
  169. data: nameArr
  170. }],
  171. yAxis: [{
  172. type: 'value',
  173. show: false,
  174. axisLine: {
  175. show: true,
  176. lineStyle: {
  177. color: '#dcdcdc',
  178. width: 1
  179. }
  180. },
  181. axisTick: {
  182. show: false
  183. },
  184. axisLabel: {
  185. show: false
  186. },
  187. splitArea: {
  188. show: false
  189. },
  190. splitLine: {
  191. show: false
  192. },
  193. axisLabel: {
  194. show: false
  195. }
  196. }],
  197. series: [{
  198. name: '',
  199. type: 'bar',
  200. barWidth: 20,
  201. barMinHeight: 1,
  202. label: {
  203. normal: {
  204. show: true,
  205. position: 'top',
  206. formatter: '{c}%',
  207. textStyle: {
  208. color: '#333',
  209. fontSize: 14,
  210. },
  211. }
  212. },
  213. itemStyle: {
  214. normal: {
  215. color: function(params) {
  216. return colorList[params.dataIndex];
  217. },
  218. }
  219. },
  220. data: rateArr
  221. }]
  222. };
  223. if(year != "2016") {
  224. serviceOptions.dataZoom = [{
  225. type: 'inside',
  226. orient: 'horizontal',
  227. filterMode: 'none',
  228. zoomLock: false,
  229. zoomOnMouseWheel: false,
  230. preventDefaultMouseMove: false,
  231. xAxisIndex: 0,
  232. start: 0,
  233. end: 40
  234. }]
  235. }
  236. serviceChart.clear();
  237. serviceChart.setOption(serviceOptions);
  238. }
  239. //性别情况
  240. function sexData(femaleData, maleData) {
  241. sexChart = echarts.init(document.getElementById('sexChart'));
  242. var sexOptions = {
  243. color: ['#12B7F5', '#FB5DAB'],
  244. series: [{
  245. type: 'pie',
  246. legendHoverLink: false,
  247. hoverAnimation: false,
  248. avoidLabelOverlap: false,
  249. radius: ['50%', '70%'],
  250. center: ['50%', '50%'], //饼图的位置
  251. data: [{
  252. name: '男性',
  253. value: maleData,
  254. itemStyle: {
  255. normal: {
  256. label: {
  257. show: true,
  258. position: 'center',
  259. color: '#666',
  260. formatter: function(params) {
  261. return '性别情况\n分析';
  262. }
  263. },
  264. labelLine: {
  265. show: false
  266. }
  267. }
  268. }
  269. },
  270. {
  271. name: '女性',
  272. value: femaleData,
  273. itemStyle: labelBottom
  274. }
  275. ]
  276. }]
  277. };
  278. sexChart.clear();
  279. sexChart.setOption(sexOptions);
  280. }
  281. //年龄分布
  282. function ageData(arr) {
  283. ageChart = echarts.init(document.getElementById('ageChart'));
  284. var ageOptions = {
  285. calculable: true,
  286. grid: {
  287. y: 25,
  288. y2: 30,
  289. x: 20,
  290. x2: 20,
  291. borderColor: '#ffffff'
  292. },
  293. xAxis: [{
  294. type: 'category',
  295. axisLine: {
  296. show: true,
  297. lineStyle: {
  298. color: '#dcdcdc',
  299. width: 1
  300. }
  301. },
  302. axisTick: {
  303. show: false
  304. },
  305. axisLabel: {
  306. show: true,
  307. color: '#666'
  308. },
  309. splitArea: {
  310. show: false
  311. },
  312. splitLine: {
  313. show: false
  314. },
  315. data: ['0-6岁', '7-18岁', '19-30岁', '31-50岁', '51-64岁', '65岁以上']
  316. }],
  317. yAxis: [{
  318. type: 'value',
  319. axisLine: {
  320. show: true,
  321. lineStyle: {
  322. color: '#dcdcdc',
  323. width: 1
  324. }
  325. },
  326. axisTick: {
  327. show: false
  328. },
  329. axisLabel: {
  330. show: false
  331. },
  332. splitArea: {
  333. show: false
  334. },
  335. splitLine: {
  336. show: false
  337. },
  338. axisLabel: {
  339. show: false
  340. }
  341. }],
  342. series: [{
  343. name: '年龄分布比例',
  344. type: 'bar',
  345. barWidth: 40,
  346. itemStyle: {
  347. normal: {
  348. color: function(params) {
  349. var colorList = ['#12B7F5', '#FB5DAB', '#CD67FD', '#FFC800', '#61EB41', '#909090'];
  350. return colorList[params.dataIndex]
  351. },
  352. label: {
  353. show: true,
  354. position: 'top',
  355. formatter: function(params) {
  356. return params.value;
  357. }
  358. },
  359. barBorderRadius: 0
  360. }
  361. },
  362. data: arr
  363. }]
  364. };
  365. ageChart.clear();
  366. ageChart.setOption(ageOptions);
  367. }
  368. window.onresize = function() {
  369. jiaoFeiChart.resize();
  370. healthChart.resize();
  371. serviceChart.resize();
  372. sexChart.resize();
  373. ageChart.resize();
  374. }