fix: 修复可折叠图表组高度问题

This commit is contained in:
chenjinsong
2022-03-11 21:04:51 +08:00
parent c3b7136d3c
commit e8677c02b3
4 changed files with 17 additions and 14 deletions

View File

@@ -30,7 +30,7 @@
justify-content:space-between;
align-items:center;
padding: 10px 20px 10px 18px;
height: 47px;
flex: 0 0 40px;
font-size: 16px;
color: $--color-text-primary;
@@ -214,7 +214,6 @@
position: relative;
border-radius: 2px;
flex-grow: 1;
overflow: auto;
width: 100%;
.chart-drawing {
height: 100%;

View File

@@ -21,7 +21,7 @@
justify-content:space-between;
align-items:center;
padding: 10px 20px 10px 0px;
height: 40px;
flex: 0 0 40px;
font-size: 14px;
color: $--color-text-primary;

View File

@@ -66,7 +66,7 @@
<script>
import PanelChart from '@/views/charts/PanelChart'
import VueGridLayout from 'vue-grid-layout'
import { getGroupHeight, getTypeCategory } from './charts/tools'
import { getGroupHeight, getTypeCategory, isGroup } from './charts/tools'
import _ from 'lodash'
export default {
@@ -126,7 +126,7 @@ export default {
if (item.params.collapse) {
item.h = 1
} else {
item.h = getGroupHeight(item.children) + 1.5
item.h = getGroupHeight(item.children) + 0.4 + 1
}
}
})
@@ -139,13 +139,8 @@ export default {
const children = parent.children.find(item => item.id === chart.id)
children.h = chart.h
children.params = chart.params
let sumGroup = 0
childrenList.forEach(item => {
if (item.type === 94) {
sumGroup++
}
})
parent.h = getGroupHeight(childrenList) + sumGroup * 0.5
// 第二个是空隙,第三个是标题的高度
parent.h = getGroupHeight(childrenList) + 0.4 + 1
this.copyDataList = [...this.copyDataList]
}, 100)
}

View File

@@ -219,7 +219,16 @@ export function getLayout (type) {
export function getGroupHeight (arr) {
if (arr.length) {
let lastItem = []
let minYArr = [...arr]
minYArr.sort((a, b) => {
return a.y - b.y
})
let maxYArr = [...arr]
maxYArr.sort((a, b) => {
return (b.y + b.h) - (a.y + a.h)
})
return maxYArr[0].y + maxYArr[0].h - minYArr[0].y
/*let lastItem = []
let maxY = arr[0].y
arr.forEach((children, index) => {
if (maxY === children.y) {
@@ -238,7 +247,7 @@ export function getGroupHeight (arr) {
if (maxY < 0) {
maxY = 0
}
return maxHeight + maxY
return maxHeight + maxY*/
} else {
return 1
}