fix :修改 chartDiagram

This commit is contained in:
zhangyu
2023-06-08 19:13:05 +08:00
parent 7bf1a2ca87
commit 7f9d2f12a0
7 changed files with 75 additions and 22 deletions

View File

@@ -1,31 +1,56 @@
<template>
<div class="chart-diagram" v-if="chartInfo.loaded">
<diagram
style="height: 100%;width: 100%"
:topoData="chartInfo.param.topo"
:fromChart="true"
:isScreen="isFullscreen"
:topologyIndexF="isFullscreen ? (chartInfo.id + '-' + 'isFullscreen') : chartInfo.id"
:isPanel="true"
ref="diagram"
:chartInfo="chartInfo" />
<!-- <diagram-->
<!-- style="height: 100%;width: 100%"-->
<!-- :topoData="chartInfo.param.topo"-->
<!-- :fromChart="true"-->
<!-- :isScreen="isFullscreen"-->
<!-- :topologyIndexF="isFullscreen ? (chartInfo.id + '-' + 'isFullscreen') : chartInfo.id"-->
<!-- :isPanel="true"-->
<!-- ref="diagram"-->
<!-- :chartInfo="chartInfo" />-->
<meta2dMain :meta2dId="chartInfo.id + '-' + isFullscreen" :topoData="chartInfo.param.topo" :querysArray="querysArray" :params="params" :iconArray="iconArray" :isChart="true"/>
</div>
</template>
<script>
import diagram from '@/components/common/ChartDiagram/diagram'
import beforeMeta2d from '@/components/common/mixin/beforeMeta2d'
import meta2dMain from '@/components/common/project/meta2d/meta2dMain'
import { clearTopology } from '@/components/common/js/common'
import chartMixin from '@/components/chart/chartMixin'
import chartFormat from '@/components/chart/chartFormat'
import bus from '@/libs/bus'
export default {
name: 'chart-diagram',
mixins: [chartMixin, chartFormat],
mixins: [chartMixin, chartFormat, beforeMeta2d],
components: {
diagram
meta2dMain
},
data () {
return {
isPreview: {
show: false,
topoData: {},
querysArray: {},
currentProject: {},
params: {}
}
}
},
mounted () {
bus.$on('showMeta2dPreview', (params) => {
this.isPreview = params
})
console.log(JSON.stringify(this.chartInfo.param.topo))
},
methods: {
resize () {
this.$refs.diagram.winResize()
}
},
destroyed () {
bus.$off('showMeta2dPreview')
clearTopology()
}
}
</script>

View File

@@ -137,6 +137,7 @@ export const chartTimeSeriesLineOption = {
],
series: [{
name: '',
cursor: 'pointer',
type: 'line',
symbol: 'emptyCircle', // 去掉点
connectNulls: true,

View File

@@ -18,9 +18,9 @@ export default {
},
methods: {
reload () {
console.log(123213)
if (this.currentProject.id) {
this.$get('monitor/project/topo', { projectId: this.currentProject.id }).then(res => {
if (res.data && res.data.topo) {
this.topoData = res.data.topo || {}
if (res.data.topo.topo) {
@@ -38,6 +38,26 @@ export default {
}
}
})
} else if (this.isChart) {
const res = {
data: this.chartInfo.param
}
if (res.data && res.data.topo) {
this.topoData = res.data.topo || {}
if (res.data.topo.topo) {
this.topoData = res.data.topo.topo || {}
}
this.querysArray = res.data.topo.elements || []
this.params = {
timeType: res.data.topo.timeType || 5
}
} else {
this.topoData = {}
this.querysArray = []
this.params = {
timeType: 5
}
}
}
}
}

View File

@@ -127,11 +127,13 @@ export default {
const endTime = new Date().getTime()
const startTime = endTime - 60 * this.params.timeType * 1000
this.getQueryValues(this.querysArray, startTime, endTime).then((arr) => {
this.clacTopoData(this.topoData, arr).then((data) => {
this.clacTopoData(this.$loadsh.cloneDeep(this.topoData), arr).then((data) => {
if (!getTopology(this.meta2dId)) {
return
}
if (this.project) {
this.getModule()
}
getTopology(this.meta2dId).resize()
getTopology(this.meta2dId).open(data)
if (this.isChart) {
@@ -140,7 +142,7 @@ export default {
getTopology(this.meta2dId).centerView()
}
getTopology(this.meta2dId).lock(1)
this.getNodesArr()
// this.getNodesArr()
})
})
},

View File

@@ -9,7 +9,7 @@
>
</topology-top-tool>
</div>
<div v-if="!editFlag" class="top-tool-right">
<div v-if="!isChart && !editFlag" class="top-tool-right">
<pick-time
v-show="!editFlag"
ref="pickTime"

View File

@@ -13,7 +13,7 @@
@getNodesArr="getNodesArr"
/>
<div class="meta2d-main" :class="isChart ? 'meta2d-chart': 'meta2d-project'" @contextmenu="onContextMenu($event)" style="position: relative">
<div v-for="(item,index) in nodesArr" v-if="!editFlag"
<div v-for="(item,index) in nodesArr" v-if="!editFlag && project"
:key="index"
v-show="(item.y + offsetY - 48 > -20) && (item.x + item.width/2 + offsetX - 24 > - 20)"
:style="{position: 'absolute',top:item.y + offsetY - 48 + 'px',left:item.x + item.width/2 + offsetX - 24 +'px', 'z-index': 10}"
@@ -110,7 +110,7 @@
<script>
import meta2dHeader from '@/components/common/project/meta2d/meta2dHeader'
import meta2dProps from '@/components/common/project/meta2d/meta2dProps'
import meta2dMain from '@/components/common/project/meta2d/js/meta2dMain'
import meta2dMainCalc from '@/components/common/project/meta2d/js/meta2dMainCalc'
import meta2dTooltip from '@/components/common/project/meta2d/meta2dTooltip'
import CanvasContextMenu from '@/components/common/project/meta2d/CanvasContextMenu'
import popDataMain from '@/components/common/project/popData/Main'
@@ -124,7 +124,7 @@ import bus from '@/libs/bus'
import { globalStore } from '@meta2d/core'
export default {
name: 'meta2dMain',
mixins: [meta2dMain, topoUtil],
mixins: [meta2dMainCalc, topoUtil],
props: {
meta2dId: {}, // 唯一id 不可重复
iconArray: {
@@ -167,6 +167,7 @@ export default {
topoData: {
immediate: false,
handler () {
console.log(123213)
if (!this.isChart) {
this.reload()
}

View File

@@ -141,7 +141,8 @@
<el-form-item v-if="isDiagram(chartConfig.type)" >
<div class="topology-box">
<div class="topology-mc"></div>
<diagram :topoData="chartConfig.param.topo" :fromChartBox="true" :topologyIndexF="-1"/>
<!-- <diagram :topoData="chartConfig.param.topo" :fromChartBox="true" :topologyIndexF="-1"/>-->
<meta2dMain :meta2dId="'rightBoxChart'" :topoData="chartConfig.param.topo" :querysArray="[]" :params="params" :iconArray="iconArray" @reload="reload"/>
</div>
</el-form-item>
<!--topplogy-->
@@ -298,9 +299,12 @@ import publicConfig from '@/components/common/rightBox/chart/publicConfig'
import chartTypeShow from '@/components/common/rightBox/chart/chartTypeShow'
import diagram from '@/components/common/ChartDiagram/diagram'
import richTextEditor from '@/components/chart/richTextEditor'
import beforeMeta2d from '@/components/common/mixin/beforeMeta2d'
import meta2dMain from '@/components/common/project/meta2d/meta2dMain'
import { clearTopology } from '@/components/common/js/common'
export default {
name: 'otherChartConfig',
mixins: [publicConfig, chartTypeShow],
mixins: [publicConfig, chartTypeShow, beforeMeta2d],
components: {
diagram,
richTextEditor