Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
scrm-micro-custom
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 806c8897
authored
Dec 26, 2023
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
饼状图添加label
1 parent
836b2ecc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
src/views/userPortrait/components/PieChart.vue
src/views/userPortrait/components/PieChart.vue
View file @
806c889
<
template
>
<
template
>
<div>
<div>
<p
class=
"line-color-title"
>
{{
title
}}
</p>
<p
class=
"line-color-title"
>
{{
title
}}
</p>
<div
v-if=
"data"
ref=
"pieChart"
style=
"margin-top:10px;width: 100%; height:25vh;"
></div>
<div
v-if=
"data"
ref=
"pieChart"
style=
"margin-top:10px;width: 100%; height:2
4.
5vh;"
></div>
</div>
</div>
</
template
>
</
template
>
...
@@ -47,10 +47,19 @@ export default {
...
@@ -47,10 +47,19 @@ export default {
});
});
},
},
createFormatter
(
params
)
{
createFormatter
(
params
)
{
const
styleKey
=
'style'
+
(
params
.
dataIndex
%
this
.
colors
.
length
);
const
dataIndex
=
params
.
dataIndex
;
return
`{
${
styleKey
}
|
${
params
.
value
}
%}\n\n{b|
${
params
.
name
}${
params
.
displayQuantity
?(
params
.
displayQuantity
+
'人'
):
''
}
}`
;
const
dataItem
=
this
.
data
[
dataIndex
];
// 获取当前索引下的数据项
const
styleKey
=
'style'
+
(
dataIndex
%
this
.
colors
.
length
);
// 确保dataItem存在,并且displayQuantity已定义
const
displayQuantityText
=
dataItem
&&
dataItem
.
displayQuantity
!==
undefined
&&
dataItem
.
displayQuantity
!==
null
?
'('
+
dataItem
.
displayQuantity
+
'人'
+
')'
:
''
;
return
`{
${
styleKey
}
|
${
params
.
value
}
%}\n\n{b|
${
params
.
name
}${
displayQuantityText
}
}`
;
},
},
drawChart
()
{
drawChart
()
{
this
.
generateRichStyles
();
// 生成动态样式
this
.
generateRichStyles
();
// 生成动态样式
const
chart
=
echarts
.
init
(
this
.
$refs
.
pieChart
);
const
chart
=
echarts
.
init
(
this
.
$refs
.
pieChart
);
...
@@ -98,7 +107,7 @@ export default {
...
@@ -98,7 +107,7 @@ export default {
@media
screen
and
(
min-resolution
:
2dppx
)
{
@media
screen
and
(
min-resolution
:
2dppx
)
{
/* 针对高分辨率显示屏的样式调整 */
/* 针对高分辨率显示屏的样式调整 */
.pieChart
{
.pieChart
{
height
:
30
vh
;
/* 可能需要更大的高度 */
height
:
28
vh
;
/* 可能需要更大的高度 */
}
}
}
}
</
style
>
</
style
>
Write
Preview
Markdown
is supported
Attach a file
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 post a comment