提交 f116a441 编写于 作者: D devilangelia

Auto Commit

上级 1e6fb97e
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
* content?: string | number; // 自定义显示文本 * content?: string | number; // 自定义显示文本
* animation?: boolean; // 是否启用数字动画,默认 true * animation?: boolean; // 是否启用数字动画,默认 true
* showPercentage?: boolean; // true显示百分比,false显示原始值,默认 true * showPercentage?: boolean; // true显示百分比,false显示原始值,默认 true
* show?: boolean; // 是否显示文本,默认 true
* } * }
* } * }
* *
...@@ -83,6 +84,8 @@ interface ChartOptions { ...@@ -83,6 +84,8 @@ interface ChartOptions {
animation?: boolean; animation?: boolean;
// 是否显示百分比(包括值和符号),默认 true // 是否显示百分比(包括值和符号),默认 true
showPercentage?: boolean; showPercentage?: boolean;
// 是否显示文本,默认 true
show?: boolean;
}; };
} }
...@@ -102,7 +105,8 @@ const props = withDefaults(defineProps<{ ...@@ -102,7 +105,8 @@ const props = withDefaults(defineProps<{
size: null, size: null,
color: '#333', color: '#333',
font: 'Arial', font: 'Arial',
showPercentage: true showPercentage: true,
show: true // 默认显示文本
} }
}) })
}) })
...@@ -260,14 +264,14 @@ function startDraw(end: number, start?: number, dontClear?: boolean) { ...@@ -260,14 +264,14 @@ function startDraw(end: number, start?: number, dontClear?: boolean) {
ctx.fill(); ctx.fill();
ctx.closePath(); ctx.closePath();
// 在绘制内圆之后添加文本绘制 // 只在 show 为 true 时绘制文本
if (props.options.text?.show !== false) {
ctx.beginPath(); ctx.beginPath();
ctx.font = `${fontSize.value}px ${props.options.text?.font || 'Arial'}`; ctx.font = `${fontSize.value}px ${props.options.text?.font || 'Arial'}`;
ctx.textAlign = 'center'; ctx.textAlign = 'center';
ctx.textBaseline = 'middle'; ctx.textBaseline = 'middle';
ctx.fillStyle = props.options.text?.color || '#333'; ctx.fillStyle = props.options.text?.color || '#333';
// 处理显示文本
let displayText: string; let displayText: string;
if (props.options.text?.content !== undefined) { if (props.options.text?.content !== undefined) {
displayText = String(props.options.text.content); displayText = String(props.options.text.content);
...@@ -285,6 +289,7 @@ function startDraw(end: number, start?: number, dontClear?: boolean) { ...@@ -285,6 +289,7 @@ function startDraw(end: number, start?: number, dontClear?: boolean) {
ctx.fillText(displayText, centerX, centerY); ctx.fillText(displayText, centerX, centerY);
ctx.closePath(); ctx.closePath();
}
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册