f45_vline.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. function initEcharts() {
  2. initRealPopulation();
  3. initPopulationStructure();
  4. initAging();
  5. }
  6. //实有人口
  7. function initRealPopulation() {
  8. let realEcharts = echarts.init(document.getElementById("population"));
  9. var realPopulationOption = {
  10. tooltip: {
  11. trigger: "axis",
  12. axisPointer: {
  13. type: "shadow",
  14. },
  15. },
  16. grid: {
  17. top: "30%",
  18. left: "3%",
  19. right: "4%",
  20. bottom: "-10%",
  21. containLabel: true,
  22. },
  23. xAxis: {
  24. type: "value",
  25. boundaryGap: [0, 0.5],
  26. show: false,
  27. },
  28. yAxis: {
  29. type: "category",
  30. data: ["常住人口", "流动人口"],
  31. axisLabel: {
  32. show: true,
  33. textStyle: {
  34. color: "#fff", //坐标轴文字颜色
  35. },
  36. },
  37. axisLine: {
  38. show: false,
  39. },
  40. },
  41. series: [
  42. {
  43. type: "bar",
  44. label: {
  45. show: true,
  46. color: "#fff",
  47. textStyle: {
  48. fontSize: 10,
  49. },
  50. },
  51. data: [130365, 52729],
  52. itemStyle: {
  53. normal: {
  54. barBorderRadius: [15, 15, 15, 15],
  55. color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
  56. {
  57. offset: 0,
  58. color: "#4d68ee", //0%处的颜色
  59. },
  60. {
  61. offset: 0.6,
  62. color: "#25b1f5", //50%处的颜色
  63. },
  64. {
  65. offset: 1,
  66. color: "#01f5ff", //100%处的颜色
  67. },
  68. ]),
  69. },
  70. },
  71. },
  72. ],
  73. };
  74. realEcharts.setOption(realPopulationOption);
  75. window.addEventListener("resize", function () {
  76. realEcharts.resize();
  77. });
  78. }
  79. //人口结构
  80. function initPopulationStructure() {
  81. let structureEcharts = echarts.init(document.getElementById("structure"));
  82. var structureOption = {
  83. tooltip: {
  84. trigger: "item",
  85. },
  86. legend: {
  87. textStyle: {
  88. color: "#fff",
  89. },
  90. top: "8%",
  91. left: "center",
  92. icon: "circle",
  93. itemWidth: 10,
  94. },
  95. color: ["#a20bd1", "#b2ba00", "#49ad00", "#03dfa7", "#8185b3", "#4c67eb", "#ab7900"],
  96. series: [
  97. {
  98. name: "男性",
  99. type: "pie",
  100. radius: ["60%", "40%"],
  101. center: ["25%", "70%"],
  102. avoidLabelOverlap: false,
  103. label: {
  104. show: true,
  105. position: "inner",
  106. formatter: "{d}%",
  107. textStyle: {
  108. fontSize: 10,
  109. },
  110. },
  111. emphasis: {
  112. label: {
  113. show: true,
  114. fontSize: "10",
  115. fontWeight: "bold",
  116. color: "#fff",
  117. },
  118. },
  119. labelLine: {
  120. show: false,
  121. },
  122. data: [
  123. { value: 1048, name: "0-0.6" },
  124. { value: 735, name: "0.6-2" },
  125. { value: 580, name: "3-6" },
  126. { value: 484, name: "7-14" },
  127. { value: 300, name: "15-35" },
  128. { value: 300, name: "36-60" },
  129. { value: 300, name: "61以上" },
  130. ],
  131. },
  132. {
  133. name: "女性",
  134. type: "pie",
  135. radius: ["60%", "40%"],
  136. center: ["75%", "70%"],
  137. avoidLabelOverlap: false,
  138. label: {
  139. show: true,
  140. position: "inner",
  141. formatter: "{d}%",
  142. textStyle: {
  143. fontSize: 10,
  144. },
  145. },
  146. data: [
  147. { value: 148, name: "0-0.6" },
  148. { value: 735, name: "0.6-2" },
  149. { value: 580, name: "3-6" },
  150. { value: 484, name: "7-14" },
  151. { value: 300, name: "15-35" },
  152. { value: 300, name: "36-60" },
  153. { value: 300, name: "61以上" },
  154. ],
  155. },
  156. ],
  157. };
  158. structureEcharts.setOption(structureOption);
  159. window.addEventListener("resize", function () {
  160. structureEcharts.resize();
  161. });
  162. }
  163. //人口老龄化分析
  164. function initAging() {
  165. let agingEcharts = echarts.init(document.getElementById("agingAnalysis"));
  166. var agingOption = {
  167. tooltip: {
  168. trigger: "axis",
  169. axisPointer: {
  170. // 坐标轴指示器,坐标轴触发有效
  171. type: "shadow", // 默认为直线,可选为:'line' | 'shadow'
  172. },
  173. formatter: function (params, ticket) {
  174. return "女性:" + params[0].value + "<br/>男性:" + Math.abs(params[1].value);
  175. },
  176. },
  177. color: ["#c145c5", "#21b8f6"],
  178. legend: {
  179. data: ["女性", "男性"],
  180. },
  181. grid: {
  182. x: 0,
  183. y: 0,
  184. x2: 0,
  185. y2: 0,
  186. top: "10%",
  187. left: "10%",
  188. containLabel: true,
  189. },
  190. xAxis: [
  191. {
  192. type: "value",
  193. axisTick: {
  194. show: false,
  195. },
  196. show: false,
  197. },
  198. ],
  199. yAxis: [
  200. {
  201. type: "category",
  202. data: ["60-65岁", "65-70岁", "70-75岁", "75-80岁", "80岁以上"],
  203. axisLabel: {
  204. textStyle: {
  205. color: "#fff", //坐标轴文字颜色
  206. },
  207. },
  208. },
  209. ],
  210. series: [
  211. {
  212. type: "bar",
  213. stack: "总量",
  214. label: {
  215. show: false,
  216. },
  217. emphasis: {
  218. focus: "series",
  219. },
  220. data: [700, 300, 330, 160, 70],
  221. barCategoryGap: "50%",
  222. itemStyle: {
  223. normal: {
  224. barBorderRadius: [15, 15, 15, 15],
  225. },
  226. },
  227. },
  228. {
  229. type: "bar",
  230. stack: "总量",
  231. label: {
  232. show: false,
  233. position: "left",
  234. },
  235. emphasis: {
  236. focus: "series",
  237. },
  238. data: [-800, -400, -350, -200, -100],
  239. itemStyle: {
  240. normal: {
  241. barBorderRadius: [15, 15, 15, 15],
  242. },
  243. },
  244. },
  245. ],
  246. };
  247. agingEcharts.setOption(agingOption);
  248. window.addEventListener("resize", function () {
  249. agingEcharts.resize();
  250. });
  251. }