123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700 |
- 'use strict';
- const chartsMixin = function () {// 通知消息
- return {
- data(){
- return {
- dataTime: '',
- yearMonth: []
- }
- },
- computed:{
- pickerOptionsH5(){
- const _self = this
- return {
- disabledDate(time) {
- // 获取时间选择器的年份信息
- const timeYear = time.getFullYear(); // 获取时间选择器的年份
- // 获取时间选择器的月份信息
- let timeMonth = time.getMonth() + 1; // 获取时间选择器的月份
- if (timeMonth >= 1 && timeMonth <= 9) {
- timeMonth = "0" + timeMonth; // 如果月份小于10,前面补0
- }
- const elTimeData = timeYear.toString() + timeMonth.toString(); // 组合年份和月份字符串
- // 根据需要禁用多个月份,这里禁用了2021年的10月和11月作为选择范围
- return _self.yearMonth.includes(elTimeData)
- }
- }
- },
- pickerOptions(){
- const _self = this
- return {
- disabledDate(time) {
- // 获取时间选择器的年份信息
- const timeYear = time.getFullYear(); // 获取时间选择器的年份
- // 获取时间选择器的月份信息
- let timeMonth = time.getMonth() + 1; // 获取时间选择器的月份
- if (timeMonth >= 1 && timeMonth <= 9) {
- timeMonth = "0" + timeMonth; // 如果月份小于10,前面补0
- }
- const elTimeData = timeYear.toString() + timeMonth.toString(); // 组合年份和月份字符串
- // 根据需要禁用多个月份,这里禁用了2021年的10月和11月作为选择范围
- return _self.yearMonth.includes(elTimeData)
- },
- shortcuts: [{
- text: '本月',
- onClick(picker) {
- picker.$emit('pick', [new Date(), new Date()]);
- }
- }, {
- text: '今年至今',
- onClick(picker) {
- const end = new Date();
- const start = new Date(new Date().getFullYear(), 0);
- picker.$emit('pick', [start, end]);
- }
- }, {
- text: '最近六个月',
- onClick(picker) {
- const end = new Date();
- const start = new Date();
- start.setMonth(start.getMonth() - 6);
- picker.$emit('pick', [start, end]);
- }
- }]
- }
- }
- },
- methods: {
- chartWordCloud(data){// 词云
- let myChart = echarts.init(document.getElementById('myChart0'));
- let option = {
- title: {text: '关键词云图'},
- tooltip: {trigger: 'item'},
- series: [{
- type: 'wordCloud',
- shape: 'circle',
- keepAspect: false,
- maskImage: '',
- left: 'center',
- top: 'center',
- width: '90%',
- height: '85%',
- right: null,
- bottom: null,
- sizeRange: [12, 60],
- rotationRange: [-90, 90],
- rotationStep: 45,
- gridSize: 10,
- drawOutOfBound: false,
- shrinkToFit: false,
- layoutAnimation: true,
- textStyle: {
- fontFamily: 'sans-serif',
- fontWeight: 'bold',
- color: function () {
- // Random color
- return 'rgb(' + [
- Math.round(Math.random() * 160),
- Math.round(Math.random() * 160),
- Math.round(Math.random() * 160)
- ].join(',') + ')';
- }
- },
- emphasis: {
- focus: 'self',
- textStyle: {
- textShadowBlur: 10,
- textShadowColor: '#333'
- }
- },
- data:data
- }]
- }
- myChart.setOption(option)
- window.addEventListener("resize", function() {
- myChart.resize()
- })
- },
- //公众号推文
- chartWechats(data,shopName){
- let myChart = echarts.init(document.getElementById('myChart1'))
- let option = {
- title: {
- text: `推文数据`
- },
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow'
- }
- },
- legend: {},
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- data: data.names
- },
- yAxis: {
- type: 'value',
- boundaryGap: [0, 0.01],
- },
- series: [
- {
- name: '点击量',
- type: 'line',
- color:['#A294FF'],
- data: data.values
- },
- {
- name: '展现量',
- type: 'line',
- color:['#45CCF8'],
- data: data.backupsValues
- }
- ]
- };
- myChart.setOption(option); // 将选项应用到图表实例上,生成图表
- },
- chartIntention(data,shopName){ // 采美全渠道展现量
- let myChart = echarts.init(document.getElementById('myChart2'))
- let option = {
- title: {
- text: ` 采美全渠道展现量`
- },
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow' //
- }
- },
- legend: {
- orient: 'horizontal',
- right: '0%',
- top:'0%',
- itemGap: 10, // 这里可以设置图例每项之间的间隔
- itemWidth: 20, // 这里可以设置图例标记的宽度
- itemHeight: 14, // 这里可以设置图例标记的高度
- textStyle: {
- fontSize: 12,
- }
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- data: data.names
- },
- yAxis: {
- type: 'value'
- },
- series: [
- {
- type: 'bar',
- stack: 'total',
- label: {
- show: false
- },
- emphasis: {
- focus: 'series'
- },
- barGap:'55%',
- barCategoryGap:'55%',
- data: data.values,
- itemStyle: {
- color: function(params) {
- // params 是当前柱状图的数据点信息对象
- const colorList = ['#07c160','#d48265','#fa5151','#1890ff'];
- return colorList[params.dataIndex]
- }
- }
- }
- ]
- };
- myChart.setOption(option); // 将选项应用到图表实例上,生成图表
- },
- // 采美全渠道点击量
- chartAllVisits(data,shopName){
- let myChart = echarts.init(document.getElementById('myChart3'))
- let option = {
- title: {
- text: ` 采美全渠道点击量`
- },
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow' //
- }
- },
- legend: {
- orient: 'horizontal',
- right: '0%',
- top:'0%',
- itemGap: 10, // 这里可以设置图例每项之间的间隔
- itemWidth: 20, // 这里可以设置图例标记的宽度
- itemHeight: 14, // 这里可以设置图例标记的高度
- textStyle: {
- fontSize: 12,
- }
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- data: data.names
- },
- yAxis: {
- type: 'value',
- },
- series: [
- {
- type: 'bar',
- stack: 'total',
- label: {
- show: false
- },
- emphasis: {
- focus: 'series'
- },
- barGap:'55%',
- barCategoryGap:'55%',
- data: data.values,
- itemStyle: {
- color: function(params) {
- // params 是当前柱状图的数据点信息对象
- const colorList = ['#07c160','#d48265','#fa5151','#1890ff'];
- return colorList[params.dataIndex]
- }
- }
- }
- ]
- };
- myChart.setOption(option); // 将选项应用到图表实例上,生成图表
- },
- chartProportion(data,shopName){ // 渠道来源占比
- let myChart = echarts.init(document.getElementById('myChart4'))
- let option = {
- title: {
- text: ` 访问用户渠道来源占比`
- },
- tooltip: {
- trigger: 'item'
- },
- legend: {
- orient: 'horizontal',
- top:'bottom'
- },
- series: [
- {
- name: '',
- color:['#45CCF8','#4880FF','#1CC170','#FF726E'],
- type: 'pie',
- radius: ['35%', '25%'],
- center: ['50%', '50%'],
- avoidLabelOverlap: false,
- label: {
- show: true,
- formatter(param) {
- // correct the percentage
- return param.name + ' (' + param.value + '%)';
- }
- },
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)'
- }
- },
- data:data
- }
- ]
- };
- myChart.setOption(option); // 将选项应用到图表实例上,生成图表
- },
- // 采美站内访问量
- chartStationVisits(data,shopName){
- let myChart = echarts.init(document.getElementById('myChart5'))
- let option = {
- title: {
- text: ` 品牌整体访问量`
- },
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow' //
- }
- },
- legend: {
- orient: 'horizontal',
- right: '0%',
- top:'0%',
- itemGap: 10, // 这里可以设置图例每项之间的间隔
- itemWidth: 20, // 这里可以设置图例标记的宽度
- itemHeight: 14, // 这里可以设置图例标记的高度
- textStyle: {
- fontSize: 12,
- },
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- data: data.names
- },
- yAxis: {
- type: 'value',
- },
- series: [
- {
- type: 'bar',
- stack: 'total',
- label: {
- show: false
- },
- emphasis: {
- focus: 'series'
- },
- barGap:'80%',
- barCategoryGap:'80%',
- data: data.values,
- itemStyle: {
- color: function(params) {
- // params 是当前柱状图的数据点信息对象
- const colorList = ['#07c160','#1890ff'];
- return colorList[params.dataIndex]
- }
- }
- }
- ]
- };
- myChart.setOption(option); // 将选项应用到图表实例上,生成图表
- },
- chartVisitTimes(data,shopName){ // 页面平均访问时长top5
- let myChart = echarts.init(document.getElementById('myChart6'))
- let option = {
- title: {
- text: ` 访问页面平均时长top5(单位:秒)`,
- left: 'left'
- },
- tooltip: {
- trigger: 'axis',
- color:'#FE8645',
- formatter: function(params) { // 格式化 tooltip 内容
- return '访问时长:'+ params[0].value + 's'
- },
- axisPointer: {
- type: 'shadow'
- }
- },
- legend: {
- show:false,
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- data: data.names
- },
- yAxis: {
- type: 'value',
- splitLine:{
- show: true,
- lineStyle:{
- opacity:0.8,
- color:'#E1E1E1',
- type:'dashed'
- }
- },
- boundaryGap: [0, 0.01],
- axisLabel:{
- show: true,
- textStyle:{
- color: '#999999', //更改坐标轴文字颜色
- fontSize : 14, //更改坐标轴文字大小
- }
- },
- axisTick: {//轴网格,在xAxis或yAxis根下
- lineStyle:{
- width:1,
- color:'#E1E1E1',
- type:'dashed'
- }
- }
- },
- series: [
- {
- type: 'line',
- name: '访问时长',
- data: data.values,
- color:'#4880FF',
- label: {
- show: true
- },
- areaStyle: {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- {
- offset: 0,
- color: 'rgb(72,128,255)'
- },
- {
- offset: 1,
- color: 'rgb(68,92,207)'
- }
- ])
- }
- }
- ]
- };
- myChart.setOption(option); // 将选项应用到图表实例上,生成图表
- },
- // 咨询用户月度分布
- chartLeadUserMonthly(data,shopName){
- let myChart = echarts.init(document.getElementById('myChart7'))
- let option = {
- title: {
- text: ` 咨询用户月度数量(单位:个)`
- },
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow' //
- }
- },
- legend: {
- orient: 'horizontal',
- right: '0%',
- top:'0%',
- show:false,
- itemGap: 10, // 这里可以设置图例每项之间的间隔
- itemWidth: 20, // 这里可以设置图例标记的宽度
- itemHeight: 14, // 这里可以设置图例标记的高度
- textStyle: {
- fontSize: 12,
- }
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: {
- type: 'value',
- },
- yAxis: {
- type: 'category',
- data: data.names
- },
- series: [
- {
- name: '咨询用户月度数量:',
- type: 'bar',
- stack: 'total',
- label: {
- show: true
- },
- emphasis: {
- focus: 'series'
- },
- barGap:'80%',
- barCategoryGap:'80%',
- color:'#4880FF',
- data: data.values
- }
- ]
- };
- myChart.setOption(option); // 将选项应用到图表实例上,生成图表
- },
- chartChannels(data,shopName){// 咨询用户地狱分布
- let myChart = echarts.init(document.getElementById('myChart8'))
- let option = {
- title: {
- text: ` 访问用户地域分布`
- },
- tooltip: {
- trigger: 'item'
- },
- visualMap: {
- min: 0,
- max: 1000,
- left: 'left',
- top: 'bottom',
- text: ['高', '低'], // 文本,默认为数值文本
- calculable: true,
- inRange: {
- color: ['#e0ffff', '#006edd']
- }
- },
- series: [
- {
- name: '中国',
- type: 'map',
- mapType: 'china', // 设置地图类型为中国省份地图
- roam: false, // 禁止缩放和平移操作
- label: {
- show: true,
- // formatter(param) {
- // // correct the percentage
- // return param.name + ' (' + param.value + '%)';
- // }
- },
- data: data,
- itemStyle:{
- fontSize: 14,
- color:'#FE8645'
- }
- }
- ]
- };
- myChart.setOption(option); // 将选项应用到图表实例上,生成图表
- },
- chartUrbanize(data,shopName){ // 用户类型分布
- let myChart = echarts.init(document.getElementById('myChart9'))
- let option = {
- title: {
- text: ` 访问用户类型分布`,
- left: 'left'
- },
- tooltip: {
- trigger: 'item'
- },
- legend: {
- orient: 'horizontal',
- top:'bottom'
- },
- series: [
- {
- name: '',
- color:['#45CCF8','#4880FF','#FE8645'],
- type: 'pie',
- radius: ['35%', '25%'],
- center: ['50%', '50%'],
- avoidLabelOverlap: false,
- label: {
- show: true,
- formatter(param) {
- // correct the percentage
- return param.name + ' (' + param.value + '%)';
- }
- },
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)'
- }
- },
- data: data
- }
- ]
- };
- myChart.setOption(option); // 将选项应用到图表实例上,生成图表
- },
- chartUserIdentity(data,shopName){ // 用户身份分布
- let myChart = echarts.init(document.getElementById('myChart10'))
- let option = {
- title: {
- text: ` 访问用户身份分布`,
- left: 'left'
- },
- tooltip: {
- trigger: 'item'
- },
- legend: {
- orient: 'horizontal',
- top:'bottom'
- },
- series: [
- {
- name: '',
- color:['#45CCF8','#4880FF','#1CC170'],
- type: 'pie',
- radius: ['35%', '25%'],
- center: ['50%', '50%'],
- avoidLabelOverlap: false,
- label: {
- show: true,
- formatter(param) {
- // correct the percentage
- return param.name + ' (' + param.value + '%)';
- }
- },
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)'
- }
- },
- data: data
- }
- ]
- };
- myChart.setOption(option); // 将选项应用到图表实例上,生成图表
- },
- chartIntentions(data,shopName){ // 用户意向分布
- let myChart = echarts.init(document.getElementById('myChart11'))
- let option = {
- title: {
- text: ` 用户意向分布`,
- left: 'left'
- },
- tooltip: {
- trigger: 'item'
- },
- legend: {
- orient: 'horizontal',
- top:'bottom'
- },
- series: [
- {
- name: '',
- color:['#45CCF8','#4880FF','#1CC170','#FF726E'],
- type: 'pie',
- radius: ['35%', '25%'],
- center: ['50%', '50%'],
- avoidLabelOverlap: false,
- label: {
- show: true,
- formatter(param) {
- // correct the percentage
- return param.name + ' (' + param.value + '%)';
- }
- },
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)'
- }
- },
- data:data.series
- }
- ]
- };
- myChart.setOption(option); // 将选项应用到图表实例上,生成图表
- }
- },
- };
- }();
|