Skip to content

Commit

Permalink
fix: 修复title的字符长度为1时不显示title的问题 (#1929)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenKun1997 authored May 8, 2023
1 parent 3fc6bb1 commit abd6f77
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/graphs/src/utils/set-ellipsis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export const setEllipsis = (text: string, fontStyle: { [key: string]: unknown },
let currentText = text;
let flag = false;
ctx.fillText(currentText, 0, 0);
if(text.length === 1) {
return text;
}
for (let i = text.length - 1; i > 0; i--) {
const { width } = ctx.measureText(currentText);
if (width <= contentWidth) {
Expand Down

0 comments on commit abd6f77

Please sign in to comment.