alertCharts.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. var quxianChart = function(options){
  2. var series0data = options.series[0].data || [];
  3. var yAxisData = options.xAxis[0].data;
  4. var option = {
  5. "title": {
  6. "text": "区县分布",
  7. "x": "center",
  8. "textStyle": {
  9. color: ['#b5e1fc']
  10. },
  11. "padding": [10, 0, 0, 0]
  12. },
  13. "tooltip": {
  14. "trigger": "axis"
  15. },
  16. grid: {
  17. top: 80,
  18. bottom: 30,
  19. left: 80
  20. },
  21. "yAxis": [{
  22. "type": "category",
  23. "name": "人次",
  24. "data": yAxisData,
  25. axisPointer: {
  26. type: 'shadow'
  27. },
  28. axisTick: {
  29. show: false
  30. },
  31. axisLine: {
  32. lineStyle: {
  33. color: '#095f8e'
  34. }
  35. },
  36. axisLabel: {
  37. color: '#b5e1fc'
  38. },
  39. nameTextStyle: {
  40. color: '#b5e1fc'
  41. }
  42. }],
  43. "xAxis": [{
  44. "type": "value",
  45. axisPointer: {
  46. type: 'shadow'
  47. },
  48. axisTick: {
  49. show: false
  50. },
  51. axisLine: {
  52. lineStyle: {
  53. color: '#095f8e'
  54. }
  55. },
  56. axisLabel: {
  57. color: '#fff'
  58. },
  59. splitLine: {
  60. show: false // 不显示坐标轴刻度
  61. }
  62. }],
  63. "series": [{
  64. "smooth": true,
  65. "name": "区县分布",
  66. "type": "bar",
  67. barWidth: 20,
  68. "label": {
  69. show: false,
  70. position: "right"
  71. },
  72. "itemStyle": {
  73. "normal": {
  74. "lineStyle": {
  75. "shadowColor": "rgba(0,0,0,0.4)"
  76. },
  77. barBorderRadius: [0, 8, 8, 0],
  78. color: '#00e6f3'
  79. }
  80. },
  81. "data": series0data
  82. }, ]
  83. }
  84. return option
  85. },
  86. xingbieChart = function(options){
  87. console.log(options)
  88. var title = options.title.text;
  89. var data = options.series[0].data;
  90. var legend = data.map(function(item){
  91. return item.name;
  92. })
  93. var option = {
  94. "title": {
  95. "text": title,
  96. "x": "center",
  97. "textStyle": {
  98. color: ['#b5e1fc']
  99. },
  100. "padding": [10, 0, 0, 0]
  101. },
  102. "tooltip": {
  103. "trigger": "item"
  104. },
  105. legend: {
  106. orient: 'vertical',
  107. // x: 'right',
  108. data: legend,
  109. right: '25%',
  110. top: '40%',
  111. textStyle: {
  112. color: ['#b5e1fc']
  113. }
  114. },
  115. "series": [{
  116. "center": [
  117. "35%",
  118. "50%"
  119. ],
  120. radius: ['30%', '40%'],
  121. "name": "",
  122. "type": "pie",
  123. "itemStyle": {
  124. "normal": {
  125. "label": {
  126. "show": false
  127. },
  128. "labelLine": {
  129. "show": false
  130. }
  131. }
  132. },
  133. "data": data
  134. }]
  135. }
  136. return option
  137. },
  138. jibingTopChart = function(options){
  139. var title = options.title.text;
  140. var yAxisData = options.xAxis[0].data
  141. var xAxisData = options.series[0].data
  142. var option = {
  143. "title": {
  144. "text": title,
  145. "x": "center",
  146. "textStyle": {
  147. color: ['#b5e1fc']
  148. },
  149. "padding": [10, 0, 0, 0]
  150. },
  151. "tooltip": {
  152. "trigger": "axis"
  153. },
  154. grid: {
  155. top: 40,
  156. bottom: 30,
  157. left: 80,
  158. right:20
  159. },
  160. "yAxis": [{
  161. "type": "category",
  162. "name": "",
  163. "data": yAxisData,
  164. axisPointer: {
  165. type: 'shadow'
  166. },
  167. axisTick: {
  168. show: false
  169. },
  170. axisLine: {
  171. lineStyle: {
  172. color: '#095f8e'
  173. }
  174. },
  175. axisLabel: {
  176. color: '#b5e1fc',
  177. formatter(v){
  178. return getBrStr(v,5,true);
  179. }
  180. },
  181. nameTextStyle: {
  182. color: '#b5e1fc'
  183. },
  184. }],
  185. "xAxis": [{
  186. "type": "value",
  187. axisPointer: {
  188. type: 'shadow'
  189. },
  190. axisTick: {
  191. show: false
  192. },
  193. axisLine: {
  194. lineStyle: {
  195. color: '#095f8e'
  196. }
  197. },
  198. axisLabel: {
  199. color: '#fff'
  200. },
  201. splitLine: {
  202. show: false // 不显示坐标轴刻度
  203. }
  204. }],
  205. "series": [{
  206. "smooth": true,
  207. "name": "并发症排行",
  208. "type": "bar",
  209. barWidth: 20,
  210. "label": {
  211. show: false,
  212. position: "right"
  213. },
  214. "itemStyle": {
  215. "normal": {
  216. "lineStyle": {
  217. "shadowColor": "rgba(0,0,0,0.4)"
  218. },
  219. barBorderRadius: [0, 8, 8, 0],
  220. color: '#00e6f3'
  221. }
  222. },
  223. "data": xAxisData
  224. }, ]
  225. }
  226. return option
  227. },
  228. qushiChart = function(options){
  229. debugger
  230. console.log(options);
  231. var title = options.title.text;
  232. var xAxisData = options.xAxis[0].data;
  233. var series0data = options.series[0].data || [];
  234. var series1data = options.series[1].data || [];
  235. var option = {
  236. "title": {
  237. "text": title,
  238. "x": "center",
  239. textStyle: {
  240. color: '#b5e1fc',
  241. fontSize: 16,
  242. fontWeight: 'bold'
  243. },
  244. "padding": [10, 0, 0, 0]
  245. },
  246. tooltip: {
  247. trigger: 'axis',
  248. axisPointer: {
  249. type: 'cross',
  250. crossStyle: {
  251. color: '#fff'
  252. }
  253. }
  254. },
  255. "grid": {
  256. top: '90',
  257. left: '60',
  258. bottom:'25',
  259. right:'60'
  260. },
  261. legend: {
  262. data: ['新增人次', '环比'],
  263. textStyle: {
  264. color: '#b5e1fc'
  265. },
  266. top: '45'
  267. },
  268. xAxis: [{
  269. type: 'category',
  270. "data": xAxisData,
  271. axisPointer: {
  272. type: 'shadow'
  273. },
  274. axisTick: {
  275. show: false
  276. },
  277. axisLine: {
  278. lineStyle: {
  279. color: '#095f8e'
  280. }
  281. },
  282. axisLabel: {
  283. color: '#b5e1fc'
  284. }
  285. }],
  286. yAxis: [{
  287. type: 'value',
  288. name: '新增人次',
  289. nameTextStyle: {
  290. color: '#b5e1fc' // 坐标轴名称颜色
  291. },
  292. splitLine: {
  293. show: false
  294. },
  295. axisLine: {
  296. lineStyle: {
  297. color: '#095f8e'
  298. }
  299. },
  300. axisLabel: {
  301. color: '#b5e1fc'
  302. }
  303. },
  304. {
  305. type: 'value',
  306. name: '环比',
  307. nameTextStyle: {
  308. color: '#b5e1fc' // 坐标轴名称颜色
  309. },
  310. splitLine: {
  311. show: false // 不显示坐标轴刻度
  312. },
  313. axisLine: {
  314. lineStyle: {
  315. color: '#095f8e' // 坐标轴轴线颜色
  316. }
  317. },
  318. axisLabel: {
  319. color: '#b5e1fc' // 坐标轴刻度标签文本颜色
  320. }
  321. }
  322. ],
  323. series: [{
  324. name: '新增人次',
  325. type: 'bar',
  326. "data":series0data,
  327. barWidth: 20,
  328. label: {
  329. normal: {
  330. show: true,
  331. position: 'top', // 在柱状图上方显示
  332. color: '#fff' // 柱状图上方显示的数值颜色
  333. }
  334. },
  335. itemStyle: {
  336. barBorderRadius: [8, 8, 0, 0],
  337. color: '#00e6f3'
  338. }
  339. },
  340. {
  341. name: '环比',
  342. type: 'line',
  343. yAxisIndex: 1,
  344. "data": series1data,
  345. itemStyle: {
  346. color: '#03fa6d'
  347. }
  348. }
  349. ]
  350. }
  351. return option
  352. },
  353. nianlingChart = function(options){
  354. var title = options.title.text;
  355. var data = options.series[0].data
  356. var legend = data.map(function(item){
  357. return item.name;
  358. })
  359. var option = {
  360. "title": {
  361. "text": title,
  362. "x": "center",
  363. "textStyle": {
  364. color: ['#b5e1fc']
  365. },
  366. "padding": [10, 0, 0, 0]
  367. },
  368. "tooltip": {
  369. "trigger": "item"
  370. },
  371. legend: {
  372. orient: 'vertical',
  373. data: legend,
  374. right: '15%',
  375. top: '25%',
  376. textStyle: {
  377. color: ['#b5e1fc']
  378. }
  379. },
  380. "series": [{
  381. "center": [
  382. "35%",
  383. "50%"
  384. ],
  385. radius: ['30%', '40%'],
  386. "name": "",
  387. "type": "pie",
  388. "itemStyle": {
  389. "normal": {
  390. "label": {
  391. "show": false
  392. },
  393. "labelLine": {
  394. "show": false
  395. }
  396. }
  397. },
  398. "data": data
  399. }]
  400. }
  401. return option
  402. }
  403. function getBrStr(str,num,yRoute2){
  404. if(!str)return ''
  405. var newParamsName = "";// 最终拼接成的字符串
  406. var provideNumber = num || 10;// 每行能显示的字的个数
  407. var strArr=str.split('');
  408. if(strArr.length>15 && num && !yRoute2) { //如果是Y轴 TOP5的 最多显示两行 然后用省略号
  409. strArr = strArr.slice(0,9)
  410. strArr.push('...')
  411. }
  412. else if(yRoute2 && strArr.length >5){
  413. strArr = strArr.slice(0,4)
  414. strArr.push('...');
  415. }
  416. strArr.map((v,i)=>{
  417. var str =v;
  418. if(i!=0 && (i+1)%provideNumber == 0 && !yRoute2){
  419. str+='\n';
  420. num++;
  421. }
  422. newParamsName+=str
  423. })
  424. return newParamsName
  425. }