This commit is contained in:
2026-01-30 12:10:31 +08:00
parent 39cf4b27f5
commit 4ad9f4976f
4 changed files with 161 additions and 73 deletions

View File

@ -3,7 +3,7 @@
</template>
<script setup>
import * as echarts from "echarts";
import { onMounted, ref, reactive, defineProps, onUnmounted, watch, nextTick } from "vue";
import { onMounted, ref, defineEmits, defineProps, onUnmounted, watch, nextTick } from "vue";
const props = defineProps({
echartsId: {
type: String,
@ -14,6 +14,7 @@ const props = defineProps({
default: () => { }
}
});
const emit = defineEmits(['click']);
// 保存echarts实例
const myChart = ref(null);
@ -136,9 +137,11 @@ function chartFn() {
},
axisTick: {
show: true
}, axisLabel: {
interval: 0 // 控制标签的显示间隔0 表示全部显示,可以根据需要调整为其他值,例如 1 表示每隔一个显示一个标签。
}
},
axisLabel: {
interval: 1, // 控制标签的显示间隔0 表示全部显示,可以根据需要调整为其他值,例如 1 表示每隔一个显示一个标签。
color: '#666666'
}
},
yAxis: {
type: "value",
@ -208,6 +211,9 @@ function chartFn() {
};
option && myChart.value.setOption(option);
myChart.value.on('click', function (param) {
emit('click', param.name);
});
}
// 监听数据变化