Skip to content

Commit 5ce21bc

Browse files
committed
fix: 更新图表容器和元素的宽度限制逻辑,以增强响应式布局
1 parent ae408f8 commit 5ce21bc

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/plugins/chart/ChartMark/Container.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const Container: React.FC<{
7676
ref={htmlRef}
7777
onClick={onSize}
7878
style={{
79-
maxHeight: htmlRef.current?.clientWidth || '400px',
79+
maxHeight: `max(${htmlRef.current?.clientWidth || 400}px, 400px)`,
8080
}}
8181
/>
8282
</ResizeObserver>

src/plugins/chart/index.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export const ChartElement: React.FC<RenderElementProps> = (props) => {
154154
data-be={'chart'}
155155
style={{
156156
flex: 1,
157-
minWidth: Math.min(minWidth, 856),
157+
minWidth: `min(${Math.min(minWidth, 856)}px, 100%)`,
158158
maxWidth: '100%',
159159
}}
160160
ref={htmlRef}
@@ -289,6 +289,7 @@ export const ChartElement: React.FC<RenderElementProps> = (props) => {
289289
onColumnLengthChange={setColumnLength}
290290
chartType={chartType}
291291
chartData={chartData}
292+
title={rest?.title}
292293
config={{
293294
height,
294295
x,
@@ -331,7 +332,7 @@ export const ChartElement: React.FC<RenderElementProps> = (props) => {
331332
border: '1px solid #eee',
332333
borderRadius: '0.5em',
333334
margin: 'auto',
334-
minWidth: `calc(${100 / columnLength}% - 16px)`,
335+
minWidth: `max(calc(${100 / columnLength}% - 16px), 256px)`,
335336
flex: 1,
336337
}}
337338
onClick={(e) => {

0 commit comments

Comments
 (0)