timeline-finance.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="esl.js"></script>
  5. <script src="config.js"></script>
  6. <meta name="viewport" content="width=device-width, initial-scale=1" />
  7. </head>
  8. <body>
  9. <style>
  10. html, body, #main {
  11. width: 100%;
  12. height: 100%;
  13. margin: 0;
  14. }
  15. #main {
  16. background: #fff;
  17. }
  18. </style>
  19. <div id="main"></div>
  20. <script src="data/timelineGDP.js"></script>
  21. <script>
  22. // markLine: {
  23. // symbol: ['arrow','none'],
  24. // symbolSize: [4, 2],
  25. // itemStyle: {
  26. // normal: {
  27. // lineStyle: {color:'orange'},
  28. // barBorderColor:'orange',
  29. // label: {
  30. // position:'left',
  31. // formatter:function(params){
  32. // return Math.round(params.value);
  33. // },
  34. // textStyle:{color:'orange'}
  35. // }
  36. // }
  37. // },
  38. // data: [{type: 'average', name: '平均值'}]
  39. // }
  40. require([
  41. 'echarts',
  42. 'echarts/chart/bar',
  43. 'echarts/chart/pie',
  44. 'echarts/component/title',
  45. 'echarts/component/legend',
  46. 'echarts/component/grid',
  47. 'echarts/component/tooltip',
  48. 'echarts/component/timeline'
  49. ], function (echarts) {
  50. var chart = echarts.init(document.getElementById('main'), null, {
  51. renderer: 'canvas'
  52. });
  53. var option = {
  54. baseOption: {
  55. timeline: {
  56. // y: 0,
  57. axisType: 'category',
  58. // realtime: false,
  59. // loop: false,
  60. autoPlay: true,
  61. // currentIndex: 2,
  62. playInterval: 1000,
  63. // controlStyle: {
  64. // position: 'left'
  65. // },
  66. data: [
  67. '2002-01-01','2003-01-01','2004-01-01',
  68. {
  69. value: '2005-01-01',
  70. tooltip: {
  71. formatter: '{b} GDP达到一个高度'
  72. },
  73. symbol: 'diamond',
  74. symbolSize: 16,
  75. },
  76. '2006-01-01', '2007-01-01','2008-01-01','2009-01-01','2010-01-01',
  77. {
  78. value: '2011-01-01',
  79. tooltip: {
  80. formatter: function (params) {
  81. return params.name + 'GDP达到又一个高度';
  82. }
  83. },
  84. symbol: 'diamond',
  85. symbolSize: 18
  86. },
  87. ],
  88. label: {
  89. formatter : function(s) {
  90. return (new Date(s)).getFullYear();
  91. }
  92. }
  93. },
  94. title: {
  95. subtext: '数据来自国家统计局'
  96. },
  97. tooltip: {
  98. trigger:'axis',
  99. axisPointer: {
  100. type: 'shadow'
  101. }
  102. },
  103. legend: {
  104. align: 'right',
  105. x: 'right',
  106. data: ['第一产业', '第二产业', '第三产业', 'GDP', '金融', '房地产'],
  107. selected: {
  108. 'GDP': false, '金融': false, '房地产': false
  109. }
  110. },
  111. calculable: true,
  112. grid: {
  113. top:80, bottom: 100
  114. },
  115. xAxis: {
  116. 'type':'category',
  117. 'axisLabel':{'interval':0},
  118. 'data':[
  119. '北京','\n天津','河北','\n山西','内蒙古','\n辽宁','吉林','\n黑龙江',
  120. '上海','\n江苏','浙江','\n安徽','福建','\n江西','山东','\n河南',
  121. '湖北','\n湖南','广东','\n广西','海南','\n重庆','四川','\n贵州',
  122. '云南','\n西藏','陕西','\n甘肃','青海','\n宁夏','新疆'
  123. ],
  124. splitLine: {show: false}
  125. },
  126. yAxis: [
  127. {
  128. type: 'value',
  129. name: 'GDP(亿元)',
  130. // max: 53500
  131. max: 30000
  132. }
  133. ],
  134. series: [
  135. {name: 'GDP', type: 'bar'},
  136. {name: '金融', type: 'bar'},
  137. {name: '房地产', type: 'bar'},
  138. {name: '第一产业', type: 'bar'},
  139. {name: '第二产业', type: 'bar'},
  140. {name: '第三产业', type: 'bar'},
  141. {
  142. name: 'GDP占比',
  143. type: 'pie',
  144. center: ['75%', '35%'],
  145. radius: '28%'
  146. }
  147. ]
  148. },
  149. options: [
  150. {
  151. title: {text: '2002全国宏观经济指标'},
  152. series: [
  153. {data: dataMap.dataGDP['2002']},
  154. {data: dataMap.dataFinancial['2002']},
  155. {data: dataMap.dataEstate['2002']},
  156. {data: dataMap.dataPI['2002']},
  157. {data: dataMap.dataSI['2002']},
  158. {data: dataMap.dataTI['2002']},
  159. {data: [
  160. {name: '第一产业', value: dataMap.dataPI['2002sum']},
  161. {name: '第二产业', value: dataMap.dataSI['2002sum']},
  162. {name: '第三产业', value: dataMap.dataTI['2002sum']}
  163. ]}
  164. ]
  165. },
  166. {
  167. title : {text: '2003全国宏观经济指标'},
  168. series : [
  169. {data: dataMap.dataGDP['2003']},
  170. {data: dataMap.dataFinancial['2003']},
  171. {data: dataMap.dataEstate['2003']},
  172. {data: dataMap.dataPI['2003']},
  173. {data: dataMap.dataSI['2003']},
  174. {data: dataMap.dataTI['2003']},
  175. {data: [
  176. {name: '第一产业', value: dataMap.dataPI['2003sum']},
  177. {name: '第二产业', value: dataMap.dataSI['2003sum']},
  178. {name: '第三产业', value: dataMap.dataTI['2003sum']}
  179. ]}
  180. ]
  181. },
  182. {
  183. title : {text: '2004全国宏观经济指标'},
  184. series : [
  185. {data: dataMap.dataGDP['2004']},
  186. {data: dataMap.dataFinancial['2004']},
  187. {data: dataMap.dataEstate['2004']},
  188. {data: dataMap.dataPI['2004']},
  189. {data: dataMap.dataSI['2004']},
  190. {data: dataMap.dataTI['2004']},
  191. {data: [
  192. {name: '第一产业', value: dataMap.dataPI['2004sum']},
  193. {name: '第二产业', value: dataMap.dataSI['2004sum']},
  194. {name: '第三产业', value: dataMap.dataTI['2004sum']}
  195. ]}
  196. ]
  197. },
  198. {
  199. title : {text: '2005全国宏观经济指标'},
  200. series : [
  201. {data: dataMap.dataGDP['2005']},
  202. {data: dataMap.dataFinancial['2005']},
  203. {data: dataMap.dataEstate['2005']},
  204. {data: dataMap.dataPI['2005']},
  205. {data: dataMap.dataSI['2005']},
  206. {data: dataMap.dataTI['2005']},
  207. {data: [
  208. {name: '第一产业', value: dataMap.dataPI['2005sum']},
  209. {name: '第二产业', value: dataMap.dataSI['2005sum']},
  210. {name: '第三产业', value: dataMap.dataTI['2005sum']}
  211. ]}
  212. ]
  213. },
  214. {
  215. title : {text: '2006全国宏观经济指标'},
  216. series : [
  217. {data: dataMap.dataGDP['2006']},
  218. {data: dataMap.dataFinancial['2006']},
  219. {data: dataMap.dataEstate['2006']},
  220. {data: dataMap.dataPI['2006']},
  221. {data: dataMap.dataSI['2006']},
  222. {data: dataMap.dataTI['2006']},
  223. {data: [
  224. {name: '第一产业', value: dataMap.dataPI['2006sum']},
  225. {name: '第二产业', value: dataMap.dataSI['2006sum']},
  226. {name: '第三产业', value: dataMap.dataTI['2006sum']}
  227. ]}
  228. ]
  229. },
  230. {
  231. title : {text: '2007全国宏观经济指标'},
  232. series : [
  233. {data: dataMap.dataGDP['2007']},
  234. {data: dataMap.dataFinancial['2007']},
  235. {data: dataMap.dataEstate['2007']},
  236. {data: dataMap.dataPI['2007']},
  237. {data: dataMap.dataSI['2007']},
  238. {data: dataMap.dataTI['2007']},
  239. {data: [
  240. {name: '第一产业', value: dataMap.dataPI['2007sum']},
  241. {name: '第二产业', value: dataMap.dataSI['2007sum']},
  242. {name: '第三产业', value: dataMap.dataTI['2007sum']}
  243. ]}
  244. ]
  245. },
  246. {
  247. title : {text: '2008全国宏观经济指标'},
  248. series : [
  249. {data: dataMap.dataGDP['2008']},
  250. {data: dataMap.dataFinancial['2008']},
  251. {data: dataMap.dataEstate['2008']},
  252. {data: dataMap.dataPI['2008']},
  253. {data: dataMap.dataSI['2008']},
  254. {data: dataMap.dataTI['2008']},
  255. {data: [
  256. {name: '第一产业', value: dataMap.dataPI['2008sum']},
  257. {name: '第二产业', value: dataMap.dataSI['2008sum']},
  258. {name: '第三产业', value: dataMap.dataTI['2008sum']}
  259. ]}
  260. ]
  261. },
  262. {
  263. title : {text: '2009全国宏观经济指标'},
  264. series : [
  265. {data: dataMap.dataGDP['2009']},
  266. {data: dataMap.dataFinancial['2009']},
  267. {data: dataMap.dataEstate['2009']},
  268. {data: dataMap.dataPI['2009']},
  269. {data: dataMap.dataSI['2009']},
  270. {data: dataMap.dataTI['2009']},
  271. {data: [
  272. {name: '第一产业', value: dataMap.dataPI['2009sum']},
  273. {name: '第二产业', value: dataMap.dataSI['2009sum']},
  274. {name: '第三产业', value: dataMap.dataTI['2009sum']}
  275. ]}
  276. ]
  277. },
  278. {
  279. title : {text: '2010全国宏观经济指标'},
  280. series : [
  281. {data: dataMap.dataGDP['2010']},
  282. {data: dataMap.dataFinancial['2010']},
  283. {data: dataMap.dataEstate['2010']},
  284. {data: dataMap.dataPI['2010']},
  285. {data: dataMap.dataSI['2010']},
  286. {data: dataMap.dataTI['2010']},
  287. {data: [
  288. {name: '第一产业', value: dataMap.dataPI['2010sum']},
  289. {name: '第二产业', value: dataMap.dataSI['2010sum']},
  290. {name: '第三产业', value: dataMap.dataTI['2010sum']}
  291. ]}
  292. ]
  293. },
  294. {
  295. title : {text: '2011全国宏观经济指标'},
  296. series : [
  297. {data: dataMap.dataGDP['2011']},
  298. {data: dataMap.dataFinancial['2011']},
  299. {data: dataMap.dataEstate['2011']},
  300. {data: dataMap.dataPI['2011']},
  301. {data: dataMap.dataSI['2011']},
  302. {data: dataMap.dataTI['2011']},
  303. {data: [
  304. {name: '第一产业', value: dataMap.dataPI['2011sum']},
  305. {name: '第二产业', value: dataMap.dataSI['2011sum']},
  306. {name: '第三产业', value: dataMap.dataTI['2011sum']}
  307. ]}
  308. ]
  309. }
  310. ]
  311. };
  312. chart.setOption(option);
  313. chart.on('legendSelected', function () {
  314. });
  315. chart.on('click', function (params) {
  316. console.log(params);
  317. });
  318. window.onresize = chart.resize;
  319. });
  320. </script>
  321. </body>
  322. </html>