index.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  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('/mainapp.php/screen/index', (res) => {
  25. init(res.data)
  26. })
  27. function init(data) {
  28. $('.broker_total').text(data.broker_total);
  29. $('.comjobs_total').text(data.comjobs_total);
  30. $('.company_total').text(data.company_total);
  31. $('.people_man').text(data.people_man);
  32. $('.people_total').text(data.people_total);
  33. $('.people_woman').text(data.people_woman);
  34. $('.train').text(data.train);
  35. $('.train_join').text(data.train_join);
  36. this.geo(data);
  37. this.monitor(data);
  38. this.pieAge(data);
  39. this.pie(data);
  40. this.userType(data);
  41. this.user(data);
  42. this.order(data);
  43. this.sale(data);
  44. this.gauge(data);
  45. this.province(data);
  46. }
  47. function geo(data) {
  48. let community = data.community;
  49. let other = 0;
  50. let max = 0; //最大人数
  51. community = community.map((item) => {
  52. if (item.name == '其他') {
  53. other += item.count;
  54. } else if (item.count > max) {
  55. max = item.count;
  56. }
  57. return {
  58. name: item.name,
  59. value: item.count
  60. };
  61. });
  62. community.push({
  63. name: '泉州出口加工区',
  64. value: 0
  65. });
  66. community.push({
  67. name: '安平开发区',
  68. value: 0
  69. });
  70. var myecharts = echarts.init($('.map .geo')[0])
  71. // $.get('https://geo.datav.aliyun.com/areas_v3/bound/350582.json', result => {
  72. $.get('js/350582.json', result => {
  73. // 注册 echarts 地图
  74. echarts.registerMap('jinjiang', result);
  75. var option = {
  76. backgroundColor: '#080a20',
  77. title: {
  78. text: '其他地区:' + other + ' (人)',
  79. // subtext: '其他地区:' + community[community.length - 1].count,
  80. left: 'left',
  81. textStyle: {
  82. color: '#ffffff'
  83. }
  84. },
  85. tooltip: {
  86. trigger: 'item',
  87. formatter: '{b}<br/>{c} (人)'
  88. },
  89. visualMap: {
  90. min: 0,
  91. max: max,
  92. text: ['多', '少'],
  93. realtime: true,
  94. calculable: true,
  95. color: '#fff',
  96. inRange: {
  97. color: ['#142957', '#0b1c2d']
  98. },
  99. textStyle: {
  100. color: '#fff'
  101. }
  102. },
  103. series: [{
  104. type: 'map',
  105. map: 'jinjiang',
  106. zoom: 1.2,
  107. roam: true,
  108. coordinateSystem: 'geo',
  109. // rippleEffect: {
  110. // brushType: 'stroke'
  111. // },
  112. symbolSize: function(val, params) {
  113. return 8;
  114. },
  115. label: {
  116. show: true,
  117. color: '#fff'
  118. },
  119. itemStyle: {
  120. normal: {
  121. areaColor: '#142957',
  122. borderColor: '#0692a4'
  123. }
  124. },
  125. emphasis: {
  126. areaColor: '#0b1c2d'
  127. },
  128. data: community,
  129. nameMap: {
  130. '晋江市经济开发区': '经济开发区'
  131. }
  132. }]
  133. };
  134. myecharts.setOption(option);
  135. })
  136. }
  137. function monitor(data) {
  138. //事件委托
  139. $('.monitor').on('click', ' a', function () {
  140. //点击当前的a 加类名 active 他的兄弟删除类名
  141. $(this).addClass('active').siblings().removeClass('active');
  142. //获取一一对应的下标
  143. var index = $(this).index();
  144. //选取content 然后狗日对应下标的 显示 当前的兄弟.content隐藏
  145. $('.content').eq(index).show().siblings('.content').hide();
  146. });
  147. //填充数据
  148. let comjobs = data.comjobs;
  149. var html = '';
  150. comjobs.hot.forEach(function(item) {
  151. html += `<div class="row">`;
  152. html += `<span class="col">${item.title}</span>`;
  153. html += `<span class="col">${item.worker.ftitle}</span>`;
  154. html += `<span class="col">${item.bwagall || '面谈'}</span>`;
  155. html += `<span class="icon-dot"></span>`;
  156. html += `</div>`;
  157. });
  158. //渲染
  159. $('.monitor .marquee.hot').html(html);
  160. html = '';
  161. comjobs.new.forEach(function(item) {
  162. html += `<div class="row">`;
  163. html += `<span class="col">${item.title}</span>`;
  164. html += `<span class="col">${item.company}</span>`;
  165. html += `<span class="col">${item.salary || '面谈'}</span>`;
  166. html += `<span class="icon-dot"></span>`;
  167. html += `</div>`;
  168. });
  169. //渲染
  170. $('.monitor .marquee.new').html(html);
  171. //滚动
  172. //原理:把marquee下面的子盒子都复制一遍 加入到marquee中
  173. // 然后动画向上滚动,滚动到一半重新开始滚动
  174. //因为选取的是两个marquee 所以要遍历
  175. // $('.monitor .marquee').each(function (index, dom) {
  176. // //将每个 的所有子级都复制一遍
  177. // var rows = $(dom).children().clone();
  178. // //再将新的到的加入原来的
  179. // $(dom).append(rows);
  180. // });
  181. }
  182. function pieAge(data) {
  183. let eduction = data.user_age;
  184. let unknown = 0;
  185. let total = 0;
  186. eduction.map((item, index) => {
  187. if (item.name == '其他') {
  188. unknown += item.count;
  189. // eduction.splice(index, 1);
  190. //其他数据
  191. item.value = item.count;
  192. } else {
  193. total += item.count;
  194. item.value = item.count;
  195. }
  196. return item;
  197. });
  198. console.log(eduction)
  199. $('.age-unknown').text(unknown);
  200. $('.age-total').text(total);
  201. var myechartAge = echarts.init($('.pie.age')[0]);
  202. option = {
  203. // 控制提示
  204. tooltip: {
  205. // 非轴图形,使用item的意思是放到数据对应图形上触发提示
  206. trigger: 'item',
  207. // 格式化提示内容:
  208. // a 代表图表名称 b 代表数据名称 c 代表数据 d代表 当前数据/总数据的比例
  209. formatter: "{a} <br/>{b} : {c} ({d}%)"
  210. },
  211. // 控制图表
  212. series: [{
  213. // 图表名称
  214. name: '年龄',
  215. // 图表类型
  216. type: 'pie',
  217. // 南丁格尔玫瑰图 有两个圆 内圆半径10% 外圆半径70%
  218. // 百分比基于 图表DOM容器的半径
  219. radius: ['10%', '70%'],
  220. // 图表中心位置 left 50% top 50% 距离图表DOM容器
  221. center: ['50%', '50%'],
  222. // 半径模式,另外一种是 area 面积模式
  223. roseType: 'radius',
  224. // 数据集 value 数据的值 name 数据的名称
  225. data: eduction,
  226. //文字调整
  227. label: {
  228. fontSize: 10
  229. },
  230. //引导线
  231. labelLine: {
  232. length: 8,
  233. length2: 10
  234. }
  235. }],
  236. color: ['#006cff', '#9fe6b8', '#32c5e9', '#1d9dff', '#60cda0', '#ed8884', '#ff9f7f', '#0096ff']
  237. };
  238. myechartAge.setOption(option);
  239. }
  240. function pie(data) {
  241. let eduction = data.eduction;
  242. let unknown = 0;
  243. let total = 0;
  244. eduction.map((item, index) => {
  245. if (item.name == '未知') {
  246. unknown += item.count;
  247. eduction.splice(index, 1);
  248. } else {
  249. total += item.count;
  250. item.value = item.count;
  251. }
  252. return item;
  253. });
  254. $('.edu-unknown').text(unknown);
  255. $('.edu-total').text(total);
  256. var myechart = echarts.init($('.pie.edu')[0]);
  257. option = {
  258. // 控制提示
  259. tooltip: {
  260. // 非轴图形,使用item的意思是放到数据对应图形上触发提示
  261. trigger: 'item',
  262. // 格式化提示内容:
  263. // a 代表图表名称 b 代表数据名称 c 代表数据 d代表 当前数据/总数据的比例
  264. formatter: "{a} <br/>{b} : {c} ({d}%)"
  265. },
  266. // 控制图表
  267. series: [{
  268. // 图表名称
  269. name: '学历',
  270. // 图表类型
  271. type: 'pie',
  272. // 南丁格尔玫瑰图 有两个圆 内圆半径10% 外圆半径70%
  273. // 百分比基于 图表DOM容器的半径
  274. radius: ['10%', '70%'],
  275. // 图表中心位置 left 50% top 50% 距离图表DOM容器
  276. center: ['50%', '50%'],
  277. // 半径模式,另外一种是 area 面积模式
  278. roseType: 'radius',
  279. // 数据集 value 数据的值 name 数据的名称
  280. data: eduction,
  281. //文字调整
  282. label: {
  283. fontSize: 10
  284. },
  285. //引导线
  286. labelLine: {
  287. length: 8,
  288. length2: 10
  289. }
  290. }],
  291. color: ['#006cff', '#60cda0', '#ed8884', '#ff9f7f', '#0096ff', '#9fe6b8', '#32c5e9', '#1d9dff']
  292. };
  293. myechart.setOption(option);
  294. }
  295. // 用户
  296. function userType(data) {
  297. let cate = data.type;
  298. let titleArr = [];
  299. let countArr = [];
  300. let total = 0;
  301. let count = cate.length;
  302. // 中间省略的数据 准备三项
  303. var hiddenItem = {
  304. name: '',
  305. value: 10,
  306. // 柱子颜色
  307. itemStyle: {
  308. color: '#254065'
  309. },
  310. // 鼠标经过柱子颜色
  311. emphasis: {
  312. itemStyle: {
  313. color: '#254065'
  314. }
  315. },
  316. // 工具提示隐藏
  317. tooltip: {
  318. extraCssText: 'opacity:0'
  319. }
  320. };
  321. let titleAttr = {
  322. 1: '按月',
  323. 2: '按时',
  324. 3: '按件',
  325. 4: '按项目',
  326. 5: '其他',
  327. }
  328. cate.forEach((item, index) => {
  329. if (index < 5 || index + 5 >= count) {
  330. titleArr.push(titleAttr[item.wtype])
  331. countArr.push(item.count)
  332. } else if (count > 10 && index == 5) {
  333. //随机三个
  334. let arr = []
  335. for (let i = 5; i < count - 5; i++) {
  336. arr.push(i)
  337. }
  338. let randomArr = [];
  339. while (randomArr.length < 3) {
  340. let temp = (Math.random() * arr.length) >> 0;
  341. randomArr.push(arr.splice(temp, 1)[0]);
  342. }
  343. randomArr.forEach((randomIndex) => {
  344. titleArr.push(titleAttr[cate[randomIndex].wtype])
  345. countArr.push(cate[randomIndex].count)
  346. })
  347. }
  348. total += item.count
  349. });
  350. $('.type-count').text(count)
  351. $('.type-total').text(total)
  352. option = {
  353. // 工具提示
  354. tooltip: {
  355. // 触发类型 经过轴触发axis 经过轴触发item
  356. trigger: 'item',
  357. // 轴触发提示才有效
  358. axisPointer: {
  359. // 默认为直线,可选为:'line' 线效果 | 'shadow' 阴影效果
  360. type: 'shadow'
  361. }
  362. },
  363. // 图表边界控制
  364. grid: {
  365. // 距离 上右下左 的距离
  366. left: '0',
  367. right: '3%',
  368. bottom: '3%',
  369. top: '5%',
  370. // 大小是否包含文本【类似于boxsizing】
  371. containLabel: true,
  372. //显示边框
  373. show: true,
  374. //边框颜色
  375. borderColor: 'rgba(0, 240, 255, 0.3)'
  376. },
  377. // 控制x轴
  378. xAxis: [{
  379. // 使用类目,必须有data属性
  380. type: 'category',
  381. // 使用 data 中的数据设为刻度文字
  382. data: titleArr,
  383. // 刻度设置
  384. axisTick: {
  385. // true意思:图形在刻度中间
  386. // false意思:图形在刻度之间
  387. alignWithLabel: false,
  388. show: false
  389. },
  390. //文字
  391. axisLabel: {
  392. color: '#4c9bfd'
  393. }
  394. }],
  395. // 控制y轴
  396. yAxis: [{
  397. // 使用数据的值设为刻度文字
  398. type: 'value',
  399. axisTick: {
  400. // true意思:图形在刻度中间
  401. // false意思:图形在刻度之间
  402. alignWithLabel: false,
  403. show: false
  404. },
  405. //文字
  406. axisLabel: {
  407. color: '#4c9bfd'
  408. },
  409. splitLine: {
  410. lineStyle: {
  411. color: 'rgba(0, 240, 255, 0.3)'
  412. }
  413. },
  414. }],
  415. // 控制x轴
  416. series: [
  417. {
  418. // series配置
  419. // 颜色
  420. itemStyle: {
  421. // 提供的工具函数生成渐变颜色
  422. color: new echarts.graphic.LinearGradient(
  423. // (x1,y2) 点到点 (x2,y2) 之间进行渐变
  424. 0, 0, 0, 1,
  425. [{
  426. offset: 0,
  427. color: '#00fffb'
  428. }, // 0 起始颜色
  429. {
  430. offset: 1,
  431. color: '#0061ce'
  432. } // 1 结束颜色
  433. ]
  434. )
  435. },
  436. // 图表数据名称
  437. name: '岗位统计',
  438. // 图表类型
  439. type: 'bar',
  440. // 柱子宽度
  441. barWidth: '60%',
  442. // 数据
  443. data: countArr
  444. }
  445. ]
  446. };
  447. var myechart = echarts.init($('.users .bar.type')[0]);
  448. myechart.setOption(option);
  449. }
  450. // 用户
  451. function user(data) {
  452. let cate = data.cate;
  453. let titleArr = [];
  454. let countArr = [];
  455. let total = 0;
  456. let count = cate.length;
  457. // 中间省略的数据 准备三项
  458. var hiddenItem = {
  459. name: '',
  460. value: 10,
  461. // 柱子颜色
  462. itemStyle: {
  463. color: '#254065'
  464. },
  465. // 鼠标经过柱子颜色
  466. emphasis: {
  467. itemStyle: {
  468. color: '#254065'
  469. }
  470. },
  471. // 工具提示隐藏
  472. tooltip: {
  473. extraCssText: 'opacity:0'
  474. }
  475. };
  476. cate.forEach((item, index) => {
  477. if (index < 5 || index + 5 >= count) {
  478. titleArr.push(item.title)
  479. countArr.push(item.count)
  480. } else if (count > 10 && index == 5) {
  481. //随机三个
  482. let arr = []
  483. for (let i = 5; i < count - 5; i++) {
  484. arr.push(i)
  485. }
  486. let randomArr = [];
  487. while (randomArr.length < 3) {
  488. let temp = (Math.random() * arr.length) >> 0;
  489. randomArr.push(arr.splice(temp, 1)[0]);
  490. }
  491. randomArr.forEach((randomIndex) => {
  492. titleArr.push(cate[randomIndex].title)
  493. countArr.push(cate[randomIndex].count)
  494. })
  495. }
  496. total += item.count
  497. });
  498. $('.cate-count').text(count)
  499. $('.cate-total').text(total)
  500. option = {
  501. // 工具提示
  502. tooltip: {
  503. // 触发类型 经过轴触发axis 经过轴触发item
  504. trigger: 'item',
  505. // 轴触发提示才有效
  506. axisPointer: {
  507. // 默认为直线,可选为:'line' 线效果 | 'shadow' 阴影效果
  508. type: 'shadow'
  509. }
  510. },
  511. // 图表边界控制
  512. grid: {
  513. // 距离 上右下左 的距离
  514. left: '0',
  515. right: '3%',
  516. bottom: '3%',
  517. top: '5%',
  518. // 大小是否包含文本【类似于boxsizing】
  519. containLabel: true,
  520. //显示边框
  521. show: true,
  522. //边框颜色
  523. borderColor: 'rgba(0, 240, 255, 0.3)'
  524. },
  525. // 控制x轴
  526. xAxis: [{
  527. // 使用类目,必须有data属性
  528. type: 'category',
  529. // 使用 data 中的数据设为刻度文字
  530. data: titleArr,
  531. // 刻度设置
  532. axisTick: {
  533. // true意思:图形在刻度中间
  534. // false意思:图形在刻度之间
  535. alignWithLabel: false,
  536. show: false
  537. },
  538. //文字
  539. axisLabel: {
  540. color: '#4c9bfd'
  541. }
  542. }],
  543. // 控制y轴
  544. yAxis: [{
  545. // 使用数据的值设为刻度文字
  546. type: 'value',
  547. axisTick: {
  548. // true意思:图形在刻度中间
  549. // false意思:图形在刻度之间
  550. alignWithLabel: false,
  551. show: false
  552. },
  553. //文字
  554. axisLabel: {
  555. color: '#4c9bfd'
  556. },
  557. splitLine: {
  558. lineStyle: {
  559. color: 'rgba(0, 240, 255, 0.3)'
  560. }
  561. },
  562. }],
  563. // 控制x轴
  564. series: [
  565. {
  566. // series配置
  567. // 颜色
  568. itemStyle: {
  569. // 提供的工具函数生成渐变颜色
  570. color: new echarts.graphic.LinearGradient(
  571. // (x1,y2) 点到点 (x2,y2) 之间进行渐变
  572. 0, 0, 0, 1,
  573. [{
  574. offset: 0,
  575. color: '#00fffb'
  576. }, // 0 起始颜色
  577. {
  578. offset: 1,
  579. color: '#0061ce'
  580. } // 1 结束颜色
  581. ]
  582. )
  583. },
  584. // 图表数据名称
  585. name: '岗位统计',
  586. // 图表类型
  587. type: 'bar',
  588. // 柱子宽度
  589. barWidth: '60%',
  590. // 数据
  591. data: countArr
  592. }
  593. ]
  594. };
  595. var myechart = echarts.init($('.users .bar.cate')[0]);
  596. myechart.setOption(option);
  597. }
  598. //订单
  599. function order(data) {
  600. var data = {
  601. day365: {
  602. orders: '20,301,987',
  603. amount: '99834'
  604. },
  605. day90: {
  606. orders: '301,987',
  607. amount: '9834'
  608. },
  609. day30: {
  610. orders: '1,987',
  611. amount: '3834'
  612. },
  613. day1: {
  614. orders: '987',
  615. amount: '834'
  616. }
  617. }
  618. //点击事件
  619. $('.order').on('click', '.filter a', function() {
  620. //点击之后加类名
  621. $(this).addClass('active').siblings().removeClass('active');
  622. // 先获取点击a的 data-key自定义属性
  623. var key = $(this).attr('data-key');
  624. //获取自定义属性
  625. // data{}==>data.shuxing data['shuxing]
  626. key = data[key]; //
  627. $('.order .item h4:eq(0)').text(key.orders);
  628. $('.order .item h4:eq(1)').text(key.amount);
  629. });
  630. //定时器
  631. var index = 0;
  632. var aclick = $('.order a');
  633. setInterval(function() {
  634. index++;
  635. if (index > 3) {
  636. index = 0;
  637. }
  638. //每san秒调用点击事件
  639. aclick.eq(index).click();
  640. }, 3000);
  641. }
  642. //销售
  643. function sale(data) {
  644. let user_month = data.user_month;
  645. let titleArr = [];
  646. let countArr = [];
  647. user_month.forEach((item, index) => {
  648. titleArr.push(item.name)
  649. countArr.push(item.count)
  650. });
  651. var option = {
  652. //鼠标提示工具
  653. tooltip: {
  654. trigger: 'axis'
  655. },
  656. xAxis: {
  657. // 类目类型
  658. type: 'category',
  659. // x轴刻度文字
  660. data: titleArr,
  661. axisTick: {
  662. show: false //去除刻度线
  663. },
  664. axisLabel: {
  665. color: '#4c9bfd' //文本颜色
  666. },
  667. axisLine: {
  668. show: false //去除轴线
  669. },
  670. boundaryGap: false //去除轴内间距
  671. },
  672. yAxis: {
  673. // 数据作为刻度文字
  674. type: 'value',
  675. axisTick: {
  676. show: false //去除刻度线
  677. },
  678. axisLabel: {
  679. color: '#4c9bfd' //文本颜色
  680. },
  681. axisLine: {
  682. show: false //去除轴线
  683. },
  684. boundaryGap: false //去除轴内间距
  685. },
  686. //图例组件
  687. legend: {
  688. textStyle: {
  689. color: '#4c9bfd' // 图例文字颜色
  690. },
  691. right: '10%' //距离右边10%
  692. },
  693. // 设置网格样式
  694. grid: {
  695. show: true, // 显示边框
  696. top: '20%',
  697. left: '3%',
  698. right: '4%',
  699. bottom: '3%',
  700. borderColor: '#012f4a', // 边框颜色
  701. containLabel: true // 包含刻度文字在内
  702. },
  703. series: [{
  704. name: '注册用户',
  705. // 数据
  706. data: countArr,
  707. // 图表类型
  708. type: 'line',
  709. // 圆滑连接
  710. smooth: true,
  711. itemStyle: {
  712. color: '#00f2f1' // 线颜色
  713. }
  714. }]
  715. };
  716. var myechart = echarts.init($('.line')[0]);
  717. myechart.setOption(option);
  718. //点击效果
  719. var data = {
  720. year: [
  721. [24, 40, 101, 134, 90, 230, 210, 230, 120, 230, 210, 120],
  722. [40, 64, 191, 324, 290, 330, 310, 213, 180, 200, 180, 79]
  723. ],
  724. quarter: [
  725. [23, 75, 12, 97, 21, 67, 98, 21, 43, 64, 76, 38],
  726. [43, 31, 65, 23, 78, 21, 82, 64, 43, 60, 19, 34]
  727. ],
  728. month: [
  729. [34, 87, 32, 76, 98, 12, 32, 87, 39, 36, 29, 36],
  730. [56, 43, 98, 21, 56, 87, 43, 12, 43, 54, 12, 98]
  731. ],
  732. week: [
  733. [43, 73, 62, 54, 91, 54, 84, 43, 86, 43, 54, 53],
  734. [32, 54, 34, 87, 32, 45, 62, 68, 93, 54, 54, 24]
  735. ]
  736. }
  737. $('.sales ').on('click', '.caption a', function() {
  738. $(this).addClass('active').siblings('a').removeClass('active');
  739. //option series data
  740. //获取自定义属性值
  741. var key = $(this).attr('data-type');
  742. //取出对应的值
  743. key = data[key];
  744. //将值设置到 图表中
  745. option.series[0].data = key[0];
  746. option.series[1].data = key[1];
  747. //再次调用才能在页面显示
  748. myechart.setOption(option);
  749. });
  750. //定时器
  751. var index = 0;
  752. var timer = setInterval(function() {
  753. index++;
  754. if (index > 4) {
  755. index = 0;
  756. };
  757. $('.sales .caption a').eq(index).click();
  758. }, 2000);
  759. }
  760. function gauge(data) {
  761. var option = {
  762. series: [{
  763. type: 'pie',
  764. radius: ['130%', '150%'], // 放大图形
  765. center: ['50%', '80%'], // 往下移动 套住75%文字
  766. label: {
  767. show: false,
  768. },
  769. startAngle: 180,
  770. hoverOffset: 0, // 鼠标经过不变大
  771. data: [{
  772. value: 100,
  773. itemStyle: { // 颜色渐变#00c9e0->#005fc1
  774. color: {
  775. type: 'linear',
  776. x: 0,
  777. y: 0,
  778. x2: 0,
  779. y2: 1,
  780. colorStops: [{
  781. offset: 0,
  782. color: '#00c9e0'
  783. },
  784. {
  785. offset: 1,
  786. color: '#005fc1'
  787. }
  788. ]
  789. }
  790. }
  791. },
  792. {
  793. value: 100,
  794. itemStyle: {
  795. color: '#12274d'
  796. }
  797. }, // 颜色#12274d
  798. {
  799. value: 200,
  800. itemStyle: {
  801. color: 'transparent'
  802. }
  803. } // 透明隐藏第三块区域
  804. ]
  805. }]
  806. };
  807. var myechart = echarts.init($('.gauge')[0]);
  808. myechart.setOption(option);
  809. }
  810. function province(data) {
  811. var data = [{
  812. name: '可爱多',
  813. num: '9,086'
  814. },
  815. {
  816. name: '娃哈哈',
  817. num: '8,341'
  818. },
  819. {
  820. name: '喜之郎',
  821. num: '7,407'
  822. },
  823. {
  824. name: '八喜',
  825. num: '6,080'
  826. },
  827. {
  828. name: '小洋人',
  829. num: '6,724'
  830. },
  831. {
  832. name: '好多鱼',
  833. num: '2,170'
  834. },
  835. ]
  836. $('.inner').on('mouseenter', '.sup li', function() {
  837. $(this).addClass('active').siblings().removeClass('active');
  838. //获取随机的值 sort方法 是给数组排序 a-b是从小到大
  839. //.5-随机0-1的数 可能为正可能为负 排序就会随机
  840. var radomData = data.sort(function(a, b) {
  841. return 0.5 - Math.random()
  842. });
  843. var html = '';
  844. radomData.forEach(function(item) {
  845. html +=
  846. `<li><span>${item.name}</span><span>${item.num} <s class="icon-up"></s></span></li>`;
  847. });
  848. //渲染
  849. $('.sub').html(html);
  850. });
  851. $('.province .sup li').eq(0).mouseenter();
  852. var index = 0;
  853. var timer = setInterval(() => {
  854. index++;
  855. if (index > 5) {
  856. index = 0;
  857. }
  858. $('.sup li').eq(index).mouseenter();
  859. }, 2000);
  860. }