Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DevilAngelia
环形进度条组件,支持渐变色、动画效果和文本显示
提交
f116a441
环
环形进度条组件,支持渐变色、动画效果和文本显示
项目概览
DevilAngelia
/
环形进度条组件,支持渐变色、动画效果和文本显示
与 Fork 源项目一致
Fork自
inscode / VueJS
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
环
环形进度条组件,支持渐变色、动画效果和文本显示
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
f116a441
编写于
2月 05, 2025
作者:
D
devilangelia
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Auto Commit
上级
1e6fb97e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
23 deletion
+28
-23
src/components/ProgressBar.vue
src/components/ProgressBar.vue
+28
-23
未找到文件。
src/components/ProgressBar.vue
浏览文件 @
f116a441
...
...
@@ -38,6 +38,7 @@
* content?: string | number; // 自定义显示文本
* animation?: boolean; // 是否启用数字动画,默认 true
* showPercentage?: boolean; // true显示百分比,false显示原始值,默认 true
* show?: boolean; // 是否显示文本,默认 true
* }
* }
*
...
...
@@ -83,6 +84,8 @@ interface ChartOptions {
animation
?:
boolean
;
// 是否显示百分比(包括值和符号),默认 true
showPercentage
?:
boolean
;
// 是否显示文本,默认 true
show
?:
boolean
;
};
}
...
...
@@ -102,7 +105,8 @@ const props = withDefaults(defineProps<{
size
:
null
,
color
:
'
#333
'
,
font
:
'
Arial
'
,
showPercentage
:
true
showPercentage
:
true
,
show
:
true
// 默认显示文本
}
})
})
...
...
@@ -260,31 +264,32 @@ function startDraw(end: number, start?: number, dontClear?: boolean) {
ctx
.
fill
();
ctx
.
closePath
();
// 在绘制内圆之后添加文本绘制
ctx
.
beginPath
();
ctx
.
font
=
`
${
fontSize
.
value
}
px
${
props
.
options
.
text
?.
font
||
'
Arial
'
}
`
;
ctx
.
textAlign
=
'
center
'
;
ctx
.
textBaseline
=
'
middle
'
;
ctx
.
fillStyle
=
props
.
options
.
text
?.
color
||
'
#333
'
;
// 处理显示文本
let
displayText
:
string
;
if
(
props
.
options
.
text
?.
content
!==
undefined
)
{
displayText
=
String
(
props
.
options
.
text
.
content
);
}
else
{
const
maxValue
=
props
.
options
.
maxValue
||
100
;
const
currentValue
=
currentDisplayNumber
.
value
;
if
(
props
.
options
.
text
?.
showPercentage
!==
false
)
{
const
percentage
=
Math
.
round
((
currentValue
/
maxValue
)
*
100
);
displayText
=
`
${
percentage
}
%`
;
// 只在 show 为 true 时绘制文本
if
(
props
.
options
.
text
?.
show
!==
false
)
{
ctx
.
beginPath
();
ctx
.
font
=
`
${
fontSize
.
value
}
px
${
props
.
options
.
text
?.
font
||
'
Arial
'
}
`
;
ctx
.
textAlign
=
'
center
'
;
ctx
.
textBaseline
=
'
middle
'
;
ctx
.
fillStyle
=
props
.
options
.
text
?.
color
||
'
#333
'
;
let
displayText
:
string
;
if
(
props
.
options
.
text
?.
content
!==
undefined
)
{
displayText
=
String
(
props
.
options
.
text
.
content
);
}
else
{
displayText
=
String
(
Math
.
round
(
currentValue
));
const
maxValue
=
props
.
options
.
maxValue
||
100
;
const
currentValue
=
currentDisplayNumber
.
value
;
if
(
props
.
options
.
text
?.
showPercentage
!==
false
)
{
const
percentage
=
Math
.
round
((
currentValue
/
maxValue
)
*
100
);
displayText
=
`
${
percentage
}
%`
;
}
else
{
displayText
=
String
(
Math
.
round
(
currentValue
));
}
}
ctx
.
fillText
(
displayText
,
centerX
,
centerY
);
ctx
.
closePath
();
}
ctx
.
fillText
(
displayText
,
centerX
,
centerY
);
ctx
.
closePath
();
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录