Commit 087bfa1c by 匡雅琴

饼图样式调整

1 parent b5778096
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<script> <script>
import * as echarts from 'echarts' import * as echarts from 'echarts'
import utils from '@/utils/util.js'
export default { export default {
name: 'PieChart', name: 'PieChart',
...@@ -44,6 +45,10 @@ export default { ...@@ -44,6 +45,10 @@ export default {
size: { size: {
type: String, type: String,
default: '0.6vw' default: '0.6vw'
},
formatter: {
type: Boolean,
default: false
} }
}, },
...@@ -75,8 +80,7 @@ export default { ...@@ -75,8 +80,7 @@ export default {
} }
}, },
mounted() { mounted() {},
},
methods: { methods: {
// 初始化数据 // 初始化数据
...@@ -128,10 +132,19 @@ export default { ...@@ -128,10 +132,19 @@ export default {
color: '#fff', color: '#fff',
formatter(params) { formatter(params) {
const _dataIndex = params.dataIndex const _dataIndex = params.dataIndex
const _avarage = _this.list[_dataIndex].averprice const _purchaseamount = utils.numAddSymbol(_this.list[_dataIndex].purchaseamount)
console.log(_this.list, _avarage); const _avarage = utils.numAddSymbol(_this.list[_dataIndex].averprice)
if (_avarage) return `${params.name}\n均价¥${_avarage || ''}` console.log(_purchaseamount, _avarage)
if (_this.formatter) return `{a|¥ ${_purchaseamount}}\n{b|均价¥ ${_avarage}}`
return `${params.name}` return `${params.name}`
},
rich: {
a: {
color: '#c8c8c8'
},
b: {
color: '#ffffff66'
}
} }
} }
}, },
......
...@@ -23,34 +23,35 @@ export default { ...@@ -23,34 +23,35 @@ export default {
// 采购占比饼图结构 // 采购占比饼图结构
propertionChart: { propertionChart: {
id: 'propertion', id: 'propertion',
keys: ['goodsname', 'purchaseamount', 'averprice'], keys: ['goodsname', 'purchaseamount'],
height: '15.34vh', height: '15.34vh',
colors: ['#16E193', '#747DFF', '#E588FF', '#34AFFF', '#FFC200', '#EB6001'] colors: ['#16E193', '#747DFF', '#E588FF', '#34AFFF', '#FFC200', '#EB6001'],
formatter: true
}, },
// 采购占比数据 // 采购占比数据
propertionData: [], propertionData: [],
propertionLegend: [ propertionLegend: [
{ {
name: 'goodsname', name: 'goodsname',
width: '2.5vw' width: '11.11vw'
}, },
{ {
name: 'rate', name: 'rate',
type: 'decimal', type: 'decimal',
width: '1.88vw' width: '1.88vw'
}, },
{ // {
name: 'purchaseamount', // name: 'purchaseamount',
hasIcon: '¥', // hasIcon: '¥',
type: 'number', // type: 'number',
width: '4.06vw' // width: '4.06vw'
}, // },
{ // {
name: 'averprice', // name: 'averprice',
hasIcon: '均价¥', // hasIcon: '均价¥',
type: 'number', // type: 'number',
width: '6.24vw' // width: '6.24vw'
} // }
] ]
} }
}, },
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
--> -->
<template> <template>
<div class="main-box"> <div class="main-box">
<pie-chart class="pie-chart" :id="chart.id" :list="listData" :keys="chart.keys" :height="chart.height" :colors="chart.colors"></pie-chart> <pie-chart class="pie-chart" :id="chart.id" :list="listData" :keys="chart.keys" :formatter="chart.formatter" :height="chart.height" :colors="chart.colors"></pie-chart>
<Legend class="legend" :list="listData" :legentList="legentList" :colors="legendColors"></Legend> <Legend class="legend" :list="listData" :legentList="legentList" :colors="legendColors"></Legend>
</div> </div>
</template> </template>
......
...@@ -55,60 +55,62 @@ export default { ...@@ -55,60 +55,62 @@ export default {
id: 'shopmall', id: 'shopmall',
keys: ['goodsname', 'purchaseamount'], keys: ['goodsname', 'purchaseamount'],
height: '16vh', height: '16vh',
colors: ['#16E193', '#747DFF', '#E588FF', '#34AFFF', '#FFC200', '#EB6001'] colors: ['#16E193', '#747DFF', '#E588FF', '#34AFFF', '#FFC200', '#EB6001'],
formatter: true
}, },
shopmallLegend: [ shopmallLegend: [
{ {
name: 'goodsname', name: 'goodsname',
width: '7vw' width: '15.28vw'
}, },
{ {
name: 'rate', name: 'rate',
type: 'decimal', type: 'decimal',
width: '3vw' width: '3vw'
}, },
{ // {
name: 'purchaseamount', // name: 'purchaseamount',
hasIcon: '¥', // hasIcon: '¥',
type: 'number', // type: 'number',
width: '5vw' // width: '5vw'
}, // },
{ // {
name: 'averprice', // name: 'averprice',
hasIcon: '均价¥', // hasIcon: '均价¥',
type: 'number', // type: 'number',
width: '5vw' // width: '5vw'
} // }
], ],
// 自采饼图结构 // 自采饼图结构
selfPickChart: { selfPickChart: {
id: 'selfPick', id: 'selfPick',
keys: ['goodsname', 'purchaseamount'], keys: ['goodsname', 'purchaseamount'],
height: '16vh', height: '16vh',
colors: ['#16E193', '#747DFF', '#E588FF', '#34AFFF', '#FFC200', '#EB6001'] colors: ['#16E193', '#747DFF', '#E588FF', '#34AFFF', '#FFC200', '#EB6001'],
formatter: true
}, },
selfPickLegend: [ selfPickLegend: [
{ {
name: 'goodsname', name: 'goodsname',
width: '7vw' width: '15.28vw'
}, },
{ {
name: 'rate', name: 'rate',
type: 'decimal', type: 'decimal',
width: '3vw' width: '3vw'
}, },
{ // {
name: 'purchaseamount', // name: 'purchaseamount',
hasIcon: '¥', // hasIcon: '¥',
type: 'number', // type: 'number',
width: '5vw' // width: '5vw'
}, // },
{ // {
name: 'averprice', // name: 'averprice',
hasIcon: '均价¥', // hasIcon: '均价¥',
type: 'number', // type: 'number',
width: '5vw' // width: '5vw'
} // }
] ]
} }
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!