湖里大屏:新增 jChart/pie/JNestedRingChart.vue 组件
This commit is contained in:
parent
c4df3b65d9
commit
34bc0c6178
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<Card :title="title">
|
<Card :title="title">
|
||||||
<JNestedRingChart />
|
<JNestedRingChart :title="{ text: 652, subTitle: '本周总任务' }" :series="series" />
|
||||||
</Card>
|
</Card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -16,7 +16,27 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
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>
|
</script>
|
||||||
|
|||||||
@ -5,7 +5,22 @@
|
|||||||
<script>
|
<script>
|
||||||
import echarts from 'echarts4'
|
import echarts from 'echarts4'
|
||||||
export default {
|
export default {
|
||||||
props: {},
|
props: {
|
||||||
|
title: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({
|
||||||
|
text: '',
|
||||||
|
subTitle: '',
|
||||||
|
x: '48%',
|
||||||
|
y: '36%'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
series: {
|
||||||
|
required: true,
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.jNestedRingChart = echarts.init(this.$refs.jNestedRingChart)
|
this.jNestedRingChart = echarts.init(this.$refs.jNestedRingChart)
|
||||||
this.createChart()
|
this.createChart()
|
||||||
@ -17,14 +32,26 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
createChart() {
|
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 = {
|
const option = {
|
||||||
title: {
|
title: {
|
||||||
x: '29%',
|
text: title.text,
|
||||||
y: '35%',
|
subtext: title.subTitle,
|
||||||
|
x: title.x || '29%',
|
||||||
|
y: title.y || '35%',
|
||||||
show: true,
|
show: true,
|
||||||
text: 654,
|
|
||||||
subtext: '本周总任务',
|
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
textStyle: {
|
textStyle: {
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
@ -54,32 +81,7 @@ export default {
|
|||||||
fontSize: 14
|
fontSize: 14
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
series: [
|
series: setSeries
|
||||||
{
|
|
||||||
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]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
this.jNestedRingChart.setOption(option)
|
this.jNestedRingChart.setOption(option)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user