湖里大屏:扩展 jChart/pie/JProblemChart.vue 组件
This commit is contained in:
parent
65df1404d6
commit
37c8a9df85
@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- 质量问题 -->
|
<!-- 质量问题 -->
|
||||||
<div class="myChart" ref="myChart" />
|
<div class="myChart" ref="myChart" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import echarts from "echarts4";
|
import echarts from 'echarts4'
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
title: {
|
title: {
|
||||||
@ -22,24 +22,55 @@ export default {
|
|||||||
},
|
},
|
||||||
color: {
|
color: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => ['#3cabfd','#57ec72','#f294c6','#f43a8d','#6ee4f0']
|
default: () => ['#3cabfd', '#57ec72', '#f294c6', '#f43a8d', '#6ee4f0']
|
||||||
},
|
},
|
||||||
|
centerPie: {
|
||||||
|
type: Object,
|
||||||
|
default: () => null
|
||||||
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {}
|
||||||
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
mounted(){
|
mounted() {
|
||||||
this.initMyChart();
|
this.initMyChart()
|
||||||
},
|
},
|
||||||
methods:{
|
methods: {
|
||||||
initMyChart() {
|
initMyChart() {
|
||||||
const myChart = echarts.init(this.$refs.myChart);
|
const myChart = echarts.init(this.$refs.myChart)
|
||||||
|
const { data, centerPie } = this
|
||||||
|
const setSeries = ((data, centerPie) => {
|
||||||
|
const series = [
|
||||||
|
{
|
||||||
|
type: 'pie',
|
||||||
|
radius: ['50%', '65%'],
|
||||||
|
center: ['30%', '50%'],
|
||||||
|
avoidLabelOverlap: true,
|
||||||
|
label: { show: false },
|
||||||
|
emphasis: {
|
||||||
|
label: { show: false }
|
||||||
|
},
|
||||||
|
labelLine: { show: false },
|
||||||
|
data
|
||||||
|
}
|
||||||
|
]
|
||||||
|
if (centerPie) {
|
||||||
|
series.push({
|
||||||
|
type: 'pie',
|
||||||
|
roseType: 'area',
|
||||||
|
label: { show: false },
|
||||||
|
color: centerPie.color,
|
||||||
|
radius: centerPie.radius,
|
||||||
|
data: centerPie.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return series
|
||||||
|
})(data, centerPie)
|
||||||
|
|
||||||
const option = {
|
const option = {
|
||||||
title: {
|
title: {
|
||||||
x: this.title.x || '29%' ,
|
x: this.title.x || '29%',
|
||||||
y: this.title.y || '43%' ,
|
y: this.title.y || '43%',
|
||||||
show: true,
|
show: true,
|
||||||
text: this.title.text,
|
text: this.title.text,
|
||||||
subtext: this.title.subTitle,
|
subtext: this.title.subTitle,
|
||||||
@ -47,16 +78,16 @@ export default {
|
|||||||
textStyle: {
|
textStyle: {
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: 'normal',
|
fontWeight: 'normal',
|
||||||
color: '#fff',
|
color: '#fff'
|
||||||
},
|
},
|
||||||
subtextStyle: {
|
subtextStyle: {
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: 'normal',
|
fontWeight: 'normal',
|
||||||
color: '#fff'
|
color: '#fff'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
trigger: "item",
|
trigger: 'item'
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
type: 'scroll',
|
type: 'scroll',
|
||||||
@ -69,48 +100,22 @@ export default {
|
|||||||
icon: 'circle',
|
icon: 'circle',
|
||||||
textStyle: {
|
textStyle: {
|
||||||
color: '#ffffff',
|
color: '#ffffff',
|
||||||
fontSize: 14,
|
fontSize: 14
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
color: this.color,
|
color: this.color,
|
||||||
series: [
|
series: setSeries
|
||||||
{
|
}
|
||||||
type: "pie",
|
|
||||||
radius: ["50%", "65%"],
|
|
||||||
center: ['30%', '50%'],
|
|
||||||
avoidLabelOverlap: true,
|
|
||||||
label: {
|
|
||||||
show: false,
|
|
||||||
position: "center",
|
|
||||||
},
|
|
||||||
emphasis: {
|
|
||||||
label: {
|
|
||||||
show: false,
|
|
||||||
fontSize: "20",
|
|
||||||
color: '#fff',
|
|
||||||
fontWeight: "bold",
|
|
||||||
},
|
|
||||||
scaleSize: 12,
|
|
||||||
},
|
|
||||||
labelLine: {
|
|
||||||
show: false,
|
|
||||||
},
|
|
||||||
data: this.data,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
myChart.setOption(option);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
|
myChart.setOption(option)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.myChart {
|
.myChart {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
Loading…
x
Reference in New Issue
Block a user