Skip to content

Commit

Permalink
🐛 fix: Fix on server side
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed Nov 24, 2024
1 parent a0c4c8d commit b0171ca
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"cross-env": "^7.0.3",
"dayjs": "^1.11.13",
"dumi": "^2.4.14",
"dumi-theme-lobehub": "^1.9.2",
"dumi-theme-lobehub": "^1.10.4",
"eslint": "^8.57.1",
"father": "^4.5.1",
"husky": "^9.1.7",
Expand Down
3 changes: 2 additions & 1 deletion src/DonutChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import NoData, { type NoDataProps } from '@/common/NoData';
import { useThemeColorRange } from '@/hooks/useThemeColorRange';
import type { EventProps } from '@/types';
import { ValueFormatter } from '@/types';
import { defaultValueFormatter } from '@/utils';
import { defaultValueFormatter, isOnSeverSide } from '@/utils';

import { DonutChartTooltip } from './DonutChartTooltip';
import { parseLabelInput } from './inputParser';
Expand Down Expand Up @@ -80,6 +80,7 @@ const DonutChart = forwardRef<HTMLDivElement, DonutChartProps>((props, ref) => {
const hasOnValueChange = !!onValueChange;

useEffect(() => {
if (isOnSeverSide) return;
const pieSectors = document.querySelectorAll('.recharts-pie-sector');
if (pieSectors) {
for (const sector of pieSectors) {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/getMaxLabelLength.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ValueFormatter } from '@/types';
import { defaultValueFormatter } from '@/utils/index';
import { defaultValueFormatter, isOnSeverSide } from '@/utils/index';

export const getTextWidth = (text: string) => {
if (isOnSeverSide) return 0;

// 创建临时 span 元素
const span = document.createElement('span');

Expand Down

0 comments on commit b0171ca

Please sign in to comment.