Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
TC
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qlintonger xeno
TC
Commits
bef5c888
Commit
bef5c888
authored
Apr 18, 2025
by
qlintonger xeno
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 使用定位实现布局+1补正
parent
38208deb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
27 deletions
+47
-27
src/lib/Table2Chart/Components/global-echarts.vue
+5
-10
src/lib/Table2Chart/ScreenChart.vue
+12
-15
src/lib/Table2Chart/funcs/mapStyle.ts
+30
-2
No files found.
src/lib/Table2Chart/Components/global-echarts.vue
View file @
bef5c888
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
import
*
as
echarts
from
"echarts"
;
import
*
as
echarts
from
"echarts"
;
import
{
ECBasicOption
}
from
"echarts/types/dist/shared"
;
import
{
ECBasicOption
}
from
"echarts/types/dist/shared"
;
import
{
isNumber
}
from
"lodash"
;
import
{
isNumber
}
from
"lodash"
;
import
{
computed
,
nextTick
,
onMounted
,
onUnmounted
,
ref
,
watch
}
from
"vue"
;
import
{
computed
,
getCurrentInstance
,
nextTick
,
onMounted
,
onUnmounted
,
ref
,
watch
}
from
"vue"
;
interface
Props
{
interface
Props
{
options
?:
ECBasicOption
;
options
?:
ECBasicOption
;
...
@@ -35,28 +35,23 @@ const getHeight = computed(() => {
...
@@ -35,28 +35,23 @@ const getHeight = computed(() => {
}
}
});
});
const
chartRef
=
ref
(
null
);
const
chartRef
=
ref
(
null
);
let
ro
:
ResizeObserver
|
null
=
null
let
chartInstance
=
null
as
unknown
as
echarts
.
ECharts
;
let
chartInstance
=
null
as
unknown
as
echarts
.
ECharts
;
const
es
=
defineEmits
([
'node-inserted'
])
onMounted
(()
=>
{
onMounted
(()
=>
{
const
el
=
chartRef
.
value
;
const
el
=
chartRef
.
value
;
const
inst
=
getCurrentInstance
()
console
.
log
(
'inst'
,
{
inst
})
if
(
el
)
{
if
(
el
)
{
nextTick
(()
=>
{
nextTick
(()
=>
{
chartInstance
=
echarts
.
init
(
el
);
chartInstance
=
echarts
.
init
(
el
);
setOptions
(
ps
.
options
);
setOptions
(
ps
.
options
);
if
(
!
ro
)
{
es
(
'node-inserted'
,
{
uid
:
inst
!
.
uid
,
f
:
()
=>
chartInstance
})
ro
=
new
ResizeObserver
(
function
()
{
chartInstance
?.
resize
();
});
ro
.
observe
(
el
,
{
box
:
"border-box"
});
}
chartInstance
?.
resize
();
chartInstance
?.
resize
();
});
});
}
}
});
});
onUnmounted
(()
=>
{
onUnmounted
(()
=>
{
chartInstance
?.
dispose
();
chartInstance
?.
dispose
();
ro
?.
disconnect
();
ro
=
null
});
});
watch
(
watch
(
()
=>
ps
.
options
,
()
=>
ps
.
options
,
...
...
src/lib/Table2Chart/ScreenChart.vue
View file @
bef5c888
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
ScreenChartProps
}
from
"./types/ScreenChart.typing.ts"
;
import
{
ScreenChartProps
}
from
"./types/ScreenChart.typing.ts"
;
import
{
containerRef
,
getAllGridSize
,
gridItemStyle
,
mapContainerStyle
}
from
"./funcs/mapStyle.ts"
;
import
{
allGraphRegister
,
containerRef
,
getAllGridSize
,
gridItemStyle
,
mapContainerStyle
,
startNow
}
from
"./funcs/mapStyle.ts"
;
import
GlobalEcharts
from
"./Components/global-echarts.vue"
;
import
GlobalEcharts
from
"./Components/global-echarts.vue"
;
import
{
mapToEchartsOptions
}
from
"./funcs/mapToEchartsOptions.ts"
;
import
{
mapToEchartsOptions
}
from
"./funcs/mapToEchartsOptions.ts"
;
import
{
computed
,
nextTick
,
onMounted
,
onUnmounted
,
ref
}
from
"vue"
;
import
{
computed
,
nextTick
,
onMounted
,
onUnmounted
,
ref
}
from
"vue"
;
import
{
geoContainer
,}
from
"./funcs/mapGEO
Style.ts"
;
import
{
registerGraph
}
from
"./funcs/map
Style.ts"
;
const
props
=
withDefaults
(
defineProps
<
ScreenChartProps
>
(),
{
const
props
=
withDefaults
(
defineProps
<
ScreenChartProps
>
(),
{
gap
:
16
,
containerPadding
:
12
,
gridItemPadding
:
12
gap
:
16
,
containerPadding
:
12
,
gridItemPadding
:
12
...
@@ -16,22 +23,12 @@ onUnmounted(function () {
...
@@ -16,22 +23,12 @@ onUnmounted(function () {
ro
.
disconnect
()
ro
.
disconnect
()
ro
=
null
ro
=
null
}
}
allGraphRegister
.
value
=
[]
})
})
const
gridConfig
=
computed
(()
=>
{
const
gridConfig
=
computed
(()
=>
{
return
getAllGridSize
(
props
.
layout
)
return
getAllGridSize
(
props
.
layout
)
})
})
const
startNow
=
function
calcGEO
()
{
const
rect
=
containerRef
.
value
.
getBoundingClientRect
()
geoContainer
.
value
.
width
=
rect
.
width
geoContainer
.
value
.
height
=
rect
.
height
const
allStyle
=
window
.
getComputedStyle
(
containerRef
.
value
)
// @ts-ignore
geoContainer
.
value
.
contentWidth
=
parseFloat
(
allStyle
[
'width'
])
-
parseFloat
(
allStyle
[
'padding-left'
])
-
parseFloat
(
allStyle
[
'padding-right'
])
// @ts-ignore
geoContainer
.
value
.
contentHeight
=
parseFloat
(
allStyle
[
'height'
])
-
parseFloat
(
allStyle
[
'padding-top'
])
-
parseFloat
(
allStyle
[
'padding-bottom'
])
// @ts-ignore
geoContainer
.
value
.
paddingAll
=
parseFloat
(
allStyle
[
'paddingLeft'
])
}
onMounted
(
function
()
{
onMounted
(
function
()
{
nextTick
(
function
()
{
nextTick
(
function
()
{
isAllMounted
.
value
=
true
isAllMounted
.
value
=
true
...
@@ -51,7 +48,7 @@ onMounted(function () {
...
@@ -51,7 +48,7 @@ onMounted(function () {
<component
:is=
"item.renderTitle(item, props.layout)"
v-else
/>
<component
:is=
"item.renderTitle(item, props.layout)"
v-else
/>
<div
v-if=
"isAllMounted"
class=
"mt-[12px] w-full flex items-stretch justify-between"
<div
v-if=
"isAllMounted"
class=
"mt-[12px] w-full flex items-stretch justify-between"
style=
"height: calc(100% - 12px - 12px)"
>
style=
"height: calc(100% - 12px - 12px)"
>
<global-echarts
v-for=
"(z,x) in item.chartData"
:key=
"x"
:options=
"mapToEchartsOptions(z)"
/>
<global-echarts
@
node-inserted=
"registerGraph"
v-for=
"(z,x) in item.chartData"
:key=
"x"
:options=
"mapToEchartsOptions(z)"
/>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
src/lib/Table2Chart/funcs/mapStyle.ts
View file @
bef5c888
import
{
ScreenChartProps
,
SingleLayoutConf
}
from
"../types/ScreenChart.typing.ts"
;
import
{
ScreenChartProps
,
SingleLayoutConf
}
from
"../types/ScreenChart.typing.ts"
;
import
{
geoContainer
,
mapHeight
,
mapWidth
}
from
"./mapGEOStyle.ts"
;
import
{
geoContainer
,
mapHeight
,
mapWidth
}
from
"./mapGEOStyle.ts"
;
import
{
ref
}
from
"vue"
;
import
{
nextTick
,
ref
}
from
"vue"
;
export
const
containerRef
=
ref
()
export
const
containerRef
=
ref
()
export
const
gridItemStyle
=
function
(
item
:
SingleLayoutConf
,
props
:
ScreenChartProps
,
geoConf
:
{
rows
:
number
,
cols
:
number
})
{
export
const
gridItemStyle
=
function
(
item
:
SingleLayoutConf
,
props
:
ScreenChartProps
,
geoConf
:
{
rows
:
number
,
cols
:
number
})
{
...
@@ -11,7 +11,8 @@ export const gridItemStyle = function (item: SingleLayoutConf, props: ScreenChar
...
@@ -11,7 +11,8 @@ export const gridItemStyle = function (item: SingleLayoutConf, props: ScreenChar
// @ts-ignore
// @ts-ignore
padding
:
`
${
mapHeight
(
props
.
gridItemPadding
)}
px
${
mapWidth
(
props
.
gridItemPadding
)}
px
${
mapHeight
(
props
.
gridItemPadding
)}
px
${
mapWidth
(
props
.
gridItemPadding
)}
px`
,
padding
:
`
${
mapHeight
(
props
.
gridItemPadding
)}
px
${
mapWidth
(
props
.
gridItemPadding
)}
px
${
mapHeight
(
props
.
gridItemPadding
)}
px
${
mapWidth
(
props
.
gridItemPadding
)}
px`
,
fontSize
:
`
${
mapWidth
(
14
)}
px`
,
fontSize
:
`
${
mapWidth
(
14
)}
px`
,
...
wholeGridGeo
(
item
,
geoConf
,
props
.
gap
!
)
...
wholeGridGeo
(
item
,
geoConf
,
props
.
gap
!
),
transition
:
'left 0.3s ease, top 0.3 ease, width 0.3 ease, height 0.3 ease'
,
}
}
}
}
...
@@ -32,6 +33,33 @@ export const wholeGridGeo = function (item: SingleLayoutConf, geoConf: { rows: n
...
@@ -32,6 +33,33 @@ export const wholeGridGeo = function (item: SingleLayoutConf, geoConf: { rows: n
};
};
}
}
export
const
allGraphRegister
=
ref
<
Array
<
{
uid
:
string
,
f
:
Function
}
>>
([])
export
function
registerGraph
(
item
:
{
uid
:
string
,
f
:
Function
})
{
allGraphRegister
.
value
.
push
(
item
)
}
export
const
startNow
=
function
calcGEO
()
{
const
rect
=
containerRef
.
value
.
getBoundingClientRect
()
geoContainer
.
value
.
width
=
rect
.
width
geoContainer
.
value
.
height
=
rect
.
height
const
allStyle
=
window
.
getComputedStyle
(
containerRef
.
value
)
// @ts-ignore
geoContainer
.
value
.
contentWidth
=
parseFloat
(
allStyle
[
'width'
])
-
parseFloat
(
allStyle
[
'padding-left'
])
-
parseFloat
(
allStyle
[
'padding-right'
])
// @ts-ignore
geoContainer
.
value
.
contentHeight
=
parseFloat
(
allStyle
[
'height'
])
-
parseFloat
(
allStyle
[
'padding-top'
])
-
parseFloat
(
allStyle
[
'padding-bottom'
])
// @ts-ignore
geoContainer
.
value
.
paddingAll
=
parseFloat
(
allStyle
[
'paddingLeft'
])
nextTick
(
function
()
{
}).
then
(
function
()
{
for
(
const
item
of
allGraphRegister
.
value
)
{
const
chart
:
any
=
item
.
f
()
chart
.
resize
();
}
})
}
export
function
getAllGridSize
(
items
:
Array
<
SingleLayoutConf
>
)
{
export
function
getAllGridSize
(
items
:
Array
<
SingleLayoutConf
>
)
{
let
maxCol
=
0
;
let
maxCol
=
0
;
let
maxRow
=
0
;
let
maxRow
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment