|
@@ -12,7 +12,8 @@ const emit = defineEmits(['chartPage'])
|
|
|
const {proxy} = getCurrentInstance()
|
|
|
const props = defineProps({
|
|
|
data: {},
|
|
|
- layout: {default: 'radial'}
|
|
|
+ layout: {default: 'radial'},
|
|
|
+ showZero: {default: false}
|
|
|
})
|
|
|
const state: any = reactive({
|
|
|
resizeObserver: <any>null,
|
|
@@ -20,6 +21,7 @@ const state: any = reactive({
|
|
|
})
|
|
|
const ref_main = ref()
|
|
|
const setNodes = (data) => {
|
|
|
+ const arr: any = []
|
|
|
data.nodes.forEach(v => {
|
|
|
v.weight = Number(v.weight)
|
|
|
v.style = {
|
|
@@ -27,7 +29,15 @@ const setNodes = (data) => {
|
|
|
badges:[{text: String(v.num), placement: 'top-right', offsetX: -10, offsetY: 10}],
|
|
|
iconSrc: v.iconSrc,
|
|
|
}
|
|
|
+ if (props.showZero) {
|
|
|
+ arr.push(v)
|
|
|
+ } else {
|
|
|
+ if (v.num > 0) {
|
|
|
+ arr.push(v)
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
+ return arr
|
|
|
}
|
|
|
const setEdges = (data) => {
|
|
|
const arr: any = []
|
|
@@ -44,7 +54,7 @@ const setEdges = (data) => {
|
|
|
const initChart = () => {
|
|
|
if (props.data?.nodes?.length > 0) {
|
|
|
const data = JSON.parse(JSON.stringify(props.data))
|
|
|
- setNodes(data)
|
|
|
+ data.nodes = setNodes(data)
|
|
|
data.edges = setEdges(data)
|
|
|
if (state.chart) {
|
|
|
state.chart.destroy()
|
|
@@ -186,7 +196,7 @@ const initChart = () => {
|
|
|
state.resizeObserver.observe(ref_main.value);
|
|
|
}
|
|
|
}
|
|
|
-watch(() => [props.data, props.layout], () => {
|
|
|
+watch(() => [props.data, props.layout, props.showZero], () => {
|
|
|
initChart()
|
|
|
})
|
|
|
onMounted(() => {
|