Merge pull request #4226 from dataease/pr@dev_memory_component

Pr@dev memory component
This commit is contained in:
dataeaseShu 2022-12-28 18:44:20 +08:00 committed by GitHub
commit 498fed0306
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 128 deletions

View File

@ -11,10 +11,6 @@ import {
} from '@/api/chart/chart.js' } from '@/api/chart/chart.js'
export default { export default {
props: { props: {
current: {
type: Object,
default: () => {}
},
chartSize: { chartSize: {
type: Object, type: Object,
default: () => {} default: () => {}
@ -23,6 +19,8 @@ export default {
data() { data() {
return { return {
measureText: null, measureText: null,
current: {},
activeId: '',
treeData: [], treeData: [],
myChart: null, myChart: null,
datasourcePanel: { datasourcePanel: {
@ -43,8 +41,11 @@ export default {
} }
}, },
methods: { methods: {
getChartData(id) { getChartData(current) {
switch (this.current.queryType) { this.current = {...current}
const { queryType, num: id } = current
this.activeId = id
switch (queryType) {
case 'datasource': case 'datasource':
this.getDatasourceRelationship(id) this.getDatasourceRelationship(id)
break break
@ -68,9 +69,14 @@ export default {
}, },
getDatasetRelationship(id) { getDatasetRelationship(id) {
getDatasetRelationship(id).then((res) => { getDatasetRelationship(id).then((res) => {
const { id, name } = res.data
res.data.id = this.current.num
res.data.name = this.current.label
res.data.type = this.current.queryType
const arr = res.data ? [res.data] : [] const arr = res.data ? [res.data] : []
this.current = { num: id, label: name, queryType: 'datasource' }
this.treeData = [] this.treeData = []
this.dfsTree(arr, this.current.num) this.dfsTree(arr, id)
this.initEchart() this.initEchart()
}) })
}, },
@ -89,6 +95,7 @@ export default {
this.dfsTreeFlip(subRelation, { id, name }) this.dfsTreeFlip(subRelation, { id, name })
} else if (type === 'dataset') { } else if (type === 'dataset') {
this.treeData.push({ id, name, type, pid: this.current.num }) this.treeData.push({ id, name, type, pid: this.current.num })
if (obj.id) {
this.treeData.push({ this.treeData.push({
id: obj.id, id: obj.id,
name: obj.name, name: obj.name,
@ -96,6 +103,7 @@ export default {
pid: id pid: id
}) })
} }
}
}) })
}, },
dfsTree(arr = [], pid = 0) { dfsTree(arr = [], pid = 0) {
@ -374,7 +382,7 @@ export default {
], // ], //
z2: 10, z2: 10,
style: { style: {
text: api.value(5), //data text: isNaN(api.value(5)) ? data.find(ele => ele[4] === api.value(4))[5] : api.value(5), //data
color: '#1F2329', color: '#1F2329',
x: 5, x: 5,
y: 5 y: 5
@ -405,7 +413,7 @@ export default {
), ),
style: { style: {
...api.style(), ...api.style(),
fill: api.value(4) === that.current.num ? '#c2d4ff' : 'none', fill: api.value(4) === that.activeId ? '#c2d4ff' : 'none',
stroke: '#3370FF' stroke: '#3370FF'
} }
} }

View File

@ -50,14 +50,14 @@
</el-form> </el-form>
<div class="select-icon"> <div class="select-icon">
<i <i
@click="activeIcon = 'date'" @click="activeQueryType('date')"
:class="[activeIcon === 'date' ? 'active-icon' : '']" :class="[activeIcon === 'date' ? 'active-icon' : '']"
class="el-icon-date" class="el-icon-date"
></i> ></i>
<svg-icon <svg-icon
icon-class="sys-relationship" icon-class="sys-relationship"
:class="[activeIcon === 'share' ? 'active-icon' : '']" :class="[activeIcon === 'share' ? 'active-icon' : '']"
@click="activeIcon = 'share'" @click="activeQueryType('share')"
/> />
</div> </div>
<div v-show="activeIcon === 'share'" id="consanguinity"> <div v-show="activeIcon === 'share'" id="consanguinity">
@ -204,6 +204,10 @@ export default {
this.getChartSize() this.getChartSize()
}, },
methods: { methods: {
activeQueryType(activeIcon) {
this.activeIcon = activeIcon
this.onSubmit()
},
async searchDetail(id, queryType) { async searchDetail(id, queryType) {
switch (queryType) { switch (queryType) {
case 'datasource': case 'datasource':
@ -247,9 +251,13 @@ export default {
}, },
getDatasetRelationship(id) { getDatasetRelationship(id) {
getDatasetRelationship(id).then((res) => { getDatasetRelationship(id).then((res) => {
const { id, name } = res.data
res.data.id = this.current.num
res.data.name = this.current.label
res.data.type = this.current.queryType
const arr = res.data ? [res.data] : [] const arr = res.data ? [res.data] : []
this.treeData = [] this.treeData = []
this.dfsTree(arr, this.current) this.dfsTree(arr, { num: id, label: name, queryType: 'datasource' })
this.initTable() this.initTable()
}) })
}, },
@ -352,9 +360,7 @@ export default {
if (this.activeIcon === 'date') { if (this.activeIcon === 'date') {
this.getChartData() this.getChartData()
} else { } else {
this.$refs.consanguinity.getChartData( this.$refs.consanguinity.getChartData(this.current)
this.formInline.dataSourceName
)
} }
} }
}) })
@ -367,113 +373,6 @@ export default {
handleCurrentChange(currentPage) { handleCurrentChange(currentPage) {
this.paginationConfig.currentPage = currentPage this.paginationConfig.currentPage = currentPage
this.onSubmit() this.onSubmit()
},
initTree() {
const chartDom = document.getElementById('consanguinity')
this.treeChart = this.$echarts.init(chartDom)
const data = {
name: 'flare',
children: [
{
name: 'data',
children: [
{
name: 'converters',
children: [
{ name: 'Converters', value: 721 },
{ name: 'DelimitedTextConverter', value: 4294 }
]
},
{
name: 'DataUtil',
value: 3322
}
]
},
{
name: 'display',
children: [
{ name: 'DirtySprite', value: 8833 },
{ name: 'LineSprite', value: 1732 },
{ name: 'RectSprite', value: 3623 }
]
},
{
name: 'flex',
children: [{ name: 'FlareVis', value: 4116 }]
},
{
name: 'scale',
children: [
{ name: 'IScaleMap', value: 2105 },
{ name: 'LinearScale', value: 1316 },
{ name: 'LogScale', value: 3151 },
{ name: 'OrdinalScale', value: 3770 },
{ name: 'QuantileScale', value: 2435 },
{ name: 'QuantitativeScale', value: 4839 },
{ name: 'RootScale', value: 1756 },
{ name: 'Scale', value: 4268 },
{ name: 'ScaleType', value: 1821 },
{ name: 'TimeScale', value: 5833 }
]
}
]
}
const option = {
tooltip: {
trigger: 'item',
triggerOn: 'mousemove'
},
series: [
{
type: 'tree',
id: 0,
name: 'tree1',
data: [data],
top: '10%',
left: '8%',
bottom: '22%',
right: '20%',
symbolSize: 0,
edgeShape: 'polyline',
edgeForkPosition: '50%',
initialTreeDepth: 3,
lineStyle: {
width: 2
},
label: {
formatter: function (a, b) {
return [`{a|${a.data.name}a}`].join('\n')
},
rich: {
a: {
color: 'red',
backgroundColor: '#fff',
lineHeight: 10,
borderColor: '#DCDFE6',
borderWidth: '1',
borderRadius: 2,
padding: [5, 10]
}
}
},
leaves: {
label: {
position: 'right',
verticalAlign: 'middle',
align: 'left'
}
},
expandAndCollapse: true,
animationDuration: 550,
animationDurationUpdate: 750
}
]
}
this.treeChart.setOption(option)
} }
} }
} }