chart.html 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <!-- Meta, title, CSS, favicons, etc. -->
  6. <meta charset="utf-8">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  8. <meta name="viewport" content="width=device-width, initial-scale=1">
  9. <title>后台管理系统 </title>
  10. <!-- Bootstrap -->
  11. <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
  12. <!-- Font Awesome -->
  13. <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
  14. <!-- iCheck -->
  15. <link href="../vendors/iCheck/skins/flat/blue.css" rel="stylesheet">
  16. <!-- bootstrap-daterangepicker -->
  17. <link href="../vendors/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">
  18. <!-- bootstrap-datetimepicker -->
  19. <link href="../vendors/bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css" rel="stylesheet">
  20. <!-- Datatables -->
  21. <link href="../vendors/datatables.net-bs/css/dataTables.bootstrap.min.css" rel="stylesheet">
  22. <!-- Custom Theme Style -->
  23. <link href="../src/css/common.css" rel="stylesheet">
  24. </head>
  25. <body class="container child_body">
  26. <div class="row">
  27. <div class="col-md-12 col-sm-12 col-xs-24">
  28. <div class="x_panel">
  29. <div class="x_title">
  30. <h2>动态图表示例 </h2>
  31. <div class="nav navbar-right">
  32. <ul class="nav navbar-right panel_toolbox">
  33. <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
  34. </li>
  35. </ul>
  36. </div>
  37. <div class="clearfix"></div>
  38. </div>
  39. <div class="x_content">
  40. <div style="position: relative; width: 600px; height: 400px;">
  41. <div id="echart_bar_horizontal" style="height: 100%;"></div>
  42. <div class="barTime" id="barTime" style="position: absolute; right: 40px; bottom: 60px; z-index: 99; font-size: 58px;">1980</div>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. <!-- jQuery -->
  49. <script src="../vendors/jquery/dist/jquery.min.js"></script>
  50. <!-- Bootstrap -->
  51. <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
  52. <!-- FastClick -->
  53. <script src="../vendors/fastclick/lib/fastclick.js"></script>
  54. <!-- iCheck -->
  55. <script src="../vendors/iCheck/icheck.min.js"></script>
  56. <!-- Datatables -->
  57. <script src="../vendors/datatables.net/js/jquery.dataTables.min.js"></script>
  58. <script src="../vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
  59. <script src="../vendors/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>
  60. <script src="../vendors/datatables.net-fixedcolumns/js/dataTables.fixedcolumns.min.js"></script>
  61. <script src="../vendors/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>
  62. <!-- ECharts -->
  63. <script src="../vendors/echarts/dist/echarts.min.js"></script>
  64. <!-- common -->
  65. <script src="../src/js/common.js"></script>
  66. <script>
  67. $(function() {
  68. var theme = {
  69. color: [
  70. '#26B99A', '#34495E', '#BDC3C7', '#3498DB',
  71. '#9B59B6', '#8abb6f', '#759c6a', '#bfd3b7'
  72. ],
  73. title: {
  74. itemGap: 8,
  75. textStyle: {
  76. fontWeight: 'normal',
  77. color: '#408829'
  78. }
  79. },
  80. dataRange: {
  81. color: ['#1f610a', '#97b58d']
  82. },
  83. toolbox: {
  84. color: ['#408829', '#408829', '#408829', '#408829']
  85. },
  86. tooltip: {
  87. backgroundColor: 'rgba(0,0,0,0.5)',
  88. axisPointer: {
  89. type: 'line',
  90. lineStyle: {
  91. color: '#408829',
  92. type: 'dashed'
  93. },
  94. crossStyle: {
  95. color: '#408829'
  96. },
  97. shadowStyle: {
  98. color: 'rgba(200,200,200,0.3)'
  99. }
  100. }
  101. },
  102. dataZoom: {
  103. dataBackgroundColor: '#eee',
  104. fillerColor: 'rgba(64,136,41,0.2)',
  105. handleColor: '#408829'
  106. },
  107. grid: {
  108. borderWidth: 0
  109. },
  110. categoryAxis: {
  111. axisLine: {
  112. lineStyle: {
  113. color: '#408829'
  114. }
  115. },
  116. splitLine: {
  117. lineStyle: {
  118. color: ['#eee']
  119. }
  120. }
  121. },
  122. valueAxis: {
  123. axisLine: {
  124. lineStyle: {
  125. color: '#408829'
  126. }
  127. },
  128. splitArea: {
  129. show: true,
  130. areaStyle: {
  131. color: ['rgba(250,250,250,0.1)', 'rgba(200,200,200,0.1)']
  132. }
  133. },
  134. splitLine: {
  135. lineStyle: {
  136. color: ['#eee']
  137. }
  138. }
  139. },
  140. timeline: {
  141. lineStyle: {
  142. color: '#408829'
  143. },
  144. controlStyle: {
  145. normal: {color: '#408829'},
  146. emphasis: {color: '#408829'}
  147. }
  148. },
  149. k: {
  150. itemStyle: {
  151. normal: {
  152. color: '#68a54a',
  153. color0: '#a9cba2',
  154. lineStyle: {
  155. width: 1,
  156. color: '#408829',
  157. color0: '#86b379'
  158. }
  159. }
  160. }
  161. },
  162. map: {
  163. itemStyle: {
  164. normal: {
  165. areaStyle: {
  166. color: '#ddd'
  167. },
  168. label: {
  169. textStyle: {
  170. color: '#c12e34'
  171. }
  172. }
  173. },
  174. emphasis: {
  175. areaStyle: {
  176. color: '#99d2dd'
  177. },
  178. label: {
  179. textStyle: {
  180. color: '#c12e34'
  181. }
  182. }
  183. }
  184. }
  185. },
  186. force: {
  187. itemStyle: {
  188. normal: {
  189. linkStyle: {
  190. strokeColor: '#408829'
  191. }
  192. }
  193. }
  194. },
  195. chord: {
  196. padding: 4,
  197. itemStyle: {
  198. normal: {
  199. lineStyle: {
  200. width: 1,
  201. color: 'rgba(128, 128, 128, 0.5)'
  202. },
  203. chordStyle: {
  204. lineStyle: {
  205. width: 1,
  206. color: 'rgba(128, 128, 128, 0.5)'
  207. }
  208. }
  209. },
  210. emphasis: {
  211. lineStyle: {
  212. width: 1,
  213. color: 'rgba(128, 128, 128, 0.5)'
  214. },
  215. chordStyle: {
  216. lineStyle: {
  217. width: 1,
  218. color: 'rgba(128, 128, 128, 0.5)'
  219. }
  220. }
  221. }
  222. }
  223. },
  224. gauge: {
  225. startAngle: 225,
  226. endAngle: -45,
  227. axisLine: {
  228. show: true,
  229. lineStyle: {
  230. color: [[0.2, '#86b379'], [0.8, '#68a54a'], [1, '#408829']],
  231. width: 8
  232. }
  233. },
  234. axisTick: {
  235. splitNumber: 10,
  236. length: 12,
  237. lineStyle: {
  238. color: 'auto'
  239. }
  240. },
  241. axisLabel: {
  242. textStyle: {
  243. color: 'auto'
  244. }
  245. },
  246. splitLine: {
  247. length: 18,
  248. lineStyle: {
  249. color: 'auto'
  250. }
  251. },
  252. pointer: {
  253. length: '90%',
  254. color: 'auto'
  255. },
  256. title: {
  257. textStyle: {
  258. color: '#333'
  259. }
  260. },
  261. detail: {
  262. textStyle: {
  263. color: 'auto'
  264. }
  265. }
  266. },
  267. textStyle: {
  268. fontFamily: 'Arial, Verdana, sans-serif'
  269. }
  270. };
  271. //echart Bar Horizontal
  272. if ($('#echart_bar_horizontal').length ){
  273. var echartBar = echarts.init(document.getElementById('echart_bar_horizontal'), theme);
  274. var option = {
  275. title: {
  276. text: 'Bar Graph',
  277. subtext: 'Graph subtitle'
  278. },
  279. tooltip: {
  280. trigger: 'axis'
  281. },
  282. legend: {
  283. x: 100,
  284. data: ['分类一', '分类二']
  285. },
  286. toolbox: {
  287. show: true,
  288. feature: {
  289. saveAsImage: {
  290. show: true,
  291. title: "Save Image"
  292. }
  293. }
  294. },
  295. calculable: true,
  296. xAxis: [{
  297. type: 'value',
  298. boundaryGap: [0, 0.01]
  299. }],
  300. yAxis: [{
  301. type: 'category',
  302. data: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
  303. }],
  304. series: [{
  305. name: '分类一',
  306. type: 'bar',
  307. data: [18203, 23489, 29034, 104970, 131744, 530230]
  308. }, {
  309. name: '分类二',
  310. type: 'bar',
  311. data: [19325, 23438, 31000, 121594, 134141, 581807]
  312. }]
  313. };
  314. echartBar.setOption(option);
  315. var auto, start = 1980, i = 0, data = option.series;
  316. auto = setInterval(function() {
  317. if (i > 20) {
  318. clearInterval(auto);
  319. return false;
  320. }
  321. i++;
  322. start += 1;
  323. option.series.forEach(function(item, idx) {
  324. // item.data.push(10000 * i * Math.random());
  325. item.data.forEach(function(val, idx2) {
  326. val = Math.floor(val + 10000 * i * Math.random());
  327. data[idx].data[idx2] = val
  328. })
  329. // console.log('----------------- ')
  330. });
  331. option.series = data
  332. echartBar.setOption(option, true);
  333. $('#barTime').text(start);
  334. }, 2000);
  335. }
  336. })
  337. </script>
  338. </body>
  339. </html>