e733ddad955a1043f1a4a99847750351151f68d5.svn-base 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <link rel="shortcut icon" href="../../../asset/ico/favicon.png">
  6. <title>中国人口流动大潮</title>
  7. <style type="text/css">
  8. * {
  9. font-family: "Microsoft YaHei" !important;
  10. }
  11. h1 {
  12. font-family: "Microsoft YaHei";
  13. font-weight: bold;
  14. color: #FFF;
  15. background-color: #000;
  16. border: 5px none #000;
  17. background-image: url(../../../asset/img/tweed.png);
  18. background-repeat: repeat;
  19. padding-right: 15px;
  20. padding-bottom: 15px;
  21. padding-left: 15px;
  22. padding-top: 15px;
  23. }
  24. p {
  25. padding: 0 15px;
  26. }
  27. .select_box {
  28. border-top-width: 1px;
  29. border-top-style: dashed;
  30. border-top-color: #699;
  31. padding-top: 15px;
  32. padding-bottom: 15px;
  33. padding-right: 15px;
  34. padding-left: 15px;
  35. }
  36. body {
  37. background-image: url(../../../asset/img/ticks.png);
  38. background-repeat: repeat;
  39. margin-left: 0px;
  40. margin-top: 0px;
  41. margin-right: 0px;
  42. margin-bottom: 0px;
  43. }
  44. #main{
  45. background-image: url(../../../asset/img/groovepaper.png);
  46. background-repeat: repeat;
  47. }
  48. .footer {
  49. height: 100px;
  50. background-image: url(../../../asset/img/tweed.png);
  51. background-repeat: repeat;
  52. font-family: "Microsoft YaHei";
  53. font-size: 14px;
  54. color: #CCC;
  55. text-align: center;
  56. padding-top: 1px;
  57. }
  58. .footer a:hover {
  59. color:#62C462
  60. }
  61. </style>
  62. </head>
  63. <body>
  64. <h1>中国人口流动大潮1987-2011(单位:万人)</h1>
  65. <p>自上世纪90年代以来,随着中国社会经济的发展和城市化进程的加快,人口的迁移和移动已经愈发频繁。国家统计局公布的数据显示,2012年我国流动人口数量达2.36亿人,相当于每六个人中有一个是流动人口。</p>
  66. <p>探讨的流动人口,是指以中国城乡二元社会结构和特有的户籍政策为前提,其就业、生活或学习所在地与其户籍所在地处于分离状态的人口,它与其他国家的人口自由迁移现象存在着差异。
  67. 中国人口的大规模流动,是自20世纪80年代改革开放以来随着农村户籍居民离开本乡本土进城或外出务工而出现的社会现象,它表现出明显的中国时代特色:</p>
  68. <div class="select_box"><form id="form1" name="form1" method="post" action="">
  69. <label for="year">请选择年份</label>
  70. <select name="year" id="year">
  71. <option>1987</option>
  72. <option>1988</option>
  73. <option>1989</option>
  74. <option>1990</option>
  75. <option>1991</option>
  76. <option>1992</option>
  77. <option>1993</option>
  78. <option>1994</option>
  79. <option>1995</option>
  80. <option>1996</option>
  81. <option>1997</option>
  82. <option>1998</option>
  83. <option>1999</option>
  84. <option>2000</option>
  85. <option>2001</option>
  86. <option>2002</option>
  87. <option>2003</option>
  88. <option>2004</option>
  89. <option>2005</option>
  90. <option>2006</option>
  91. <option>2007</option>
  92. <option>2008</option>
  93. <option>2009</option>
  94. <option>2010</option>
  95. <option selected="selected">2011</option>
  96. </select>
  97. </form></div>
  98. <div id="main" style="height:500px;border:1px solid #ccc;padding:20px;"></div>
  99. <script src="../../www/js/echarts.js"></script>
  100. <script src="js/data-people.js"></script>
  101. <script type="text/javascript">
  102. require.config({
  103. paths:{
  104. echarts: '../../www/js'
  105. }
  106. });
  107. var myChart;
  108. var colorList;
  109. require(
  110. [
  111. 'echarts',
  112. 'echarts/chart/bar',
  113. 'echarts/chart/line',
  114. 'echarts/chart/map'
  115. ],
  116. function (ec) {
  117. colorList = require('zrender/tool/color').getGradientColors(
  118. ['red','yellow','lightskyblue'], 10
  119. );
  120. //console.log(colorList)
  121. myChart = ec.init(document.getElementById('main'));
  122. //myChart.setOption(option);
  123. yearSelector.onchange();
  124. window.onresize = myChart.resize;
  125. var ecConfig = require('echarts/config');
  126. myChart.on(ecConfig.EVENT.MAP_SELECTED, mapSelected);
  127. }
  128. );
  129. var selected;
  130. function mapSelected(param){
  131. selected = param.selected;
  132. var mapSeries = option.series[0];
  133. var data = [];
  134. var legendData = [];
  135. var legendData = [];
  136. var name;
  137. option.series = option.series.slice(0,1);
  138. for (var p = 0, len = mapSeries.data.length; p < len; p++) {
  139. name = mapSeries.data[p].name;
  140. mapSeries.data[p].selected = selected[name];
  141. if (selected[name]) {
  142. //option.yAxis[0].name = name + ' 人口流动情况';
  143. var tarIdx;
  144. for (var i = 0, l = pList.length; i < l; i++) {
  145. if (pList[i] == name) {
  146. tarIdx = i;
  147. break;
  148. }
  149. }
  150. for (var i = 1987; i <= 2011; i++) {
  151. data.push(dataPeople[i][tarIdx]);
  152. }
  153. option.series.push({
  154. name : name,
  155. type:'line',
  156. tooltip: {
  157. trigger: 'axis'
  158. },
  159. data: data
  160. });
  161. legendData.push(name);
  162. data = [];
  163. }
  164. }
  165. //option.series[1].data = data;
  166. option.legend.data = legendData;
  167. myChart.setOption(option, true);
  168. }
  169. var yearSelector = document.getElementById('year');
  170. yearSelector.onchange = function (e){
  171. var curYear = yearSelector.selectedOptions[0].innerHTML;
  172. option.title.text = '中国人口流动图示 (' + curYear + ')';
  173. var max = dataPeople[curYear + 'max'];
  174. var min = dataPeople[curYear + 'min'];
  175. var gap = (max - min) / 5;
  176. /*
  177. var legendData = [
  178. Math.round(min + 4 * gap) + '以上',
  179. Math.round(min + 3 * gap) + ' ~' + Math.round(min + 4 * gap),
  180. Math.round(min + 2 * gap) + ' ~' + Math.round(min + 3 * gap),
  181. Math.round(min + gap) + ' ~' + Math.round(min + 2 * gap),
  182. Math.round(min + gap) + '以下',
  183. ];
  184. option.legend.data = legendData;
  185. */
  186. option.dataRange.max = max;
  187. option.dataRange.min = min;
  188. if (min >= 0) {
  189. //双正
  190. option.dataRange.color = [colorList[0], colorList[10]];
  191. /*
  192. option.color = require('zrender/tool/color').getStepColors(
  193. colorList[0], colorList[10], 5
  194. )
  195. */
  196. //option.color = [colorList[0], colorList[2], colorList[4], colorList[7], colorList[10]];
  197. }
  198. else if (max >= 0 && min <= 0) {
  199. //正负
  200. var first = Math.round(10 - max / (max - min) * 10);
  201. var end = Math.round(min / (min - max) * 10 + 10);
  202. option.dataRange.color = [
  203. colorList[first],
  204. colorList[Math.round((end - first) / 2 + first)],
  205. colorList[end]
  206. ];
  207. //console.log(first,end);
  208. /*
  209. option.color = [
  210. colorList[first], colorList[first + 2],
  211. option.dataRange.color[1],
  212. colorList[end - 2], colorList[end]
  213. ];
  214. */
  215. }
  216. else {
  217. //双负
  218. option.dataRange.color = [colorList[11], colorList[20]];
  219. /*
  220. option.color = require('zrender/tool/color').getStepColors(
  221. colorList[11], colorList[20], 5
  222. )
  223. */
  224. //option.color = [colorList[11], colorList[13], colorList[15], colorList[17], colorList[20]];
  225. }
  226. //console.log(option.color,option.dataRange.color)
  227. option.series[0].data = dataPeople[curYear];
  228. /*
  229. for (var i = 0; i <= 4; i++) {
  230. option.series[i + 1].name = legendData[i];
  231. }
  232. */
  233. if (selected) {
  234. mapSelected({selected:selected});
  235. }
  236. else{
  237. myChart.setOption(option, true);
  238. }
  239. }
  240. </script>
  241. <div class="footer">
  242. <p>&copy; 2014 Data Journalism Workshop(华媒基金会 &middot; 数据新闻工作坊) &middot; 孟立昕(腾讯)&middot; 王飞宇(证券时报) &middot; 颜冬(视觉中国) &middot; <a href="http://weibo.com/kenerlinfeng" target="_blank">林峰</a>(百度)</p>
  243. <p><a href="http://echarts.baidu.com" target="_blank">Data Visualization by ECharts</a></p>
  244. </div>
  245. </body>
  246. </html>