diff --git a/app.json b/app.json index 0cf53f8..0872f17 100644 --- a/app.json +++ b/app.json @@ -32,7 +32,7 @@ "pages/brandCrisis/crisiSet/index", "pages/brandCrisis/chooseModel/index", "pages/brandCrisis/crisisList/index", - "pages/varComm/pages/brandRatio/comm/survey/index" + "pages/varComm/pages/brandRatio/survey/index" ], "window": { "backgroundTextStyle": "light", diff --git a/components/option/multipleColumn.js b/components/option/multipleColumn.js new file mode 100644 index 0000000..6adbd73 --- /dev/null +++ b/components/option/multipleColumn.js @@ -0,0 +1,61 @@ +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, + type: 'bar', + barGap: 0, + emphasis: { + focus: 'series' + }, + data: i.data, + itemStyle: { + color: color[index] + }, + } + valData.push(ojb) + } + const option = { + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow' + } + }, + legend: { + data: columnName, + textStyle: { //图例文字的样式 + color: 'black', + fontSize: 8 + }, + left: 10, + itemWidth: 12, + itemHeight: 12, + borderRadius: 1, //圆角半径 + }, + xAxis: { + type: 'category', + axisTick: { + show: false + }, + axisLabel: { + textStyle:{ + fontSize:8 + } + }, + data: xMsg + }, + yAxis: [{ + type: 'value', + axisLabel: { + textStyle:{ + fontSize:8 + } + }, + }], + series: valData + } + return option +} \ No newline at end of file diff --git a/components/option/stackedBarChart.js b/components/option/stackedBarChart.js index f678c83..40484dd 100644 --- a/components/option/stackedBarChart.js +++ b/components/option/stackedBarChart.js @@ -1,27 +1,62 @@ -export default function brokenLine(yName=[],data=[],hoveName=[]){ +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', + // barWidth:40, + name:arr[index], + emphasis: { + focus: 'series' + }, + itemStyle:{ + color:color[index] + }, + data:i + } + msgData.push(obj) + } const option = { + legend: { + left:10, + // data:[{name:'正面'},{name:'中性'},{name:'负面'},] + textStyle: { //图例文字的样式 + color: 'black', + fontSize: 8 + }, + itemWidth: 12, + itemHeight: 12, + borderRadius: 1, + }, tooltip: { trigger: 'axis', axisPointer: { - // Use axis to trigger tooltip - type: 'shadow' // 'shadow' as default; can also be 'line' or 'shadow' + type: 'shadow' } }, grid: { - left: '3%', - right: '4%', - bottom: '3%', - containLabel: true }, xAxis: { - type: 'value' + type: 'value', + axisLabel: { + textStyle:{ + fontSize:8 + } + }, }, yAxis: { type: 'category', - data: yName + data: yName, + axisLabel: { + textStyle:{ + fontSize:8 + } + }, }, //数据 - series:[] + series:msgData } return option } \ No newline at end of file diff --git a/pages/insight/pages/brandInsight/totalReview/index.js b/pages/insight/pages/brandInsight/totalReview/index.js index 6dd664e..ffda28c 100644 --- a/pages/insight/pages/brandInsight/totalReview/index.js +++ b/pages/insight/pages/brandInsight/totalReview/index.js @@ -33,6 +33,8 @@ Component({ dx.push(key); dy.push(res[key]) }; + console.log(dx); + console.log(dy); this.setData({ brandOption: histogram(dx,dy,[],'#0084FF') }) diff --git a/pages/varComm/pages/brand/index.js b/pages/varComm/pages/brand/index.js index d557c4b..8373219 100644 --- a/pages/varComm/pages/brand/index.js +++ b/pages/varComm/pages/brand/index.js @@ -3,8 +3,7 @@ const app = getApp() const words = []; Component({ data: { - mockData: [], - result: new Array(6), + result: [], boxArr: new Array(6), }, @@ -64,29 +63,20 @@ Component({ }, onChange(event) { - let result = [] - if (this.data.result.at(-1) != undefined && event.detail.length > 6) { - Dialog.alert({ - title: '提示', - context: this, - message: '至多选择6个品牌!', - }) + const {detail} = event + const result = [] + if(detail.length>6){ + console.log('至多六个'); + return } - for (let i = 0; i < event.detail.length; i++) { - if (event.detail[i] != undefined) { - result.push(event.detail[i]) - } + for(let i of detail){ + result.push(JSON.parse(i)) } result.length = 6 - let boxArr = result - boxArr = boxArr.map(ele => { - return ele != undefined ? JSON.parse(ele) : undefined - }) - console.log(this.data.boxArr); this.setData({ - result: result, - boxArr: boxArr - }); + result:detail, + boxArr:result + }) }, }, diff --git a/pages/varComm/pages/brandRatio/comm/survey/index.js b/pages/varComm/pages/brandRatio/comm/survey/index.js deleted file mode 100644 index e05bf04..0000000 --- a/pages/varComm/pages/brandRatio/comm/survey/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// import brokenLine from "../../../../../components/option/stackingLineOption" -// const app = getApp() -// Component({ -// data:{ -// showChart: true, -// transformOption: brokenLine([],[],[],[]), -// }, -// lifetimes:{ -// attached() { -// //页面数据 -// // app.globalData.request({ -// // action: 'getUserBrand', -// // token: 't%2BrswgjvzGM=', -// // }) -// } -// } -// }) \ No newline at end of file diff --git a/pages/varComm/pages/brandRatio/comm/survey/index.wxml b/pages/varComm/pages/brandRatio/comm/survey/index.wxml deleted file mode 100644 index 34b0080..0000000 --- a/pages/varComm/pages/brandRatio/comm/survey/index.wxml +++ /dev/null @@ -1,4 +0,0 @@ - - 信息量趋势 - - \ No newline at end of file diff --git a/pages/varComm/pages/brandRatio/index.json b/pages/varComm/pages/brandRatio/index.json index 1bf4842..8b5425e 100644 --- a/pages/varComm/pages/brandRatio/index.json +++ b/pages/varComm/pages/brandRatio/index.json @@ -1,7 +1,7 @@ { "usingComponents": { "time-component":"/components/timecomponent/index", - "survey":"./comm/survey/index" + "survey":"./survey/index" }, "navigationBarTitleText": "品牌对比" } \ No newline at end of file diff --git a/pages/varComm/pages/brandRatio/index.wxss b/pages/varComm/pages/brandRatio/index.wxss index eed4ec7..84035a6 100644 --- a/pages/varComm/pages/brandRatio/index.wxss +++ b/pages/varComm/pages/brandRatio/index.wxss @@ -14,6 +14,10 @@ page { overflow-x:scroll; white-space: nowrap; } +.tiem_com{ + width: 686rpx; + margin-left: 32rpx; +} .add_box1 { display: inline-block; height: 208rpx; diff --git a/pages/varComm/pages/brandRatio/survey/index.js b/pages/varComm/pages/brandRatio/survey/index.js new file mode 100644 index 0000000..d215904 --- /dev/null +++ b/pages/varComm/pages/brandRatio/survey/index.js @@ -0,0 +1,173 @@ +import brokenLines from "../../../../../components/option/stackingLineOption" +import histogram from "../../../../../components/option/singleColumnarOption" +import stack from "../../../../../components/option/stackedBarChart" +import multipleColumn from "../../../../../components/option/multipleColumn" +import sHistogram from "../../../../../components/option/sColumnarOption" +const app = getApp() +const dColor=['#FF4852','#FF6E25','#FFBF00','#20CC62','#00D6D6','#00AAFF','#7257FF'] +Component({ + data:{ + showChart: true, + transformOption: brokenLines([],[],[],[]), + brandOption: histogram([],[],[],'#0084FF'), + brandOption2: histogram([],[],[],'#20cc62'), + brandOption3:multipleColumn([],[],[]), + brandOption4:sHistogram(), + stackOption:stack([],[],['#00aaff','#20cc62','#ff4852']), + boxArr:new Array(6), + }, + lifetimes:{ + attached() { + this.setData({ + boxArr:wx.getStorageSync('brandData') + }) + let sBrand = [] + this.data.boxArr.forEach((ele)=>{ + if(ele) sBrand.push(ele.brandname) + }) + //信息量趋势数据 + app.globalData.request({ + action: 'getCountTime0528C', + token: 't%2BrswgjvzGM=', + sType:'BrandOverview', + sTimeType:'34', + iContrastType:'1', + sBrand: sBrand.join(',') + }).then(res=>{ + let dtime = [] + let dVal = [] + let dataObj = {} + for(let i of res){ + dtime.push(i.key) + for(let j of i.value){ + let obj = {key:j.key,value:j.value} + if (!dataObj.hasOwnProperty(j.key)){ + dataObj[j.key] = [] + } + dataObj[j.key].push(obj) + } + } + Object.keys(dataObj).forEach(ele=>{ + dVal.push(dataObj[ele]) + }) + this.setData({ + transformOption: brokenLines(sBrand,dVal,dColor,dtime), + }) + }) + //整体信息量 + app.globalData.request({ + action: 'getContrastCount0528C', + token: 't%2BrswgjvzGM=', + sType:'BrandOverview', + sTimeType:'34', + iContrastType:'1', + sBrand: sBrand.join(',') + }).then(res=>{ + let dx = [] + let dy = [] + for(let i of res){ + dx.push(i.key) + dy.push(i.value) + } + this.setData({ + brandOption: histogram(dx,dy,[],'#0084FF'), + }) + }) + //整体互动人数 + app.globalData.request({ + action: 'getInteractCount0528C', + token: 't%2BrswgjvzGM=', + sType:'BrandOverview', + sTimeType:'34', + iContrastType:'1', + sBrand: sBrand.join(',') + }).then(res=>{ + let dx = [] + let dy = [] + for(let i of res){ + dx.push(i.key) + dy.push(i.value) + } + this.setData({ + brandOption2: histogram(dx,dy,[],'#20cc62'), + }) + }) + //品牌条形对比 + app.globalData.request({ + action: 'getAffectionsC', + token: 't%2BrswgjvzGM=', + sType:'BrandOverview', + sTimeType:'34', + iContrastType:'1', + sBrand: sBrand.join(',') + }).then(res=>{ + let yMsg = [] + let data = [[],[],[]] + for(let i of res){ + yMsg.push(i.Name) + data[0].push(i.Data['正面']) + data[1].push(i.Data['中性']) + data[2].push(i.Data['负面']) + } + console.log(data); + this.setData({ + stackOption:stack(yMsg,data,['#00aaff','#20cc62','#ff4852']) + }) + }) + //渠道分布 + app.globalData.request({ + action: 'getSourcetypeC', + token: 't%2BrswgjvzGM=', + sType:'BrandOverview', + sTimeType:'34', + iContrastType:'1', + sBrand: sBrand.join(',') + }).then(res=>{ + let arr = [] + let channelMsg = [] + for(let i of res){ + let obj = {name:i.Name} + let da = [] + Object.keys(i.Data).forEach(ele=>{ + da.push(i.Data[ele]) + channelMsg.push(ele) + }) + obj.data = da + arr.push(obj) + } + channelMsg = [...new Set(channelMsg)] + this.setData({ + brandOption3:multipleColumn(sBrand,channelMsg,arr), + }) + }) + //重点媒体 + app.globalData.request({ + action: 'getSourceCount0528C', + token: 't%2BrswgjvzGM=', + sType:'BrandOverview', + sTimeType:'34', + iContrastType:'1', + sBrand: sBrand.join(',') + }).then(res=>{ + let data = [] + for(let i of res[0].value){ + let obj = {name:i.key,data:[]} + data.push(obj) + } + for(let i of res){ + for(let j of i.value){ + for(let k of data){ + if(j.key==k.name) { + k.data.push(j.value) + break + } + } + } + } + data=data.map(ele=>{ return ele = ele.data}) + console.log(data); + + }) + } +} +}) \ No newline at end of file diff --git a/pages/varComm/pages/brandRatio/comm/survey/index.json b/pages/varComm/pages/brandRatio/survey/index.json similarity index 100% rename from pages/varComm/pages/brandRatio/comm/survey/index.json rename to pages/varComm/pages/brandRatio/survey/index.json diff --git a/pages/varComm/pages/brandRatio/survey/index.wxml b/pages/varComm/pages/brandRatio/survey/index.wxml new file mode 100644 index 0000000..f17216c --- /dev/null +++ b/pages/varComm/pages/brandRatio/survey/index.wxml @@ -0,0 +1,41 @@ + + 信息量趋势 + + + + + + + 整体信息量 + + + + + + + 整体互动人数 + + + + + + + 品牌调性对比 + + + + + + + 渠道分布 + + + + + + 重点媒体传播对比 + + + + + diff --git a/pages/varComm/pages/brandRatio/comm/survey/index.wxss b/pages/varComm/pages/brandRatio/survey/index.wxss similarity index 54% rename from pages/varComm/pages/brandRatio/comm/survey/index.wxss rename to pages/varComm/pages/brandRatio/survey/index.wxss index f5be1b7..ff7f863 100644 --- a/pages/varComm/pages/brandRatio/comm/survey/index.wxss +++ b/pages/varComm/pages/brandRatio/survey/index.wxss @@ -1,6 +1,7 @@ .chart_box{ + margin-top: 24rpx; width: 686rpx; - height: 454rpx; + height: 486rpx; padding-top:32rpx ; background: white; } @@ -8,4 +9,10 @@ font-size: 36rpx; font-weight: bold; margin-left:32rpx ; +} +.table{ + height: 380rpx; + width: 95%; + margin-left:16rpx ; + margin-top: 32rpx; } \ No newline at end of file