Skip to content

Commit 1722745

Browse files
committed
fix: 优化图表组件样式和渲染逻辑,提升用户交互体验
1 parent f7a0600 commit 1722745

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

src/MarkdownEditor/editor/components/ActionIconBox/style.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
ChatTokenType,
33
GenerateStyle,
4-
resetComponent,
54
useEditorStyleRegister,
65
} from '../../utils/useStyle';
76

@@ -14,7 +13,7 @@ const genStyle: GenerateStyle<ChatTokenType> = (
1413
minWidth: 14,
1514
minHeight: 14,
1615
maxHeight: 24,
17-
lineHeight: '1.5',
16+
lineHeight: 1,
1817
display: 'flex',
1918
cursor: 'pointer',
2019
padding: 4,
@@ -29,7 +28,6 @@ const genStyle: GenerateStyle<ChatTokenType> = (
2928
padding: 0,
3029
},
3130
'&:hover': {
32-
color: token.colorPrimary,
3331
background: token.colorBgTextHover,
3432
},
3533
'&-standalone': {
@@ -94,6 +92,6 @@ export function useStyle(prefixCls: string, style: React.CSSProperties) {
9492
componentCls: `.${prefixCls}`,
9593
};
9694

97-
return [genStyle(proChatToken, style), resetComponent(proChatToken)];
95+
return [genStyle(proChatToken, style)];
9896
});
9997
}

src/plugins/chart/ChartAttrToolBar/ChartAttrToolBarStyle.ts

-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ const genStyle: GenerateStyle<ChatTokenType> = (token) => {
2222
padding: '4px',
2323
borderRadius: '12px',
2424
cursor: 'pointer',
25-
'&:hover': {
26-
backgroundColor: 'rgb(209 213 219 / 0.4)',
27-
},
2825
},
2926
},
3027
};

src/plugins/chart/ChartMark/Column.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const Column: React.FC<ChartProps> = (props) => {
4141
tickCount: 5,
4242
})
4343
.style({
44-
maxWidth: 10, // 圆角样式
44+
maxWidth: 20, // 圆角样式
4545
radiusTopLeft: 4,
4646
fillOpacity: 0.85,
4747
radiusTopRight: 4,

src/plugins/chart/ChartMark/Pie.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ export const Pie: React.FC<ChartProps> = (props) => {
3636
});
3737

3838
chartRef.current = chart;
39-
chart.render();
39+
40+
setTimeout(() => {
41+
chart.render();
42+
}, 16);
4043

4144
return () => {
4245
if (!chart) return;

src/plugins/chart/ChartRender.tsx

+21-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
import { DownOutlined, SettingOutlined } from '@ant-design/icons';
1+
import {
2+
DownOutlined,
3+
ReloadOutlined,
4+
SettingOutlined,
5+
} from '@ant-design/icons';
26
import { ProForm, ProFormSelect } from '@ant-design/pro-components';
37
import { Chart } from '@antv/g2';
48
import { ConfigProvider, Descriptions, Dropdown, Popover, Table } from 'antd';
59
import { DescriptionsItemType } from 'antd/es/descriptions';
610
import React, { useMemo, useRef, useState } from 'react';
11+
import { ActionIconBox } from '../../MarkdownEditor/editor/components';
712
import { ChartAttrToolBar } from './ChartAttrToolBar';
813
import { Area, Bar, Column, Line, Pie } from './ChartMark';
914

@@ -249,13 +254,12 @@ export const ChartRender: React.FC<{
249254
</ConfigProvider>
250255
}
251256
>
252-
<span
253-
style={{
254-
padding: '4px 8px',
255-
}}
257+
<ActionIconBox
258+
title="配置图表"
259+
onClick={() => chartRef.current?.render()}
256260
>
257261
<SettingOutlined />
258-
</span>
262+
</ActionIconBox>
259263
</Popover>,
260264
].filter((item) => !!item) as JSX.Element[];
261265

@@ -435,6 +439,17 @@ export const ChartRender: React.FC<{
435439
style: { padding: 0 },
436440
icon: toolBar.at(2),
437441
},
442+
{
443+
style: { padding: 0 },
444+
icon: (
445+
<ActionIconBox
446+
title="重新渲染"
447+
onClick={() => chartRef.current?.render()}
448+
>
449+
<ReloadOutlined />
450+
</ActionIconBox>
451+
),
452+
},
438453
]}
439454
/>
440455
</div>

0 commit comments

Comments
 (0)