pie2.html 9.0 KB

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