refactor(图表): 明细表图片字段显示优化

This commit is contained in:
wisonic 2024-08-16 16:17:27 +08:00
parent 231db603a0
commit 9b945f931d
4 changed files with 10 additions and 6 deletions

View File

@ -189,7 +189,8 @@ const DETAIL_CHART_ATTR: DeepPartial<ChartObj> = {
scrollCfg: {
open: false
}
}
},
showPosition: 'dialog'
}
const state = reactive({
@ -200,7 +201,8 @@ const DETAIL_TABLE_ATTR: DeepPartial<ChartObj> = {
scrollCfg: {
open: false
}
}
},
showPosition: 'dialog'
}
const authShow = computed(() => editMode.value === 'edit' || dvInfo.value.weight > 3)

View File

@ -67,6 +67,7 @@ declare interface Chart {
seriesFieldObjs?: any[]
flowMapStartName?: Axis[]
flowMapEndName?: Axis[]
showPosition: string
}
declare type CustomAttr = DeepPartial<ChartAttr> | JSONString<DeepPartial<ChartAttr>>
declare type CustomStyle = DeepPartial<ChartStyle> | JSONString<DeepPartial<ChartStyle>>

View File

@ -18,8 +18,9 @@ class ImageCell extends TableDataCell {
!this.cfg.children && (this.cfg.children = [])
const { width: imgWidth, height: imgHeight } = img
const ratio = Math.max(imgWidth / width, imgHeight / height)
const imgShowWidth = imgWidth / ratio
const imgShowHeight = imgHeight / ratio
// 不铺满部分留白
const imgShowWidth = (imgWidth / ratio) * 0.8
const imgShowHeight = (imgHeight / ratio) * 0.8
this.textShape = this.addShape('image', {
attrs: {
x: x + (imgShowWidth < width ? (width - imgShowWidth) / 2 : 0),
@ -162,7 +163,7 @@ export class TableInfo extends S2ChartView<TableSheet> {
}
s2Options.dataCell = viewMeta => {
const deType = axisMap[viewMeta.valueField]?.deType
if (deType === 7) {
if (deType === 7 && chart.showPosition !== 'dialog') {
return new ImageCell(viewMeta, viewMeta?.spreadsheet)
}
if (viewMeta.colIndex === 0 && s2Options.showSeriesNumber) {

View File

@ -506,7 +506,7 @@ const trackMenuCalc = itemId => {
// URL
if (view.value.type === 'table-info') {
view.value.xAxis?.forEach(axis => {
if (axis.id === itemId) {
if (axis.id === itemId && axis.deType === 7) {
trackMenuInfo.push('enlarge')
}
})