echarts8.html 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>统计图表-WeAdmin Frame型后台管理系统-WeAdmin 1.0</title>
  6. <meta name="renderer" content="webkit|ie-comp|ie-stand">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  9. <meta http-equiv="Cache-Control" content="no-siteapp" />
  10. <link rel="stylesheet" href="../../static/css/font.css">
  11. <link rel="stylesheet" href="../../static/css/weadmin.css">
  12. </head>
  13. <body>
  14. <div class="weadmin-body">
  15. <blockquote class="layui-elem-quote">
  16. 特别声明:ECharts,一个纯 Javascript 的图表库,可以流畅的运行在 PC 和移动设备上,兼容当前绝大部分浏览器(IE8/9/10/11,Chrome,Firefox,Safari等),底层依赖轻量级的 Canvas 类库 ZRender,提供直观,生动,可交互,可高度个性化定制的数据可视化图表。WeAdmin提示:如需使用或者详细更多案例可以访问官网 <a href="http://echarts.baidu.com/" style="color:red">ECharts</a>。
  17. </blockquote>
  18. <!-- 为 ECharts 准备一个具备大小(宽高)的 DOM -->
  19. <div id="main" style="width: 100%;height:400px;"></div>
  20. <blockquote class="layui-elem-quote">
  21. 注意:本案例的Echarts图表库由cdn引入,需要在线才能正常使用,若要离线使用,请至Echarts官网下载。
  22. </blockquote>
  23. </div>
  24. <script src="//cdn.bootcss.com/echarts/4.0.2/echarts.min.js"></script>
  25. <!--<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/echarts.min.js"></script>-->
  26. <script type="text/javascript">
  27. // 基于准备好的dom,初始化echarts实例
  28. var myChart = echarts.init(document.getElementById('main'));
  29. // 指定图表的配置项和数据
  30. option = {
  31. tooltip : {
  32. formatter: "{a} <br/>{c} {b}"
  33. },
  34. toolbox: {
  35. show: true,
  36. feature: {
  37. restore: {show: true},
  38. saveAsImage: {show: true}
  39. }
  40. },
  41. series : [
  42. {
  43. name: '速度',
  44. type: 'gauge',
  45. z: 3,
  46. min: 0,
  47. max: 220,
  48. splitNumber: 11,
  49. radius: '50%',
  50. axisLine: { // 坐标轴线
  51. lineStyle: { // 属性lineStyle控制线条样式
  52. width: 10
  53. }
  54. },
  55. axisTick: { // 坐标轴小标记
  56. length: 15, // 属性length控制线长
  57. lineStyle: { // 属性lineStyle控制线条样式
  58. color: 'auto'
  59. }
  60. },
  61. splitLine: { // 分隔线
  62. length: 20, // 属性length控制线长
  63. lineStyle: { // 属性lineStyle(详见lineStyle)控制线条样式
  64. color: 'auto'
  65. }
  66. },
  67. title : {
  68. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  69. fontWeight: 'bolder',
  70. fontSize: 20,
  71. fontStyle: 'italic'
  72. }
  73. },
  74. detail : {
  75. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  76. fontWeight: 'bolder'
  77. }
  78. },
  79. data:[{value: 40, name: 'km/h'}]
  80. },
  81. {
  82. name: '转速',
  83. type: 'gauge',
  84. center: ['20%', '55%'], // 默认全局居中
  85. radius: '35%',
  86. min:0,
  87. max:7,
  88. endAngle:45,
  89. splitNumber:7,
  90. axisLine: { // 坐标轴线
  91. lineStyle: { // 属性lineStyle控制线条样式
  92. width: 8
  93. }
  94. },
  95. axisTick: { // 坐标轴小标记
  96. length:12, // 属性length控制线长
  97. lineStyle: { // 属性lineStyle控制线条样式
  98. color: 'auto'
  99. }
  100. },
  101. splitLine: { // 分隔线
  102. length:20, // 属性length控制线长
  103. lineStyle: { // 属性lineStyle(详见lineStyle)控制线条样式
  104. color: 'auto'
  105. }
  106. },
  107. pointer: {
  108. width:5
  109. },
  110. title: {
  111. offsetCenter: [0, '-30%'], // x, y,单位px
  112. },
  113. detail: {
  114. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  115. fontWeight: 'bolder'
  116. }
  117. },
  118. data:[{value: 1.5, name: 'x1000 r/min'}]
  119. },
  120. {
  121. name: '油表',
  122. type: 'gauge',
  123. center: ['77%', '50%'], // 默认全局居中
  124. radius: '25%',
  125. min: 0,
  126. max: 2,
  127. startAngle: 135,
  128. endAngle: 45,
  129. splitNumber: 2,
  130. axisLine: { // 坐标轴线
  131. lineStyle: { // 属性lineStyle控制线条样式
  132. width: 8
  133. }
  134. },
  135. axisTick: { // 坐标轴小标记
  136. splitNumber: 5,
  137. length: 10, // 属性length控制线长
  138. lineStyle: { // 属性lineStyle控制线条样式
  139. color: 'auto'
  140. }
  141. },
  142. axisLabel: {
  143. formatter:function(v){
  144. switch (v + '') {
  145. case '0' : return 'E';
  146. case '1' : return 'Gas';
  147. case '2' : return 'F';
  148. }
  149. }
  150. },
  151. splitLine: { // 分隔线
  152. length: 15, // 属性length控制线长
  153. lineStyle: { // 属性lineStyle(详见lineStyle)控制线条样式
  154. color: 'auto'
  155. }
  156. },
  157. pointer: {
  158. width:2
  159. },
  160. title : {
  161. show: false
  162. },
  163. detail : {
  164. show: false
  165. },
  166. data:[{value: 0.5, name: 'gas'}]
  167. },
  168. {
  169. name: '水表',
  170. type: 'gauge',
  171. center : ['77%', '50%'], // 默认全局居中
  172. radius : '25%',
  173. min: 0,
  174. max: 2,
  175. startAngle: 315,
  176. endAngle: 225,
  177. splitNumber: 2,
  178. axisLine: { // 坐标轴线
  179. lineStyle: { // 属性lineStyle控制线条样式
  180. width: 8
  181. }
  182. },
  183. axisTick: { // 坐标轴小标记
  184. show: false
  185. },
  186. axisLabel: {
  187. formatter:function(v){
  188. switch (v + '') {
  189. case '0' : return 'H';
  190. case '1' : return 'Water';
  191. case '2' : return 'C';
  192. }
  193. }
  194. },
  195. splitLine: { // 分隔线
  196. length: 15, // 属性length控制线长
  197. lineStyle: { // 属性lineStyle(详见lineStyle)控制线条样式
  198. color: 'auto'
  199. }
  200. },
  201. pointer: {
  202. width:2
  203. },
  204. title: {
  205. show: false
  206. },
  207. detail: {
  208. show: false
  209. },
  210. data:[{value: 0.5, name: 'gas'}]
  211. }
  212. ]
  213. };
  214. setInterval(function (){
  215. option.series[0].data[0].value = (Math.random()*100).toFixed(2) - 0;
  216. option.series[1].data[0].value = (Math.random()*7).toFixed(2) - 0;
  217. option.series[2].data[0].value = (Math.random()*2).toFixed(2) - 0;
  218. option.series[3].data[0].value = (Math.random()*2).toFixed(2) - 0;
  219. myChart.setOption(option,true);
  220. },2000);
  221. // 使用刚指定的配置项和数据显示图表。
  222. myChart.setOption(option);
  223. </script>
  224. </body>
  225. </html>