main.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. $(function () {
  2. // 定义字体大小
  3. function placeholderPic() {
  4. w = document.documentElement.clientWidth / 80;
  5. document.documentElement.style.fontSize = w + 'px';
  6. }
  7. placeholderPic()
  8. // TOP5颜色循环
  9. function topColor() {
  10. var ele = $('.top5-content ul').children();
  11. var length = ele.length;
  12. var i = 1;
  13. setInterval(function () {
  14. $(ele[i]).find('.cicle').css({
  15. 'background': 'url(./images/orange.png) no-repeat center',
  16. 'backgroundSize': '100%'
  17. })
  18. $(ele[i]).find('.li-content').css({
  19. 'background': 'url(./images/border2.png) no-repeat center',
  20. 'backgroundSize': 'contain'
  21. })
  22. $(ele[i]).siblings().find('.cicle').css({
  23. 'background': 'url(./images/green.png) no-repeat center',
  24. 'backgroundSize': '100%'
  25. })
  26. $(ele[i]).siblings().find('.li-content').css({
  27. 'background': 'url(./images/border.png) no-repeat center',
  28. 'backgroundSize': 'contain'
  29. })
  30. i++
  31. if (i == length) {
  32. i = 0
  33. }
  34. }, 3000)
  35. }
  36. topColor()
  37. // 水波图
  38. function waterChart(ele) {
  39. var myChart = echarts.init(document.querySelector(ele));
  40. option = {
  41. series: [{
  42. color:['#09828e','#09c2c8'],
  43. type: 'liquidFill',
  44. data: [0.78, 0.78],
  45. radius: '90%',
  46. outline: {
  47. show: false
  48. },
  49. backgroundStyle: {
  50. color:'transparent',
  51. borderColor: '#0ac1c7',
  52. borderWidth: 1,
  53. shadowColor: 'rgba(0, 0, 0, 0.4)',
  54. shadowBlur: 20
  55. },
  56. shape: 'path://"M61.3,2c6.2,0,12.1,1.1,17.5,3.4C84.3,7.7,89,10.8,93,14.6c4.1,4,7.3,8.6,9.7,13.8c2.4,5.2,3.5,10.9,3.5,16.9c0,8.1-2.4,16.9-7.1,26.4c-4.7,9.4-9.9,18.2-15.5,26.2c-5.6,8-13.1,17.4-22.4,28.1c-9.3-10.7-16.8-20-22.4-28.1c-5.6-8-10.8-16.8-15.5-26.2c-4.7-9.4-7.1-18.2-7.1-26.4c0-6,1.2-11.6,3.5-16.9c2.4-5.2,5.6-9.8,9.7-13.8c4-3.9,8.8-7,14.2-9.2C49.2,3.1,55,2,61.3,2L61.3,2z"',
  57. label: {
  58. normal: {
  59. position: ['50%', '50%'],
  60. formatter: function () {
  61. return '78%';
  62. },
  63. textStyle: {
  64. fontSize: 0.5 * w,
  65. color: '#D94854'
  66. }
  67. }
  68. }
  69. }]
  70. }
  71. myChart.setOption(option)
  72. }
  73. waterChart('.chart1')
  74. waterChart('.chart2')
  75. function draw(ele, val, con, max, color) {
  76. var chart = echarts.init(document.querySelector(ele))
  77. var value = val
  78. option = {
  79. grid: {
  80. left: '20%',
  81. top: '0',
  82. right: '20%',
  83. bottom: '0'
  84. },
  85. "xAxis": {
  86. type: 'value',
  87. "splitLine": {
  88. "show": false
  89. },
  90. "axisLine": {
  91. "show": false
  92. },
  93. "axisLabel": {
  94. "show": false
  95. },
  96. "axisTick": {
  97. "show": false
  98. }
  99. },
  100. "yAxis": [{
  101. "type": "category",
  102. "inverse": false,
  103. "data": [],
  104. "axisLine": {
  105. "show": false
  106. },
  107. "axisTick": {
  108. "show": false
  109. },
  110. "axisLabel": {
  111. show: false
  112. }
  113. }],
  114. "series": [
  115. {
  116. type: 'pictorialBar',
  117. data: [value],
  118. itemStyle: {
  119. normal: {
  120. color: color
  121. }
  122. },
  123. symbolRepeat: 'fixed',
  124. symbolClip: true,
  125. symbolSize: [0.5 * w, w],
  126. symbol: 'roundRect',
  127. label: {
  128. show: true,
  129. position: 'left',
  130. formatter: function () {
  131. return con
  132. },
  133. color: '#fff',
  134. fontSize: 0.7 * w,
  135. },
  136. z: 1000
  137. },
  138. {
  139. type: 'pictorialBar',
  140. itemStyle: {
  141. normal: {
  142. color: '#193040'
  143. }
  144. },
  145. data: [max],
  146. animationDuration: 0,
  147. symbolRepeat: 'fixed',
  148. // symbolMargin: '20%',
  149. symbol: 'roundRect',
  150. symbolSize: [0.5 * w, w],
  151. label: {
  152. show: true,
  153. position: 'right',
  154. formatter: function () {
  155. return Math.floor(val * 100 / max) + '%'
  156. },
  157. color: '#fff',
  158. fontSize: 0.7 * w,
  159. }
  160. }
  161. ]
  162. };
  163. chart.setOption(option)
  164. }
  165. draw('.shoeChart', 52563, '完成率', 65000, '#09c4ca')
  166. draw('.clothesChart', 32563, '完成率', 45000, '#09c4ca')
  167. draw('.mzChart', 12563, '完成率', 35000, '#09c4ca')
  168. // 折线图
  169. function lineChart(ele) {
  170. var chart = echarts.init(document.querySelector(ele));
  171. var xdata = [];
  172. var dataArr = [];
  173. for (var i = 1; i < 30; i++) {
  174. xdata.push(i);
  175. dataArr.push(Math.floor(Math.random() * 20 + 5))
  176. }
  177. var max = Math.max.apply(null, dataArr);
  178. var seriesName = '';
  179. option = {
  180. grid: {
  181. left: "5%",
  182. // right: "2%",
  183. bottom: "5%",
  184. top: "15%",
  185. containLabel: true
  186. },
  187. xAxis: {
  188. type: "category",
  189. data: xdata,
  190. axisLabel: {
  191. show: true,
  192. textStyle: {
  193. color: "#fff",
  194. fontSize: 0.5 * w
  195. }
  196. },
  197. axisLine: {
  198. lineStyle: {
  199. color: 'transparent',
  200. width: 2 //这里是为了突出显示加上的
  201. }
  202. }
  203. },
  204. tooltip: {
  205. show: true,
  206. trigger: 'item'
  207. },
  208. yAxis: [{
  209. type: 'value',
  210. // name: '立方米',
  211. min: 0,
  212. max: 25,
  213. axisLabel: {
  214. formatter: '{value}k',
  215. textStyle: {
  216. color: '#fff',
  217. fontSize: 0.5 * w
  218. }
  219. },
  220. axisLine: {
  221. lineStyle: {
  222. color: 'transparent',
  223. width: 2 //这里是为了突出显示加上的
  224. }
  225. },
  226. axisTick: {
  227. show: false,
  228. },
  229. splitLine: {
  230. show: false
  231. }
  232. }],
  233. series: [{
  234. name: seriesName,
  235. type: 'line',
  236. stack: '总量',
  237. symbol: 'none',
  238. smooth: false,
  239. symbol: "circle",
  240. itemStyle: {
  241. normal: {
  242. color: '#34a39a',
  243. lineStyle: {
  244. color: "#34a39a",
  245. width: 2
  246. },
  247. areaStyle: {
  248. //color: '#94C9EC'
  249. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  250. offset: 0,
  251. color: "#08808b"
  252. },
  253. {
  254. offset: 1,
  255. color: 'rgba(0,0,0,0.2)',
  256. }
  257. ])
  258. }
  259. }
  260. },
  261. data: dataArr
  262. },]
  263. };
  264. var index = 0; //播放所在下标
  265. var mTime = setInterval(function () {
  266. chart.dispatchAction({
  267. type: 'showTip',
  268. seriesIndex: 0,
  269. dataIndex: index
  270. });
  271. index++;
  272. if (index > xdata.length) {
  273. index = 0;
  274. }
  275. }, 1500);
  276. chart.setOption(option)
  277. }
  278. lineChart('.lineChart')
  279. // 中间背景雨
  280. function rainBg() {
  281. var c = document.querySelector(".rain");
  282. var ctx = c.getContext("2d");//获取canvas上下文
  283. var w = c.width = document.querySelector('.total').clientWidth;
  284. var h = c.height = document.querySelector('.total').clientHeight;
  285. //设置canvas宽、高
  286. function random(min, max) {
  287. return Math.random() * (max - min) + min;
  288. }
  289. function RainDrop() { }
  290. //雨滴对象 这是绘制雨滴动画的关键
  291. RainDrop.prototype = {
  292. init: function () {
  293. this.x = random(0, w);//雨滴的位置x
  294. this.y = h;//雨滴的位置y
  295. this.color = 'hsl(180, 100%, 50%)';//雨滴颜色 长方形的填充色
  296. this.vy = random(4, 5);//雨滴下落速度
  297. this.hit = 0;//下落的最大值
  298. this.size = 2;//长方形宽度
  299. },
  300. draw: function () {
  301. if (this.y > this.hit) {
  302. var linearGradient = ctx.createLinearGradient(this.x, this.y, this.x, this.y + this.size * 30)
  303. // 设置起始颜色
  304. linearGradient.addColorStop(0, '#14789c')
  305. // 设置终止颜色
  306. linearGradient.addColorStop(1, '#090723')
  307. // 设置填充样式
  308. ctx.fillStyle = linearGradient
  309. ctx.fillRect(this.x, this.y, this.size, this.size * 50);//绘制长方形,通过多次叠加长方形,形成雨滴下落效果
  310. }
  311. this.update();//更新位置
  312. },
  313. update: function () {
  314. if (this.y > this.hit) {
  315. this.y -= this.vy;//未达到底部,增加雨滴y坐标
  316. } else {
  317. this.init();
  318. }
  319. }
  320. };
  321. function resize() {
  322. w = c.width = window.innerWidth;
  323. h = c.height = window.innerHeight;
  324. }
  325. //初始化一个雨滴
  326. var rs = []
  327. for (var i = 0; i < 10; i++) {
  328. setTimeout(function () {
  329. var r = new RainDrop();
  330. r.init();
  331. rs.push(r);
  332. }, i * 300)
  333. }
  334. function anim() {
  335. ctx.clearRect(0, 0, w, h);//填充背景色,注意不要用clearRect,否则会清空前面的雨滴,导致不能产生叠加的效果
  336. for (var i = 0; i < rs.length; i++) {
  337. rs[i].draw();//绘制雨滴
  338. }
  339. requestAnimationFrame(anim);//控制动画帧
  340. }
  341. window.addEventListener("resize", resize);
  342. //启动动画
  343. anim()
  344. }
  345. rainBg()
  346. // 中间虚线
  347. function dashed() {
  348. var canvas = document.querySelector('.dashed')
  349. var ctx = canvas.getContext('2d')
  350. var w = canvas.width = document.querySelector('.total').clientWidth
  351. var h = canvas.height = document.querySelector('.total').clientHeight / 3 * 2
  352. ctx.lineWidth = 3
  353. ctx.setLineDash([3, 3]);
  354. ctx.fillStyle = '#93f8fb'
  355. ctx.shadowOffsetX = 0;
  356. // 阴影的y偏移
  357. ctx.shadowOffsetY = 0;
  358. // 阴影颜色
  359. ctx.shadowColor = '#93f8fb';
  360. // 阴影的模糊半径
  361. ctx.shadowBlur = 15;
  362. ctx.save() //缓存初始状态
  363. // 绘制第一条曲线
  364. ctx.beginPath()
  365. var grd = ctx.createLinearGradient(w / 11 * 2, h / 3, w / 5 * 2, h);
  366. grd.addColorStop(0, "#54e2e6");
  367. grd.addColorStop(1, "#065261");
  368. ctx.strokeStyle = grd;
  369. ctx.moveTo(w / 5 * 2, h)
  370. ctx.quadraticCurveTo(w / 5, h / 6 * 5, w / 11 * 2, h / 3);
  371. ctx.stroke();
  372. // 绘制第一条曲线上的圆光效果
  373. ctx.beginPath()
  374. ctx.moveTo(w / 11 * 2, h / 3)
  375. ctx.arc(w / 11 * 2, h / 3, 5, 0, Math.PI * 2)
  376. ctx.fill()
  377. ctx.restore()
  378. ctx.save()
  379. // 绘制第二条线
  380. ctx.beginPath()
  381. var grd = ctx.createLinearGradient(w / 11 * 3.3, h / 2, w / 3 * 1.1, h / 6 * 5);
  382. grd.addColorStop(0, "#e08d03");
  383. grd.addColorStop(1, "#2e6a5c");
  384. ctx.strokeStyle = grd;
  385. ctx.moveTo(w / 3 * 1.1, h / 6 * 5)
  386. ctx.quadraticCurveTo(w / 5 * 1.5, h / 6 * 4.2, w / 11 * 3.3, h / 2);
  387. ctx.stroke();
  388. // 绘制第二条曲线上的圆光效果
  389. ctx.beginPath()
  390. ctx.moveTo(w / 11 * 3.3, h / 2)
  391. ctx.arc(w / 11 * 3.3, h / 2, 5, 0, Math.PI * 2)
  392. ctx.fill()
  393. ctx.restore()
  394. ctx.save()
  395. // 绘制第三条线
  396. ctx.beginPath()
  397. var grd = ctx.createLinearGradient(w / 3 * 1.4, h / 5, w / 5 * 2, h / 2);
  398. grd.addColorStop(0, "#e08d03");
  399. grd.addColorStop(1, "#2e6a5c");
  400. ctx.strokeStyle = grd;
  401. ctx.moveTo(w / 5 * 2, h / 2 )
  402. ctx.quadraticCurveTo(w / 3 * 1.2, h / 4 * 1.4, w / 3 * 1.4, h / 5);
  403. ctx.stroke();
  404. // 绘制第三条曲线上的圆光效果
  405. ctx.beginPath()
  406. ctx.moveTo(w / 3 * 1.4, h / 5)
  407. ctx.arc(w / 3 * 1.4, h / 5, 5, 0, Math.PI * 2)
  408. ctx.fill()
  409. ctx.restore()
  410. ctx.save()
  411. // 绘制第四条线
  412. ctx.beginPath()
  413. var grd = ctx.createLinearGradient(w / 5 * 3.1, h / 3*1.2, w / 5 * 3.2, h / 2 * 1.5);
  414. grd.addColorStop(0, "#e08d03");
  415. grd.addColorStop(1, "#2e6a5c");
  416. ctx.strokeStyle = grd;
  417. ctx.moveTo(w / 5 * 3.2, h / 2 * 1.5)
  418. ctx.quadraticCurveTo(w / 5 * 3.35, h / 2 * 1.2, w / 5 * 3.1, h / 3*1.2);
  419. ctx.stroke();
  420. // 绘制第四条曲线上的圆光效果
  421. ctx.beginPath()
  422. ctx.moveTo( w / 5 * 3.1, h / 3*1.2)
  423. ctx.arc( w / 5 * 3.1, h / 3*1.2, 5, 0, Math.PI * 2)
  424. ctx.fill()
  425. ctx.restore()
  426. ctx.save()
  427. // 绘制第五条线
  428. ctx.beginPath()
  429. var grd = ctx.createLinearGradient(w / 5 * 3.3, h / 4, w / 5 * 3.2, h / 2 * 1.9);
  430. grd.addColorStop(0, "#e08d03");
  431. grd.addColorStop(1, "#2e6a5c");
  432. ctx.strokeStyle = grd;
  433. ctx.moveTo(w / 5 * 3.03, h / 2 * 1.9)
  434. ctx.quadraticCurveTo(w / 5 * 3.8, h / 2 * 1.2, w / 5 * 3.3, h / 4);
  435. ctx.stroke();
  436. // 绘制第五条曲线上的圆光效果
  437. ctx.beginPath()
  438. ctx.moveTo(w / 5 * 3.3, h / 4)
  439. ctx.arc(w / 5 * 3.3, h / 4, 5, 0, Math.PI * 2)
  440. ctx.fill()
  441. ctx.restore()
  442. ctx.save()
  443. // 绘制第六条线
  444. ctx.beginPath()
  445. var grd = ctx.createLinearGradient(w / 5 * 3.8, h / 2*1.2, w / 5 * 2.9, h);
  446. grd.addColorStop(0, "#e08d03");
  447. grd.addColorStop(1, "#2e6a5c");
  448. ctx.strokeStyle = grd;
  449. ctx.moveTo(w / 5 * 2.9, h)
  450. ctx.quadraticCurveTo(w / 5 * 3.7, h / 2 * 1.6, w / 5 * 3.8, h / 2*1.2);
  451. ctx.stroke();
  452. // 绘制第六条曲线上的圆光效果
  453. ctx.beginPath()
  454. ctx.moveTo(w / 5 * 3.8, h / 2*1.2)
  455. ctx.arc(w / 5 * 3.8, h / 2*1.2, 5, 0, Math.PI * 2)
  456. ctx.fill()
  457. }
  458. dashed()
  459. })