|
@@ -0,0 +1,114 @@
|
|
|
|
+<template>
|
|
|
|
+ <echartsBase :option="setOption"/>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script setup>
|
|
|
|
+import { nextTick, onMounted, ref, watch } from 'vue'
|
|
|
|
+import echartsBase from './index.vue'
|
|
|
|
+
|
|
|
|
+const props = defineProps({
|
|
|
|
+ title: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: '管理费用项目分摊占比情况'
|
|
|
|
+ },
|
|
|
|
+ color: {
|
|
|
|
+ type: Array,
|
|
|
|
+ default: () => (['#5087EC', '#68BBC4'])
|
|
|
|
+ },
|
|
|
|
+ unit: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: '元'
|
|
|
|
+ },
|
|
|
|
+ datas: {
|
|
|
|
+ type: Array,
|
|
|
|
+ default: () => ([])
|
|
|
|
+ }
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+//初始变量
|
|
|
|
+const setOption = ref({})
|
|
|
|
+const titles = ref(props.title)
|
|
|
|
+const colors = ref(props.color)
|
|
|
|
+const units = ref(props.unit)
|
|
|
|
+const datas = ref(props.datas)
|
|
|
|
+
|
|
|
|
+watch(() => [
|
|
|
|
+ props.title,
|
|
|
|
+ props.color,
|
|
|
|
+ props.unit,
|
|
|
|
+], ([title, color, unit]) => {
|
|
|
|
+ titles.value = title
|
|
|
|
+ colors.value = color
|
|
|
|
+ units.value = unit
|
|
|
|
+ setOptions()
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+//深度监听数据变化
|
|
|
|
+watch(() => [
|
|
|
|
+ props.datas,
|
|
|
|
+], ([data]) => {
|
|
|
|
+ datas.value = data
|
|
|
|
+ setOptions()
|
|
|
|
+}, { deep: true })
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+//设置图表
|
|
|
|
+const setOptions = () => {
|
|
|
|
+ setOption.value = {
|
|
|
|
+ color: colors.value,
|
|
|
|
+ title: {
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ tooltip: {
|
|
|
|
+ trigger: 'axis',
|
|
|
|
+ axisPointer: {
|
|
|
|
+ type: 'shadow'
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ legend: {},
|
|
|
|
+ grid: {
|
|
|
|
+ left: '3%',
|
|
|
|
+ right: '4%',
|
|
|
|
+ bottom: '3%',
|
|
|
|
+ containLabel: true
|
|
|
|
+ },
|
|
|
|
+ xAxis: {
|
|
|
|
+ type: 'value',
|
|
|
|
+ boundaryGap: [0, 0.01],
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ yAxis: {
|
|
|
|
+ type: 'category',
|
|
|
|
+ data: ['张三', '李四', '王五', '赵六', '陈琦', '五把'],
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ series: [
|
|
|
|
+ {
|
|
|
|
+ name: '任务完成率',
|
|
|
|
+ type: 'bar',
|
|
|
|
+ data: [10, 20, 40, 60, 80, 99],
|
|
|
|
+ itemStyle: {
|
|
|
|
+ normal: {
|
|
|
|
+ label: {
|
|
|
|
+ show: true,
|
|
|
|
+ formatter: function (a, b, c) {
|
|
|
|
+ return a.data + "%";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ ]
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//渲染完成
|
|
|
|
+onMounted(() => {
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ setOptions()
|
|
|
|
+ })
|
|
|
|
+})
|
|
|
|
+</script>
|