湖里大屏:新增 jChart/pie/JNestedRingChart.vue 组件

This commit is contained in:
Jack 2022-08-05 15:57:14 +08:00
parent c4df3b65d9
commit 34bc0c6178
2 changed files with 56 additions and 34 deletions

View File

@ -1,6 +1,6 @@
<template>
<Card :title="title">
<JNestedRingChart />
<JNestedRingChart :title="{ text: 652, subTitle: '本周总任务' }" :series="series" />
</Card>
</template>
@ -16,7 +16,27 @@ export default {
}
},
data() {
return {}
return {
series: [
{
color: ['#3CABFD', '#F43A8B', '#F294C6', '#56EC6F', '#786FF0', '#6EE4EE'],
data: [
{ value: 45, name: '未戴安全帽' },
{ value: 5, name: '危险区域闯入' },
{ value: 15, name: '人员聚集报警' },
{ value: 10, name: '未穿反光衣' },
{ value: 45, name: '明火监测报警' },
{ value: 45, name: '烟雾监测报警' }
]
},
{
roseType: 'area',
radius: ['58%', '54%'],
color: ['#0B1B35', '#244D8F'],
data: [30, 40, 30, 40]
}
]
}
}
}
</script>

View File

@ -5,7 +5,22 @@
<script>
import echarts from 'echarts4'
export default {
props: {},
props: {
title: {
type: Object,
default: () => ({
text: '',
subTitle: '',
x: '48%',
y: '36%'
})
},
series: {
required: true,
type: Array,
default: () => []
}
},
mounted() {
this.jNestedRingChart = echarts.init(this.$refs.jNestedRingChart)
this.createChart()
@ -17,14 +32,26 @@ export default {
},
methods: {
createChart() {
const { title } = this
const { title, series } = this
const setSeries = (series => {
return series.map(item => ({
type: 'pie',
label: false,
center: ['30%', '50%'],
radius: item.radius || ['65%', '80%'],
roseType: item.roseType,
color: item.color,
data: item.data
}))
})(series)
const option = {
title: {
x: '29%',
y: '35%',
text: title.text,
subtext: title.subTitle,
x: title.x || '29%',
y: title.y || '35%',
show: true,
text: 654,
subtext: '本周总任务',
textAlign: 'center',
textStyle: {
fontSize: 20,
@ -54,32 +81,7 @@ export default {
fontSize: 14
}
},
series: [
{
type: 'pie',
label: false,
color: ['#3cabfd', '#57ec72', '#f294c6', '#f43a8d', '#6ee4f0', 'red'],
radius: ['65%', '80%'],
center: ['30%', '50%'],
data: [
{ value: 45, name: '未戴安全帽' },
{ value: 5, name: '危险区域闯入' },
{ value: 15, name: '人员聚集报警' },
{ value: 10, name: '未穿反光衣' },
{ value: 45, name: '明火监测报警' },
{ value: 45, name: '烟雾监测报警' }
]
},
{
type: 'pie',
label: false,
roseType: 'area',
color: ['#0B1B35', '#244D8F'],
radius: ['58%', '54%'],
center: ['30%', '50%'],
data: [30, 40, 30, 40]
}
]
series: setSeries
}
this.jNestedRingChart.setOption(option)
}