From 96db7c8d9008616707cb28081bf73584a1f98210 Mon Sep 17 00:00:00 2001 From: fengachen <373943794@qq.com> Date: Tue, 25 Oct 2022 15:54:04 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AE=8C=E6=88=90=E7=99=BE=E5=88=86=E6=AF=94=20?= =?UTF-8?q?=E6=80=BB=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/DepartmentTotalEcharts.vue | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/views/dashboard/DepartmentTotalEcharts.vue b/src/views/dashboard/DepartmentTotalEcharts.vue index b136123..1fb56c1 100644 --- a/src/views/dashboard/DepartmentTotalEcharts.vue +++ b/src/views/dashboard/DepartmentTotalEcharts.vue @@ -119,7 +119,7 @@ export default { let dataIndex = 'key' + index tableData[0][dataIndex] = item.allMoney tableData[1][dataIndex] = item.confirmAmount - tableData[2][dataIndex] = this.calcPercent(item.confirmAmount,item.allMoney) + tableData[2][dataIndex] = item.value + '%' }) this.dataSource = tableData } @@ -139,7 +139,7 @@ export default { { title: '', align: 'center', - width: 100, + width: 140, dataIndex: 'indexName', scopedSlots: {customRender: 'text'} }, @@ -148,7 +148,7 @@ export default { this.columns.push({ title: item.name, align: 'center', - width: 160, + width: index < 7 ? 190 : 120, dataIndex: 'key' + index, scopedSlots: {customRender: 'allMoney'} },) @@ -159,10 +159,13 @@ export default { let xData = data.reduce((pre, val) => { return pre.concat(val.name) }, []) + xData = xData.slice(0,7) // 处理y轴数据 - data.map(item => { - this.echartsData.allMoney.push(item.allMoney) - this.echartsData.confirmAmount.push(item.confirmAmount) + data.map((item,index) => { + if(index < 7){ + this.echartsData.allMoney.push({value:item.allMoney,percent:item.value}) + this.echartsData.confirmAmount.push({value:item.confirmAmount,percent:item.value}) + } }) let chartDom = document.getElementById('departmentTotal') @@ -173,7 +176,7 @@ export default { color: ['#069F99', '#FFA17A'], grid: { left: '3%', - right: '0%', + right: '7%', bottom: '3%', containLabel: true }, @@ -183,7 +186,7 @@ export default { tooltip: { trigger: 'axis', formatter: params => { - let percent = this.calcPercent(params[1].data,params[0].data) + let percent = params[0].data.percent + '%' // 获取xAxis data中的数据 let dataStr = '' params.forEach(item => { @@ -193,7 +196,7 @@ export default { ${item.seriesName} -
${this.formatMoney(item.data)}
+
${this.formatMoney(item.value)}
` }) @@ -303,7 +306,7 @@ export default { * */ calcPercent(num1,num2){ let pointNo = Number(num1) / Number(num2) * 100 - return pointNo.toFixed(2) + '%' + return pointNo.toFixed(1) + '%' } } }