Skip to content

Commit 4d05cd5

Browse files
committed
fix: some bugfix
1 parent 416fb69 commit 4d05cd5

3 files changed

Lines changed: 39 additions & 27 deletions

File tree

src/frontend/platform/src/pages/Dashboard/colorSchemes.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,15 +528,15 @@ export const getDefaultMetricStyle = (title, subtitle) => ({
528528
"titleUnderline": false,
529529
subtitle,
530530
"subtitleFontSize": 14,
531-
"subtitleColor": "#000000",
531+
"subtitleColor": "#666",
532532
"subtitleAlign": "left",
533533
"subtitleBold": false,
534534
"subtitleItalic": false,
535535
"subtitleUnderline": false,
536-
"metricFontSize": 14,
537-
"metricColor": "#000000",
538-
"metricAlign": "left",
539-
"metricBold": false,
536+
"metricFontSize": 28,
537+
"metricColor": "#4882f6",
538+
"metricAlign": "start",
539+
"metricBold": true,
540540
"metricItalic": false,
541541
"metricUnderline": false,
542542
})

src/frontend/platform/src/pages/Dashboard/components/charts/BaseChart.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ const getCartesianChartOption = (
279279
name: styleConfig.yAxisTitle || '',
280280
nameLocation: styleConfig.yAxisAlign === 'right' ? 'end' : styleConfig.yAxisAlign === 'left' ? 'start' : 'center',
281281
nameRotate: isHorizontal ? 0 : 90,
282-
nameTextStyle: yAxisTitleStyle
282+
nameTextStyle: yAxisTitleStyle,
283+
boundaryGap: [0, '20%']
283284
};
284285

285286
const lastValueIndexes = dimensions.map((_, dimIdx) => {
@@ -333,7 +334,7 @@ const getCartesianChartOption = (
333334
};
334335
}
335336
if (isStacked) item.stack = 'total';
336-
if (isArea) item.areaStyle = {};
337+
if (isArea) item.areaStyle = {opacity: 0.1};
337338
// if (isLineOrArea) item.smooth = true;
338339

339340
return item;

src/frontend/platform/src/pages/Dashboard/components/charts/MetricCard.tsx

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,38 @@ export function MetricCard({ title: indicatorName, data, isPreviewMode, dataConf
163163
align: styleConfig.metricAlign
164164
})
165165

166+
const subtitleLineHeight = styleConfig.subtitleFontSize ? styleConfig.subtitleFontSize * 1.5 : 21 // 默认14px * 1.5
167+
const maxSubtitleHeight = subtitleLineHeight * 4
168+
166169
return (
167-
<div className="group h-full flex flex-col justify-between select-none">
168-
{/* subtitle */}
170+
<div className="group h-full flex flex-col select-none py-1 px-2">
171+
{/* title - single line */}
172+
<div style={titleStyle} className='truncate mb-1'>{indicatorName}</div>
173+
174+
{/* subtitle - max 4 lines with ellipsis */}
169175
{styleConfig.showSubtitle && subTitle ? (
170-
<div style={subtitleStyle}>{subTitle}</div>
171-
) : <div></div>}
172-
<div className='flex justify-between items-end'>
173-
{/* title */}
174-
<div style={titleStyle} className='w-1/2 truncate'>{indicatorName}</div>
175-
{/* value */}
176-
<div style={metricStyle} className='w-1/2 leading-[1.2em] truncate pr-1'>
176+
<div
177+
style={{
178+
...subtitleStyle,
179+
display: '-webkit-box',
180+
WebkitLineClamp: 4,
181+
WebkitBoxOrient: 'vertical',
182+
overflow: 'hidden',
183+
textOverflow: 'ellipsis',
184+
wordBreak: 'break-all',
185+
lineHeight: `${subtitleLineHeight}px`,
186+
maxHeight: `${maxSubtitleHeight}px`,
187+
flex: 1,
188+
minHeight: 0
189+
}}
190+
>
191+
{subTitle}
192+
</div>
193+
) : <div className="flex-1"></div>}
194+
195+
{/* value - stays at bottom */}
196+
<div className='mt-auto pt-2'>
197+
<div style={metricStyle} className='leading-[1.2em] truncate'>
177198
{formatValue}
178199
{displayUnit && <span className="text-xl ml-2 text-muted-foreground">{displayUnit}</span>}
179200
</div>
@@ -188,16 +209,6 @@ export function MetricCard({ title: indicatorName, data, isPreviewMode, dataConf
188209
)}
189210
size={16}
190211
/>}
191-
{/* 趋势信息 */}
192-
{/* {trend && (
193-
<div className="flex items-center gap-1 text-sm">
194-
{getTrendIcon()}
195-
<span className={getTrendColor()}>
196-
{trend.value > 0 ? '+' : ''}{trend.value}%
197-
</span>
198-
<span className="text-muted-foreground ml-1">{trend.label}</span>
199-
</div>
200-
)} */}
201212
</div>
202213
)
203-
}
214+
}

0 commit comments

Comments
 (0)