chartMixin.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  1. 'use strict';
  2. const chartMixin = function () {// 通知消息
  3. return {
  4. data(){
  5. return{
  6. }
  7. },
  8. methods: {
  9. chartWordCloud(data){// 词云
  10. let myChart = echarts.init(document.getElementById('myChart0'));
  11. let option = {
  12. title: {text: '关键词云图'},
  13. tooltip: {trigger: 'item'},
  14. series: [{
  15. type: 'wordCloud',
  16. shape: 'circle',
  17. keepAspect: false,
  18. maskImage: '',
  19. left: 'center',
  20. top: 'center',
  21. width: '90%',
  22. height: '85%',
  23. right: null,
  24. bottom: null,
  25. sizeRange: [12, 60],
  26. rotationRange: [-90, 90],
  27. rotationStep: 45,
  28. gridSize: 10,
  29. drawOutOfBound: false,
  30. shrinkToFit: false,
  31. layoutAnimation: true,
  32. textStyle: {
  33. fontFamily: 'sans-serif',
  34. fontWeight: 'bold',
  35. color: function () {
  36. // Random color
  37. return 'rgb(' + [
  38. Math.round(Math.random() * 160),
  39. Math.round(Math.random() * 160),
  40. Math.round(Math.random() * 160)
  41. ].join(',') + ')';
  42. }
  43. },
  44. emphasis: {
  45. focus: 'self',
  46. textStyle: {
  47. textShadowBlur: 10,
  48. textShadowColor: '#333'
  49. }
  50. },
  51. data:data
  52. }]
  53. }
  54. myChart.setOption(option)
  55. window.addEventListener("resize", function() {
  56. myChart.resize()
  57. })
  58. },
  59. //公众号推文
  60. chartWechats(data){
  61. let myChart = echarts.init(document.getElementById('myChart1'))
  62. let option = {
  63. title: {
  64. text: '公众号推文数据'
  65. },
  66. tooltip: {
  67. trigger: 'axis',
  68. axisPointer: {
  69. type: 'shadow'
  70. }
  71. },
  72. legend: {},
  73. grid: {
  74. left: '3%',
  75. right: '4%',
  76. bottom: '3%',
  77. containLabel: true
  78. },
  79. xAxis: {
  80. type: 'category',
  81. data: data.xAxis
  82. },
  83. yAxis: {
  84. type: 'value',
  85. boundaryGap: [0, 0.01],
  86. },
  87. series: [
  88. {
  89. name: '阅读量',
  90. type: 'line',
  91. color:['#A294FF'],
  92. data: data.yAxis.yuedu
  93. },
  94. {
  95. name: '触达量',
  96. type: 'line',
  97. color:['#45CCF8'],
  98. data: data.yAxis.chuda
  99. }
  100. ]
  101. };
  102. myChart.setOption(option); // 将选项应用到图表实例上,生成图表
  103. },
  104. chartIntention(data){ // 采美全渠道展现量
  105. let myChart = echarts.init(document.getElementById('myChart2'))
  106. let option = {
  107. title: {
  108. text: '采美全渠道展现量'
  109. },
  110. tooltip: {
  111. trigger: 'axis',
  112. axisPointer: {
  113. type: 'shadow' //
  114. }
  115. },
  116. legend: {
  117. orient: 'horizontal',
  118. right: '0%',
  119. top:'0%',
  120. itemGap: 10, // 这里可以设置图例每项之间的间隔
  121. itemWidth: 20, // 这里可以设置图例标记的宽度
  122. itemHeight: 14, // 这里可以设置图例标记的高度
  123. textStyle: {
  124. fontSize: 12,
  125. },
  126. data: ['官网', '公众号', '微博', '小红书','其他渠道']
  127. },
  128. grid: {
  129. left: '3%',
  130. right: '4%',
  131. bottom: '3%',
  132. containLabel: true
  133. },
  134. xAxis: {
  135. type: 'category',
  136. data: data.xAxis
  137. },
  138. yAxis: {
  139. type: 'value',
  140. },
  141. series: [
  142. {
  143. name: '官网',
  144. type: 'bar',
  145. stack: 'total',
  146. label: {
  147. show: false
  148. },
  149. emphasis: {
  150. focus: 'series'
  151. },
  152. barGap:'60%',
  153. barCategoryGap:'60%',
  154. data: data.yAxis.website
  155. },
  156. {
  157. name: '公众号',
  158. type: 'bar',
  159. stack: 'total',
  160. label: {
  161. show: false
  162. },
  163. emphasis: {
  164. focus: 'series'
  165. },
  166. barGap:'60%',
  167. barCategoryGap:'60%',
  168. data: data.yAxis.general
  169. },
  170. {
  171. name: '微博',
  172. type: 'bar',
  173. stack: 'total',
  174. label: {
  175. show: false
  176. },
  177. emphasis: {
  178. focus: 'series'
  179. },
  180. barGap:'60%',
  181. barCategoryGap:'60%',
  182. data: data.yAxis.twitter
  183. },
  184. {
  185. name: '小红书',
  186. type: 'bar',
  187. stack: 'total',
  188. label: {
  189. show: false
  190. },
  191. emphasis: {
  192. focus: 'series'
  193. },
  194. barGap:'60%',
  195. barCategoryGap:'60%',
  196. data: data.yAxis.redBook
  197. },
  198. {
  199. name: '其他渠道',
  200. type: 'bar',
  201. stack: 'total',
  202. label: {
  203. show: false
  204. },
  205. emphasis: {
  206. focus: 'series'
  207. },
  208. barGap:'60%',
  209. barCategoryGap:'60%',
  210. data: data.yAxis.other
  211. }
  212. ]
  213. };
  214. myChart.setOption(option); // 将选项应用到图表实例上,生成图表
  215. },
  216. // 全渠道访问用户数量
  217. chartAllVisits(data){
  218. let myChart = echarts.init(document.getElementById('myChart3'))
  219. let option = {
  220. title: {
  221. text: '采美全渠道访问量'
  222. },
  223. tooltip: {
  224. trigger: 'axis',
  225. axisPointer: {
  226. type: 'shadow' //
  227. }
  228. },
  229. legend: {
  230. orient: 'horizontal',
  231. right: '0%',
  232. top:'0%',
  233. itemGap: 10, // 这里可以设置图例每项之间的间隔
  234. itemWidth: 20, // 这里可以设置图例标记的宽度
  235. itemHeight: 14, // 这里可以设置图例标记的高度
  236. textStyle: {
  237. fontSize: 12,
  238. },
  239. data: ['信息中心', '公众号', '微博', '小红书','其他渠道']
  240. },
  241. grid: {
  242. left: '3%',
  243. right: '4%',
  244. bottom: '3%',
  245. containLabel: true
  246. },
  247. xAxis: {
  248. type: 'category',
  249. data: data.xAxis
  250. },
  251. yAxis: {
  252. type: 'value',
  253. },
  254. series: [
  255. {
  256. name: '信息中心',
  257. type: 'bar',
  258. stack: 'total',
  259. label: {
  260. show: false
  261. },
  262. emphasis: {
  263. focus: 'series'
  264. },
  265. barGap:'60%',
  266. barCategoryGap:'60%',
  267. data: data.yAxis.website
  268. },
  269. {
  270. name: '公众号',
  271. type: 'bar',
  272. stack: 'total',
  273. label: {
  274. show: false
  275. },
  276. emphasis: {
  277. focus: 'series'
  278. },
  279. barGap:'60%',
  280. barCategoryGap:'60%',
  281. data: data.yAxis.general
  282. },
  283. {
  284. name: '微博',
  285. type: 'bar',
  286. stack: 'total',
  287. label: {
  288. show: false
  289. },
  290. emphasis: {
  291. focus: 'series'
  292. },
  293. barGap:'60%',
  294. barCategoryGap:'60%',
  295. data: data.yAxis.twitter
  296. },
  297. {
  298. name: '小红书',
  299. type: 'bar',
  300. stack: 'total',
  301. label: {
  302. show: false
  303. },
  304. emphasis: {
  305. focus: 'series'
  306. },
  307. barGap:'60%',
  308. barCategoryGap:'60%',
  309. data: data.yAxis.redBook
  310. },
  311. {
  312. name: '其他渠道',
  313. type: 'bar',
  314. stack: 'total',
  315. label: {
  316. show: false
  317. },
  318. emphasis: {
  319. focus: 'series'
  320. },
  321. barGap:'60%',
  322. barCategoryGap:'60%',
  323. data: data.yAxis.other
  324. }
  325. ]
  326. };
  327. myChart.setOption(option); // 将选项应用到图表实例上,生成图表
  328. },
  329. chartProportion(data){ // 渠道来源占比
  330. let myChart = echarts.init(document.getElementById('myChart4'))
  331. let option = {
  332. title: {
  333. text: '访问用户渠道来源占比'
  334. },
  335. legend: {
  336. orient: 'horizontal',
  337. right: '0%',
  338. top:'0%',
  339. itemGap: 10, // 这里可以设置图例每项之间的间隔
  340. itemWidth: 20, // 这里可以设置图例标记的宽度
  341. itemHeight: 14, // 这里可以设置图例标记的高度
  342. textStyle: {
  343. fontSize: 12,
  344. },
  345. data: ['商城', '公众号', '小红书']
  346. },
  347. xAxis: {
  348. type: 'category',
  349. data: data.xAxis
  350. },
  351. yAxis: {
  352. type: 'value',
  353. },
  354. series: [
  355. {
  356. name: '商城',
  357. type: 'line',
  358. data: data.yAxis.mall,
  359. label: {
  360. show: true,
  361. formatter(param) {
  362. // correct the percentage
  363. return param.value + '%'
  364. }
  365. }
  366. },
  367. {
  368. name: '公众号',
  369. type: 'line',
  370. data: data.yAxis.general,
  371. label: {
  372. show: true,
  373. formatter(param) {
  374. // correct the percentage
  375. return param.value + '%'
  376. }
  377. }
  378. },
  379. {
  380. name: '小红书',
  381. type: 'line',
  382. data: data.yAxis.redBook,
  383. label: {
  384. show: true,
  385. formatter(param) {
  386. // correct the percentage
  387. return param.value + '%'
  388. }
  389. }
  390. }
  391. ]
  392. };
  393. myChart.setOption(option); // 将选项应用到图表实例上,生成图表
  394. },
  395. // 采美站内访问量
  396. chartStationVisits(data){
  397. let myChart = echarts.init(document.getElementById('myChart5'))
  398. let option = {
  399. title: {
  400. text: '品牌整体访问量'
  401. },
  402. tooltip: {
  403. trigger: 'axis',
  404. axisPointer: {
  405. type: 'shadow' //
  406. }
  407. },
  408. legend: {
  409. orient: 'horizontal',
  410. right: '0%',
  411. top:'0%',
  412. itemGap: 10, // 这里可以设置图例每项之间的间隔
  413. itemWidth: 20, // 这里可以设置图例标记的宽度
  414. itemHeight: 14, // 这里可以设置图例标记的高度
  415. textStyle: {
  416. fontSize: 12,
  417. },
  418. data: ['游客访问量', '机构访问量']
  419. },
  420. grid: {
  421. left: '3%',
  422. right: '4%',
  423. bottom: '3%',
  424. containLabel: true
  425. },
  426. xAxis: {
  427. type: 'category',
  428. data: data.xAxis
  429. },
  430. yAxis: {
  431. type: 'value',
  432. },
  433. series: [
  434. {
  435. name: '游客访问量',
  436. type: 'bar',
  437. stack: 'total',
  438. label: {
  439. show: false
  440. },
  441. emphasis: {
  442. focus: 'series'
  443. },
  444. barGap:'60%',
  445. barCategoryGap:'60%',
  446. data: data.yAxis.tourist
  447. },
  448. {
  449. name: '机构访问量',
  450. type: 'bar',
  451. stack: 'total',
  452. label: {
  453. show: false
  454. },
  455. emphasis: {
  456. focus: 'series'
  457. },
  458. barGap:'60%',
  459. barCategoryGap:'60%',
  460. data: data.yAxis.clubs
  461. }
  462. ]
  463. };
  464. myChart.setOption(option); // 将选项应用到图表实例上,生成图表
  465. },
  466. chartVisitTimes(data){ // 页面平均访问时长top5
  467. let myChart = echarts.init(document.getElementById('myChart6'))
  468. let option = {
  469. title: {
  470. text: '访问页面平均时长top5(单位:秒)',
  471. left: 'left'
  472. },
  473. tooltip: {
  474. trigger: 'axis',
  475. color:'#FE8645',
  476. formatter: function(params) { // 格式化 tooltip 内容
  477. return '访问时长:'+ params[0].value + 's'
  478. },
  479. axisPointer: {
  480. type: 'shadow'
  481. }
  482. },
  483. legend: {
  484. show:false,
  485. },
  486. grid: {
  487. left: '3%',
  488. right: '4%',
  489. bottom: '3%',
  490. containLabel: true
  491. },
  492. xAxis: {
  493. type: 'category',
  494. data: data.xAxis
  495. },
  496. yAxis: {
  497. type: 'value',
  498. splitLine:{
  499. show: true,
  500. lineStyle:{
  501. opacity:0.8,
  502. color:'#E1E1E1',
  503. type:'dashed'
  504. }
  505. },
  506. boundaryGap: [0, 0.01],
  507. axisLabel:{
  508. show: true,
  509. textStyle:{
  510. color: '#999999', //更改坐标轴文字颜色
  511. fontSize : 14, //更改坐标轴文字大小
  512. }
  513. },
  514. axisTick: {//轴网格,在xAxis或yAxis根下
  515. lineStyle:{
  516. width:1,
  517. color:'#E1E1E1',
  518. type:'dashed'
  519. }
  520. }
  521. },
  522. series: [
  523. {
  524. type: 'line',
  525. name: '访问时长',
  526. data: data.yAxis.series,
  527. color:'#4880FF',
  528. label: {
  529. show: true
  530. },
  531. areaStyle: {
  532. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  533. {
  534. offset: 0,
  535. color: 'rgb(72,128,255)'
  536. },
  537. {
  538. offset: 1,
  539. color: 'rgb(68,92,207)'
  540. }
  541. ])
  542. }
  543. }
  544. ]
  545. };
  546. myChart.setOption(option); // 将选项应用到图表实例上,生成图表
  547. },
  548. // 线索用户月度分布
  549. chartLeadUserMonthly(data){
  550. let myChart = echarts.init(document.getElementById('myChart7'))
  551. let option = {
  552. title: {
  553. text: '线索用户月度分布(单位:个)'
  554. },
  555. tooltip: {
  556. trigger: 'axis',
  557. axisPointer: {
  558. type: 'shadow' //
  559. }
  560. },
  561. legend: {
  562. orient: 'horizontal',
  563. right: '0%',
  564. top:'0%',
  565. itemGap: 10, // 这里可以设置图例每项之间的间隔
  566. itemWidth: 20, // 这里可以设置图例标记的宽度
  567. itemHeight: 14, // 这里可以设置图例标记的高度
  568. textStyle: {
  569. fontSize: 12,
  570. },
  571. data: ['6月', '7月', '8月', '9月']
  572. },
  573. grid: {
  574. left: '3%',
  575. right: '4%',
  576. bottom: '3%',
  577. containLabel: true
  578. },
  579. xAxis: {
  580. type: 'category',
  581. data: data.xAxis
  582. },
  583. yAxis: {
  584. type: 'value',
  585. },
  586. series: [
  587. {
  588. name: '线索用户月度分布',
  589. type: 'bar',
  590. stack: 'total',
  591. label: {
  592. show: true
  593. },
  594. emphasis: {
  595. focus: 'series'
  596. },
  597. barGap:'60%',
  598. barCategoryGap:'60%',
  599. color:'#4880FF',
  600. data: data.yAxis.series
  601. }
  602. ]
  603. };
  604. myChart.setOption(option); // 将选项应用到图表实例上,生成图表
  605. },
  606. chartChannels(data){// 线索用户地狱分布
  607. let myChart = echarts.init(document.getElementById('myChart8'))
  608. let option = {
  609. title: {
  610. text: '线索用户地域分布'
  611. },
  612. tooltip: {
  613. trigger: 'item'
  614. },
  615. visualMap: {
  616. min: 0,
  617. max: 1000,
  618. left: 'left',
  619. top: 'bottom',
  620. text: ['高', '低'], // 文本,默认为数值文本
  621. calculable: true,
  622. inRange: {
  623. color: ['#e0ffff', '#006edd']
  624. }
  625. },
  626. series: [
  627. {
  628. name: '中国',
  629. type: 'map',
  630. mapType: 'china', // 设置地图类型为中国省份地图
  631. roam: false, // 禁止缩放和平移操作
  632. label: {
  633. show: true // 显示省份标签
  634. },
  635. data: data.yAxis.series,
  636. itemStyle:{
  637. fontSize: 14,
  638. color:'#FE8645'
  639. }
  640. }
  641. ]
  642. };
  643. myChart.setOption(option); // 将选项应用到图表实例上,生成图表
  644. },
  645. chartUrbanize(data){ // 用户类型分布
  646. let myChart = echarts.init(document.getElementById('myChart9'))
  647. let option = {
  648. title: {
  649. text: '用户类型分布',
  650. left: 'left'
  651. },
  652. tooltip: {
  653. trigger: 'item'
  654. },
  655. legend: {
  656. orient: 'horizontal',
  657. top:'bottom'
  658. },
  659. series: [
  660. {
  661. name: '',
  662. color:['#45CCF8','#4880FF','#FE8645'],
  663. type: 'pie',
  664. radius: ['35%', '25%'],
  665. center: ['50%', '50%'],
  666. avoidLabelOverlap: false,
  667. label: {
  668. show: true,
  669. formatter(param) {
  670. // correct the percentage
  671. return param.name + ' (' + param.value + '%)';
  672. }
  673. },
  674. emphasis: {
  675. itemStyle: {
  676. shadowBlur: 10,
  677. shadowOffsetX: 0,
  678. shadowColor: 'rgba(0, 0, 0, 0.5)'
  679. }
  680. },
  681. data: data.series
  682. }
  683. ]
  684. };
  685. myChart.setOption(option); // 将选项应用到图表实例上,生成图表
  686. },
  687. chartUserIdentity(data){ // 用户身份分布
  688. let myChart = echarts.init(document.getElementById('myChart10'))
  689. let option = {
  690. title: {
  691. text: '用户身份分布',
  692. left: 'left'
  693. },
  694. tooltip: {
  695. trigger: 'item'
  696. },
  697. legend: {
  698. orient: 'horizontal',
  699. top:'bottom'
  700. },
  701. series: [
  702. {
  703. name: '',
  704. color:['#45CCF8','#4880FF','#1CC170'],
  705. type: 'pie',
  706. radius: ['35%', '25%'],
  707. center: ['50%', '50%'],
  708. avoidLabelOverlap: false,
  709. label: {
  710. show: true,
  711. formatter(param) {
  712. // correct the percentage
  713. return param.name + ' (' + param.value + '%)';
  714. }
  715. },
  716. emphasis: {
  717. itemStyle: {
  718. shadowBlur: 10,
  719. shadowOffsetX: 0,
  720. shadowColor: 'rgba(0, 0, 0, 0.5)'
  721. }
  722. },
  723. data: data.series
  724. }
  725. ]
  726. };
  727. myChart.setOption(option); // 将选项应用到图表实例上,生成图表
  728. },
  729. chartIntentions(data){ // 用户意向分布
  730. let myChart = echarts.init(document.getElementById('myChart11'))
  731. let option = {
  732. title: {
  733. text: '用户意向分布',
  734. left: 'left'
  735. },
  736. tooltip: {
  737. trigger: 'item'
  738. },
  739. legend: {
  740. orient: 'horizontal',
  741. top:'bottom'
  742. },
  743. series: [
  744. {
  745. name: '',
  746. color:['#45CCF8','#4880FF','#1CC170','#FF726E'],
  747. type: 'pie',
  748. radius: ['35%', '25%'],
  749. center: ['50%', '50%'],
  750. avoidLabelOverlap: false,
  751. label: {
  752. show: true,
  753. formatter(param) {
  754. // correct the percentage
  755. return param.name + ' (' + param.value + '%)';
  756. }
  757. },
  758. emphasis: {
  759. itemStyle: {
  760. shadowBlur: 10,
  761. shadowOffsetX: 0,
  762. shadowColor: 'rgba(0, 0, 0, 0.5)'
  763. }
  764. },
  765. data:data.series
  766. }
  767. ]
  768. };
  769. myChart.setOption(option); // 将选项应用到图表实例上,生成图表
  770. }
  771. },
  772. };
  773. }();