media-pie.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="esl.js"></script>
  5. <script src="config.js"></script>
  6. <script src="lib/jquery.min.js"></script>
  7. <script src="lib/draggable.js"></script>
  8. <link rel="stylesheet" href="reset.css">
  9. <meta name="viewport" content="width=device-width, initial-scale=1" />
  10. </head>
  11. <body>
  12. <style>
  13. body {
  14. position: absolute;
  15. left: 0;
  16. top: 0;
  17. }
  18. #main {
  19. position: absolute;
  20. top: 10px;
  21. left: 10px;
  22. width: 700px;
  23. height: 650px;
  24. background: #fff;
  25. }
  26. </style>
  27. <div id="main"></div>
  28. <script src="data/timelineGDP.js"></script>
  29. <script>
  30. require([
  31. 'echarts',
  32. 'echarts/chart/pie',
  33. 'echarts/component/title',
  34. 'echarts/component/legend',
  35. 'echarts/component/tooltip'
  36. ], function (echarts) {
  37. chart = echarts.init(document.getElementById('main'), null, {
  38. renderer: 'canvas'
  39. });
  40. draggable.init(
  41. document.getElementById('main'),
  42. chart,
  43. {throttle: 70}
  44. );
  45. option = {
  46. baseOption: {
  47. title : {
  48. text: '南丁格尔玫瑰图',
  49. subtext: '纯属虚构',
  50. x:'center'
  51. },
  52. tooltip : {
  53. trigger: 'item',
  54. formatter: "{a} <br/>{b} : {c} ({d}%)"
  55. },
  56. legend: {
  57. data:['rose1','rose2','rose3','rose4','rose5','rose6','rose7','rose8']
  58. },
  59. toolbox: {
  60. show : true,
  61. feature : {
  62. mark : {show: true},
  63. dataView : {show: true, readOnly: false},
  64. magicType : {
  65. show: true,
  66. type: ['pie', 'funnel']
  67. },
  68. restore : {show: true},
  69. saveAsImage : {show: true}
  70. }
  71. },
  72. calculable : true,
  73. series : [
  74. {
  75. name:'半径模式',
  76. type:'pie',
  77. roseType : 'radius',
  78. label: {
  79. normal: {
  80. show: false
  81. },
  82. emphasis: {
  83. show: true
  84. }
  85. },
  86. lableLine: {
  87. normal: {
  88. show: false
  89. },
  90. emphasis: {
  91. show: true
  92. }
  93. },
  94. data:[
  95. {value:10, name:'rose1'},
  96. {value:5, name:'rose2'},
  97. {value:15, name:'rose3'},
  98. {value:25, name:'rose4'},
  99. {value:20, name:'rose5'},
  100. {value:35, name:'rose6'},
  101. {value:30, name:'rose7'},
  102. {value:40, name:'rose8'}
  103. ]
  104. },
  105. {
  106. name:'面积模式',
  107. type:'pie',
  108. roseType : 'area',
  109. data:[
  110. {value:10, name:'rose1'},
  111. {value:5, name:'rose2'},
  112. {value:15, name:'rose3'},
  113. {value:25, name:'rose4'},
  114. {value:20, name:'rose5'},
  115. {value:35, name:'rose6'},
  116. {value:30, name:'rose7'},
  117. {value:40, name:'rose8'}
  118. ]
  119. }
  120. ]
  121. },
  122. media: [
  123. {
  124. option: {
  125. legend: {
  126. right: 'center',
  127. bottom: 0,
  128. orient: 'horizontal'
  129. },
  130. series: [
  131. {
  132. radius: [20, 110],
  133. center: ['25%', 200]
  134. },
  135. {
  136. radius: [30, 110],
  137. center: ['75%', 200]
  138. }
  139. ]
  140. }
  141. },
  142. {
  143. query: {
  144. minAspectRatio: 1
  145. },
  146. option: {
  147. legend: {
  148. right: 'center',
  149. bottom: 0,
  150. orient: 'horizontal'
  151. },
  152. series: [
  153. {
  154. radius: [20, 110],
  155. center: ['25%', 200]
  156. },
  157. {
  158. radius: [30, 110],
  159. center: ['75%', 200]
  160. }
  161. ]
  162. }
  163. },
  164. {
  165. query: {
  166. maxAspectRatio: 1
  167. },
  168. option: {
  169. legend: {
  170. right: 'center',
  171. bottom: 0,
  172. orient: 'horizontal'
  173. },
  174. series: [
  175. {
  176. radius: [20, 110],
  177. center: [200, '30%']
  178. },
  179. {
  180. radius: [30, 110],
  181. center: [200, '70%']
  182. }
  183. ]
  184. }
  185. },
  186. {
  187. query: {
  188. maxWidth: 500
  189. },
  190. option: {
  191. legend: {
  192. right: 10,
  193. top: '15%',
  194. orient: 'vertical'
  195. },
  196. series: [
  197. {
  198. radius: [20, 110],
  199. center: [200, '30%']
  200. },
  201. {
  202. radius: [30, 110],
  203. center: [200, '75%']
  204. }
  205. ]
  206. }
  207. }
  208. ]
  209. };
  210. chart.setOption(option);
  211. chart.on('legendSelected', function () {
  212. });
  213. window.onresize = chart.resize;
  214. });
  215. </script>
  216. </body>
  217. </html>