当前位置:   article > 正文

4【源码】数据可视化:基于 Echarts +Java SpringBoot 实现的动态实时大屏范例-厦门市某医院_如何java搭建大屏展示demo

如何java搭建大屏展示demo

数据可视化大屏的出现,掀起一番又一番的浪潮,众多企业主纷纷想要打造属于自己的“酷炫吊炸天”的霸道总裁大屏驾驶舱。

之前有小伙伴们建议我出一些视频课程来学习Echarts,这样可以更快上手,所以我就追星赶月的录制了《Echarts - 0基础入门课程》,希望对有需要的小伙伴有帮助。

传送门

YYDatav的数据可视化大屏《精彩案例汇总》(Java SpringBoot&Echarts源码)_YYDataV的博客-CSDN博客

4【源码】数据可视化:基于Echarts+JavaSpringBoot实现的动态实时大屏范例-医院大屏.zip_java大屏数据实时交互-企业管理文档类资源-CSDN下载

效果图展示

 

 

一、 确定需求方案

1、确定产品上线部署的屏幕LED分辨率

本案例基于16:9 屏宽比,F11全屏显示。

2、部署方式 

基于免安装可执行程序:支持Windows、Linux、Mac等各种操作系统;将程序复制到服务器上即可,无需其它环境依赖;

观看方式:既可在服务器上直接观看程序界面,也可在远程用浏览器打开播放,例如Chrome浏览器、360浏览器等。

二、整体架构设计

  1. 前端基于Echarts开源库设计,使用WebStorm编辑器;
  2. 后端基于Java Web实现,使用 IDEA 编辑器;
  3. 数据传输格式:JSON;
  4. 数据源类型:目前采用JSON文件方式,自行添加Mybatis可支持PostgreSQL、MySQL、Oracle、Microsoft SQL Server、SQLite,自行添加POI可支持Excel表格等,还可以定制HTTP API接口方式。
  5. 数据更新方式:采用http get 轮询方式 。在实际应用中,也可以视情况选择监测后端数据实时更新,实时推送到前端的方式;

三、编码实现 (关键代码)

1、前端html代码 - 页面布局layout&样式style

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>数据可视化demo</title>
  6. <link href="../styles/common.css" rel="stylesheet">
  7. <script src="../scripts/Plugin/jquery-3.3.1.min.js"></script>
  8. <script src="../scripts/Plugin/echarts.min.js"></script>
  9. <script src="../scripts/Plugin/bmap.min.js"></script>
  10. <script src="http://api.map.baidu.com/api?v=2.0&ak=AgasQmKK2z6YZjy4w5dFPY93c6uPw7RI"></script>
  11. <script src="../scripts/common.js"></script>
  12. <script src="../scripts/index.js"></script>
  13. <script src="../scripts/Plugin/laydate/laydate.js"></script>
  14. </head>
  15. <body>
  16. <!--顶部-->
  17. <header class="header left">
  18. <div class="left nav">
  19. <ul>
  20. <li class="nav_active"><i class="nav_1"></i><a href="index.html">采集概况</a> </li>
  21. <li><i class="nav_2"></i><a href="quota.html">指标分析</a> </li>
  22. <li><i class="nav_3"></i><a href="trend.html">趋势分析</a> </li>
  23. <li><i class="nav_4"></i><a href="chronic.html">慢病病人列表</a> </li>
  24. </ul>
  25. </div>
  26. <div class="header_center left" style="position:relative">
  27. <h2><strong>厦门市某医院大数据展示案例</strong></h2>
  28. </div>
  29. <div class="right nav text_right">
  30. <ul>
  31. </ul>
  32. </div>
  33. </header>
  34. <!--内容部分-->
  35. <div class="con left">
  36. <!--数据总概-->
  37. <div class="con_div">
  38. <div class="con_div_text left">
  39. <div class="con_div_text01 left">
  40. <img src="../images/info_1.png" class="left text01_img"/>
  41. <div class="left text01_div">
  42. <p>总采集数据量(G)</p>
  43. <p id="t0">1235</p>
  44. </div>
  45. </div>
  46. <div class="con_div_text01 right">
  47. <img src="../images/info_2.png" class="left text01_img"/>
  48. <div class="left text01_div">
  49. <p>当月采集数据量(G)</p>
  50. <p id="t1">235</p>
  51. </div>
  52. </div>
  53. </div>
  54. <div class="con_div_text left">
  55. <div class="con_div_text01 left">
  56. <img src="../images/info_3.png" class="left text01_img"/>
  57. <div class="left text01_div">
  58. <p>总门诊数(人)</p>
  59. <p id="t2" class="sky">12356</p>
  60. </div>
  61. </div>
  62. <div class="con_div_text01 right">
  63. <img src="../images/info_4.png" class="left text01_img"/>
  64. <div class="left text01_div">
  65. <p>当月门诊数(人)</p>
  66. <p id="t3" class="sky">12356</p>
  67. </div>
  68. </div>
  69. </div>
  70. <div class="con_div_text left">
  71. <div class="con_div_text01 left">
  72. <img src="../images/info_5.png" class="left text01_img"/>
  73. <div class="left text01_div">
  74. <p>总住院数(人)</p>
  75. <p id="t4" class="org">12356</p>
  76. </div>
  77. </div>
  78. <div class="con_div_text01 right">
  79. <img src="../images/info_6.png" class="left text01_img"/>
  80. <div class="left text01_div">
  81. <p>当月住院数(人)</p>
  82. <p id="t5" class="org">12356</p>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. <!--统计分析图-->
  88. <div class="div_any">
  89. <div class="left div_any01">
  90. <div class="div_any_child">
  91. <div class="div_any_title"><img src="../images/title_1.png">各医院采集数据量</div>
  92. <p id="pieChart1" class="p_chart"></p>
  93. </div>
  94. <div class="div_any_child">
  95. <div class="div_any_title"><img src="../images/title_2.png">各医院门诊住院费用</div>
  96. <p id="histogramChart" class="p_chart"></p>
  97. </div>
  98. </div>
  99. <div class="div_any02 left ">
  100. <div class="div_any_child div_height">
  101. <div class="div_any_title any_title_width"><img src="../images/title_0.png">厦门市地图 </div>
  102. <div id="mapChart" style="width:97.5%;height:95%;display: inline-block;padding-left: 1.25%;padding-top:2.2%"></div>
  103. </div>
  104. </div>
  105. <div class="right div_any01">
  106. <div class="div_any_child">
  107. <div class="div_any_title"><img src="../images/title_3.png">数据采集条数(当日)</div>
  108. <p id="lineChart" class="p_chart"></p>
  109. </div>
  110. <div class="div_any_child">
  111. <div class="div_any_title"><img src="../images/title_4.png">就诊人数(当日)</div>
  112. <p id="lineChart2" class="p_chart"></p>
  113. </div>
  114. </div>
  115. </div>
  116. <div id="el-dialog" class="">
  117. <div class="xc_layer"></div>
  118. <div class="popBox" id="printView">
  119. <div class="ttBox"><span class="tt" id="reportTitle">第一医院</span><img src="../images/close.png" style="width: 30px;float: right;cursor: pointer;" title="关闭弹窗" class="close"/></div>
  120. <div class="txtBox" id="el-dialog_body">
  121. <div style="height:100%;width: 98%;margin-left: 1%;">
  122. <div class="left div_any01" style="width: 64%;">
  123. <div class="div_any_child">
  124. <div class="div_any_title"><div type="text" class="demo-input" id="date1" style="display: inline-block;cursor: pointer;margin-right: 16px;"></div><img src="../images/title_4.png">门诊住院人次</div>
  125. <p id="lineChart3" class="p_chart"></p>
  126. </div>
  127. <div class="div_any_child">
  128. <div class="div_any_title"><div type="text" class="demo-input" id="date2" style="display: inline-block;cursor: pointer;margin-right: 16px;"></div><img src="../images/title_7.png">医疗费用</div>
  129. <p id="lineChart4" class="p_chart"></p>
  130. </div>
  131. </div>
  132. <div class="left div_any01" style="width: 32%;">
  133. <div class="div_any_child">
  134. <div class="div_any_title"><div type="text" class="demo-input" id="date3" style="display: inline-block;cursor: pointer;margin-right: 16px;"></div><img src="../images/title_18.png">病人年龄段分布</div>
  135. <p id="pieChart2" class="p_chart"></p>
  136. </div>
  137. <div class="div_any_child">
  138. <div class="div_any_title"><div type="text" class="demo-input" id="date4" style="display: inline-block;cursor: pointer;margin-right: 16px;"></div><img src="../images/title_20.png">医疗费用组成</div>
  139. <p id="pieChart3" class="p_chart"></p>
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. </div>
  146. </div>
  147. <script>
  148. function async_data() {
  149. async_map_data();
  150. // async_chart_1();
  151. // async_chart_2();
  152. // async_chart_3();
  153. // async_chart_4();
  154. // async_chart_5();
  155. // async_chart_6();
  156. }
  157. async_data() ;
  158. </script>
  159. </body>
  160. </html>

2、前端JS代码 - 各个echarts图表

  1. var symptomName = last_month_day();
  2. $(function(){
  3. init();
  4. init2();
  5. $("#el-dialog").addClass("hide");
  6. $(".close").click(function(event) {
  7. $("#el-dialog").addClass("hide");
  8. });
  9. var date = new Date();
  10. var numble = date.getDate();
  11. var today = getFormatMonth(new Date());
  12. $("#date1").html(today);
  13. $("#date2").html(today);
  14. $("#date3").html(today);
  15. $("#date4").html(today);
  16. lay('.demo-input').each(function(){
  17. laydate.render({
  18. type: 'month',
  19. elem: this,
  20. trigger: 'click',
  21. theme: '#95d7fb',
  22. calendar: true,
  23. showBottom: true,
  24. done: function () {
  25. console.log( $("#startDate").val())
  26. }
  27. })
  28. });
  29. })
  30. function init(){
  31. //地图
  32. var mapChart = echarts.init(document.getElementById('mapChart'));
  33. mapChart.setOption({
  34. bmap: {
  35. center: [118.104103,24.477761],
  36. zoom: 15,
  37. roam: true,
  38. },
  39. tooltip : {
  40. trigger: 'item',
  41. formatter:function(params, ticket, callback){
  42. console.log(params)
  43. return params.value[2] + ":<br>" + params.value[3]
  44. }
  45. },
  46. series: [{
  47. type: 'scatter',
  48. coordinateSystem: 'bmap',
  49. symbolSize: 20,
  50. data: [
  51. [118.096435, 24.485408, '厦门市'] ,
  52. [118.094564, 24.457358, '厦门第一医院'] ,
  53. [118.104103, 24.477761, '厦门中山医院'],
  54. [118.14748, 24.506295, '厦门中医院'],
  55. [118.254841, 24.665349, '厦门第五医院'],
  56. ]
  57. }]
  58. });
  59. mapChart.on('click', function (params) {
  60. $("#el-dialog").removeClass('hide');
  61. $("#reportTitle").html(params.value[2]);
  62. });
  63. var bmap = mapChart.getModel().getComponent('bmap').getBMap()
  64. bmap.addControl(new BMap.MapTypeControl({mapTypes: [BMAP_NORMAL_MAP,BMAP_SATELLITE_MAP ]}));
  65. bmap.setMapStyle({style:'midnight'})
  66. var pieChart1 = echarts.init(document.getElementById('pieChart1'));
  67. pieChart1.setOption({
  68. color:["#87cefa","#ff7f50","#32cd32","#da70d6",],
  69. legend: {
  70. y : '260',
  71. x : 'center',
  72. textStyle : {
  73. color : '#ffffff',
  74. },
  75. data : ['厦门第一医院','厦门中山医院','厦门中医院','厦门第五医院',],
  76. },
  77. tooltip : {
  78. trigger: 'item',
  79. formatter: "{a}<br/>{b}<br/>{c}G ({d}%)"
  80. },
  81. calculable : false,
  82. series : [
  83. {
  84. name:'采集数据量',
  85. type:'pie',
  86. radius : ['40%', '70%'],
  87. center : ['50%', '45%'],
  88. itemStyle : {
  89. normal : {
  90. label : {
  91. show : false
  92. },
  93. labelLine : {
  94. show : false
  95. }
  96. },
  97. emphasis : {
  98. label : {
  99. show : true,
  100. position : 'center',
  101. textStyle : {
  102. fontSize : '20',
  103. fontWeight : 'bold'
  104. }
  105. }
  106. }
  107. },
  108. data:[
  109. {value:335, name:'厦门第一医院'},
  110. {value:310, name:'厦门中山医院'},
  111. {value:234, name:'厦门中医院'},
  112. {value:135, name:'厦门第五医院'}
  113. ]
  114. }
  115. ]
  116. });
  117. var lineChart = echarts.init(document.getElementById('lineChart'));
  118. lineChart.setOption({
  119. color:["#87cefa","#ff7f50","#32cd32","#da70d6",],
  120. legend: {
  121. y : '260',
  122. x : 'center',
  123. textStyle : {
  124. color : '#ffffff',
  125. },
  126. data : ['厦门第一医院','厦门中山医院','厦门中医院','厦门第五医院',],
  127. },
  128. calculable : false,
  129. tooltip : {
  130. trigger: 'item',
  131. formatter: "{a}<br/>{b}<br/>{c}条"
  132. },
  133. yAxis: [
  134. {
  135. type: 'value',
  136. axisLine : {onZero: false},
  137. axisLine:{
  138. lineStyle:{
  139. color: '#034c6a'
  140. },
  141. },
  142. axisLabel: {
  143. textStyle: {
  144. color: '#fff'
  145. },
  146. formatter: function (value) {
  147. return value + "k条"
  148. },
  149. },
  150. splitLine:{
  151. lineStyle:{
  152. width:0,
  153. type:'solid'
  154. }
  155. }
  156. }
  157. ],
  158. xAxis: [
  159. {
  160. type: 'category',
  161. data : ['8:00','10:00','12:00','14:00','16:00','18:00','20:00','22:00'],
  162. axisLine:{
  163. lineStyle:{
  164. color: '#034c6a'
  165. },
  166. },
  167. splitLine: {
  168. "show": false
  169. },
  170. axisLabel: {
  171. textStyle: {
  172. color: '#fff'
  173. },
  174. formatter: function (value) {
  175. return value + ""
  176. },
  177. },
  178. splitLine:{
  179. lineStyle:{
  180. width:0,
  181. type:'solid'
  182. }
  183. },
  184. }
  185. ],
  186. grid:{
  187. left: '5%',
  188. right: '5%',
  189. bottom: '20%',
  190. containLabel: true
  191. },
  192. series : [
  193. {
  194. name:'厦门第一医院',
  195. type:'line',
  196. smooth:true,
  197. itemStyle: {
  198. normal: {
  199. lineStyle: {
  200. shadowColor : 'rgba(0,0,0,0.4)'
  201. }
  202. }
  203. },
  204. data:[15, 0, 20, 45, 22.1, 25, 70, 55, 76]
  205. },
  206. {
  207. name:'厦门中山医院',
  208. type:'line',
  209. smooth:true,
  210. itemStyle: {
  211. normal: {
  212. lineStyle: {
  213. shadowColor : 'rgba(0,0,0,0.4)'
  214. }
  215. }
  216. },
  217. data:[25, 10, 30, 55, 32.1, 35, 80, 65, 76]
  218. },
  219. {
  220. name:'厦门中医院',
  221. type:'line',
  222. smooth:true,
  223. itemStyle: {
  224. normal: {
  225. lineStyle: {
  226. shadowColor : 'rgba(0,0,0,0.4)'
  227. }
  228. }
  229. },
  230. data:[35, 20, 40, 65, 42.1, 45, 90, 75, 96]
  231. },
  232. {
  233. name:'厦门第五医院',
  234. type:'line',
  235. smooth:true,
  236. itemStyle: {
  237. normal: {
  238. lineStyle: {
  239. shadowColor : 'rgba(0,0,0,0.4)'
  240. }
  241. }
  242. },
  243. data:[45, 30, 50, 75, 52.1, 55, 100, 85, 106]
  244. }
  245. ]
  246. });
  247. var histogramChart = echarts.init(document.getElementById('histogramChart'));
  248. histogramChart.setOption({
  249. color:["#87cefa","#ff7f50","#32cd32","#da70d6",],
  250. legend: {
  251. y : '250',
  252. x : 'center',
  253. data:['厦门第一医院', '厦门中山医院','厦门中医院','厦门第五医院'],
  254. textStyle : {
  255. color : '#ffffff',
  256. }
  257. },
  258. calculable :false,
  259. grid:{
  260. left: '5%',
  261. right: '5%',
  262. bottom: '20%',
  263. containLabel: true
  264. },
  265. tooltip : {
  266. trigger: 'axis',
  267. axisPointer : {
  268. type : 'shadow'
  269. }
  270. },
  271. xAxis : [
  272. {
  273. type : 'value',
  274. axisLabel: {
  275. show: true,
  276. textStyle: {
  277. color: '#fff'
  278. }
  279. },
  280. splitLine:{
  281. lineStyle:{
  282. color:['#f2f2f2'],
  283. width:0,
  284. type:'solid'
  285. }
  286. }
  287. }
  288. ],
  289. yAxis : [
  290. {
  291. type : 'category',
  292. data:['门诊人数(人)', '住院人次(人)','人均费用(元)'],
  293. axisLabel: {
  294. show: true,
  295. textStyle: {
  296. color: '#fff'
  297. }
  298. },
  299. splitLine:{
  300. lineStyle:{
  301. width:0,
  302. type:'solid'
  303. }
  304. }
  305. }
  306. ],
  307. series : [
  308. {
  309. name:'厦门第一医院',
  310. type:'bar',
  311. stack: '总量',
  312. itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
  313. data:[320, 302, 301]
  314. },
  315. {
  316. name:'厦门中山医院',
  317. type:'bar',
  318. stack: '总量',
  319. itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
  320. data:[120, 132, 101]
  321. },
  322. {
  323. name:'厦门中医院',
  324. type:'bar',
  325. stack: '总量',
  326. itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
  327. data:[220, 182, 191]
  328. },
  329. {
  330. name:'厦门第五医院',
  331. type:'bar',
  332. stack: '总量',
  333. itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
  334. data:[150, 212, 201]
  335. }
  336. ]
  337. });
  338. var lineChart2 = echarts.init(document.getElementById('lineChart2'));
  339. lineChart2.setOption({
  340. color:["#87cefa","#ff7f50","#32cd32","#da70d6",],
  341. legend: {
  342. y : '260',
  343. x : 'center',
  344. textStyle : {
  345. color : '#ffffff',
  346. },
  347. data : ['厦门第一医院','厦门中山医院','厦门中医院','厦门第五医院',],
  348. },
  349. calculable : false,
  350. tooltip : {
  351. trigger: 'item',
  352. formatter: "{a}<br/>{b}<br/>{c}条"
  353. },
  354. yAxis: [
  355. {
  356. type: 'value',
  357. axisLine : {onZero: false},
  358. axisLine:{
  359. lineStyle:{
  360. color: '#034c6a'
  361. },
  362. },
  363. axisLabel: {
  364. textStyle: {
  365. color: '#fff'
  366. },
  367. formatter: function (value) {
  368. return value + "k条"
  369. },
  370. },
  371. splitLine:{
  372. lineStyle:{
  373. width:0,
  374. type:'solid'
  375. }
  376. }
  377. }
  378. ],
  379. xAxis: [
  380. {
  381. type: 'category',
  382. data : ['8:00','10:00','12:00','14:00','16:00','18:00'],
  383. axisLine:{
  384. lineStyle:{
  385. color: '#034c6a'
  386. },
  387. },
  388. splitLine: {
  389. "show": false
  390. },
  391. axisLabel: {
  392. textStyle: {
  393. color: '#fff'
  394. },
  395. formatter: function (value) {
  396. return value + ""
  397. },
  398. },
  399. splitLine:{
  400. lineStyle:{
  401. width:0,
  402. type:'solid'
  403. }
  404. },
  405. }
  406. ],
  407. grid:{
  408. left: '5%',
  409. right: '5%',
  410. bottom: '20%',
  411. containLabel: true
  412. },
  413. series : [
  414. {
  415. name:'厦门第一医院',
  416. type:'line',
  417. smooth:true,
  418. itemStyle: {
  419. normal: {
  420. lineStyle: {
  421. shadowColor : 'rgba(0,0,0,0.4)'
  422. }
  423. }
  424. },
  425. data:[15, 0, 20, 45, 22.1, 25,].reverse()
  426. },
  427. {
  428. name:'厦门中山医院',
  429. type:'line',
  430. smooth:true,
  431. itemStyle: {
  432. normal: {
  433. lineStyle: {
  434. shadowColor : 'rgba(0,0,0,0.4)'
  435. }
  436. }
  437. },
  438. data:[25, 10, 30, 55, 32.1, 35, ].reverse()
  439. },
  440. {
  441. name:'厦门中医院',
  442. type:'line',
  443. smooth:true,
  444. itemStyle: {
  445. normal: {
  446. lineStyle: {
  447. shadowColor : 'rgba(0,0,0,0.4)'
  448. }
  449. }
  450. },
  451. data:[35, 20, 40, 65, 42.1, 45, ].reverse()
  452. },
  453. {
  454. name:'厦门第五医院',
  455. type:'line',
  456. smooth:true,
  457. itemStyle: {
  458. normal: {
  459. lineStyle: {
  460. shadowColor : 'rgba(0,0,0,0.4)'
  461. }
  462. }
  463. },
  464. data:[45, 30, 50, 75, 52.1, 55, 6].reverse()
  465. }
  466. ]
  467. });
  468. }
  469. function init2(){
  470. var lineChart3 = echarts.init(document.getElementById('lineChart3'));
  471. lineChart3.setOption({
  472. color:["#87cefa","#ff7f50",],
  473. legend: {
  474. y : 'top',
  475. x : 'center',
  476. textStyle : {
  477. color : '#ffffff',
  478. },
  479. data : ['门诊人次','住院人次'],
  480. },
  481. calculable : false,
  482. tooltip : {
  483. trigger: 'item',
  484. formatter: "{a}<br/>{b}<br/>{c}人"
  485. },
  486. dataZoom: {
  487. show: true,
  488. realtime : true,
  489. start: 0,
  490. end: 18,
  491. height: 20,
  492. backgroundColor: '#f8f8f8',
  493. dataBackgroundColor: '#e4e4e4',
  494. fillerColor: '#87cefa',
  495. handleColor: '#87cefa',
  496. },
  497. yAxis: [
  498. {
  499. type: 'value',
  500. axisLine : {onZero: false},
  501. axisLine:{
  502. lineStyle:{
  503. color: '#034c6a'
  504. },
  505. },
  506. axisLabel: {
  507. textStyle: {
  508. color: '#fff'
  509. },
  510. formatter: function (value) {
  511. return value + "人"
  512. },
  513. },
  514. splitLine:{
  515. lineStyle:{
  516. width:0,
  517. type:'solid'
  518. }
  519. }
  520. }
  521. ],
  522. xAxis: [
  523. {
  524. type: 'category',
  525. data : symptomName,
  526. boundaryGap : false,
  527. axisLine:{
  528. lineStyle:{
  529. color: '#034c6a'
  530. },
  531. },
  532. splitLine: {
  533. "show": false
  534. },
  535. axisLabel: {
  536. textStyle: {
  537. color: '#fff'
  538. },
  539. formatter: function (value) {
  540. return value + ""
  541. },
  542. },
  543. splitLine:{
  544. lineStyle:{
  545. width:0,
  546. type:'solid'
  547. }
  548. },
  549. }
  550. ],
  551. grid:{
  552. left: '5%',
  553. right: '5%',
  554. bottom: '20%',
  555. containLabel: true
  556. },
  557. series : [
  558. {
  559. name:'门诊费用',
  560. type:'line',
  561. smooth:true,
  562. itemStyle: {
  563. normal: {
  564. lineStyle: {
  565. shadowColor : 'rgba(0,0,0,0.4)'
  566. }
  567. }
  568. },
  569. data:[1150, 180, 2100, 2415, 1212.1, 3125,1510, 810, 2100, 2415, 1122.1, 3215,1510, 801, 2001, 2245, 1232.1, 3245,1520, 830, 2200, 2145, 1223.1, 3225,150, 80, 200, 245, 122.1, 325]
  570. },
  571. {
  572. name:'住院费用',
  573. type:'line',
  574. smooth:true,
  575. itemStyle: {
  576. normal: {
  577. lineStyle: {
  578. shadowColor : 'rgba(0,0,0,0.4)'
  579. }
  580. }
  581. },
  582. data:[2500, 1000, 3000, 5005, 3200.1, 3005, 2500, 1000, 3000, 5005, 3200.1, 3005,2500, 1000, 3000, 5005, 3200.1, 3005,2500, 1000, 3000, 5005, 3200.1, 3005, 2500, 1000, 3000, 5005, 3200.1, 3005,2500, 1000, 3000, 5005, 3200.1, 3005,]
  583. },
  584. ]
  585. });
  586. var lineChart4 = echarts.init(document.getElementById('lineChart4'));
  587. lineChart4.setOption({
  588. color:["#87cefa","#ff7f50",],
  589. calculable : false,
  590. tooltip : {
  591. trigger: 'item',
  592. formatter: "{a}<br/>{b}<br/>{c}元"
  593. },
  594. dataZoom: {
  595. show: true,
  596. realtime : true,
  597. start: 0,
  598. end: 18,
  599. height: 20,
  600. backgroundColor: '#f8f8f8',
  601. dataBackgroundColor: '#e4e4e4',
  602. fillerColor: '#87cefa',
  603. handleColor: '#87cefa',
  604. },
  605. yAxis: [
  606. {
  607. type: 'value',
  608. axisLine : {onZero: false},
  609. axisLine:{
  610. lineStyle:{
  611. color: '#034c6a'
  612. },
  613. },
  614. axisLabel: {
  615. textStyle: {
  616. color: '#fff'
  617. },
  618. formatter: function (value) {
  619. return value + "元"
  620. },
  621. },
  622. splitLine:{
  623. lineStyle:{
  624. width:0,
  625. type:'solid'
  626. }
  627. }
  628. }
  629. ],
  630. xAxis: [
  631. {
  632. type: 'category',
  633. data : symptomName,
  634. boundaryGap : false,
  635. axisLine:{
  636. lineStyle:{
  637. color: '#034c6a'
  638. },
  639. },
  640. splitLine: {
  641. "show": false
  642. },
  643. axisLabel: {
  644. textStyle: {
  645. color: '#fff'
  646. },
  647. formatter: function (value) {
  648. return value + ""
  649. },
  650. },
  651. splitLine:{
  652. lineStyle:{
  653. width:0,
  654. type:'solid'
  655. }
  656. },
  657. }
  658. ],
  659. grid:{
  660. left: '5%',
  661. right: '5%',
  662. bottom: '20%',
  663. containLabel: true
  664. },
  665. series : [
  666. {
  667. name:'医疗费用',
  668. type:'line',
  669. smooth:true,
  670. itemStyle: {
  671. normal: {
  672. lineStyle: {
  673. shadowColor : 'rgba(0,0,0,0.4)'
  674. }
  675. }
  676. },
  677. data:[1500, 800, 1200, 2450, 1122.1, 1325,1150, 180, 1200, 1245, 1122.1, 1325,150, 180, 1200, 2145, 1212.1, 3215,1510, 180, 2100, 2415, 122.1, 325,150, 80, 200, 245, 122.1, 325].reverse()
  678. },
  679. ]
  680. });
  681. //年龄分布
  682. var pieChart2 = echarts.init(document.getElementById('pieChart2'));
  683. pieChart2.setOption({
  684. color:["#32cd32","#ff7f50","#87cefa","#FD6C88","#4b5cc4","#faff72"],
  685. tooltip : {
  686. trigger: 'item',
  687. formatter: "{a}<br/>{b}<br/>{c}人"
  688. },
  689. calculable : true,
  690. series : [
  691. {
  692. name:'发病人数',
  693. type:'pie',
  694. radius : [30, 110],
  695. center : ['50%', '50%'],
  696. roseType : 'area',
  697. x: '50%',
  698. sort : 'ascending',
  699. data:[
  700. {value:10, name:'婴儿(1-3岁)'},
  701. {value:5, name:'少儿(4-10岁)'},
  702. {value:15, name:'少年(10-18岁)'},
  703. {value:25, name:'青年(18-45岁)'},
  704. {value:125, name:'中年(45-60岁)'},
  705. {value:175, name:'老年(60岁以上)'},
  706. ]
  707. }
  708. ]
  709. })
  710. //医疗费用组成
  711. var pieChart3 = echarts.init(document.getElementById('pieChart3'));
  712. pieChart3.setOption({
  713. color:["#32cd32","#ff7f50","#87cefa","#FD6C88","#4b5cc4","#faff72"],
  714. tooltip : {
  715. trigger: 'item',
  716. formatter: "{a}<br/>{b}<br/>{c}元"
  717. },
  718. calculable : true,
  719. series : [
  720. {
  721. name:'发病人数',
  722. type:'pie',
  723. radius : [30, 110],
  724. center : ['50%', '50%'],
  725. roseType : 'area',
  726. x: '50%',
  727. sort : 'ascending',
  728. data:[
  729. {value:10, name:'诊察费用'},
  730. {value:500, name:'检查费用'},
  731. {value:150, name:'检验费用'},
  732. {value:250, name:'西药费用'},
  733. {value:125, name:'中药费用'},
  734. {value:1750, name:'手术费用'},
  735. ]
  736. }
  737. ]
  738. })
  739. }
  740. var chartMapElementId = 'mapChart';
  741. // var chartMapElement = document.getElementById(chartMapElementId); 这种有问题,不显示图
  742. //相对路径,页面的当前目录
  743. // var jsonFileName = 'json/map.json';
  744. //绝对路径,根目录
  745. var jsonFileName = '/json/map.json';
  746. var jsonFileNamechart_1 = '/json/chart_1.json';
  747. var jsonFileNamechart_2 = '/json/chart_2.json';
  748. function get_legend(data) {
  749. var listLegend = new Array();
  750. for (i=0; i<data.length; i++) {
  751. n = data[i]["name"];
  752. listLegend.push(n);
  753. }
  754. console.log("get_legend", listLegend);
  755. return listLegend
  756. }
  757. function get_value(data) {
  758. var listLegend = new Array();
  759. var listValue = new Array();
  760. for (i=0; i<data.length; i++) {
  761. n = data[i][2];
  762. v = data[i][3];
  763. tmp = {"name": n, "value": v};
  764. listLegend.push(n);
  765. listValue.push(tmp);
  766. }
  767. console.log("get_value", listLegend, listValue);
  768. return [listLegend, listValue]
  769. }
  770. function get_value2(data) {
  771. var listLegend = new Array();
  772. var listValue = new Array();
  773. for (i=0; i<data.length; i++) {
  774. n = data[i][2];
  775. v = [data[i][3], data[i][4], data[i][5]];
  776. tmp = {"name": n, "data": v};
  777. listLegend.push(n);
  778. listValue.push(tmp);
  779. }
  780. console.log("get_value2", listLegend, listValue);
  781. return [listLegend, listValue]
  782. }
  783. function get_value3(data) {
  784. var listLegend = new Array();
  785. var listValue = new Array();
  786. for (i=0; i<data.length; i++) {
  787. n = data[i][2];
  788. v = [data[i][3], data[i][4], data[i][5], data[i][3], data[i][4], data[i][5], data[i][3], data[i][4], data[i][5]];
  789. tmp = {"name": n, "data": v};
  790. listLegend.push(n);
  791. listValue.push(tmp);
  792. }
  793. console.log("get_value3", listLegend, listValue);
  794. return [listLegend, listValue]
  795. }
  796. function async_map_data() {
  797. // 异步加载数据
  798. $.getJSON(jsonFileName).done(function (data) {
  799. // 1
  800. var chartMapElement = document.getElementById(chartMapElementId);
  801. console.log(chartMapElementId, "async_data")
  802. var myChart = echarts.init(chartMapElement);
  803. console.log(data)
  804. myChart.setOption({
  805. series: [{
  806. data: data
  807. }]
  808. });
  809. // 2
  810. var pieChart1Element = document.getElementById("pieChart1");
  811. var pieChart1 = echarts.init(pieChart1Element);
  812. rs = get_value(data);
  813. console.log(rs);
  814. pieChart1.setOption({
  815. legend: {
  816. data: rs[0]
  817. },
  818. series: [{
  819. data: rs[1]
  820. }]
  821. })
  822. //3
  823. var histogramChartElement = document.getElementById('histogramChart');
  824. var histogramChart = echarts.init(histogramChartElement);
  825. rs = get_value2(data);
  826. console.log(rs);
  827. histogramChart.setOption({
  828. legend: {
  829. data: rs[0]
  830. },
  831. series: rs[1]
  832. })
  833. // 4
  834. var lineChart = echarts.init(document.getElementById('lineChart'));
  835. rs = get_value3(data);
  836. lineChart.setOption({
  837. legend: {
  838. data: rs[0]
  839. },
  840. series: rs[1]
  841. })
  842. // end
  843. });//end $.getJSON
  844. // 异步加载数据
  845. $.getJSON(jsonFileNamechart_1).done(function (data) {
  846. console.log(data);
  847. var lineChart2 = echarts.init(document.getElementById('lineChart2'));
  848. lineChart2.setOption({
  849. legend: {
  850. data: get_legend(data)
  851. },
  852. series: data
  853. })
  854. });//end $.getJSON
  855. $.getJSON(jsonFileNamechart_2).done(function (data) {
  856. t0 = document.getElementById('t0');
  857. t0.innerText = data[0];
  858. t1 = document.getElementById('t1');
  859. t1.innerText = data[1];
  860. t2 = document.getElementById('t2');
  861. t2.innerText = data[2];
  862. t3 = document.getElementById('t3');
  863. t3.innerText = data[3];
  864. t4 = document.getElementById('t4');
  865. t4.innerText = data[4];
  866. t5 = document.getElementById('t5');
  867. t5.innerText = data[5];
  868. });//end $.getJSON
  869. }

3、后端Java代码

  1. @RestController
  2. @RequestMapping("/json")
  3. public class Process {
  4. @RequestMapping("/{filename}")
  5. public String json(@PathVariable("filename") String filename) throws Exception {
  6. System.out.println(filename);
  7. ChangeJSON(filename);
  8. String jsonStr = readJSON(filename);
  9. System.out.println(jsonStr);
  10. return jsonStr;
  11. }

4、数据通信 JSON

[{"name": "厦门医学院附属第二医院", "data": [235, 215, 275, 260, 115, 262, 72, 47, 121, 253, 254, 107, 30, 165, 259, 84, 290, 130, 75, 13, 248, 40, 17, 176, 288, 20, 236]}, {"name": "厦门第一医院", "data": [235, 215, 275, 260, 115, 262, 72, 47, 121, 253, 254, 107, 30, 165, 259, 84, 290, 130, 75, 13, 248, 40, 17, 176, 288, 20, 236]}, {"name": "厦门大学附属第一医院", "data": [235, 215, 275, 260, 115, 262, 72, 47, 121, 253, 254, 107, 30, 165, 259, 84, 290, 130, 75, 13, 248, 40, 17, 176, 288, 20, 236]}]

四、开发配置&代码结构说明

​数据可视化:基于 Echarts +Java SpringBoot 实现的动态实时大屏【Java开发环境搭建】

五、更多案例 


YYDatav的数据可视化大屏《精彩案例汇总》(Python&Echarts源码)_YYDataV的博客-CSDN博客

《工厂订单出入库信息管理系统》完整案例详解(含演示网址账号)(Go&Vue源码)_YYDataV的博客-CSDN博客

本次分享结束,欢迎讨论!QQ微信同号: 6550523

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/599530
推荐阅读
相关标签
  

闽ICP备14008679号