pie2.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="lib/esl.js"></script>
  5. <script src="lib/config.js"></script>
  6. </head>
  7. <body>
  8. <style>
  9. html, body, #main {
  10. width: 100%;
  11. height: 100%;
  12. }
  13. </style>
  14. <div id="main"></div>
  15. <script>
  16. require([
  17. 'echarts'
  18. // 'echarts/chart/pie',
  19. // 'echarts/component/title',
  20. // 'echarts/component/legend',
  21. // 'echarts/component/grid',
  22. // 'echarts/component/tooltip'
  23. ], function (echarts) {
  24. var chart = echarts.init(document.getElementById('main'), null, {
  25. });
  26. var labelTop = {
  27. normal : {
  28. label : {
  29. show : true,
  30. position : 'center',
  31. formatter : '{b}',
  32. textStyle: {
  33. baseline : 'bottom'
  34. }
  35. },
  36. labelLine : {
  37. show : false
  38. }
  39. }
  40. };
  41. var labelFromatter = {
  42. normal : {
  43. label : {
  44. formatter : function (params){
  45. return 100 - params.value + '%'
  46. },
  47. textStyle: {
  48. baseline : 'top'
  49. }
  50. }
  51. },
  52. }
  53. var labelBottom = {
  54. normal : {
  55. color: '#ccc',
  56. label : {
  57. show : true,
  58. position : 'center'
  59. },
  60. labelLine : {
  61. show : false
  62. }
  63. }
  64. };
  65. var radius = [40, 55];
  66. chart.setOption({
  67. legend: {
  68. left: 'center',
  69. top: 'center',
  70. data:[
  71. 'GoogleMaps','Facebook','Youtube','Google+','Weixin',
  72. 'Twitter', 'Skype', 'Messenger', 'Whatsapp', 'Instagram'
  73. ]
  74. },
  75. title: {
  76. text: 'The App World',
  77. subtext: 'from global web index',
  78. x: 'center'
  79. },
  80. toolbox: {
  81. show : true,
  82. feature : {
  83. dataView : {show: true, readOnly: false},
  84. magicType : {
  85. show: true,
  86. type: ['pie', 'funnel'],
  87. option: {
  88. funnel: {
  89. width: '20%',
  90. height: '30%',
  91. itemStyle : {
  92. normal : {
  93. label : {
  94. formatter : function (params){
  95. return 'other\n' + params.value + '%\n'
  96. },
  97. textStyle: {
  98. baseline : 'middle'
  99. }
  100. }
  101. },
  102. }
  103. }
  104. }
  105. },
  106. restore : {show: true},
  107. saveAsImage : {show: true}
  108. }
  109. },
  110. series : [
  111. {
  112. type : 'pie',
  113. center : ['10%', '30%'],
  114. radius : radius,
  115. itemStyle : labelFromatter,
  116. data : [
  117. {name:'other', value:46, itemStyle : labelBottom},
  118. {name:'GoogleMaps', value:54,itemStyle : labelTop}
  119. ]
  120. },
  121. {
  122. type : 'pie',
  123. center : ['30%', '30%'],
  124. radius : radius,
  125. itemStyle : labelFromatter,
  126. data : [
  127. {name:'other', value:56, itemStyle : labelBottom},
  128. {name:'Facebook', value:44,itemStyle : labelTop}
  129. ]
  130. },
  131. {
  132. type : 'pie',
  133. center : ['50%', '30%'],
  134. radius : radius,
  135. itemStyle : labelFromatter,
  136. data : [
  137. {name:'other', value:65, itemStyle : labelBottom},
  138. {name:'Youtube', value:35,itemStyle : labelTop}
  139. ]
  140. },
  141. {
  142. type : 'pie',
  143. center : ['70%', '30%'],
  144. radius : radius,
  145. itemStyle : labelFromatter,
  146. data : [
  147. {name:'other', value:70, itemStyle : labelBottom},
  148. {name:'Google+', value:30,itemStyle : labelTop}
  149. ]
  150. },
  151. {
  152. type : 'pie',
  153. center : ['90%', '30%'],
  154. radius : radius,
  155. itemStyle : labelFromatter,
  156. data : [
  157. {name:'other', value:73, itemStyle : labelBottom},
  158. {name:'Weixin', value:27,itemStyle : labelTop}
  159. ]
  160. },
  161. {
  162. type : 'pie',
  163. center : ['10%', '70%'],
  164. radius : radius,
  165. itemStyle : labelFromatter,
  166. data : [
  167. {name:'other', value:78, itemStyle : labelBottom},
  168. {name:'Twitter', value:22,itemStyle : labelTop}
  169. ]
  170. },
  171. {
  172. type : 'pie',
  173. center : ['30%', '70%'],
  174. radius : radius,
  175. itemStyle : labelFromatter,
  176. data : [
  177. {name:'other', value:78, itemStyle : labelBottom},
  178. {name:'Skype', value:22,itemStyle : labelTop}
  179. ]
  180. },
  181. {
  182. type : 'pie',
  183. center : ['50%', '70%'],
  184. radius : radius,
  185. itemStyle : labelFromatter,
  186. data : [
  187. {name:'other', value:78, itemStyle : labelBottom},
  188. {name:'Messenger', value:22,itemStyle : labelTop}
  189. ]
  190. },
  191. {
  192. type : 'pie',
  193. center : ['70%', '70%'],
  194. radius : radius,
  195. itemStyle : labelFromatter,
  196. data : [
  197. {name:'other', value:83, itemStyle : labelBottom},
  198. {name:'Whatsapp', value:17,itemStyle : labelTop}
  199. ]
  200. },
  201. {
  202. type : 'pie',
  203. center : ['90%', '70%'],
  204. radius : radius,
  205. itemStyle : labelFromatter,
  206. data : [
  207. {name:'other', value:89, itemStyle : labelBottom},
  208. {name:'Instagram', value:11,itemStyle : labelTop}
  209. ]
  210. }
  211. ]
  212. });
  213. })
  214. </script>
  215. </body>
  216. </html>