xychart.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>ECahrt 示例</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
  7. <meta name="apple-mobile-web-app-capable" content="yes">
  8. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  9. <!--标准mui.css-->
  10. <link rel="stylesheet" href="../../css/mui.min.css">
  11. <!--App自定义的css-->
  12. <link rel="stylesheet" type="text/css" href="../../css/app.css" />
  13. <style>
  14. .chart {
  15. height: 200px;
  16. margin: 0px;
  17. padding: 0px;
  18. }
  19. h5 {
  20. margin-top: 30px;
  21. font-weight: bold;
  22. }
  23. h5:first-child {
  24. margin-top: 15px;
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <header class="mui-bar mui-bar-nav">
  30. <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  31. <h1 class="mui-title">血糖监测</h1>
  32. <a id="xyAdd" class="mui-icon mui-pull-right" style="font-size: 16px;padding-top: 14px;" data-url="xyjc.html">新增</a>
  33. </header>
  34. <div class="mui-content">
  35. <div class="mui-content-padded">
  36. <h5>总计</h5>
  37. <div class="chart" id="pieChart"></div>
  38. <h5>走势图</h5>
  39. <div class="chart" id="lineChart"></div>
  40. </div>
  41. </div>
  42. <script src="../../js/mui.min.js"></script>
  43. <script src="../../libs/echarts-all.js"></script>
  44. <script>
  45. document.getElementById("xyAdd").addEventListener('tap', function() {
  46. var url = this.getAttribute('data-url');
  47. mui.openWindow({
  48. url: url
  49. });
  50. });
  51. var getOption = function(chartType) {
  52. var chartOption = chartType == 'pie' ? {
  53. calculable: false,
  54. series: [{
  55. name: '访问来源',
  56. type: 'pie',
  57. radius: '65%',
  58. center: ['50%', '50%'],
  59. data: [{
  60. value: 53,
  61. name: '偏高(53%)'
  62. }, {
  63. value: 1,
  64. name: '偏低(1%)'
  65. }, {
  66. value: 46,
  67. name: '正常(46%)'
  68. }]
  69. }]
  70. } : {
  71. legend: {
  72. data: ['高血压','高血压','正常']
  73. },
  74. grid: {
  75. x: 35,
  76. x2:38,
  77. x3:40,
  78. y: 30,
  79. y2:40,
  80. y3:55
  81. },
  82. toolbox: {
  83. show: false,
  84. feature: {
  85. mark: {
  86. show: true
  87. },
  88. dataView: {
  89. show: true,
  90. readOnly: false
  91. },
  92. magicType: {
  93. show: true,
  94. type: ['line', 'bar']
  95. },
  96. restore: {
  97. show: true
  98. },
  99. saveAsImage: {
  100. show: true
  101. }
  102. }
  103. },
  104. calculable: false,
  105. xAxis: [{
  106. type: 'category',
  107. data: ['9-28', '10-3', '10-10', '10-17', '10-24', '11-1', '11-8', '11-15', '11-23', '11-30', '12-6', '12-13']
  108. }],
  109. yAxis: [{
  110. type: 'value',
  111. splitArea: {
  112. show: true
  113. }
  114. }],
  115. series: [{
  116. name: '高血压',
  117. type: chartType,
  118. data: [143.0, 124.9, 137.0, 113.2, 155.6, 126.7, 135.6, 162.2, 132.6, 120.0, 136.4, 153.3]
  119. },{
  120. name: '低血压',
  121. type: chartType,
  122. data: [43.0, 34.9, 47.0, 33.2, 45.6, 56.7, 55.6, 62.2, 32.6, 40.0, 36.4, 53.3]
  123. },{
  124. name: '正常',
  125. type: chartType,
  126. data: [83.0, 64.9, 87.0, 63.2, 85.6, 106.7, 105.6, 122.2, 72.6, 90.0, 66.4, 103.3]
  127. }]
  128. };
  129. return chartOption;
  130. };
  131. var byId = function(id) {
  132. return document.getElementById(id);
  133. };
  134. var lineChart = echarts.init(byId('lineChart'));
  135. lineChart.setOption(getOption('line'));
  136. var pieChart = echarts.init(byId('pieChart'));
  137. pieChart.setOption(getOption('pie'));
  138. byId("echarts").addEventListener('tap', function() {
  139. var url = this.getAttribute('data-url');
  140. plus.runtime.openURL(url);
  141. }, false);
  142. </script>
  143. </body>
  144. </html>