pie3.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. option = {
  36. tooltip : {
  37. trigger: 'item',
  38. formatter: "{a} <br/>{b} : {c} ({d}%)"
  39. },
  40. legend: {
  41. orient : 'vertical',
  42. x : 'left',
  43. data:['直达','营销广告','搜索引擎','邮件营销','联盟广告','视频广告','百度','谷歌','必应','其他']
  44. },
  45. toolbox: {
  46. show : true,
  47. feature : {
  48. mark : {show: true},
  49. dataView : {show: true, readOnly: false},
  50. magicType : {
  51. show: true,
  52. type: ['pie', 'funnel']
  53. },
  54. restore : {show: true},
  55. saveAsImage : {show: true}
  56. }
  57. },
  58. calculable : false,
  59. series : [
  60. {
  61. name:'访问来源',
  62. type:'pie',
  63. selectedMode: 'single',
  64. radius : [0, 70],
  65. // for funnel
  66. x: '20%',
  67. width: '40%',
  68. funnelAlign: 'right',
  69. max: 1548,
  70. itemStyle : {
  71. normal : {
  72. label : {
  73. position : 'inner'
  74. },
  75. labelLine : {
  76. show : false
  77. }
  78. }
  79. },
  80. data:[
  81. {value:335, name:'直达'},
  82. {value:679, name:'营销广告'},
  83. {value:1548, name:'搜索引擎', selected:true}
  84. ]
  85. },
  86. {
  87. name:'访问来源',
  88. type:'pie',
  89. radius : [100, 140],
  90. // for funnel
  91. x: '60%',
  92. width: '35%',
  93. funnelAlign: 'left',
  94. max: 1048,
  95. data:[
  96. {value:335, name:'直达'},
  97. {value:310, name:'邮件营销'},
  98. {value:234, name:'联盟广告'},
  99. {value:135, name:'视频广告'},
  100. {value:1048, name:'百度'},
  101. {value:251, name:'谷歌'},
  102. {value:147, name:'必应'},
  103. {value:102, name:'其他'}
  104. ]
  105. }
  106. ]
  107. };
  108. var ecConfig = require('echarts/config');
  109. myChart.on(ecConfig.EVENT.PIE_SELECTED, function (param){
  110. var selected = param.selected;
  111. var serie;
  112. var str = '当前选择: ';
  113. for (var idx in selected) {
  114. serie = option.series[idx];
  115. for (var i = 0, l = serie.data.length; i < l; i++) {
  116. if (selected[idx][i]) {
  117. str += '【系列' + idx + '】' + serie.name + ' : ' +
  118. '【数据' + i + '】' + serie.data[i].name + ' ';
  119. }
  120. }
  121. }
  122. document.getElementById('wrong-message').innerHTML = str;
  123. })
  124. </textarea>
  125. </div><!--/.well -->
  126. </div><!--/span-->
  127. <div id="graphic" class="col-md-8">
  128. <div id="main" class="main"></div>
  129. <div>
  130. <button type="button" class="btn btn-sm btn-success" onclick="refresh(true)">刷 新</button>
  131. <span class="text-primary">切换主题</span>
  132. <select id="theme-select"></select>
  133. <span id='wrong-message' style="color:red"></span>
  134. </div>
  135. </div><!--/span-->
  136. </div><!--/row-->
  137. </div><!--/.fluid-container-->
  138. <footer id="footer"></footer>
  139. <!-- Le javascript
  140. ================================================== -->
  141. <!-- Placed at the end of the document so the pages load faster -->
  142. <script src="../asset/js/jquery.min.js"></script>
  143. <script type="text/javascript" src="../asset/js/echartsHome.js"></script>
  144. <script src="../asset/js/bootstrap.min.js"></script>
  145. <script src="../asset/js/echartsExample.js"></script>
  146. </body>
  147. </html>