option1.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. function option1 (curSelected) {
  2. var option = {
  3. color: ['#87cefa','#ff7f50','#da70d6','#32cd32','#6495ed',
  4. '#ff69b4','#ba55d3','#cd5c5c','#ffa500','#40e0d0',
  5. '#1e90ff','#ff6347','#7b68ee','#00fa9a','#ffd700',
  6. '#6699FF','#ff6666','#3cb371','#b8860b','#30e0e0'],
  7. title : {
  8. subtext: '数据来自国家统计局'
  9. },
  10. tooltip : {
  11. trigger: 'axis'
  12. },
  13. legend: {
  14. data : ['GDP','金融','房地产','第一产业','第二产业','第三产业'],
  15. selected : curSelected
  16. },
  17. toolbox: {
  18. show : true,
  19. feature : {
  20. mark : {show: true},
  21. dataView : {show: true, readOnly: false},
  22. magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
  23. restore : {show: true},
  24. saveAsImage : {show: true}
  25. }
  26. },
  27. calculable : true,
  28. grid : {
  29. y : 80,
  30. y2 : 100,
  31. },
  32. xAxis : [
  33. {
  34. type : 'category',
  35. axisLabel: {
  36. interval: 0
  37. },
  38. data : [
  39. '北京','\n天津','河北','\n山西','内蒙古','\n辽宁',
  40. '吉林','\n黑龙江','上海','\n江苏','浙江','\n安徽',
  41. '福建','\n江西','山东','\n河南','湖北','\n湖南',
  42. '广东','\n广西','海南','\n重庆','四川','\n贵州',
  43. '云南','\n西藏','陕西','\n甘肃','青海','\n宁夏','新疆'
  44. ]
  45. }
  46. ],
  47. yAxis : [
  48. {
  49. type : 'value',
  50. name : 'GDP(亿元)',
  51. max: 53500,
  52. splitArea : {show : true}
  53. },
  54. {
  55. type : 'value',
  56. name : '其他(亿元)',
  57. splitArea : {show : true}
  58. }
  59. ],
  60. series : [
  61. {
  62. name:'GDP',
  63. _name: 'GDP',
  64. type:'bar',
  65. markLine: {
  66. symbol : ['arrow','none'],symbolSize : [4, 2],itemStyle : {normal: {
  67. lineStyle: {color:'orange'},
  68. borderColor:'orange',
  69. label:{position:'left',formatter:function(params){return Math.round(params.value)},
  70. textStyle:{color:"orange"}
  71. }}},
  72. data : [
  73. {type : 'average', name : '平均值'}
  74. ]
  75. }
  76. },
  77. {
  78. name:'金融',
  79. _name: 'Financial',
  80. yAxisIndex: 1,
  81. type:'bar'
  82. },
  83. {
  84. name:'房地产',
  85. _name: 'Estate',
  86. yAxisIndex: 1,
  87. type:'bar'
  88. },
  89. {
  90. name:'第一产业',
  91. _name: 'PI',
  92. yAxisIndex: 1,
  93. type:'bar'
  94. },
  95. {
  96. name:'第二产业',
  97. _name: 'SI',
  98. yAxisIndex: 1,
  99. type:'bar'
  100. },
  101. {
  102. name:'第三产业',
  103. _name: 'TI',
  104. yAxisIndex: 1,
  105. type:'bar'
  106. }
  107. ]
  108. };
  109. var timelineOption = {
  110. timeline : {
  111. data : (function(){
  112. var a = [];
  113. for (var i = 2002; i <= 2011; i++) {
  114. a.push(i + '-01-01');
  115. }
  116. return a;
  117. })(),
  118. label : {
  119. formatter : function(s) {
  120. return s.slice(0, 4);
  121. }
  122. },
  123. playInterval : 1000
  124. },
  125. options : []
  126. };
  127. var curYear = 2002;
  128. option.title.text = curYear + '全国宏观经济指标'
  129. for (var i = 0, l = option.series.length; i < l; i++) {
  130. option.series[i].data = dataMap['data' + option.series[i]._name][curYear]
  131. }
  132. timelineOption.options.push(option);
  133. for (curYear = 2003; curYear <= 2011; curYear++) {
  134. var newSeries = [
  135. {
  136. name:'GDP',
  137. _name: 'GDP'
  138. },
  139. {
  140. name:'金融',
  141. _name: 'Financial',
  142. yAxisIndex: 1
  143. },
  144. {
  145. name:'房地产',
  146. _name: 'Estate',
  147. yAxisIndex: 1
  148. },
  149. {
  150. name:'第一产业',
  151. _name: 'PI',
  152. yAxisIndex: 1
  153. },
  154. {
  155. name:'第二产业',
  156. _name: 'SI',
  157. yAxisIndex: 1
  158. },
  159. {
  160. name:'第三产业',
  161. _name: 'TI',
  162. yAxisIndex: 1
  163. }
  164. ];
  165. for (var i = 0, l = newSeries.length; i < l; i++) {
  166. newSeries[i].data = dataMap['data' + newSeries[i]._name][curYear]
  167. }
  168. timelineOption.options.push({
  169. title : {
  170. text : curYear + '全国宏观经济指标'
  171. },
  172. series : newSeries
  173. })
  174. }
  175. return timelineOption;
  176. }