|
@@ -21,9 +21,9 @@ let props = defineProps({
|
|
|
}
|
|
|
},
|
|
|
echartData: {
|
|
|
- type: Object,
|
|
|
+ type: Array,
|
|
|
default: () => {
|
|
|
- return {}
|
|
|
+ return []
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -31,42 +31,13 @@ let props = defineProps({
|
|
|
//获取dom元素节点
|
|
|
let chartRef = ref<any>();
|
|
|
// 类别
|
|
|
-let category = [
|
|
|
- {
|
|
|
- name: "报警",
|
|
|
- value: 300
|
|
|
- },
|
|
|
- {
|
|
|
- name: "重大风险",
|
|
|
- value: 300
|
|
|
- },
|
|
|
- {
|
|
|
- name: "较大风险",
|
|
|
- value: 300.2
|
|
|
- },
|
|
|
- {
|
|
|
- name: "一般风险",
|
|
|
- value: 548.7
|
|
|
- },
|
|
|
- {
|
|
|
- name: "低风险",
|
|
|
- value: 612.5
|
|
|
- },
|
|
|
-
|
|
|
-];
|
|
|
-let total = ref(1000) // 数据总数
|
|
|
-let datas = [];
|
|
|
-category.forEach(value => {
|
|
|
- datas.push(value.value);
|
|
|
-});
|
|
|
-
|
|
|
+let category = ref<any[]>([])
|
|
|
+let echartY=ref<any[]>([])
|
|
|
function getOption() {
|
|
|
-
|
|
|
-
|
|
|
let myChart = echarts.init(chartRef.value);
|
|
|
let option = {
|
|
|
xAxis: {
|
|
|
- max: 1000,
|
|
|
+ max: 10,
|
|
|
splitLine: {
|
|
|
show: false
|
|
|
},
|
|
@@ -82,14 +53,14 @@ function getOption() {
|
|
|
},
|
|
|
grid: {
|
|
|
left: 10,
|
|
|
- top: 15, // 设置条形图的边距
|
|
|
+ top: 10, // 设置条形图的边距
|
|
|
right: 10,
|
|
|
- bottom: 15
|
|
|
+ bottom: 0
|
|
|
},
|
|
|
yAxis: [{
|
|
|
type: "category",
|
|
|
inverse: false,
|
|
|
- data: category,
|
|
|
+ data: category.value,
|
|
|
axisLine: {
|
|
|
show: false
|
|
|
},
|
|
@@ -99,8 +70,6 @@ function getOption() {
|
|
|
axisLabel: {
|
|
|
show: false
|
|
|
},
|
|
|
-
|
|
|
-
|
|
|
}],
|
|
|
series: [
|
|
|
{
|
|
@@ -118,20 +87,18 @@ function getOption() {
|
|
|
},
|
|
|
label: {
|
|
|
normal: {
|
|
|
- // formatter: '{warnLevel1|}', // 使用富文本占位符
|
|
|
formatter: (params) => {
|
|
|
- console.log(params,)
|
|
|
let text;
|
|
|
if (params.dataIndex == 0) {
|
|
|
- text = `{warnLevel5|\u00A0\u00A0\u00A0\u00A0${params.data.name}}`;
|
|
|
+ text = `{warnLevel5|\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0${params.data.name}}`;
|
|
|
} else if (params.dataIndex == 1) {
|
|
|
- // text = `{warnLevel4|${params.data.name}}`;
|
|
|
+ text = `{warnLevel4|\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0${params.data.name}}`;
|
|
|
} else if (params.dataIndex == 2) {
|
|
|
- // text = `{warnLevel3|${params.data.name}}`;
|
|
|
+ text = `{warnLevel3|\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0${params.data.name}}`;
|
|
|
} else if (params.dataIndex == 3) {
|
|
|
- // text = `{warnLevel2|${params.data.name}}`;
|
|
|
+ text = `{warnLevel2|\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0${params.data.name}}`;
|
|
|
} else if (params.dataIndex == 4) {
|
|
|
- // text = `{warnLevel1|${params.data.name}}`;
|
|
|
+ text = `{warnLevel1|\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0${params.data.name}}`;
|
|
|
}
|
|
|
return text;
|
|
|
},
|
|
@@ -139,29 +106,36 @@ function getOption() {
|
|
|
color: "#fff",
|
|
|
fontSize: 12
|
|
|
},
|
|
|
- position: [20, -21],
|
|
|
+ position: [0, -22],
|
|
|
show: true,
|
|
|
rich: { //富文本
|
|
|
warnLevel1: {
|
|
|
backgroundColor: {
|
|
|
image: warnLevel1,
|
|
|
},
|
|
|
+ height: 16,
|
|
|
+ width: 16,
|
|
|
},
|
|
|
warnLevel2: {
|
|
|
backgroundColor: { //这里可以添加你想自定义的图片
|
|
|
image: warnLevel2,
|
|
|
-
|
|
|
},
|
|
|
+ height: 16,
|
|
|
+ width: 16,
|
|
|
},
|
|
|
warnLevel3: {
|
|
|
backgroundColor: {
|
|
|
image: warnLevel3,
|
|
|
},
|
|
|
+ height: 16,
|
|
|
+ width: 16,
|
|
|
},
|
|
|
warnLevel4: {
|
|
|
backgroundColor: { //这里可以添加你想自定义的图片
|
|
|
image: warnLevel4,
|
|
|
},
|
|
|
+ height: 16,
|
|
|
+ width: 16,
|
|
|
},
|
|
|
warnLevel5: {
|
|
|
backgroundColor: { //这里可以添加你想自定义的图片
|
|
@@ -169,15 +143,13 @@ function getOption() {
|
|
|
},
|
|
|
height: 16,
|
|
|
width: 16,
|
|
|
- align: 'left',
|
|
|
- padding: [0, 5, 0, 0] // 右侧增加5px间距
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
},
|
|
|
- data: category,
|
|
|
+ data: category.value,
|
|
|
z: 1,
|
|
|
animationEasing: "elasticOut"
|
|
|
},
|
|
@@ -197,8 +169,8 @@ function getOption() {
|
|
|
symbolSize: [10, 24],
|
|
|
symbolPosition: "start",
|
|
|
symbolOffset: [1, -4],
|
|
|
- symbolBoundingData: 1000,
|
|
|
- data: [1000, 1000, 1000, 1000, 1000],
|
|
|
+ symbolBoundingData: 10,
|
|
|
+ data: [10, 10, 10, 10, 10],
|
|
|
z: 2,
|
|
|
animationEasing: "elasticOut",
|
|
|
|
|
@@ -207,7 +179,7 @@ function getOption() {
|
|
|
{
|
|
|
// label
|
|
|
type: "pictorialBar",
|
|
|
- symbolBoundingData: 1000,
|
|
|
+ symbolBoundingData: 10,
|
|
|
itemStyle: {
|
|
|
normal: {
|
|
|
color: "none"
|
|
@@ -253,11 +225,11 @@ function getOption() {
|
|
|
color: "#fff"
|
|
|
},
|
|
|
},
|
|
|
- position: [330, -15],
|
|
|
+ position: [330, -12],
|
|
|
show: true
|
|
|
}
|
|
|
},
|
|
|
- data: [612.5, 548.7, 300.2, 300, 299],
|
|
|
+ data: echartY.value,
|
|
|
z: 0,
|
|
|
|
|
|
},
|
|
@@ -266,7 +238,7 @@ function getOption() {
|
|
|
name: "外框",
|
|
|
type: "bar",
|
|
|
barGap: "-130%", // 设置外框粗细
|
|
|
- data: [1000, 1000, 1000, 1000, 1000],
|
|
|
+ data: [10, 10, 10, 10, 10],
|
|
|
|
|
|
barWidth: 29,
|
|
|
itemStyle: {
|
|
@@ -279,7 +251,7 @@ function getOption() {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- z: 0
|
|
|
+ z: 2
|
|
|
},
|
|
|
{
|
|
|
type: 'scatter',
|
|
@@ -293,7 +265,7 @@ function getOption() {
|
|
|
color: "#3ecca7"
|
|
|
}
|
|
|
},
|
|
|
- data: [1000, 1000, 1000, 1000, 1000],
|
|
|
+ data: [10, 10, 10, 10, 10],
|
|
|
}
|
|
|
|
|
|
]
|
|
@@ -306,17 +278,20 @@ function getOption() {
|
|
|
}
|
|
|
|
|
|
|
|
|
-onMounted(() => {
|
|
|
- getOption()
|
|
|
|
|
|
-})
|
|
|
|
|
|
|
|
|
-// let windData = reactive<any>({})
|
|
|
|
|
|
-// watch(() => props.echartData, (newV, oldV) => {
|
|
|
-// windData = Object.assign({}, newV)
|
|
|
-// }, { immediate: true, deep: true })
|
|
|
+
|
|
|
+watch(() => props.echartData, (newV, oldV) => {
|
|
|
+ console.log(newV,'99900')
|
|
|
+ if(newV.length){
|
|
|
+ category.value=newV
|
|
|
+ echartY.value=newV.map((el:any)=>el.value)
|
|
|
+ console.log(echartY.value,'900')
|
|
|
+ getOption()
|
|
|
+ }
|
|
|
+}, { immediate: true, })
|
|
|
|
|
|
</script>
|
|
|
|