diff --git a/components/chartdisplay/index.js b/components/chartdisplay/index.js index 6b2b120..daef192 100644 --- a/components/chartdisplay/index.js +++ b/components/chartdisplay/index.js @@ -30,12 +30,25 @@ Component({ }).then(res => { let carName = [] let carValue=[] + let carName1 = [] + let carValue1=[] res.forEach(e =>{ carName.push(e.seriesname), carValue.push(e.salescount) }) + console.log(carValue) + console.log(carName) + let a=0 + for(let i=carName.length; i>0;i--){ + a++ + carName1.push(carName[i-1]) + carValue1.push(carValue[i-1]) + } + console.log(carValue1) + console.log(carName1) + console.log(a) this.setData({ - brandOption: histogram(carName,carValue,'#0084FF',false) + brandOption: histogram(carName1,carValue1,'#0084FF',false) }) })}, priceSel(e){ diff --git a/components/chartdisplay/index.wxml b/components/chartdisplay/index.wxml index 976b029..e671443 100644 --- a/components/chartdisplay/index.wxml +++ b/components/chartdisplay/index.wxml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/components/indexCom/rankingChild/index.js b/components/indexCom/rankingChild/index.js index 362152b..8e1c3df 100644 --- a/components/indexCom/rankingChild/index.js +++ b/components/indexCom/rankingChild/index.js @@ -1,5 +1,4 @@ import histogram from "../../option/columnarOption" - const app = getApp() Component({ data: { @@ -59,7 +58,7 @@ Component({ carCount.push(e.salescount) }); this.setData({ - brandOption: histogram(carName, carCount, '#0084FF'), + brandOption: histogram(carName, carCount,'#0084FF'), }) resolve(true) }).catch(() => { diff --git a/components/option/columnarOption.js b/components/option/columnarOption.js index 7b74958..58e587d 100644 --- a/components/option/columnarOption.js +++ b/components/option/columnarOption.js @@ -1,4 +1,5 @@ // 单柱状 +import {doStr} from "./text" export default function histogram(dx = [], ds = [], color1 = '', direction = true) { // direction true为垂直 false为水平 return { @@ -13,9 +14,9 @@ export default function histogram(dx = [], ds = [], color1 = '', direction = tru dataZoom: direction?[{ //添加X轴滚动条 type: 'inside', show: false, - start: 10, - end: 40, - handleSize: 5 + start: 0, + end:30 , + handleSize: 30 }]:[{ type:"inside", show:false, @@ -53,6 +54,10 @@ export default function histogram(dx = [], ds = [], color1 = '', direction = tru }, axisLabel: { color: '#999999', //x轴文本颜色 + formatter:(value)=>{ + let res=doStr(value,4) + return res + }, textStyle: { fontSize: 8 } @@ -124,7 +129,11 @@ export default function histogram(dx = [], ds = [], color1 = '', direction = tru show: false, //去除轴线 }, axisLabel: { - color: '#999999', //x轴文本颜色 + color: '#999999', //y轴文本颜色 + formatter:(value)=>{ + let res=doStr(value,4) + return res + }, textStyle: { fontSize: 9 } @@ -133,7 +142,7 @@ export default function histogram(dx = [], ds = [], color1 = '', direction = tru series: { type: 'bar', data: ds, - barWidth: 24, + barWidth: direction?24:12, stack: "Search Engine", emphasis: { //折线图的高亮状态。 focus: "series", //聚焦当前高亮的数据所在的系列的所有图形。 diff --git a/components/option/text.js b/components/option/text.js new file mode 100644 index 0000000..e97b135 --- /dev/null +++ b/components/option/text.js @@ -0,0 +1,19 @@ +export function doStr(str, n) { + let totalCount = 0; + let txt = ""; + for (var i = 0; i < str.length; i++) { + let c = str.charCodeAt(i); + if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) { + totalCount++; + } else { + totalCount += 2; + } + if (totalCount <= n) { + txt += str[i]; + } else { + txt += '...'; + return txt + } + } + return txt; + } \ No newline at end of file diff --git a/pages/index/Salesranking/Vehicletype/Vehicletype.js b/pages/index/Salesranking/Vehicletype/Vehicletype.js index 4a2c712..c6e1872 100644 --- a/pages/index/Salesranking/Vehicletype/Vehicletype.js +++ b/pages/index/Salesranking/Vehicletype/Vehicletype.js @@ -14,7 +14,7 @@ Component({ grade_name3:'按能源', grade_name4:'列表展示', grades4:['列表展示','图表展示'], - positiveOption:brokenLine(dValue,data), + //弹出框 show: false, duration: 300, @@ -23,7 +23,7 @@ Component({ overlay: true, showChart: true, //图表 - positiveOption:brokenLine(dName,dValue,dColor,data), + // positiveOption:brokenLine(dName,dValue,dColor,data), imageUrl: getApp().globalData.imageUrl, date:'2021-01', accountIndex:0, @@ -43,9 +43,7 @@ Component({ let sStartTime = wx.getStorageSync("sStartTime") || ''; let sEndTime = wx.getStorageSync("sEndTime") || ''; this.getData(sTimeType, sStartTime, sEndTime); - this.getTrend(); - } - + } }, onLoad() { let pages = getCurrentPages(); @@ -55,14 +53,14 @@ Component({ id: options.id }) }, - onShow() { + onShow() { this.getData().then(() => { this.getLikeData() }) }, //页面上拉触底事件的处理函数 onReachBottom: function () { - console.log("上拉触底事件") + // console.log("上拉触底事件") let that = this if (!that.data.loadMore) { that.setData({ @@ -81,7 +79,7 @@ Component({ wx.showToast({ title: '加载中', icon: 'loading', - duration: 300000 + duration: 3000 }) this.getAmount(sTimeType, sStartTime, sEndTime), this.getTrend() @@ -90,7 +88,6 @@ Component({ },500) }, getTrend(){ - let obj = { action: 'getCheZhuCarSeriesRankingHome', sType:'Marketing', @@ -122,8 +119,6 @@ Component({ this.setData({ ranking:arr }) - console.log('22',arr) - }).then(res =>{ if (res && res.length > 0) { iPageIndex++; @@ -188,6 +183,10 @@ Component({ } arr.push(obj) }) +<<<<<<< HEAD +======= + // console.log(arr) +>>>>>>> 5f994ea039fb1c7fa98c3aedf10373552ea61bfa this.setData({ grades1:arr, }) @@ -200,8 +199,13 @@ Component({ }else{ this.data.builds = e.detail.val } +<<<<<<< HEAD console.log('11',this.data.roomLevel) console.log('123',this.data.builds) +======= + // console.log(this.data.roomLevel) + // console.log(this.data.builds) +>>>>>>> 5f994ea039fb1c7fa98c3aedf10373552ea61bfa }, bindShowMsg(e){ var id=e.currentTarget.id @@ -244,7 +248,7 @@ Component({ var name=e.currentTarget.dataset.name.name var value=e.currentTarget.dataset.name.value wx.setStorageSync('sSpec',value) - console.log(value) + // console.log(value) this.setData({ grade_name1:name, select1:false @@ -319,7 +323,7 @@ Component({ }) }, bindAccountChange(e){ - console.log('切换改变的值', e.detail.value); + // console.log('切换改变的值', e.detail.value); this.setData({ accountIndex: e.detail.value }) @@ -327,9 +331,31 @@ Component({ //弹出框 popup(e) { let duration = this.data.duration - this.setData({ - show: true, - duration + let models=e.currentTarget.dataset.car + + app.globalData.request({ + action:"getCheZhuCarSeriesListHome", + sType:"Marketing", + sSeriesName:models}).then(res => { + const dataTime=[] + const dataCar=[] + for(let i=0;i<6;i++){ + // console.log((res[i].sourcetime).substring(5,7)) + if((res[i].sourcetime).substring(5,6)=="0"){ + dataTime.push((res[i].sourcetime).substring((res[i].sourcetime).length-1,(res[i].sourcetime).length)+'月') + }else{ + dataTime.push((res[i].sourcetime).substring((res[i].sourcetime).length-2,(res[i].sourcetime).length)+"月") + } + dataCar.push(res[i].salescount) + } + // console.log(dataCar,dataTime) + // console.log(models) + this.setData({ + show: true, + duration, + positiveOption:brokenLine(dataCar,dataTime), + models + }) }) }, exit() { diff --git a/pages/index/Salesranking/Vehicletype/Vehicletype.wxml b/pages/index/Salesranking/Vehicletype/Vehicletype.wxml index 8dcd1d8..d73f5a5 100644 --- a/pages/index/Salesranking/Vehicletype/Vehicletype.wxml +++ b/pages/index/Salesranking/Vehicletype/Vehicletype.wxml @@ -81,7 +81,7 @@ 品牌名称 销量 - + @@ -104,7 +104,7 @@ {{item.volume}} - + 销量趋势 @@ -116,7 +116,7 @@ - + + + + + + 销量趋势 + + + + + {{models}}销量趋势 + + + + +