media-finance.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  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. .code-panel {
  27. position: fixed;
  28. top: 10px;
  29. right: 10px;
  30. width: 200px;
  31. border: 2px solid #555;
  32. }
  33. .code-line {
  34. margin: 15px 5px;
  35. font-size: 12px;
  36. }
  37. .code-line textarea{
  38. width: 190px;
  39. height: 80px;
  40. margin-bottom: 5px;
  41. }
  42. </style>
  43. <div id="main"></div>
  44. <div class="code-panel">
  45. <div class="code-line">
  46. <textarea id="code1">
  47. chart.setOption({backgroundColor: '#000'});
  48. </textarea>
  49. <input type="button" value="run" onclick="runCode('code1');"/>
  50. Then press restore buttton.
  51. </div>
  52. <div class="code-line">
  53. <textarea id="code2">
  54. chart.setOption({backgroundColor: '#fff'});
  55. </textarea>
  56. <input type="button" value="run" onclick="runCode('code2');"/>
  57. </div>
  58. <div class="code-line">
  59. <textarea id="code3">
  60. chart.setOption({
  61. series: [
  62. {id: 'pie0', label: {normal: {position: 'inside'}}}
  63. ]
  64. });
  65. </textarea>
  66. <input type="button" value="run" onclick="runCode('code3');"/>
  67. </div>
  68. <div class="code-line">
  69. <textarea id="code4">
  70. chart.setOption({
  71. timeline: {
  72. currentIndex: 5
  73. }
  74. });
  75. </textarea>
  76. <input type="button" value="run" onclick="runCode('code4');"/>
  77. </div>
  78. </div>
  79. <script src="data/timelineGDP.js"></script>
  80. <script>
  81. var chart;
  82. var echarts;
  83. // markLine: {
  84. // symbol: ['arrow','none'],
  85. // symbolSize: [4, 2],
  86. // itemStyle: {
  87. // normal: {
  88. // lineStyle: {color:'orange'},
  89. // barBorderColor:'orange',
  90. // label: {
  91. // position:'left',
  92. // formatter:function(params){
  93. // return Math.round(params.value);
  94. // },
  95. // textStyle:{color:'orange'}
  96. // }
  97. // }
  98. // },
  99. // data: [{type: 'average', name: '平均值'}]
  100. // }
  101. require([
  102. 'echarts',
  103. 'echarts/chart/bar',
  104. 'echarts/chart/pie',
  105. 'echarts/component/title',
  106. 'echarts/component/legend',
  107. 'echarts/component/grid',
  108. 'echarts/component/tooltip',
  109. 'echarts/component/timeline',
  110. 'echarts/component/toolbox'
  111. ], function (ec) {
  112. echarts = ec;
  113. chart = echarts.init(document.getElementById('main'), null, {
  114. renderer: 'canvas'
  115. });
  116. draggable.init(
  117. document.getElementById('main'),
  118. chart,
  119. {throttle: 70}
  120. );
  121. var categoryData = [
  122. '北京','天津','河北','山西','内蒙古','辽宁','吉林','黑龙江',
  123. '上海','江苏','浙江','安徽','福建','江西','山东','河南',
  124. '湖北','湖南','广东','广西','海南','重庆','四川','贵州',
  125. '云南','西藏','陕西','甘肃','青海','宁夏','新疆'
  126. ];
  127. var categoryDataWithReturn = [];
  128. for (var i = 0; i < categoryData.length; i++) {
  129. var word = categoryData[i];
  130. if (i % 2 === 0) {
  131. word = '\n' + word;
  132. }
  133. categoryDataWithReturn.push(word);
  134. }
  135. var categoryData = [
  136. '北京','天津','河北','山西','内蒙古','辽宁','吉林','黑龙江',
  137. '上海','江苏','浙江','安徽','福建','江西','山东','河南',
  138. '湖北','湖南','广东','广西','海南','重庆','四川','贵州',
  139. '云南','西藏','陕西','甘肃','青海','宁夏','新疆'
  140. ];
  141. option = {
  142. baseOption: {
  143. timeline: {
  144. axisType: 'category',
  145. autoPlay: true,
  146. playInterval: 1000,
  147. data: [
  148. '2002-01-01', '2003-01-01', '2004-01-01',
  149. '2005-01-01', '2006-01-01', '2007-01-01',
  150. '2008-01-01', '2009-01-01', '2010-01-01',
  151. '2011-01-01'
  152. ],
  153. label: {
  154. formatter : function(s) {
  155. return (new Date(s)).getFullYear();
  156. }
  157. }
  158. },
  159. toolbox: {
  160. left: 0,
  161. bottom: 0,
  162. feature: {
  163. restore: {}
  164. }
  165. },
  166. title: {
  167. subtext: 'Media Query 示例'
  168. },
  169. tooltip: {
  170. trigger:'axis',
  171. axisPointer: {
  172. type: 'shadow'
  173. }
  174. },
  175. xAxis: {
  176. type: 'value',
  177. name: 'GDP(亿元)',
  178. max: 30000,
  179. data: null
  180. },
  181. yAxis: {
  182. type: 'category',
  183. data: categoryData,
  184. axisLabel: {interval: 0},
  185. splitLine: {show: false}
  186. },
  187. legend: {
  188. data: ['第一产业', '第二产业', '第三产业', 'GDP', '金融', '房地产'],
  189. selected: {
  190. 'GDP': false, '金融': false, '房地产': false
  191. }
  192. },
  193. calculable : true,
  194. series: [
  195. {name: 'GDP', type: 'bar'},
  196. {name: '金融', type: 'bar'},
  197. {name: '房地产', type: 'bar'},
  198. {name: '第一产业', type: 'bar'},
  199. {name: '第二产业', type: 'bar'},
  200. {name: '第三产业', type: 'bar'},
  201. {name: 'GDP占比', type: 'pie', id: 'pie0'}
  202. ]
  203. },
  204. media: [
  205. {
  206. option: {
  207. legend: {
  208. orient: 'horizontal',
  209. left: 'right',
  210. itemGap: 10
  211. },
  212. grid: {
  213. left: '10%',
  214. top: 80,
  215. right: 90,
  216. bottom: 100
  217. },
  218. xAxis: {
  219. nameLocation: 'end',
  220. nameGap: 10,
  221. splitLine: {
  222. show: true
  223. },
  224. axisLabel: {
  225. interval: 'auto'
  226. }
  227. },
  228. timeline: {
  229. show: true,
  230. orient: 'horizontal',
  231. inverse: false,
  232. left: '20%',
  233. right: '20%',
  234. bottom: 10,
  235. height: 40
  236. },
  237. series: [
  238. {name: 'GDP占比', center: ['75%', '30%'], radius: '28%'}
  239. ]
  240. }
  241. },
  242. {
  243. query: {maxWidth: 670, minWidth: 550},
  244. option: {
  245. legend: {
  246. orient: 'horizontal',
  247. left: 200,
  248. itemGap: 5
  249. },
  250. grid: {
  251. left: '10%',
  252. top: 80,
  253. right: 90,
  254. bottom: 100
  255. },
  256. xAxis: {
  257. nameLocation: 'end',
  258. nameGap: 10,
  259. splitLine: {
  260. show: true
  261. },
  262. axisLabel: {
  263. interval: 'auto'
  264. }
  265. },
  266. timeline: {
  267. show: true,
  268. orient: 'horizontal',
  269. inverse: false,
  270. left: '20%',
  271. right: '20%',
  272. bottom: 10,
  273. height: 40
  274. },
  275. series: [
  276. {name: 'GDP占比', center: ['75%', '30%'], radius: '28%'}
  277. ]
  278. }
  279. },
  280. {
  281. query: {maxWidth: 550},
  282. option: {
  283. legend: {
  284. orient: 'vertical',
  285. left: 'right',
  286. itemGap: 5
  287. },
  288. grid: {
  289. left: 55,
  290. top: '32%',
  291. right: 100,
  292. bottom: 50
  293. },
  294. xAxis: {
  295. nameLocation: 'middle',
  296. nameGap: 25,
  297. axisLabel: {
  298. interval: 1
  299. }
  300. },
  301. timeline: {
  302. show: true,
  303. orient: 'vertical',
  304. inverse: true,
  305. right: 10,
  306. top: 150,
  307. bottom: 10,
  308. width: 55
  309. },
  310. series: [
  311. {name: 'GDP占比', center: ['45%', '20%'], radius: '28%'}
  312. ]
  313. }
  314. },
  315. {
  316. query: {maxWidth: 350},
  317. option: {
  318. legend: {
  319. orient: 'vertical',
  320. left: 'right',
  321. itemGap: 5
  322. },
  323. grid: {
  324. left: 55,
  325. top: '32%',
  326. right: 100,
  327. bottom: 50
  328. },
  329. xAxis: {
  330. nameLocation: 'middle',
  331. nameGap: 25,
  332. axisLabel: {
  333. interval: 1
  334. }
  335. },
  336. timeline: {
  337. show: false
  338. },
  339. series: [
  340. {name: 'GDP占比', center: ['45%', '20%'], radius: '28%'}
  341. ]
  342. }
  343. }
  344. ],
  345. options: [
  346. {
  347. title: {text: '2002全国宏观经济指标'},
  348. series: [
  349. {data: dataMap.dataGDP['2002']},
  350. {data: dataMap.dataFinancial['2002']},
  351. {data: dataMap.dataEstate['2002']},
  352. {data: dataMap.dataPI['2002']},
  353. {data: dataMap.dataSI['2002']},
  354. {data: dataMap.dataTI['2002']},
  355. {data: [
  356. {name: '第一产业', value: dataMap.dataPI['2002sum']},
  357. {name: '第二产业', value: dataMap.dataSI['2002sum']},
  358. {name: '第三产业', value: dataMap.dataTI['2002sum']}
  359. ], id: 'pie0'}
  360. ]
  361. },
  362. {
  363. title : {text: '2003全国宏观经济指标'},
  364. series : [
  365. {data: dataMap.dataGDP['2003']},
  366. {data: dataMap.dataFinancial['2003']},
  367. {data: dataMap.dataEstate['2003']},
  368. {data: dataMap.dataPI['2003']},
  369. {data: dataMap.dataSI['2003']},
  370. {data: dataMap.dataTI['2003']},
  371. {data: [
  372. {name: '第一产业', value: dataMap.dataPI['2003sum']},
  373. {name: '第二产业', value: dataMap.dataSI['2003sum']},
  374. {name: '第三产业', value: dataMap.dataTI['2003sum']}
  375. ], id: 'pie0'}
  376. ]
  377. },
  378. {
  379. title : {text: '2004全国宏观经济指标'},
  380. series : [
  381. {data: dataMap.dataGDP['2004']},
  382. {data: dataMap.dataFinancial['2004']},
  383. {data: dataMap.dataEstate['2004']},
  384. {data: dataMap.dataPI['2004']},
  385. {data: dataMap.dataSI['2004']},
  386. {data: dataMap.dataTI['2004']},
  387. {data: [
  388. {name: '第一产业', value: dataMap.dataPI['2004sum']},
  389. {name: '第二产业', value: dataMap.dataSI['2004sum']},
  390. {name: '第三产业', value: dataMap.dataTI['2004sum']}
  391. ], id: 'pie0'}
  392. ]
  393. },
  394. {
  395. title : {text: '2005全国宏观经济指标'},
  396. series : [
  397. {data: dataMap.dataGDP['2005']},
  398. {data: dataMap.dataFinancial['2005']},
  399. {data: dataMap.dataEstate['2005']},
  400. {data: dataMap.dataPI['2005']},
  401. {data: dataMap.dataSI['2005']},
  402. {data: dataMap.dataTI['2005']},
  403. {data: [
  404. {name: '第一产业', value: dataMap.dataPI['2005sum']},
  405. {name: '第二产业', value: dataMap.dataSI['2005sum']},
  406. {name: '第三产业', value: dataMap.dataTI['2005sum']}
  407. ], id: 'pie0'}
  408. ]
  409. },
  410. {
  411. title : {text: '2006全国宏观经济指标'},
  412. series : [
  413. {data: dataMap.dataGDP['2006']},
  414. {data: dataMap.dataFinancial['2006']},
  415. {data: dataMap.dataEstate['2006']},
  416. {data: dataMap.dataPI['2006']},
  417. {data: dataMap.dataSI['2006']},
  418. {data: dataMap.dataTI['2006']},
  419. {data: [
  420. {name: '第一产业', value: dataMap.dataPI['2006sum']},
  421. {name: '第二产业', value: dataMap.dataSI['2006sum']},
  422. {name: '第三产业', value: dataMap.dataTI['2006sum']}
  423. ], id: 'pie0'}
  424. ]
  425. },
  426. {
  427. title : {text: '2007全国宏观经济指标'},
  428. series : [
  429. {data: dataMap.dataGDP['2007']},
  430. {data: dataMap.dataFinancial['2007']},
  431. {data: dataMap.dataEstate['2007']},
  432. {data: dataMap.dataPI['2007']},
  433. {data: dataMap.dataSI['2007']},
  434. {data: dataMap.dataTI['2007']},
  435. {data: [
  436. {name: '第一产业', value: dataMap.dataPI['2007sum']},
  437. {name: '第二产业', value: dataMap.dataSI['2007sum']},
  438. {name: '第三产业', value: dataMap.dataTI['2007sum']}
  439. ], id: 'pie0'}
  440. ]
  441. },
  442. {
  443. title : {text: '2008全国宏观经济指标'},
  444. series : [
  445. {data: dataMap.dataGDP['2008']},
  446. {data: dataMap.dataFinancial['2008']},
  447. {data: dataMap.dataEstate['2008']},
  448. {data: dataMap.dataPI['2008']},
  449. {data: dataMap.dataSI['2008']},
  450. {data: dataMap.dataTI['2008']},
  451. {data: [
  452. {name: '第一产业', value: dataMap.dataPI['2008sum']},
  453. {name: '第二产业', value: dataMap.dataSI['2008sum']},
  454. {name: '第三产业', value: dataMap.dataTI['2008sum']}
  455. ], id: 'pie0'}
  456. ]
  457. },
  458. {
  459. title : {text: '2009全国宏观经济指标'},
  460. series : [
  461. {data: dataMap.dataGDP['2009']},
  462. {data: dataMap.dataFinancial['2009']},
  463. {data: dataMap.dataEstate['2009']},
  464. {data: dataMap.dataPI['2009']},
  465. {data: dataMap.dataSI['2009']},
  466. {data: dataMap.dataTI['2009']},
  467. {data: [
  468. {name: '第一产业', value: dataMap.dataPI['2009sum']},
  469. {name: '第二产业', value: dataMap.dataSI['2009sum']},
  470. {name: '第三产业', value: dataMap.dataTI['2009sum']}
  471. ], id: 'pie0'}
  472. ]
  473. },
  474. {
  475. title : {text: '2010全国宏观经济指标'},
  476. series : [
  477. {data: dataMap.dataGDP['2010']},
  478. {data: dataMap.dataFinancial['2010']},
  479. {data: dataMap.dataEstate['2010']},
  480. {data: dataMap.dataPI['2010']},
  481. {data: dataMap.dataSI['2010']},
  482. {data: dataMap.dataTI['2010']},
  483. {data: [
  484. {name: '第一产业', value: dataMap.dataPI['2010sum']},
  485. {name: '第二产业', value: dataMap.dataSI['2010sum']},
  486. {name: '第三产业', value: dataMap.dataTI['2010sum']}
  487. ], id: 'pie0'}
  488. ]
  489. },
  490. {
  491. title : {text: '2011全国宏观经济指标'},
  492. series : [
  493. {data: dataMap.dataGDP['2011']},
  494. {data: dataMap.dataFinancial['2011']},
  495. {data: dataMap.dataEstate['2011']},
  496. {data: dataMap.dataPI['2011']},
  497. {data: dataMap.dataSI['2011']},
  498. {data: dataMap.dataTI['2011']},
  499. {data: [
  500. {name: '第一产业', value: dataMap.dataPI['2011sum']},
  501. {name: '第二产业', value: dataMap.dataSI['2011sum']},
  502. {name: '第三产业', value: dataMap.dataTI['2011sum']}
  503. ], id: 'pie0'}
  504. ]
  505. }
  506. ]
  507. };
  508. chart.setOption(option);
  509. chart.on('legendSelected', function () {
  510. });
  511. window.onresize = chart.resize;
  512. });
  513. </script>
  514. <script type="text/javascript">
  515. function runCode(id) {
  516. var textarea = document.getElementById(id);
  517. var code = textarea.value;
  518. (new Function('chart', 'echarts', code))(chart, echarts);
  519. }
  520. </script>
  521. </body>
  522. </html>