对比模块

dev
Esdese 3 years ago
parent 92d1f80829
commit ea5f3329ae

@ -74,6 +74,7 @@ Component({
arr1.push(o)
})
const resArr = arr1.slice(0,50)
console.log(resArr);
this.setData({
HotWords: resArr,
showTu: true

@ -1,7 +1,6 @@
export default function multipleColumn(columnName = [], xMsg = [], data = []) {
const valData = []
const color = ['#ff4852', '#ff6e25', '#ffbf00', '#20cc62', '#00d6d6', '#0084ff']
console.log(xMsg);
for (let [index, i] of data.entries()) {
let ojb = {
name: i.name,

@ -2,7 +2,6 @@ export default function stack(yName=[],data=[],color=[]){
let msgData = []
let arr = ['正面','中性','负面',]
for(let [index,i] of data.entries()){
console.log(i);
let obj = {
type: 'bar',
stack: 'total',

@ -1,130 +1,133 @@
// 多折线
export default function brokenLines(dName = [], dValue = [], dColor = [], dx = []) {
return {
tooltip: {
trigger: "axis",
backgroundColor: "#08182F",
color: "#fff",
borderColor: "#3373CC",
textStyle: {
color: "#fff", //设置文字颜色
fontSize: 9
return {
tooltip: {
trigger: "axis",
backgroundColor: "#08182F",
color: "#fff",
borderColor: "#3373CC",
textStyle: {
color: "#fff", //设置文字颜色
fontSize: 9
},
extraCssText: "box-shadow: 0px 0px 10px 0px #3373CC;",
confine: true,
},
extraCssText: "box-shadow: 0px 0px 10px 0px #3373CC;",
confine: true,
},
legend: {
icon: 'rectangle', //data图标样式
itemWidth: 8, //data图标大小
itemHeight: 8,
left: 5,
textStyle: {
fontSize: 8,
fontWeight: 400
},
// data: ['微博', '其他','短视频', '微信','APP', '论坛', '新闻'],
data: dName
// color:['#FF4852','#FF6E25','#FFBF00','#20CC62','#00D6D6','#00AAFF','#7257FF'],
}, //图表位置
grid: {
left: 7,
right: 7,
bottom: 7,
top: 36,
containLabel: true
},
yAxis: [{
type: 'value',
axisTick: {
show: false //去除刻度线
},
axisLine: {
show: false //去除轴线
},
axisLabel: {
color: '#999999', //y轴文本颜色
textStyle: {
fontSize: 9
legend: {
icon: 'rectangle', //data图标样式
itemWidth: 8, //data图标大小
itemHeight: 8,
left: 5,
textStyle: {
fontSize: 8,
fontWeight: 400
},
// data: ['微博', '其他','短视频', '微信','APP', '论坛', '新闻'],
data: dName
// color:['#FF4852','#FF6E25','#FFBF00','#20CC62','#00D6D6','#00AAFF','#7257FF'],
}, //图表位置
grid: {
left: 7,
right: 7,
bottom: 7,
top: 36,
containLabel: true
},
formatter: (value) => {
if (value >= 10000) {
value = (value / 10000) + '万';
}
return value;
}
},
splitLine: { //分割线
// lineStyle:{
// // color:"#2d3436"
yAxis: [{
type: 'value',
axisTick: {
show: false //去除刻度线
},
axisLine: {
show: false //去除轴线
},
axisLabel: {
color: '#999999', //y轴文本颜色
textStyle: {
fontSize: 9
},
formatter: (value) => {
if (value >= 10000) {
value = (value / 10000) + '万';
}
return value;
}
},
splitLine: { //分割线
// lineStyle:{
// // color:"#2d3436"
// }
show: true,
lineStyle: {
type: 'dashed',
color: '#E8E8E8',
}
}
}],
xAxis: [{
type: 'category',
// data: ['00:00', '04:00', '08:00', '12:00', '16:00', '20:00', '24:00'],
data: dx,
axisTick: {
show: false //去除刻度线
},
axisLine: {
show: false, //去除轴线
},
axisLabel: {
color: '#999999', //x轴文本颜色
textStyle: {
fontSize: 9
},
formatter: (value) => {
let rex = "00:00:00";
let isCont = false;
let str = value;
for (let i = 0; i < dx.length - 1; i++) {
//连续两条带小时
if (dx[i].indexOf(rex) === -1 && dx[i + 1].indexOf(rex) === -1) {
isCont = true;
break;
// }
show: true,
lineStyle: {
type: 'dashed',
color: '#E8E8E8',
}
}
}
if (isCont == true) {
str = value.substring(10, 16)
} else {
str = value.substring(5, 10)
}
return str;
}
}],
xAxis: [{
type: 'category',
// data: ['00:00', '04:00', '08:00', '12:00', '16:00', '20:00', '24:00'],
data: dx,
axisTick: {
show: false //去除刻度线
},
axisLine: {
show: false, //去除轴线
},
axisLabel: {
color: '#999999', //x轴文本颜色
textStyle: {
fontSize: 9
},
formatter: (value) => {
let rex = "00:00:00";
let isCont = false;
let str = value;
for (let i = 0; i < dx.length - 1; i++) {
//连续两条带小时
if (dx[i].indexOf(rex) === -1 && dx[i + 1].indexOf(rex) === -1) {
isCont = true;
break;
}
}
if(value.length==7){
return str
}
if (isCont == true) {
str = value.substring(10, 16)
} else {
str = value.substring(5, 10)
}
return str;
}
}
}],
series: Multiple(dName, dValue, dColor)
}
}
}],
series: Multiple(dName, dValue, dColor)
}
}
function Multiple(dName = [], dValue = [], dColor = []) {
// MS true为单fales为双
let list = []
for (let i = 0; i < dName.length; i++) {
// const element = array[index];
// MS true为单fales为双
let list = []
for (let i = 0; i < dName.length; i++) {
// const element = array[index];
list.push({
name: dName[i],
type: 'line',
symbol: 'none', //去圆点
data: dValue[i],
itemStyle: {
normal: {
color: dColor[i],
lineStyle: {
color: dColor[i]
}
}
}
})
}
return list;
list.push({
name: dName[i],
type: 'line',
symbol: 'none', //去圆点
data: dValue[i],
itemStyle: {
normal: {
color: dColor[i],
lineStyle: {
color: dColor[i]
}
}
}
})
}
return list;
}

@ -7,14 +7,22 @@ const app = getApp()
const dColor=['#FF4852','#FF6E25','#FFBF00','#20CC62','#00D6D6','#00AAFF','#7257FF']
Component({
data:{
imageUrl: getApp().globalData.imageUrl,
showChart: true,
transformOption: brokenLines([],[],[],[]),
transformOption2:brokenLines([],[],[],[]),
brandOption: histogram([],[],[],'#0084FF'),
brandOption2: histogram([],[],[],'#20cc62'),
brandOption3:multipleColumn([],[],[]),
brandOption4:sHistogram(),
stackOption:stack([],[],['#00aaff','#20cc62','#ff4852']),
boxArr:new Array(6),
topActive:0, //品牌传播
brandTop:[],
brandTopData:[],
cloudActive:0, //词云
positiveWord:[],
negativeWord:[],//负面
},
lifetimes:{
attached() {
@ -28,8 +36,8 @@ Component({
//信息量趋势数据
app.globalData.request({
action: 'getCountTime0528C',
token: 't%2BrswgjvzGM=',
sType:'BrandOverview',
token: wx.getStorageSync('token'),
sTimeType:'34',
iContrastType:'1',
sBrand: sBrand.join(',')
@ -49,7 +57,7 @@ Component({
}
Object.keys(dataObj).forEach(ele=>{
dVal.push(dataObj[ele])
})
})
this.setData({
transformOption: brokenLines(sBrand,dVal,dColor,dtime),
})
@ -57,7 +65,7 @@ Component({
//整体信息量
app.globalData.request({
action: 'getContrastCount0528C',
token: 't%2BrswgjvzGM=',
token: wx.getStorageSync('token'),
sType:'BrandOverview',
sTimeType:'34',
iContrastType:'1',
@ -76,7 +84,7 @@ Component({
//整体互动人数
app.globalData.request({
action: 'getInteractCount0528C',
token: 't%2BrswgjvzGM=',
token: wx.getStorageSync('token'),
sType:'BrandOverview',
sTimeType:'34',
iContrastType:'1',
@ -95,7 +103,7 @@ Component({
//品牌条形对比
app.globalData.request({
action: 'getAffectionsC',
token: 't%2BrswgjvzGM=',
token: wx.getStorageSync('token'),
sType:'BrandOverview',
sTimeType:'34',
iContrastType:'1',
@ -109,7 +117,6 @@ Component({
data[1].push(i.Data['中性'])
data[2].push(i.Data['负面'])
}
console.log(data);
this.setData({
stackOption:stack(yMsg,data,['#00aaff','#20cc62','#ff4852'])
})
@ -117,7 +124,7 @@ Component({
//渠道分布
app.globalData.request({
action: 'getSourcetypeC',
token: 't%2BrswgjvzGM=',
token: wx.getStorageSync('token'),
sType:'BrandOverview',
sTimeType:'34',
iContrastType:'1',
@ -143,31 +150,124 @@ Component({
//重点媒体
app.globalData.request({
action: 'getSourceCount0528C',
token: 't%2BrswgjvzGM=',
token: wx.getStorageSync('token'),
sType:'BrandOverview',
sTimeType:'34',
iContrastType:'1',
sBrand: sBrand.join(',')
}).then(res=>{
let data = []
let xMsg = []
for(let i of res[0].value){
let obj = {name:i.key,data:[]}
data.push(obj)
xMsg.push(i.key)
}
for(let i of res){
let data = new Array(res.length).fill([])
for(let [index,i] of res.entries()){
for(let j of i.value){
for(let k of data){
if(j.key==k.name) {
k.data.push(j.value)
break
}
}
data[index].push(j.value)
}
}
data=data.map(ele=>{ return ele = ele.data})
console.log(data);
//横轴,数据,纵轴
this.setData({
brandOption4:sHistogram(xMsg,data,sBrand,[])
})
})
//品牌传播TOP媒体
app.globalData.request({
action: 'getSourceTopCount0528C',
token: wx.getStorageSync('token'),
sType:'BrandOverview',
sTimeType:'34',
iContrastType:'1',
sBrand: sBrand.join(',')
}).then(res=>{
this.setData({
brandTop:[res[0],res[1]],
brandTopData:res
})
})
}
//销量对比
app.globalData.request({
action: 'getCheZhuCountTimeC',
token: wx.getStorageSync('token'),
sType:'Marketing1C',
iContrastType:'1',
sBrand: sBrand.join(',')
}).then(res=>{
let dDate = []
let dVal = new Array(res.Data[0].value.length).fill([])
dVal = dVal.map(ele=>{
ele = JSON.stringify(ele)
ele = JSON.parse(ele)
return ele
})
for(let i of res.Data){
dDate.push(i.key)
for(let [index,j] of i.value.entries()){
dVal[index].push(j)
}
}
this.setData({
salesDate:res.Time,
transformOption2: brokenLines(sBrand,dVal,dColor,dDate),
})
})
//正负词云
// app.globalData.request({
// action: 'getPositiveAndNegative0528C',
// token: wx.getStorageSync('token'),
// sType:'BrandOverview',
// sTimeType:'34',
// iContrastType:'1',
// sBrand: sBrand.join(',')
// }).then(res=>{
// let positiveWord = []
// let negativeWord = []
// for(let i of res){
// let pobj = {}
// let nobj = {}
// pobj.name = i.key
// nobj.name = i.key
// for(let j of i.value){
// if(j.key=='正面词'){
// pobj.value = j.value.map(ele=>{
// return [ele.key,ele.value]
// })
// }else{
// nobj.value = j.value.map(ele=>{
// return [ele.key,ele.value]
// })
// }
// }
// positiveWord.push(pobj)
// negativeWord.push(nobj)
// }
// this.setData({
// positiveWord,
// negativeWord
// })
// })
},
},
methods:{
//品牌传播top媒体
changeModalHot(event) {
let obj = {
0:[this.data.brandTopData[0]||{},this.data.brandTopData[1]||{}],
1:[this.data.brandTopData[2]||{},this.data.brandTopData[3]||{}],
2:[this.data.brandTopData[4]||{},this.data.brandTopData[5]||{}]
}
let index = event.detail.index
console.log(index);
this.setData({
topActive: index,
brandTop:obj[index]
})
},
changeModalHot2(event) {
},
}
})

@ -1,6 +1,7 @@
{
"usingComponents": {
"c-echars": "../../../../../../components/c-echars/index"
"c-echars": "../../../../../../components/c-echars/index",
"word-cloud": "../../../../../components/word-cloud/index"
},
"component": true
}

@ -34,8 +34,95 @@
</view>
<view class="chart_box">
<view class="chart_title">重点媒体传播对比</view>
<view class="table" style="height: 100%;">
<view class="table">
<c-echars showChart="{{showChart}}" canvasId="brandbar-canvas" chartId="brandbar" chartOption="{{brandOption4}}" height="100%"></c-echars>
</view>
</view>
<view class="top_box">
<view class="top-title">
<view style="width: 45%;">品牌传播TOP媒体</view>
<view style="width:50%;margin-right: 32rpx;">
<van-tabs type="card" active="{{ topActive }}" color="#BBBBBB" bind:change="changeModalHot">
<van-tab title="组一"></van-tab>
<van-tab title="组二" wx:if="{{brandTopData.length>2}}"></van-tab>
<van-tab title="组三" wx:if="{{brandTopData.length>4}}"></van-tab>
</van-tabs>
</view>
</view>
<view style="font-size:32rpx;margin-left:30rpx;">{{brandTop[0].key}}</view>
<view class="rank_list">
<view class="ranking">
<view style=" display: inline-block;">排名</view>
<view style=" display: inline-block;margin-left: 172rpx;">车型</view>
<view style=" display: inline-block;margin-left: 272rpx;">传播量</view>
</view>
<view class="ranking_cell" wx:for="{{brandTop[0].value}}" wx:for-item="item" wx:if="{{index>=0 && index<=4}}" wx:key="V">
<view wx:if="{{index==0}}">
<image src="{{imageUrl}}/img_diyi.png" style="height:46rpx;width:53rpx;"></image>
</view>
<view wx:elif="{{index==1}}">
<image src="{{imageUrl}}/img_dier.png" style="height:46rpx;width:53rpx;"></image>
</view>
<view wx:elif="{{index==2}}">
<image src="{{imageUrl}}/img_disan.png" style="height:46rpx;width:53rpx;"></image>
</view>
<view wx:else style="font-size: 28rpx;color: #999999;font-weight: bolder;width: 52rpx;">{{"0"+(index+1)}}</view>
<view style=" display: inline-block;font-size: 28rpx;width: 112rpx;margin-left: 166rpx; font-weight: bolder;">{{item.key}}</view>
<view style=" display: inline-block;font-size: 28rpx;width: 94rpx;margin-left: 194rpx;color: #0084ff;font-weight: bolder;">{{item.value}}</view>
</view>
</view>
<view class="henxian"></view>
<view style="font-size:32rpx;margin-left:30rpx;">{{brandTop[1].key}}</view>
<view class="rank_list">
<view class="ranking" wx:if="{{brandTop[1].key}}">
<view style=" display: inline-block;">排名</view>
<view style=" display: inline-block;margin-left: 172rpx;">车型</view>
<view style=" display: inline-block;margin-left: 272rpx;">传播量</view>
</view>
<view class="ranking_cell" wx:for="{{brandTop[1].value}}" wx:for-item="item" wx:if="{{index>=0 && index<=4}}" wx:key="S">
<view wx:if="{{index==0}}">
<image src="{{imageUrl}}/img_diyi.png" style="height:46rpx;width:53rpx;"></image>
</view>
<view wx:elif="{{index==1}}">
<image src="{{imageUrl}}/img_dier.png" style="height:46rpx;width:53rpx;"></image>
</view>
<view wx:elif="{{index==2}}">
<image src="{{imageUrl}}/img_disan.png" style="height:46rpx;width:53rpx;"></image>
</view>
<view wx:else style="font-size: 28rpx;color: #999999;font-weight: bolder;width: 52rpx;">{{"0"+(index+1)}}</view>
<view style=" display: inline-block;font-size: 28rpx;width: 112rpx;margin-left: 166rpx; font-weight: bolder;">{{item.key}}</view>
<view style=" display: inline-block;font-size: 28rpx;width: 94rpx;margin-left: 194rpx;color: #0084ff;font-weight: bolder;">{{item.value}}</view>
</view>
</view>
</view>
<view class="chart_box">
<view class="chart_title">销量对比</view>
<view class="table">
<c-echars height="100%" showChart="{{showChart}}" canvasId="eventbar-canvas" chartId="eventbar" chartOption="{{transformOption2}}"></c-echars>
</view>
</view>
<!-- 词云 -->
<!-- <view class="cloud_box">
<view class="cloud_title">
<view style="width: 45%;">负面词云对比</view>
<view style="width:50%;margin-right: 32rpx; ">
<van-tabs type="card" active="{{ topActive2 }}" color="#BBBBBB" bind:change="changeModalHot2">
<van-tab title="组一"></van-tab>
<van-tab title="组二"></van-tab>
<van-tab title="组三"></van-tab>
</van-tabs>
</view>
</view>
<view class="cloud_content" wx:for="{{negativeWord}}" wx:for-index="index" wx:key="index">
<view class="">{{item.name}}</view>
<view class="">
<view>
<word-cloud canvasId="{{'w'+index}}" list="{{item.value}}" width="100%" height="200" color="#0284FF"></word-cloud>
</view>
</view>
</view>
</view> -->

@ -15,4 +15,55 @@
width: 95%;
margin-left:16rpx ;
margin-top: 32rpx;
}
.top_box{
margin-top: 24rpx;
width: 686rpx;
height: 1312rpx;
background:#ffffff;
border-radius: 8rpx;
padding-top:32rpx;
}
.top-title {
width: 100%;
font-size: 18px;
padding-left: 32rpx;
font-weight: 600;
color: #333333;
display: flex;
justify-content: flex-start;
}
.rank_list{
margin-left: 32rpx;
margin-top: 16rpx;
}
.ranking{
font-size: 12px;
font-weight: 400;
color: #999999;
}
.ranking_cell{
height: 104rpx;
display: flex ; align-items: center;
}
.henxian{
height: 2rpx;
background:linear-gradient(to right,white, #f2f1f1,white);
}
.cloud_box{
margin-top: 24rpx;
width: 686rpx;
height: 884rpx;
background:#ffffff;
border-radius: 8rpx;
padding-top:32rpx;
}
.cloud_title {
width: 100%;
font-size: 18px;
padding-left: 32rpx;
font-weight: 600;
color: #333333;
display: flex;
justify-content: flex-start;
}
Loading…
Cancel
Save