Commit 14ef3fe8 by 匡雅琴

饼图样式调整

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