You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
272 lines
9.9 KiB
272 lines
9.9 KiB
import histogram from "../../../components/option/singleColumnarOption"
|
|
import stack from "../../../components/option/stackedBarChart"
|
|
import sHistogram from "../../../components/option/sColumnarOption"
|
|
import pictographicOption from '../../../components/option/pictographicOption'
|
|
import negaposiOption from '../../../components/option/negaposiOption2'
|
|
import pieOption from '../../../components/option/pieOption2'
|
|
const app = getApp()
|
|
const dColor = ['#FF4852', '#FF6E25', '#FFBF00', '#20CC62', '#00D6D6', '#00AAFF', '#7257FF']
|
|
Component({
|
|
data: {
|
|
imageUrl: getApp().globalData.imageUrl,
|
|
showChart: true,
|
|
brandOption: histogram([], [], [], '#0084FF'),
|
|
brandOption2: histogram([], [], [], '#20cc62'),
|
|
brandOption4: sHistogram(),
|
|
stackOption: stack([], [], ['#00aaff', '#20cc62', '#ff4852']),
|
|
genderOption: negaposiOption([], {}),
|
|
genderOptio2: negaposiOption([], {}),
|
|
boxArr: new Array(6),
|
|
topActive: 0, //品牌传播
|
|
userActive: 0, //活跃用户信息
|
|
brandTop: [],
|
|
brandTopData: [],
|
|
areaActive: 0,
|
|
area: [],
|
|
weiboDist: [],
|
|
sex:[],
|
|
attestation:[],
|
|
pieColor: [
|
|
'background: rgb(244,72,85)',
|
|
'background: rgb(245,109,47)',
|
|
'background: rgb(248,189,32)',
|
|
'background: rgb(75,203,100)',
|
|
'background: rgb(75,214,213)',
|
|
'background: rgb(244,72,85)',
|
|
'background: rgb(245,109,47)',
|
|
'background: rgb(248,189,32)',
|
|
'background: rgb(75,203,100)',
|
|
'background: rgb(75,214,213)',
|
|
],
|
|
},
|
|
lifetimes: {
|
|
attached() {
|
|
let brandRatioTime = wx.getStorageSync('brandRatioTime')
|
|
let eventData = wx.getStorageSync('eventData')
|
|
this.setData({
|
|
boxArr: eventData
|
|
})
|
|
let sRele = []
|
|
this.data.boxArr.forEach((ele) => {
|
|
if (ele) sRele.push(ele.events_id)
|
|
})
|
|
//微博信息量对比
|
|
app.globalData.request({
|
|
action: 'getContrastCount0528C',
|
|
token: wx.getStorageSync('token'),
|
|
sType: 'BrandWeiBo',
|
|
...brandRatioTime,
|
|
iContrastType: '3',
|
|
sRele: sRele.join(',')
|
|
}).then(res => {
|
|
let dx = []
|
|
let dy = []
|
|
for (let i of res) {
|
|
dx.push(i.key)
|
|
dy.push(i.value)
|
|
}
|
|
this.setData({
|
|
brandOption: histogram(['事件一', '事件二'], dy, [], '#0084FF'),
|
|
})
|
|
})
|
|
//微博互动人数
|
|
app.globalData.request({
|
|
action: 'getInteractCount0528C',
|
|
token: wx.getStorageSync('token'),
|
|
sType: 'BrandWeiBo',
|
|
...brandRatioTime,
|
|
iContrastType: '3',
|
|
sRele: sRele.join(',')
|
|
}).then(res => {
|
|
let dy = []
|
|
for (let i of res) {
|
|
dy.push(i.value)
|
|
}
|
|
this.setData({
|
|
brandOption2: histogram(['事件一', '事件二'], dy, [], '#20cc62'),
|
|
})
|
|
})
|
|
|
|
//微博大V
|
|
app.globalData.request({
|
|
action: 'getBoauthen0528C',
|
|
token: wx.getStorageSync('token'),
|
|
sType: 'BrandWeiBo',
|
|
...brandRatioTime,
|
|
iContrastType: '3',
|
|
sRele: sRele.join(',')
|
|
}).then(res => {
|
|
console.log(res);
|
|
let xMsg = []
|
|
for (let i of res[0].value) {
|
|
xMsg.push(i.key)
|
|
}
|
|
let data = new Array(res.length).fill([])
|
|
data = data.map(ele => {
|
|
ele = JSON.stringify(ele)
|
|
ele = JSON.parse(ele)
|
|
return ele
|
|
})
|
|
for (let [index, i] of res.entries()) {
|
|
for (let j of i.value) {
|
|
data[index].push(j.value)
|
|
}
|
|
}
|
|
console.log(data);
|
|
//横轴,数据,纵轴
|
|
this.setData({
|
|
brandOption4: sHistogram(xMsg, data, ['事件一', '事件二'], dColor)
|
|
})
|
|
})
|
|
//微博调性对比
|
|
app.globalData.request({
|
|
action: 'getAffectionsC',
|
|
token: wx.getStorageSync('token'),
|
|
sType: 'BrandWeiBo',
|
|
sRele: sRele.join(','),
|
|
...brandRatioTime,
|
|
iContrastType: '3',
|
|
}).then(res => {
|
|
let data = []
|
|
for (let i of res) {
|
|
let arr = []
|
|
let sum = 0
|
|
Object.keys(i.Data).forEach(ele => {
|
|
sum += Number(i.Data[ele])
|
|
})
|
|
Object.keys(i.Data).forEach(ele => {
|
|
let obj = {
|
|
value: i.Data[ele],
|
|
name: ele,
|
|
percent: ((Number(i.Data[ele]) / sum)*100).toFixed(2)
|
|
}
|
|
arr.push(obj)
|
|
})
|
|
data.push(arr)
|
|
|
|
}
|
|
let newData = []
|
|
for (let i of data) {
|
|
let obj = {}
|
|
obj.arr = i
|
|
obj.func = pieOption(['#FF4852', '#FF6E25', '#FFBF00', '#20CC62', '#00D6D6', '#00AAFF', '#7257FF'], i)
|
|
newData.push(obj)
|
|
}
|
|
this.setData({
|
|
weiboDist: newData
|
|
})
|
|
})
|
|
|
|
//活跃用户信息
|
|
app.globalData.request({
|
|
action: 'getRegionWeiBoC',
|
|
token: wx.getStorageSync('token'),
|
|
sType: 'BrandWeiBo',
|
|
...brandRatioTime,
|
|
iContrastType: '3',
|
|
sRele: sRele.join(','),
|
|
}).then(res => {
|
|
let newRes = []
|
|
for (let i of res) {
|
|
let obj = {
|
|
name: i.Name,
|
|
region: [],
|
|
value: [],
|
|
sum: 0
|
|
}
|
|
let arr = []
|
|
Object.keys(i.Data).forEach(ele => {
|
|
arr.push({
|
|
name: ele,
|
|
value: i.Data[ele]
|
|
})
|
|
})
|
|
arr = arr.sort((a, b) => {
|
|
return a.value * 1 - b.value * 1
|
|
})
|
|
for (let j of arr) {
|
|
obj.region.push(j.name)
|
|
obj.value.push(j.value)
|
|
obj.sum += j.value * 1
|
|
}
|
|
newRes.push(obj)
|
|
}
|
|
newRes = newRes.map(ele => {
|
|
ele.func = [pictographicOption(ele.region.slice(0, 5), ele.value.slice(0, 5), ele.sum,),
|
|
pictographicOption(ele.region.slice(5, 10), ele.value.slice(5, 10), ele.sum)
|
|
]
|
|
return ele
|
|
})
|
|
|
|
console.log('ser',newRes)
|
|
this.setData({
|
|
area: newRes
|
|
})
|
|
|
|
})
|
|
//男女-认证用户
|
|
app.globalData.request({
|
|
action: 'getSexMergeWeiBoC',
|
|
token: wx.getStorageSync('token'),
|
|
sType: 'BrandWeiBo',
|
|
...brandRatioTime,
|
|
iContrastType: '3',
|
|
sRele: sRele.join(','),
|
|
}).then(res => {
|
|
let sex = []
|
|
let attestation = []
|
|
for (let i of res) {
|
|
let arr = []
|
|
let sum = 0
|
|
let arr2 = []
|
|
let sum2 = 0
|
|
Object.keys(i.Data.sex).forEach(ele => {
|
|
sum += Number(i.Data.sex[ele])
|
|
})
|
|
Object.keys(i.Data.sex).forEach(ele => {
|
|
let obj = {
|
|
value: i.Data.sex[ele],
|
|
name: ele,
|
|
percent: ((Number(i.Data.sex[ele]) / sum).toFixed(2) * 100).toFixed(2)
|
|
}
|
|
arr.push(obj)
|
|
})
|
|
|
|
Object.keys(i.Data.attestation).forEach(ele => {
|
|
sum2 += Number(i.Data.attestation[ele])
|
|
})
|
|
Object.keys(i.Data.attestation).forEach(ele => {
|
|
let obj = {
|
|
value: i.Data.attestation[ele],
|
|
name: ele,
|
|
percent: ((Number(i.Data.attestation[ele]) / sum2).toFixed(2) * 100).toFixed(2)
|
|
}
|
|
arr2.push(obj)
|
|
})
|
|
|
|
sex.push(arr)
|
|
attestation.push(arr2)
|
|
}
|
|
sex = sex.map(ele => {
|
|
return {
|
|
arr: ele,
|
|
func: pieOption(['#FF4852', '#FF6E25', '#FFBF00', '#20CC62', '#00D6D6', '#00AAFF', '#7257FF'], ele)
|
|
}
|
|
})
|
|
attestation = attestation.map(ele => {
|
|
return {
|
|
arr: ele,
|
|
func: pieOption(['#FF4852', '#FF6E25', '#FFBF00', '#20CC62', '#00D6D6', '#00AAFF', '#7257FF'], ele)
|
|
}
|
|
})
|
|
console.log(sex);
|
|
this.setData({
|
|
sex,
|
|
attestation
|
|
})
|
|
})
|
|
},
|
|
|
|
},
|
|
methods: {}
|
|
}) |