Align combined defect chart rows and spacing
This commit is contained in:
@@ -272,6 +272,7 @@ function AnalysisVisualCard({ visual, beforeExport }: { visual: AnalysisVisual;
|
||||
tabIndex={0}
|
||||
aria-label={`${chartSummary(visual)}。按 Enter 或空格查看数据。`}
|
||||
aria-busy={chartLoading}
|
||||
style={visual.sectionKey === 'defect_combined' ? { height: Math.max(320, visual.categories.length * 38 + 48) } : undefined}
|
||||
onClick={openData}
|
||||
onKeyDown={event => {
|
||||
if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); openData(); }
|
||||
|
||||
@@ -758,6 +758,7 @@ export function buildAnalysisVisualOption(visual: AnalysisVisual, theme: VisualC
|
||||
};
|
||||
}
|
||||
|
||||
const combinedDefects = visual.sectionKey === 'defect_combined' && visual.type === 'bar';
|
||||
const series = visual.series.map((item, seriesIndex) => ({
|
||||
name: plainRichText(item.label),
|
||||
type: visual.type === 'area' ? 'line' : visual.type === 'column' ? 'bar' : visual.type,
|
||||
@@ -770,7 +771,8 @@ export function buildAnalysisVisualOption(visual: AnalysisVisual, theme: VisualC
|
||||
connectNulls: false,
|
||||
smooth: false,
|
||||
...(['bar', 'column'].includes(visual.type) ? {
|
||||
barMaxWidth: 32,
|
||||
barMaxWidth: combinedDefects ? 18 : 32,
|
||||
...(combinedDefects ? { stack: 'combined-defect-stage', barWidth: 18 } : {}),
|
||||
...(visual.type === 'column' ? { barCategoryGap: '35%' } : {}),
|
||||
label: { show: true, position: visual.type === 'column' ? 'top' : 'right',
|
||||
color: ink, fontSize: 11,
|
||||
@@ -787,8 +789,8 @@ export function buildAnalysisVisualOption(visual: AnalysisVisual, theme: VisualC
|
||||
const horizontalBar = visual.type === 'bar';
|
||||
const verticalBar = visual.type === 'column';
|
||||
const tooltip = { trigger: 'axis' as const, renderMode: 'richText' as const, backgroundColor: theme.surface || '#ffffff', borderColor: line, textStyle: { color: ink }, axisPointer: { type: horizontalBar || verticalBar ? 'shadow' as const : 'line' as const }, formatter };
|
||||
const legend = { show: visual.series.length > 1, type: 'scroll' as const, top: 8, textStyle: { color: mutedInk, fontSize: 11 } };
|
||||
const grid = { left: horizontalBar ? 18 : 48, right: horizontalBar ? 96 : 24, top: visual.series.length > 1 ? 48 : 18, bottom: verticalBar ? 78 : 24, containLabel: true };
|
||||
const legend = { show: visual.series.length > 1 && !combinedDefects, type: 'scroll' as const, top: 8, textStyle: { color: mutedInk, fontSize: 11 } };
|
||||
const grid = { left: horizontalBar ? 18 : 48, right: horizontalBar ? 96 : 24, top: visual.series.length > 1 && !combinedDefects ? 48 : 18, bottom: verticalBar ? 78 : 24, containLabel: true };
|
||||
const shared = { animation: false as const, color: colors, tooltip, legend, grid, aria: { enabled: true, decal: { show: false } } };
|
||||
const valueAxis = {
|
||||
type: 'value' as const,
|
||||
@@ -895,11 +897,13 @@ export function buildAnalysisVisualExportOption(visual: AnalysisVisual, width =
|
||||
const wrappedCategories = visual.categories.map((_category, index) => wrapLines(visualCategoryLabel(visual, index), 14));
|
||||
const categoryLabelHeight = wrappedCategories.reduce((total, lines) => total + Math.max(28, lines.length * 14 + 8), 0);
|
||||
const maxCategoryLines = Math.max(1, ...wrappedCategories.map(lines => lines.length));
|
||||
const combinedDefects = visual.sectionKey === 'defect_combined' && visual.type === 'bar';
|
||||
const chartHeight = visual.type === 'donut' ? (reportMode ? Math.max(390, 290 + maxCategoryLines * 20) : Math.max(600, 300 + maxCategoryLines * 20))
|
||||
: visual.type === 'waterfall' ? (reportMode ? 300 : 480)
|
||||
: visual.type === 'heatmap' ? Math.max(reportMode ? 180 : 240, visual.series.length * (reportMode ? 62 : 90))
|
||||
: visual.type === 'pareto' ? (reportMode ? Math.max(300, 170 + maxCategoryLines * 18) : Math.max(480, categoryLabelHeight))
|
||||
: reportMode ? visual.type === 'bar' ? Math.max(230, categoryLabelHeight * 1.3) : Math.max(230, 165 + maxCategoryLines * 20) : Math.max(480, categoryLabelHeight);
|
||||
: combinedDefects ? Math.max(reportMode ? 350 : 410, visual.categories.length * (reportMode ? 42 : 46))
|
||||
: reportMode ? visual.type === 'bar' ? Math.max(230, categoryLabelHeight * 1.3) : Math.max(230, 165 + maxCategoryLines * 20) : Math.max(480, categoryLabelHeight);
|
||||
const height = chartTop + chartHeight + chartBottom;
|
||||
const base = buildAnalysisVisualOption(visual, { ink: '#263c5a', mutedInk: '#65748b', line: '#dfe5ef', surface: '#ffffff' });
|
||||
const categories = wrappedCategories.map(lines => lines.join('\n'));
|
||||
@@ -934,7 +938,7 @@ export function buildAnalysisVisualExportOption(visual: AnalysisVisual, width =
|
||||
textStyle: { color: '#65748b', fontSize: 11 },
|
||||
}
|
||||
: {
|
||||
show: visual.series.length > 1,
|
||||
show: visual.series.length > 1 && !combinedDefects,
|
||||
type: 'scroll' as const,
|
||||
top: reportMode ? chartTop + 2 : chartTop - 26,
|
||||
left: 56,
|
||||
|
||||
Reference in New Issue
Block a user