bar15.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <meta name="description" content="ECharts">
  8. <meta name="author" content="kener.linfeng@gmail.com">
  9. <title>ECharts · Example</title>
  10. <link rel="shortcut icon" href="../asset/ico/favicon.png">
  11. <link href="../asset/css/font-awesome.min.css" rel="stylesheet">
  12. <link href="../asset/css/bootstrap.css" rel="stylesheet">
  13. <link href="../asset/css/carousel.css" rel="stylesheet">
  14. <link href="../asset/css/echartsHome.css" rel="stylesheet">
  15. <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  16. <!--[if lt IE 9]>
  17. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  18. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  19. <![endif]-->
  20. <script src="./www/js/echarts.js"></script>
  21. <script src="../asset/js/codemirror.js"></script>
  22. <script src="../asset/js/javascript.js"></script>
  23. <link href="../asset/css/codemirror.css" rel="stylesheet">
  24. <link href="../asset/css/monokai.css" rel="stylesheet">
  25. </head>
  26. <body>
  27. <!-- Fixed navbar -->
  28. <div class="navbar navbar-default navbar-fixed-top" role="navigation" id="head"></div>
  29. <div class="container-fluid">
  30. <div class="row-fluid example">
  31. <div id="sidebar-code" class="col-md-4">
  32. <div class="well sidebar-nav">
  33. <div class="nav-header"><a href="#" onclick="autoResize()" class="glyphicon glyphicon-resize-full" id ="icon-resize" ></a>option</div>
  34. <textarea id="code" name="code">
  35. var zrColor = require('zrender/tool/color');
  36. var colorList = [
  37. '#ff7f50','#87cefa','#da70d6','#32cd32','#6495ed',
  38. '#ff69b4','#ba55d3','#cd5c5c','#ffa500','#40e0d0'
  39. ];
  40. var itemStyle = {
  41. normal: {
  42. color: function(params) {
  43. if (params.dataIndex < 0) {
  44. // for legend
  45. return zrColor.lift(
  46. colorList[colorList.length - 1], params.seriesIndex * 0.1
  47. );
  48. }
  49. else {
  50. // for bar
  51. return zrColor.lift(
  52. colorList[params.dataIndex], params.seriesIndex * 0.1
  53. );
  54. }
  55. }
  56. }
  57. };
  58. option = {
  59. title: {
  60. text: '2010-2013年中国城镇居民家庭人均消费构成(元)',
  61. subtext: '数据来自国家统计局',
  62. sublink: 'http://data.stats.gov.cn/search/keywordlist2?keyword=%E5%9F%8E%E9%95%87%E5%B1%85%E6%B0%91%E6%B6%88%E8%B4%B9'
  63. },
  64. tooltip: {
  65. trigger: 'axis',
  66. backgroundColor: 'rgba(255,255,255,0.7)',
  67. axisPointer: {
  68. type: 'shadow'
  69. },
  70. formatter: function(params) {
  71. // for text color
  72. var color = colorList[params[0].dataIndex];
  73. var res = '<div style="color:' + color + '">';
  74. res += '<strong>' + params[0].name + '消费(元)</strong>'
  75. for (var i = 0, l = params.length; i < l; i++) {
  76. res += '<br/>' + params[i].seriesName + ' : ' + params[i].value
  77. }
  78. res += '</div>';
  79. return res;
  80. }
  81. },
  82. legend: {
  83. x: 'right',
  84. data:['2010','2011','2012','2013']
  85. },
  86. toolbox: {
  87. show: true,
  88. orient: 'vertical',
  89. y: 'center',
  90. feature: {
  91. mark: {show: true},
  92. dataView: {show: true, readOnly: false},
  93. restore: {show: true},
  94. saveAsImage: {show: true}
  95. }
  96. },
  97. calculable: true,
  98. grid: {
  99. y: 80,
  100. y2: 40,
  101. x2: 40
  102. },
  103. xAxis: [
  104. {
  105. type: 'category',
  106. data: ['食品', '衣着', '居住', '家庭设备及用品', '医疗保健', '交通和通信', '文教娱乐服务', '其他']
  107. }
  108. ],
  109. yAxis: [
  110. {
  111. type: 'value'
  112. }
  113. ],
  114. series: [
  115. {
  116. name: '2010',
  117. type: 'bar',
  118. itemStyle: itemStyle,
  119. data: [4804.7,1444.3,1332.1,908,871.8,1983.7,1627.6,499.2]
  120. },
  121. {
  122. name: '2011',
  123. type: 'bar',
  124. itemStyle: itemStyle,
  125. data: [5506.3,1674.7,1405,1023.2,969,2149.7,1851.7,581.3]
  126. },
  127. {
  128. name: '2012',
  129. type: 'bar',
  130. itemStyle: itemStyle,
  131. data: [6040.9,1823.4,1484.3,1116.1,1063.7,2455.5,2033.5,657.1]
  132. },
  133. {
  134. name: '2013',
  135. type: 'bar',
  136. itemStyle: itemStyle,
  137. data: [6311.9,1902,1745.1,1215.1,1118.3,2736.9,2294,699.4]
  138. }
  139. ]
  140. };
  141. </textarea>
  142. </div><!--/.well -->
  143. </div><!--/span-->
  144. <div id="graphic" class="col-md-8">
  145. <div id="main" class="main"></div>
  146. <div>
  147. <button type="button" class="btn btn-sm btn-success" onclick="refresh(true)">刷 新</button>
  148. <span class="text-primary">切换主题</span>
  149. <select id="theme-select"></select>
  150. <span id='wrong-message' style="color:red"></span>
  151. </div>
  152. </div><!--/span-->
  153. </div><!--/row-->
  154. </div><!--/.fluid-container-->
  155. <footer id="footer"></footer>
  156. <!-- Le javascript
  157. ================================================== -->
  158. <!-- Placed at the end of the document so the pages load faster -->
  159. <script src="../asset/js/jquery.min.js"></script>
  160. <script type="text/javascript" src="../asset/js/echartsHome.js"></script>
  161. <script src="../asset/js/bootstrap.min.js"></script>
  162. <script src="../asset/js/echartsExample.js"></script>
  163. </body>
  164. </html>