index.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. //自调用函数
  2. (function() {
  3. // 1、页面一加载就要知道页面宽度计算
  4. var setFont = function() {
  5. // 因为要定义变量可能和别的变量相互冲突,污染,所有用自调用函数
  6. var html = document.documentElement; // 获取html
  7. // 获取宽度
  8. var width = html.clientWidth;
  9. // 判断
  10. if (width < 1024) width = 1024
  11. if (width > 1920) width = 1920
  12. // 设置html的基准值
  13. var fontSize = width / 80 + 'px';
  14. // 设置给html
  15. html.style.fontSize = fontSize;
  16. }
  17. setFont();
  18. // 2、页面改变的时候也需要设置
  19. // 尺寸改变事件
  20. window.onresize = function() {
  21. setFont();
  22. }
  23. })();
  24. $.get('https://www.jucai.gov.cn/api/config/bi/agg', (res) => {
  25. agg_init(res)
  26. });
  27. $.get('https://linggong.jinjianghc.com/mainapp.php/screen/agg', (res) => {
  28. odd_init(res.data)
  29. });
  30. function agg_init(data) {
  31. $('.resume_sex-total').text(data.resume_sex[3].count);
  32. $('.resume_sex-male').text(data.resume_sex[1].count);
  33. $('.resume_sex-female').text(data.resume_sex[2].count);
  34. $('.recruit_count').text(data.recruit_count);
  35. $('.recruit_post').text(data.recruit_post);
  36. $('.recruit_apply').text(data.recruit_apply);
  37. this.resume_trade(data.resume_trade);
  38. this.resume_age(data.resume_age);
  39. this.resume_education(data.resume_education);
  40. this.pieAge(data);
  41. this.pieEdu(data);
  42. }
  43. function odd_init(data) {
  44. this.geo(data);
  45. this.odd_total(data);
  46. }
  47. function resume_trade(data) {
  48. let titleArr = [];
  49. let countArr = [];
  50. data.forEach((item, index) => {
  51. titleArr.push(item.name)
  52. countArr.push(item.count)
  53. });
  54. var option = {
  55. //鼠标提示工具
  56. tooltip: {
  57. trigger: 'axis'
  58. },
  59. xAxis: {
  60. // 类目类型
  61. type: 'category',
  62. // x轴刻度文字
  63. data: titleArr,
  64. axisTick: {
  65. show: false //去除刻度线
  66. },
  67. axisLabel: {
  68. color: '#4c9bfd' //文本颜色
  69. },
  70. axisLine: {
  71. show: false //去除轴线
  72. },
  73. boundaryGap: false //去除轴内间距
  74. },
  75. yAxis: {
  76. // 数据作为刻度文字
  77. type: 'value',
  78. axisTick: {
  79. show: false //去除刻度线
  80. },
  81. axisLabel: {
  82. color: '#4c9bfd' //文本颜色
  83. },
  84. axisLine: {
  85. show: false //去除轴线
  86. },
  87. boundaryGap: false //去除轴内间距
  88. },
  89. //图例组件
  90. legend: {
  91. textStyle: {
  92. color: '#4c9bfd' // 图例文字颜色
  93. },
  94. right: '10%' //距离右边10%
  95. },
  96. // 设置网格样式
  97. grid: {
  98. show: true, // 显示边框
  99. top: '20%',
  100. left: '3%',
  101. right: '4%',
  102. bottom: '3%',
  103. borderColor: '#012f4a', // 边框颜色
  104. containLabel: true // 包含刻度文字在内
  105. },
  106. series: [{
  107. name: '求职人数',
  108. // 数据
  109. data: countArr,
  110. // 图表类型
  111. type: 'line',
  112. // 圆滑连接
  113. smooth: true,
  114. itemStyle: {
  115. color: '#00f2f1' // 线颜色
  116. }
  117. }]
  118. };
  119. var myechart = echarts.init($('.resume_trade')[0]);
  120. myechart.setOption(option);
  121. }
  122. function resume_age(data) {
  123. let unknown = 0;
  124. let total = 0;
  125. data.map((item, index) => {
  126. if (item.name == '其他') {
  127. unknown += item.count;
  128. //其他数据
  129. item.value = item.count;
  130. } else {
  131. total += item.count;
  132. item.value = item.count;
  133. }
  134. return item;
  135. });
  136. var myechar = echarts.init($('.resume_age')[0]);
  137. option = {
  138. // 控制提示
  139. tooltip: {
  140. // 非轴图形,使用item的意思是放到数据对应图形上触发提示
  141. trigger: 'item',
  142. // 格式化提示内容:
  143. // a 代表图表名称 b 代表数据名称 c 代表数据 d代表 当前数据/总数据的比例
  144. formatter: "{a} <br/>{b} : {c} ({d}%)"
  145. },
  146. // 控制图表
  147. series: [{
  148. // 图表名称
  149. name: '年龄',
  150. // 图表类型
  151. type: 'pie',
  152. // 南丁格尔玫瑰图 有两个圆 内圆半径10% 外圆半径70%
  153. // 百分比基于 图表DOM容器的半径
  154. radius: ['10%', '70%'],
  155. // 图表中心位置 left 50% top 50% 距离图表DOM容器
  156. center: ['50%', '50%'],
  157. // 半径模式,另外一种是 area 面积模式
  158. roseType: 'radius',
  159. // 数据集 value 数据的值 name 数据的名称
  160. data: data,
  161. //文字调整
  162. label: {
  163. fontSize: 10
  164. },
  165. //引导线
  166. labelLine: {
  167. length: 8,
  168. length2: 10
  169. }
  170. }],
  171. color: ['#006cff', '#9fe6b8', '#32c5e9', '#1d9dff', '#60cda0', '#ed8884', '#ff9f7f', '#0096ff']
  172. };
  173. myechar.setOption(option);
  174. }
  175. function resume_education(data) {
  176. let unknown = 0;
  177. let total = 0;
  178. data.map((item, index) => {
  179. if (item.name == '其他') {
  180. unknown += item.count;
  181. //其他数据
  182. item.value = item.count;
  183. } else {
  184. total += item.count;
  185. item.value = item.count;
  186. }
  187. return item;
  188. });
  189. $('.resume_education-unknown').text(unknown);
  190. $('.resume_education-total').text(total);
  191. var myechar = echarts.init($('.resume_education')[0]);
  192. option = {
  193. // 控制提示
  194. tooltip: {
  195. // 非轴图形,使用item的意思是放到数据对应图形上触发提示
  196. trigger: 'item',
  197. // 格式化提示内容:
  198. // a 代表图表名称 b 代表数据名称 c 代表数据 d代表 当前数据/总数据的比例
  199. formatter: "{a} <br/>{b} : {c} ({d}%)"
  200. },
  201. // 控制图表
  202. series: [{
  203. // 图表名称
  204. name: '学历',
  205. // 图表类型
  206. type: 'pie',
  207. // 南丁格尔玫瑰图 有两个圆 内圆半径10% 外圆半径70%
  208. // 百分比基于 图表DOM容器的半径
  209. radius: ['10%', '70%'],
  210. // 图表中心位置 left 50% top 50% 距离图表DOM容器
  211. center: ['50%', '50%'],
  212. // 半径模式,另外一种是 area 面积模式
  213. roseType: 'radius',
  214. // 数据集 value 数据的值 name 数据的名称
  215. data: data,
  216. //文字调整
  217. label: {
  218. fontSize: 10
  219. },
  220. //引导线
  221. labelLine: {
  222. length: 8,
  223. length2: 10
  224. }
  225. }],
  226. color: ['#006cff', '#9fe6b8', '#32c5e9', '#1d9dff', '#60cda0', '#ed8884', '#ff9f7f', '#0096ff']
  227. };
  228. myechar.setOption(option);
  229. }
  230. function pieAge(data) {
  231. let recruit_age = data.recruit_age;
  232. let gt35 = 0;
  233. let lt35 = 0;
  234. recruit_age.map((item, index) => {
  235. if (item.name == '35到40岁' || item.name == '40岁以上') {
  236. gt35 += item.count;
  237. //其他数据
  238. item.value = item.count;
  239. } else {
  240. lt35 += item.count;
  241. item.value = item.count;
  242. }
  243. return item;
  244. });
  245. $('.age-gt35').text(gt35);
  246. $('.age-lt35').text(lt35);
  247. var myechartAge = echarts.init($('.recruit_age')[0]);
  248. option = {
  249. // 控制提示
  250. tooltip: {
  251. // 非轴图形,使用item的意思是放到数据对应图形上触发提示
  252. trigger: 'item',
  253. // 格式化提示内容:
  254. // a 代表图表名称 b 代表数据名称 c 代表数据 d代表 当前数据/总数据的比例
  255. formatter: "{a} <br/>{b} : {c} ({d}%)"
  256. },
  257. // 控制图表
  258. series: [{
  259. // 图表名称
  260. name: '年龄',
  261. // 图表类型
  262. type: 'pie',
  263. // 南丁格尔玫瑰图 有两个圆 内圆半径10% 外圆半径70%
  264. // 百分比基于 图表DOM容器的半径
  265. radius: ['10%', '70%'],
  266. // 图表中心位置 left 50% top 50% 距离图表DOM容器
  267. center: ['50%', '50%'],
  268. // 半径模式,另外一种是 area 面积模式
  269. roseType: 'radius',
  270. // 数据集 value 数据的值 name 数据的名称
  271. data: recruit_age,
  272. //文字调整
  273. label: {
  274. fontSize: 10
  275. },
  276. //引导线
  277. labelLine: {
  278. length: 8,
  279. length2: 10
  280. }
  281. }],
  282. color: ['#006cff', '#9fe6b8', '#32c5e9', '#1d9dff', '#60cda0', '#ed8884', '#ff9f7f', '#0096ff']
  283. };
  284. myechartAge.setOption(option);
  285. }
  286. function pieEdu(data) {
  287. let eduction = data.recruit_education;
  288. let unknown = 0;
  289. let total = 0;
  290. eduction.map((item, index) => {
  291. if (item.name == '其他') {
  292. unknown += item.count;
  293. eduction.splice(index, 1);
  294. } else {
  295. total += item.count;
  296. item.value = item.count;
  297. }
  298. return item;
  299. });
  300. $('.edu-unknown').text(unknown);
  301. $('.edu-total').text(total);
  302. var myechart = echarts.init($('.recruit_education')[0]);
  303. option = {
  304. // 控制提示
  305. tooltip: {
  306. // 非轴图形,使用item的意思是放到数据对应图形上触发提示
  307. trigger: 'item',
  308. // 格式化提示内容:
  309. // a 代表图表名称 b 代表数据名称 c 代表数据 d代表 当前数据/总数据的比例
  310. formatter: "{a} <br/>{b} : {c} ({d}%)"
  311. },
  312. // 控制图表
  313. series: [{
  314. // 图表名称
  315. name: '学历',
  316. // 图表类型
  317. type: 'pie',
  318. // 南丁格尔玫瑰图 有两个圆 内圆半径10% 外圆半径70%
  319. // 百分比基于 图表DOM容器的半径
  320. radius: ['10%', '70%'],
  321. // 图表中心位置 left 50% top 50% 距离图表DOM容器
  322. center: ['50%', '50%'],
  323. // 半径模式,另外一种是 area 面积模式
  324. roseType: 'radius',
  325. // 数据集 value 数据的值 name 数据的名称
  326. data: eduction,
  327. //文字调整
  328. label: {
  329. fontSize: 10
  330. },
  331. //引导线
  332. labelLine: {
  333. length: 8,
  334. length2: 10
  335. }
  336. }],
  337. color: ['#006cff', '#60cda0', '#ed8884', '#ff9f7f', '#0096ff', '#9fe6b8', '#32c5e9', '#1d9dff']
  338. };
  339. myechart.setOption(option);
  340. }
  341. function geo(data) {
  342. let community = data.community;
  343. let other = 0;
  344. let max = 0; //最大人数
  345. community = community.map((item) => {
  346. if (item.name == '其他') {
  347. other += item.count;
  348. } else if (item.count > max) {
  349. max = item.count;
  350. }
  351. return {
  352. name: item.name,
  353. value: item.count
  354. };
  355. });
  356. community.push({
  357. name: '泉州出口加工区',
  358. value: 0
  359. });
  360. community.push({
  361. name: '安平开发区',
  362. value: 0
  363. });
  364. var myecharts = echarts.init($('.map .geo')[0])
  365. // $.get('https://geo.datav.aliyun.com/areas_v3/bound/350582.json', result => {
  366. $.get('js/350582.json', result => {
  367. // 注册 echarts 地图
  368. echarts.registerMap('jinjiang', result);
  369. var option = {
  370. backgroundColor: '#080a20',
  371. title: {
  372. text: '其他地区:' + other + ' (人)',
  373. // subtext: '其他地区:' + community[community.length - 1].count,
  374. left: 'left',
  375. textStyle: {
  376. color: '#ffffff'
  377. }
  378. },
  379. tooltip: {
  380. trigger: 'item',
  381. formatter: '{b}<br/>{c} (人)'
  382. },
  383. visualMap: {
  384. min: 0,
  385. max: max,
  386. text: ['多', '少'],
  387. realtime: true,
  388. calculable: true,
  389. color: '#fff',
  390. inRange: {
  391. color: ['#142957', '#0b1c2d']
  392. },
  393. textStyle: {
  394. color: '#fff'
  395. }
  396. },
  397. series: [{
  398. type: 'map',
  399. map: 'jinjiang',
  400. zoom: 1.2,
  401. roam: true,
  402. coordinateSystem: 'geo',
  403. // rippleEffect: {
  404. // brushType: 'stroke'
  405. // },
  406. symbolSize: function(val, params) {
  407. return 8;
  408. },
  409. label: {
  410. show: true,
  411. color: '#fff'
  412. },
  413. itemStyle: {
  414. normal: {
  415. areaColor: '#142957',
  416. borderColor: '#0692a4'
  417. }
  418. },
  419. emphasis: {
  420. areaColor: '#0b1c2d'
  421. },
  422. data: community,
  423. nameMap: {
  424. '晋江市经济开发区': '经济开发区'
  425. }
  426. }]
  427. };
  428. myecharts.setOption(option);
  429. })
  430. }
  431. function odd_total(data) {
  432. $('.odd_job_number').text(data.user_total);
  433. $('.odd_job_company').text(data.company_total);
  434. $('.odd_job_job').text(data.comjobs_total);
  435. }