Browse Source

饼图显示

shibei_master
13176889840 4 years ago
parent
commit
16e446e318
  1. 62
      src/views/modules/visual/communityGovern/resiPieOption.js
  2. 26
      src/views/modules/visual/communityGovern/resibuzz.vue

62
src/views/modules/visual/communityGovern/resiPieOption.js

@ -1,5 +1,5 @@
export function pieOption () { export function pieOption (_charts) {
const center= ['50%', '250px'] const center= ['50%', '250px']
return { return {
title: { title: {
@ -47,19 +47,14 @@ const center= ['50%', '250px']
center: center, center: center,
radius: ['55%', '55.3%'], radius: ['55%', '55.3%'],
label: { label: {
normal: {
show: false show: false
}
}, },
labelLine: { labelLine: {
normal: {
show: false show: false
}
}, },
data: [{ data: [{
value: 360, value: 360,
itemStyle: { itemStyle: {
normal: {
color: 'rgba(40, 101, 250, 0)', color: 'rgba(40, 101, 250, 0)',
width:0, width:0,
borderColor: 'rgba(40, 101, 250, 0.5)', borderColor: 'rgba(40, 101, 250, 0.5)',
@ -67,7 +62,6 @@ const center= ['50%', '250px']
borderType: 'dotted' borderType: 'dotted'
} }
} }
}
] ]
}, },
@ -85,33 +79,55 @@ const center= ['50%', '250px']
left: 'center', left: 'center',
width: 400, width: 400,
label: { label: {
position: 'outer', // show: false,
// alignTo: 'edge', position: 'outside',
formatter: '{a|{c}}\n\n{name|{b}}', alignTo: 'edge',
// minMargin: 100, // formatter: '{a|{c}}\n\n{name|{b}}',
// edgeDistance: 0, formatter: '{a|{c}}\n{r|}\n{name|{b}}',
// lineHeight: 20, minMargin: 5,
edgeDistance: 1,
lineHeight: 15,
color: '#fff', color: '#fff',
fontSize: 12, fontSize: 12,
distanceToLabelLine: -60, // distanceToLabelLine: -60,
rich: { rich: {
name: {
padding: [0, 6, 0, 6]
},
a: { a: {
fontSize: '30px', fontSize: 30,
color: ' #00F5FE', color: '#fff',
padding: [0, 6, 6, 6]
}, },
b: { r: {
lineHeight: 0, backgroundColor: 'auto',
fontSize: '20px', borderRadius: 6,
color: ' #FFFFFF' width: 6,
height: 6,
// padding: [3, 3, 0, -12]
} }
} }
}, },
labelLine: { labelLine: {
show: false,
smooth: 0.2, smooth: 0.2,
length: 30, length: 30,
length2: 90 length2: 0,
maxSurfaceAngle: 80
},
labelLayout: function (params) {
const isLeft = params.labelRect.x < _charts.getWidth() / 2;
const points = params.labelLinePoints;
// Update the end point.
if (points) {
points[2][0] = isLeft
? params.labelRect.x
: params.labelRect.x + params.labelRect.width;
}
return {
labelLinePoints: points
};
}, },
// itemStyle: { // itemStyle: {
// normal:{ // normal:{

26
src/views/modules/visual/communityGovern/resibuzz.vue

@ -116,6 +116,7 @@ export default {
pageSize: 10, pageSize: 10,
pageNo: 1, pageNo: 1,
total: 0, total: 0,
pieChartS: null
}, },
}; };
}, },
@ -159,8 +160,9 @@ export default {
}, },
methods: { methods: {
pieInitOk () { pieInitOk (dom) {
console.log('pie准备好了') console.log('pie准备好了', dom)
this.pieChartS = dom
this.pieInitState = true this.pieInitState = true
}, },
@ -180,12 +182,13 @@ export default {
// const res = await getMonthPieChart(this.shibeiAId) // const res = await getMonthPieChart(this.shibeiAId)
// pieChart // pieChart
this.pieOption = pieOption() this.pieOption = pieOption(this.pieChartS)
this.pieOption.title.text = this.pieTotal
this.pieOption.series[1].data = this.pieData
this.clickPie(0) this.clickPie(0)
this.pieOption.title.text = this.pieTotal
this.pieOption.series[1].data = this.pieData
this.$refs.pieChart.setOption(this.pieOption) this.$refs.pieChart.setOption(this.pieOption)
@ -212,6 +215,19 @@ export default {
} }
}; };
console.log('zhilma')
// element.labelLayout = (params) => {
// const isLeft = params.labelRect.x < this.pieChartS.getWidth() / 2;
// const points = params.labelLinePoints;
// console.log('isLeft', isLeft, points)
// // Update the end point.
// points[2][0] = isLeft
// ? params.labelRect.x
// : params.labelRect.x + params.labelRect.width;
// return {
// labelLinePoints: points
// };
// }
} else { } else {
element.label = { element.label = {

Loading…
Cancel
Save