Commit 087bfa1c by 匡雅琴

饼图样式调整

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