mix12.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. // original
  36. var data = [30, 20, 54, 21, 90, 30, 10];
  37. var gap = 0;
  38. var total = 0;
  39. var maxIndex;
  40. var dataArray = (function(){
  41. var max = Math.max.apply(Math, data);
  42. var min = Math.min.apply(Math, data);
  43. gap = Math.round((max - min));
  44. var nd = [{value:data[0] + gap,symbol:'none'}];
  45. for (var i = 0, l = data.length; i < l; i++) {
  46. if (data[i] == max) {
  47. maxIndex = i;
  48. }
  49. total += data[i];
  50. nd.push(data[i] + gap);
  51. }
  52. nd.push({value:data[data.length - 1] + gap,symbol:'none'});
  53. return nd;
  54. })();
  55. option = {
  56. backgroundColor:'#fff',
  57. title : {
  58. text: '某楼盘销售情况',
  59. subtext: '纯属虚构 折线饼图交互混搭实例',
  60. x: 'center'
  61. },
  62. legend: {
  63. data:['销量', '占比'],
  64. x: 'left',
  65. orient: 'vertical',
  66. selectedMode: false
  67. },
  68. tooltip : {
  69. trigger: 'item',
  70. formatter: function(params){
  71. if (params.seriesName == '占比') {
  72. return '总量 : ' + total + '<br/>'
  73. + params.name + ' : ' + params.value + '<br/>'
  74. + '占比 : ' + params.percent + '%';
  75. }
  76. else if (params.name != '占位'){
  77. update(params);
  78. return params.seriesName + '<br/>'
  79. + params.name + ' : ' + params.value;
  80. }
  81. },
  82. axisPointer: {
  83. type: 'none'
  84. }
  85. },
  86. toolbox: {
  87. show : true,
  88. feature : {
  89. saveAsImage : {show: true}
  90. }
  91. },
  92. grid:{
  93. backgroundColor:'#ccc',
  94. borderWidth:0
  95. },
  96. xAxis : [
  97. {
  98. type : 'category',
  99. boundaryGap : false,
  100. show : false,
  101. data : ['占位','周一','周二','周三','周四','周五','周六','周日','占位']
  102. }
  103. ],
  104. yAxis : [
  105. {
  106. type : 'value',
  107. boundaryGap:[0,0.5],
  108. show : false
  109. }
  110. ],
  111. animation: false,
  112. series : [
  113. {
  114. name:'销量',
  115. type:'line',
  116. symbol: 'emptyCircle',
  117. symbolSize: 6,
  118. showAllSymbol:true,
  119. smooth:true,
  120. itemStyle: {normal: {areaStyle: {type: 'default'}}},
  121. data: dataArray
  122. },
  123. {
  124. name:'遮罩',
  125. type:'pie',
  126. clickable:false,
  127. tooltip: {show:false},
  128. radius : [100, 180],
  129. itemStyle: {
  130. normal: {color: '#fff',label:{show:false},labelLine:{show:false}},
  131. emphasis: {color:'rgba(0,0,0,0)'}
  132. },
  133. data:[
  134. {value:100, name:'直接访问'}
  135. ]
  136. },
  137. {
  138. name:'占比',
  139. type:'pie',
  140. clickable: false,
  141. clockWise: true,
  142. radius : [110, 125],
  143. data:[
  144. {
  145. itemStyle: {normal: {
  146. label:{
  147. position:'inside',
  148. formatter: '\n{b} : {c}\n\n( {d}% )',
  149. textStyle: {
  150. fontSize: 15,
  151. baseline: 'top',
  152. color: '#1e90ff'
  153. }
  154. },
  155. labelLine:{show:false}
  156. }}
  157. },
  158. {
  159. name:'其他',
  160. tooltip: {show:false},
  161. itemStyle: {normal: {color: '#fff',label:{show:false},labelLine:{show:false}}}
  162. }
  163. ]
  164. }
  165. ]
  166. };
  167. function changePieSeries(params) {
  168. var curData = params.value - gap;
  169. option.series[2].startAngle = -90 + (curData / total * 360) / 2;
  170. option.series[2].data[0].name = params.name;
  171. option.series[2].data[0].value = curData;
  172. option.series[2].data[1].value = total - curData;
  173. for (var i = 1, l = option.series[0].data.length - 1; i < l; i++) {
  174. if (option.series[0].data[i].symbol) {
  175. option.series[0].data[i].symbol = 'emptyCircle';
  176. option.series[0].data[i].symbolSize = 6;
  177. }
  178. }
  179. option.series[0].data[params.dataIndex] = {
  180. name : params.name,
  181. value : params.value,
  182. symbol: 'emptyDiamond',
  183. symbolSize: 10
  184. }
  185. }
  186. function update(params){
  187. changePieSeries(params);
  188. option.animation = true;
  189. myChart.setOption(option);
  190. }
  191. changePieSeries({
  192. name : option.xAxis[0].data[maxIndex + 1],
  193. value : option.series[0].data[maxIndex + 1],
  194. dataIndex: maxIndex + 1
  195. });
  196. </textarea>
  197. </div><!--/.well -->
  198. </div><!--/span-->
  199. <div id="graphic" class="col-md-8">
  200. <div id="main" class="main" style="width:400px;"></div>
  201. <div>
  202. <button type="button" class="btn btn-sm btn-success" onclick="refresh(true)">刷 新</button>
  203. <span class="text-primary">切换主题</span>
  204. <select id="theme-select"></select>
  205. <span id='wrong-message' style="color:red"></span>
  206. </div>
  207. </div><!--/span-->
  208. </div><!--/row-->
  209. </div><!--/.fluid-container-->
  210. <footer id="footer"></footer>
  211. <!-- Le javascript
  212. ================================================== -->
  213. <!-- Placed at the end of the document so the pages load faster -->
  214. <script src="../asset/js/jquery.min.js"></script>
  215. <script type="text/javascript" src="../asset/js/echartsHome.js"></script>
  216. <script src="../asset/js/bootstrap.min.js"></script>
  217. <script src="../asset/js/echartsExample.js"></script>
  218. </body>
  219. </html>