trend.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. var symptomName = last_year_month();
  2. $(function(){
  3. init();
  4. })
  5. function init(){
  6. var myColor = ['#1089E7', '#F57474', '#56D0E3', '#F8B448', '#8B78F6'];
  7. //主要传染病
  8. var histogramChart1 = echarts.init(document.getElementById('histogramChart1'));
  9. histogramChart1.setOption({
  10. color:['#5bc0de'],
  11. grid:{
  12. left: '5%',
  13. right: '5%',
  14. bottom: '5%',
  15. containLabel: true
  16. },
  17. tooltip : {
  18. trigger: 'item',
  19. formatter: "{a}<br/>{b}<br/>{c}人"
  20. },
  21. calculable : true,
  22. xAxis : [
  23. {
  24. type : 'category',
  25. data : ['感染性腹泻','流行性感冒','登革热','手足口病','水痘','流行性眼腺炎','猩红热','甲型病毒性肝炎','疟疾'],
  26. axisLine:{
  27. lineStyle:{
  28. color: '#5bc0de'
  29. },
  30. },
  31. axisLabel : {
  32. interval:0,
  33. rotate:40,
  34. textStyle: {
  35. color: '#fff'
  36. }
  37. }
  38. }
  39. ],
  40. yAxis : [
  41. {
  42. type : 'value',
  43. axisLine:{
  44. lineStyle:{
  45. color: '#5bc0de'
  46. },
  47. },
  48. splitLine: {
  49. "show": false
  50. },
  51. axisLabel: {
  52. textStyle: {
  53. color: '#fff'
  54. },
  55. formatter: function (value) {
  56. return value + ""
  57. },
  58. },
  59. }
  60. ],
  61. series : [
  62. {
  63. name:'主要传染病',
  64. type:'bar',
  65. barWidth : 20,
  66. data:[2210,1085,926,669,634,452,412,312,156],
  67. },
  68. ]
  69. })
  70. //主要症状
  71. var histogramChart2 = echarts.init(document.getElementById('histogramChart2'));
  72. histogramChart2.setOption({
  73. color:['#FD6C88'],
  74. grid:{
  75. left: '5%',
  76. right: '5%',
  77. bottom: '10%',
  78. containLabel: true
  79. },
  80. tooltip : {
  81. trigger: 'item',
  82. formatter: "{a}<br/>{b}<br/>{c}人"
  83. },
  84. calculable : true,
  85. yAxis : [
  86. {
  87. type : 'category',
  88. data : ['腹痛、腹胀、腹泻','恶心、呕吐、食欲不振','肌肉酸痛、乏力','持续高烧','头痛、眼眶痛、肌肉疼','皮疹、水泡','呼吸浅促','发热、咳嗽、流口水'],
  89. axisLine:{
  90. lineStyle:{
  91. color: '#FD6C88'
  92. },
  93. },
  94. axisLabel : {
  95. textStyle: {
  96. color: '#fff'
  97. }
  98. }
  99. }
  100. ],
  101. xAxis : [
  102. {
  103. type : 'value',
  104. axisLine:{
  105. lineStyle:{
  106. color: '#FD6C88'
  107. },
  108. },
  109. splitLine: {
  110. "show": false
  111. },
  112. axisLabel: {
  113. textStyle: {
  114. color: '#fff'
  115. },
  116. formatter: function (value) {
  117. return value + ""
  118. },
  119. },
  120. }
  121. ],
  122. series : [
  123. {
  124. name:'主要症状',
  125. type:'bar',
  126. barWidth : 20,
  127. data:[1750,1416,1136,819,704,413,251,175],
  128. },
  129. ]
  130. })
  131. //传染病发病趋势
  132. var lineChart1 = echarts.init(document.getElementById('lineChart1'));
  133. lineChart1.setOption({
  134. title: {
  135. text: '传染病趋势',
  136. textStyle:{
  137. fontSize:16,
  138. color:'#ff7f50'
  139. },
  140. },
  141. color:["#ff7f50"],
  142. grid:{
  143. left: '15%',
  144. right: '5%',
  145. bottom: '15%',
  146. },
  147. tooltip : {
  148. trigger: 'item',
  149. formatter: "{a}<br/>{b}<br/>{c}人"
  150. },
  151. calculable : true,
  152. yAxis: [
  153. {
  154. type: 'value',
  155. axisLine:{
  156. lineStyle:{
  157. color: '#ff7f50'
  158. },
  159. },
  160. splitLine: {
  161. "show": false
  162. },
  163. axisLabel: {
  164. textStyle: {
  165. color: '#fff'
  166. },
  167. formatter: function (value) {
  168. return value + ""
  169. },
  170. },
  171. }
  172. ],
  173. xAxis: [
  174. {
  175. type: 'category',
  176. data : symptomName,
  177. boundaryGap : false,
  178. axisLine:{
  179. lineStyle:{
  180. color: '#ff7f50'
  181. },
  182. },
  183. splitLine: {
  184. "show": false
  185. },
  186. axisLabel: {
  187. // interval:0,
  188. // rotate:40,
  189. textStyle: {
  190. color: '#fff'
  191. },
  192. formatter: function (value) {
  193. return value + ""
  194. },
  195. },
  196. }
  197. ],
  198. series : [
  199. {
  200. name:'传染病人数',
  201. type:'line',
  202. smooth:true,
  203. itemStyle: {normal: {areaStyle: {type: 'default'}}},
  204. data:[120, 132, 101, 134, 90, 230, 210,120, 132, 101, 134, 90]
  205. },
  206. ]
  207. })
  208. //主要疾病排行
  209. var histogramChart3 = echarts.init(document.getElementById('histogramChart3'));
  210. histogramChart3.setOption({
  211. grid: {
  212. top: '12%',
  213. left: '30%'
  214. },
  215. xAxis: {
  216. show: false
  217. },
  218. yAxis: [{
  219. show: true,
  220. data: ['抑郁症','高血压','痔疮','肺癌','子宫肌瘤 ','乙肝','水痘','肺结核'],
  221. inverse: true,
  222. axisLine: {
  223. show: false
  224. },
  225. splitLine: {
  226. show: false
  227. },
  228. axisTick: {
  229. show: false
  230. },
  231. axisLabel: {
  232. color: '#fff',
  233. formatter: (value, index) => {
  234. return [
  235. `{lg|${index+1}} ` + '{title|' + value + '} '
  236. ].join('\n')
  237. },
  238. rich: {
  239. lg: {
  240. backgroundColor: '#339911',
  241. color: '#fff',
  242. borderRadius: 15,
  243. // padding: 5,
  244. align: 'center',
  245. width: 15,
  246. height: 15
  247. },
  248. }
  249. },
  250. }, {
  251. show: true,
  252. inverse: true,
  253. data: [2000, 1800, 1200, 1100,900,900,800,700],
  254. axisLabel: {
  255. textStyle: {
  256. fontSize: 12,
  257. color: '#fff',
  258. },
  259. },
  260. axisLine: {
  261. show: false
  262. },
  263. splitLine: {
  264. show: false
  265. },
  266. axisTick: {
  267. show: false
  268. },
  269. }],
  270. series: [{
  271. name: '条',
  272. type: 'bar',
  273. yAxisIndex: 0,
  274. data: [20,18,12,11,9,9,8,7],
  275. barWidth: 10,
  276. itemStyle: {
  277. normal: {
  278. barBorderRadius: 20,
  279. color: function(params) {
  280. var num = myColor.length;
  281. return myColor[params.dataIndex % num]
  282. },
  283. }
  284. },
  285. label: {
  286. normal: {
  287. show: true,
  288. position: 'inside',
  289. formatter: '{c}%'
  290. }
  291. },
  292. }, {
  293. name: '框',
  294. type: 'bar',
  295. yAxisIndex: 1,
  296. barGap: '-100%',
  297. data: [100, 100, 100, 100,100, 100, 100, 100],
  298. barWidth: 15,
  299. itemStyle: {
  300. normal: {
  301. color: 'none',
  302. borderColor: '#00c1de',
  303. borderWidth: 1,
  304. barBorderRadius: 15,
  305. }
  306. }
  307. }, ]
  308. })
  309. //疾病发病趋势
  310. var lineChart2 = echarts.init(document.getElementById('lineChart2'));
  311. lineChart2.setOption({
  312. title: {
  313. text: '疾病发病趋势',
  314. textStyle:{
  315. fontSize:16,
  316. color:'#32cd32'
  317. },
  318. x:"center"
  319. },
  320. color:["#32cd32"],
  321. grid:{
  322. left: '15%',
  323. right: '5%',
  324. bottom: '25%',
  325. },
  326. tooltip : {
  327. trigger: 'item',
  328. formatter: "{a}<br/>{b}<br/>{c}人"
  329. },
  330. calculable : true,
  331. yAxis: [
  332. {
  333. type: 'value',
  334. axisLine:{
  335. lineStyle:{
  336. color: '#32cd32'
  337. },
  338. },
  339. splitLine: {
  340. "show": false
  341. },
  342. axisLabel: {
  343. textStyle: {
  344. color: '#fff'
  345. },
  346. formatter: function (value) {
  347. return value + ""
  348. },
  349. },
  350. }
  351. ],
  352. xAxis: [
  353. {
  354. type: 'category',
  355. data : symptomName,
  356. boundaryGap : false,
  357. axisLine:{
  358. lineStyle:{
  359. color: '#32cd32'
  360. },
  361. },
  362. splitLine: {
  363. "show": false
  364. },
  365. axisLabel: {
  366. // interval:0,
  367. // rotate:40,
  368. textStyle: {
  369. color: '#fff'
  370. },
  371. formatter: function (value) {
  372. return value + ""
  373. },
  374. },
  375. }
  376. ],
  377. series : [
  378. {
  379. name:'疾病发病人数',
  380. type:'line',
  381. smooth:true,
  382. itemStyle: {normal: {areaStyle: {type: 'default'}}},
  383. data:[520, 232,701, 434, 190, 230, 210,120, 132, 101, 134, 890]
  384. },
  385. ]
  386. })
  387. //年龄分布
  388. var pieChart1 = echarts.init(document.getElementById('pieChart1'));
  389. pieChart1.setOption({
  390. color:["#32cd32","#ff7f50","#87cefa","#FD6C88","#4b5cc4","#faff72"],
  391. tooltip : {
  392. trigger: 'item',
  393. formatter: "{a}<br/>{b}<br/>{c}人"
  394. },
  395. calculable : true,
  396. series : [
  397. {
  398. name:'发病人数',
  399. type:'pie',
  400. radius : [30, 110],
  401. center : ['50%', '50%'],
  402. roseType : 'area',
  403. x: '50%',
  404. sort : 'ascending',
  405. data:[
  406. {value:10, name:'婴儿(1-3岁)'},
  407. {value:5, name:'少儿(4-10岁)'},
  408. {value:15, name:'少年(10-18岁)'},
  409. {value:25, name:'青年(18-45岁)'},
  410. {value:125, name:'中年(45-60岁)'},
  411. {value:175, name:'老年(60岁以上)'},
  412. ]
  413. }
  414. ]
  415. })
  416. //性别分布
  417. var labelFromatter = {
  418. normal : {
  419. label : {
  420. position : 'center',
  421. formatter : function (params){
  422. console.log(params)
  423. if(params.name == "女性"){
  424. return "女性"+":"+(params.percent + '%')
  425. }else{
  426. return "男性"+":"+(params.percent + '%')
  427. }
  428. },
  429. },
  430. labelLine : {
  431. show : false
  432. }
  433. },
  434. };
  435. var pieChart2 = echarts.init(document.getElementById('pieChart2'));
  436. pieChart2.setOption({
  437. color: ['#87cefa','#FD6C88'],
  438. tooltip : {
  439. trigger: 'item',
  440. formatter: "{b}({c})<br/>{d}%"
  441. },
  442. series : [
  443. {
  444. type : 'pie',
  445. center : ['50%', '50%'],
  446. radius : [55, 95],
  447. x: '0%', // for funnel
  448. itemStyle : labelFromatter,
  449. data : [
  450. {name:'男性', value:158},
  451. {name:'女性', value:142},
  452. ]
  453. },
  454. ],
  455. })
  456. }