Commit 14ef3fe8 by 匡雅琴

饼图样式调整

1 parent 6d3df9b9
...@@ -47,8 +47,12 @@ export default { ...@@ -47,8 +47,12 @@ export default {
default: '12px' default: '12px'
}, },
formatter: { formatter: {
type: Boolean, type: String,
default: false default: ''
},
formatterName: {
type: String,
default: ''
} }
}, },
...@@ -133,24 +137,46 @@ export default { ...@@ -133,24 +137,46 @@ export default {
fontSize: this.size, fontSize: this.size,
fontWeight: 'bold', fontWeight: 'bold',
color: '#fff', color: '#fff',
formatter: function(params) { formatter: (params) => {
const _dataIndex = params.dataIndex const _dataIndex = params.dataIndex
// 价格
const _purchaseamount = utils.numAddSymbol(_this.list[_dataIndex].purchaseamount) const _purchaseamount = utils.numAddSymbol(_this.list[_dataIndex].purchaseamount)
// 均价
const _avarage = utils.numAddSymbol(_this.list[_dataIndex].averprice) const _avarage = utils.numAddSymbol(_this.list[_dataIndex].averprice)
// const _html = `<div>¥${_purchaseamount}</div><div style="padding-left: 7px;">均价¥ ${_avarage}</div>` // 总价
if (_this.formatter) return `{a|¥${_purchaseamount}}\n{b|均价¥ ${_avarage}}` let _totalValue = 0
return `${params.name}` _this.list.forEach(item => {
// return _html _totalValue += item.value
})
let _html
/**
* price -- 价格+均价组合
* total -- 名称+总数组合
* none -- 不显示内容
* 默认显示名称
*/
switch (_this.formatter) {
case 'price':
_html = `{a|¥${_purchaseamount}}\n{b|均价¥ ${_avarage}}`
break
case 'total':
_html = `${_this.formatterName}\n${_totalValue}`
break
case 'none':
_html = ''
break
default:
_html = params.name
}
return _html
}, },
rich: { rich: {
a: { a: {
color: '#c8c8c8', color: '#c8c8c8',
wordSpacing: '5px'
}, },
b: { b: {
color: '#ffffff66', color: '#ffffff66',
fontSize: '12px', fontSize: '12px',
// padding: ['7px', 0, 0, 0],
lineHeight: '28' lineHeight: '28'
} }
} }
......
...@@ -46,12 +46,14 @@ export default { ...@@ -46,12 +46,14 @@ export default {
id: 'goodsPay', id: 'goodsPay',
keys: ['name', 'value'], keys: ['name', 'value'],
height: '15.34vh', height: '15.34vh',
colors: ['#34AFFF', '#16E193', '#FFC200'] colors: ['#34AFFF', '#16E193', '#FFC200'],
formatter: 'total',
formatterName: '支付订单'
}, },
goodsPayLegend: [ goodsPayLegend: [
{ {
name: 'name', name: 'name',
width: '5vw' width: '4vw'
}, },
{ {
name: 'rate', name: 'rate',
......
...@@ -40,7 +40,9 @@ export default { ...@@ -40,7 +40,9 @@ export default {
id: 'boutiquePropertion', id: 'boutiquePropertion',
keys: ['name', 'value'], keys: ['name', 'value'],
height: '15.34vh', height: '15.34vh',
colors: ['#16E193', '#34AFFF'] colors: ['#16E193', '#34AFFF'],
formatter: 'total',
formatterName: '总商品数'
}, },
propertionLegend: [ propertionLegend: [
{ {
......
...@@ -26,7 +26,7 @@ export default { ...@@ -26,7 +26,7 @@ export default {
keys: ['goodsname', 'purchaseamount'], keys: ['goodsname', 'purchaseamount'],
height: '17.34vh', height: '17.34vh',
colors: ['#16E193', '#747DFF', '#E588FF', '#34AFFF', '#FFC200', '#EB6001'], colors: ['#16E193', '#747DFF', '#E588FF', '#34AFFF', '#FFC200', '#EB6001'],
formatter: true formatter: 'price'
}, },
// 采购占比数据 // 采购占比数据
propertionData: [], propertionData: [],
......
...@@ -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" :formatter="chart.formatter" :height="chart.height" :colors="chart.colors"></pie-chart> <pie-chart class="pie-chart" :id="chart.id" :list="listData" :keys="chart.keys" :formatter="chart.formatter" :formatterName="chart.formatterName" :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>
......
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
keys: ['goodsname', 'purchaseamount'], keys: ['goodsname', 'purchaseamount'],
height: '18vh', height: '18vh',
colors: ['#16E193', '#747DFF', '#E588FF', '#34AFFF', '#FFC200', '#EB6001'], colors: ['#16E193', '#747DFF', '#E588FF', '#34AFFF', '#FFC200', '#EB6001'],
formatter: true formatter: 'price'
}, },
shopmallLegend: [ shopmallLegend: [
{ {
...@@ -87,7 +87,7 @@ export default { ...@@ -87,7 +87,7 @@ export default {
keys: ['goodsname', 'purchaseamount'], keys: ['goodsname', 'purchaseamount'],
height: '18vh', height: '18vh',
colors: ['#16E193', '#747DFF', '#E588FF', '#34AFFF', '#FFC200', '#EB6001'], colors: ['#16E193', '#747DFF', '#E588FF', '#34AFFF', '#FFC200', '#EB6001'],
formatter: true formatter: 'price'
}, },
selfPickLegend: [ selfPickLegend: [
{ {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!