优化:协调查询页与底部图表字体大小

This commit is contained in:
2026-10-30 23:04:31 +08:00
parent ff7bbe3e46
commit 228d55da75
3 changed files with 67 additions and 20 deletions
+4 -1
View File
@@ -17,7 +17,7 @@
- `web/src/main.tsx` 同时向 CSS 变量和 Ant Design 提供表面、文字、边框、强调色;不分别硬编码两套深色表面。 - `web/src/main.tsx` 同时向 CSS 变量和 Ant Design 提供表面、文字、边框、强调色;不分别硬编码两套深色表面。
- `web/src/workspace-finish.css` 定义各主题共用的控件、指标横条、网格与选中状态细节。 - `web/src/workspace-finish.css` 定义各主题共用的控件、指标横条、网格与选中状态细节。
- 控件圆角4px、面板圆角5px;网格线保持1px,不用大投影和霓虹发光。(Agent推断) - 控件圆角4px、面板圆角5px;网格线保持1px,不用大投影和霓虹发光。(Agent推断)
- 正文、表格字号与现有缩放保持不变;中文优先苹方/微软雅黑,业务数字使用Arial/Helvetica Neue及等宽数字特性,指标字重700、表格数字500/重点600。(Agent推断) - 全局缩放保留;查询页筛选/表格13px、辅助12px、区块标题14px、主指标32px/其他指标30px。中文优先苹方/微软雅黑,业务数字使用Arial/Helvetica Neue及等宽数字特性,指标字重700、表格数字500/重点600。(Agent推断)
- 午夜黑使用蓝黑画布、略亮的内容表面、银白正文;蓝紫/青绿分组表头均采用低亮度底色。(用户确认方向,具体色值由Agent推断) - 午夜黑使用蓝黑画布、略亮的内容表面、银白正文;蓝紫/青绿分组表头均采用低亮度底色。(用户确认方向,具体色值由Agent推断)
- 主按钮在深色模式使用深色字以确保可读,亮蓝主题的按钮背景适当加深。(Agent推断) - 主按钮在深色模式使用深色字以确保可读,亮蓝主题的按钮背景适当加深。(Agent推断)
- 既有悬停、聚焦和切换过渡沿用原时长,不新增位移动效。(Agent推断) - 既有悬停、聚焦和切换过渡沿用原时长,不新增位移动效。(Agent推断)
@@ -33,3 +33,6 @@
- 不在业务界面增加制作说明、风格编号或无用的副标签。 - 不在业务界面增加制作说明、风格编号或无用的副标签。
- 2026-10-30:用户要求字体也参照G3修改;已同步六主题中文与业务数字字体,代码/JSON仍使用等宽代码字体。(用户确认方向,具体字体选择由Agent推断) - 2026-10-30:用户要求字体也参照G3修改;已同步六主题中文与业务数字字体,代码/JSON仍使用等宽代码字体。(用户确认方向,具体字体选择由Agent推断)
- 查询页字号比例追加调整:适当放大筛选与表格、收小指标,四项指标标签统一13px/600;已按用户要求发布并同步源码。(用户反馈字号不协调,具体取值由Agent推断)
- 查询页趋势图与柏拉图同步使用页面字体变量:图例与单位使用界面字体、数值刻度使用数字字体,悬浮提示略大;抵消图表局部缩放,保持与表格文字协调。已检查趋势图深浅主题,类型检查与8项相关回归通过;底部预览已补入当前线上全年筛选的真实快照,33个细分字段齐全;已核对不良构成与柏拉图深浅主题,阶段标题14px、分类与数值13px、辅助表头12px,保留原有数据核对提示。2026-10-30 已按用户要求发布。
+40 -19
View File
@@ -52,7 +52,18 @@ import { downloadMetricWorkbook } from './metricWorkbook';
echarts.use([BarChart, LineChart, GraphicComponent, GridComponent, LegendComponent, MarkLineComponent, TooltipComponent, SVGRenderer]); echarts.use([BarChart, LineChart, GraphicComponent, GridComponent, LegendComponent, MarkLineComponent, TooltipComponent, SVGRenderer]);
const MONTHS = Array.from({ length: 12 }, (_, index) => `${String(index + 1).padStart(2, '0')}月`); const MONTHS = Array.from({ length: 12 }, (_, index) => `${String(index + 1).padStart(2, '0')}月`);
const CHART_FONT_SIZE = 12; // 图表为保持坐标交互准确使用局部 zoom,字体需抵消该缩放以匹配页面正文。
function queryChartTypography(node: HTMLElement) {
const css = getComputedStyle(node);
const zoom = Number.parseFloat(css.zoom) || 1;
const size = (token: string, fallback: number) => Math.round((Number.parseFloat(css.getPropertyValue(token)) || fallback) / zoom * 10) / 10;
return {
fontFamily: css.getPropertyValue('--font-ui').trim() || css.fontFamily,
numericFamily: css.getPropertyValue('--font-numeric').trim() || css.fontFamily,
fontSize: size('--font-control', 13),
tooltipFontSize: size('--font-reading', 14),
};
}
const TABLE_PAGE_SIZE = 20; const TABLE_PAGE_SIZE = 20;
const SUMMARY_PAGE_SIZE = 15; const SUMMARY_PAGE_SIZE = 15;
const SUMMARY_PAGE_SIZE_OPTIONS = ['10', '15', '20', '50', '100']; const SUMMARY_PAGE_SIZE_OPTIONS = ['10', '15', '20', '50', '100'];
@@ -969,9 +980,12 @@ export function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUna
}, [releaseId, fineQueryKey, onUnauthorized, onlyStage]); }, [releaseId, fineQueryKey, onUnauthorized, onlyStage]);
useEffect(() => { useEffect(() => {
const observer = new MutationObserver(() => setThemeRevision(value => value + 1)); const refresh = () => setThemeRevision(value => value + 1);
const observer = new MutationObserver(refresh);
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-workspace-theme'] }); observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-workspace-theme'] });
return () => observer.disconnect(); const compact = window.matchMedia('(max-width: 760px)');
compact.addEventListener('change', refresh);
return () => { observer.disconnect(); compact.removeEventListener('change', refresh); };
}, []); }, []);
useEffect(() => { useEffect(() => {
@@ -1006,7 +1020,9 @@ export function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUna
const instance = chart.current; const instance = chart.current;
if (!instance) return; if (!instance) return;
if (!items.length) { instance.clear(); return; } if (!items.length) { instance.clear(); return; }
const styles = getComputedStyle(document.documentElement); if (!container.current) return;
const { fontFamily, numericFamily, fontSize, tooltipFontSize } = queryChartTypography(container.current);
const styles = getComputedStyle(container.current);
const ink = styles.getPropertyValue('--ink').trim() || '#222222'; const ink = styles.getPropertyValue('--ink').trim() || '#222222';
const line = styles.getPropertyValue('--line').trim() || '#dfe5ef'; const line = styles.getPropertyValue('--line').trim() || '#dfe5ef';
const blue = styles.getPropertyValue('--blue').trim() || '#607ae1'; const blue = styles.getPropertyValue('--blue').trim() || '#607ae1';
@@ -1018,16 +1034,17 @@ export function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUna
return Number((accumulated / totalWeight * 100).toFixed(3)); return Number((accumulated / totalWeight * 100).toFixed(3));
}); });
const option: echarts.EChartsCoreOption = { const option: echarts.EChartsCoreOption = {
textStyle: { color: ink, fontFamily, fontSize },
animationDuration: 420, animationDuration: 420,
animationDurationUpdate: 520, animationDurationUpdate: 520,
grid: { left: 68, right: 72, top: 48, bottom: items.length > 12 ? 92 : 62, containLabel: true }, grid: { left: 68, right: 72, top: 48, bottom: items.length > 12 ? 92 : 62, containLabel: true },
legend: { top: 8, data: ['报废重量', '累计占比'], textStyle: { color: ink, fontSize: CHART_FONT_SIZE } }, legend: { top: 8, data: ['报废重量', '累计占比'], textStyle: { color: ink, fontFamily, fontSize, fontWeight: 500 } },
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
axisPointer: { type: 'shadow' }, axisPointer: { type: 'shadow' },
backgroundColor: surface, backgroundColor: surface,
borderColor: line, borderColor: line,
textStyle: { color: ink }, textStyle: { color: ink, fontFamily, fontSize: tooltipFontSize },
formatter: (rawParams: unknown) => { formatter: (rawParams: unknown) => {
const list = (Array.isArray(rawParams) ? rawParams : [rawParams]) as Array<{ dataIndex?: number }>; const list = (Array.isArray(rawParams) ? rawParams : [rawParams]) as Array<{ dataIndex?: number }>;
const index = Number(list[0]?.dataIndex); const index = Number(list[0]?.dataIndex);
@@ -1040,13 +1057,13 @@ export function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUna
xAxis: { xAxis: {
type: 'category', type: 'category',
data: items.map(item => item.label), data: items.map(item => item.label),
axisLabel: { color: ink, rotate: 35, interval: 0, hideOverlap: true, fontSize: CHART_FONT_SIZE }, axisLabel: { color: ink, rotate: 35, interval: 0, hideOverlap: true, fontSize },
axisLine: { lineStyle: { color: line } }, axisLine: { lineStyle: { color: line } },
axisTick: { alignWithLabel: true, lineStyle: { color: line } }, axisTick: { alignWithLabel: true, lineStyle: { color: line } },
}, },
yAxis: [ yAxis: [
{ type: 'value', name: '报废重量 / kg', nameTextStyle: { color: ink, fontSize: CHART_FONT_SIZE }, axisLabel: { color: ink, fontSize: CHART_FONT_SIZE }, splitLine: { lineStyle: { color: line, type: 'dashed' } } }, { type: 'value', name: '报废重量 / kg', nameTextStyle: { color: ink, fontSize }, axisLabel: { color: ink, fontFamily: numericFamily, fontSize }, splitLine: { lineStyle: { color: line, type: 'dashed' } } },
{ type: 'value', name: '累计占比', min: 0, max: 100, nameTextStyle: { color: ink, fontSize: CHART_FONT_SIZE }, axisLabel: { color: ink, fontSize: CHART_FONT_SIZE, formatter: '{value}%' }, splitLine: { show: false } }, { type: 'value', name: '累计占比', min: 0, max: 100, nameTextStyle: { color: ink, fontSize }, axisLabel: { color: ink, fontFamily: numericFamily, fontSize, formatter: '{value}%' }, splitLine: { show: false } },
], ],
series: [ series: [
{ name: '报废重量', type: 'bar', z: 1, barMaxWidth: 36, data: items.map(item => ({ value: item.weight, itemStyle: { color: item.kind === 'category' ? '#9aa4b2' : item.key.startsWith('black:') ? blue : teal } })) }, { name: '报废重量', type: 'bar', z: 1, barMaxWidth: 36, data: items.map(item => ({ value: item.weight, itemStyle: { color: item.kind === 'category' ? '#9aa4b2' : item.key.startsWith('black:') ? blue : teal } })) },
@@ -1221,9 +1238,12 @@ export function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedP
}, []); }, []);
useEffect(() => { useEffect(() => {
const observer = new MutationObserver(() => setThemeRevision(value => value + 1)); const refresh = () => setThemeRevision(value => value + 1);
const observer = new MutationObserver(refresh);
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-workspace-theme'] }); observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-workspace-theme'] });
return () => observer.disconnect(); const compact = window.matchMedia('(max-width: 760px)');
compact.addEventListener('change', refresh);
return () => { observer.disconnect(); compact.removeEventListener('change', refresh); };
}, []); }, []);
useEffect(() => { useEffect(() => {
@@ -1262,6 +1282,7 @@ export function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedP
const instance = chart.current; const instance = chart.current;
if (!instance || !container.current) return; if (!instance || !container.current) return;
const css = getComputedStyle(container.current); const css = getComputedStyle(container.current);
const { fontFamily, numericFamily, fontSize, tooltipFontSize } = queryChartTypography(container.current);
const ink = css.getPropertyValue('--ink').trim() || '#111111'; const ink = css.getPropertyValue('--ink').trim() || '#111111';
const blue = css.getPropertyValue('--blue').trim() || '#5368d7'; const blue = css.getPropertyValue('--blue').trim() || '#5368d7';
const barColor = css.getPropertyValue('--blue-muted').trim() || '#b0bcee'; const barColor = css.getPropertyValue('--blue-muted').trim() || '#b0bcee';
@@ -1283,11 +1304,11 @@ export function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedP
}; };
const base: echarts.EChartsCoreOption = { const base: echarts.EChartsCoreOption = {
animation: false, animation: false,
textStyle: { fontFamily: '-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif', color: ink, fontSize: CHART_FONT_SIZE }, textStyle: { fontFamily, color: ink, fontSize },
grid: { left: 65, right: mode === 'production' ? 67 : 32, top: 70, bottom: 38 }, grid: { left: 65, right: mode === 'production' ? 67 : 32, top: 70, bottom: 38 },
legend: { type: 'scroll', top: 0, left: 9, right: 9, itemWidth: 14, itemHeight: 7, itemGap: 20, textStyle: { color: ink, fontSize: CHART_FONT_SIZE } }, legend: { type: 'scroll', top: 0, left: 9, right: 9, itemWidth: 14, itemHeight: 7, itemGap: 20, textStyle: { color: ink, fontFamily, fontSize, fontWeight: 500 } },
tooltip: { trigger: 'axis', backgroundColor: surface, borderColor: line, borderWidth: 1, padding: [10, 13], textStyle: { color: ink, fontSize: CHART_FONT_SIZE }, transitionDuration: 0, axisPointer: { type: 'line', lineStyle: { color: blue, width: 1, type: 'dashed' } }, formatter: (params: unknown) => formatTooltip(params, mode === 'defects') }, tooltip: { trigger: 'axis', backgroundColor: surface, borderColor: line, borderWidth: 1, padding: [10, 13], textStyle: { color: ink, fontFamily, fontSize: tooltipFontSize }, transitionDuration: 0, axisPointer: { type: 'line', lineStyle: { color: blue, width: 1, type: 'dashed' } }, formatter: (params: unknown) => formatTooltip(params, mode === 'defects') },
xAxis: { type: 'category', data: labels, triggerEvent: true, axisLine: { lineStyle: { color: line } }, axisLabel: { color: ink, margin: 12 }, axisTick: { show: false } }, xAxis: { type: 'category', data: labels, triggerEvent: true, axisLine: { lineStyle: { color: line } }, axisLabel: { color: ink, fontFamily, fontSize, margin: 12 }, axisTick: { show: false } },
}; };
let option: echarts.EChartsCoreOption; let option: echarts.EChartsCoreOption;
const pointStyle = { z: 10, symbol: 'circle', symbolSize: 5, showSymbol: true, emphasis: { focus: 'none' as const, scale: 1.35 }, connectNulls: false }; const pointStyle = { z: 10, symbol: 'circle', symbolSize: 5, showSymbol: true, emphasis: { focus: 'none' as const, scale: 1.35 }, connectNulls: false };
@@ -1301,14 +1322,14 @@ export function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedP
silent: true, silent: true,
symbol: 'none', symbol: 'none',
lineStyle: { color: '#c47a47', width: 1.5, type: 'dashed' as const }, lineStyle: { color: '#c47a47', width: 1.5, type: 'dashed' as const },
label: { show: true, formatter: `综合率目标 ${targetRate.toFixed(2)}%`, position: 'insideEndTop' as const, color: '#a55d30', fontSize: CHART_FONT_SIZE }, label: { show: true, formatter: `综合率目标 ${targetRate.toFixed(2)}%`, position: 'insideEndTop' as const, color: '#a55d30', fontSize },
data: [{ yAxis: targetRate }], data: [{ yAxis: targetRate }],
} }; } };
option = { option = {
...base, ...base,
yAxis: [ yAxis: [
{ type: 'value', name: '重量 / kg', nameGap: 18, nameTextStyle: { color: ink, align: 'left', fontSize: CHART_FONT_SIZE }, axisLabel: { color: ink, fontSize: CHART_FONT_SIZE }, axisLine: { show: false }, axisTick: { show: false }, splitLine: { lineStyle: { color: line, type: 'dashed' } } }, { type: 'value', name: '重量 / kg', nameGap: 18, nameTextStyle: { color: ink, align: 'left', fontSize }, axisLabel: { color: ink, fontFamily: numericFamily, fontSize }, axisLine: { show: false }, axisTick: { show: false }, splitLine: { lineStyle: { color: line, type: 'dashed' } } },
{ type: 'value', name: '合格率 / %', nameGap: 18, min: minRate, max: maxRate, nameTextStyle: { color: ink, align: 'right', fontSize: CHART_FONT_SIZE }, axisLabel: { color: ink, formatter: '{value}%', fontSize: CHART_FONT_SIZE }, axisLine: { show: false }, axisTick: { show: false }, splitLine: { show: false } }, { type: 'value', name: '合格率 / %', nameGap: 18, min: minRate, max: maxRate, nameTextStyle: { color: ink, align: 'right', fontSize }, axisLabel: { color: ink, formatter: '{value}%', fontFamily: numericFamily, fontSize }, axisLine: { show: false }, axisTick: { show: false }, splitLine: { show: false } },
], ],
series: [ series: [
{ id: 'qualified-weight', name: `${stageName}合格重量`, type: 'bar', z: 1, stack: 'weight', yAxisIndex: 0, barWidth, itemStyle: { color: barColor }, emphasis: { itemStyle: { color: blue } }, data: barData('qualifiedWeight') }, { id: 'qualified-weight', name: `${stageName}合格重量`, type: 'bar', z: 1, stack: 'weight', yAxisIndex: 0, barWidth, itemStyle: { color: barColor }, emphasis: { itemStyle: { color: blue } }, data: barData('qualifiedWeight') },
@@ -1323,7 +1344,7 @@ export function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedP
const palette = [blue, teal, '#bf7d58', '#9278bf', '#598eae']; const palette = [blue, teal, '#bf7d58', '#9278bf', '#598eae'];
option = { option = {
...base, ...base,
yAxis: [{ type: 'value', name: '不良率 / %', nameGap: 18, nameTextStyle: { color: ink, align: 'left', fontSize: CHART_FONT_SIZE }, axisLabel: { color: ink, formatter: '{value}%', fontSize: CHART_FONT_SIZE }, axisLine: { show: false }, axisTick: { show: false }, splitLine: { lineStyle: { color: line, type: 'dashed' } } }], yAxis: [{ type: 'value', name: '不良率 / %', nameGap: 18, nameTextStyle: { color: ink, align: 'left', fontSize }, axisLabel: { color: ink, formatter: '{value}%', fontFamily: numericFamily, fontSize }, axisLine: { show: false }, axisTick: { show: false }, splitLine: { lineStyle: { color: line, type: 'dashed' } } }],
series: names.map((name, index) => ({ id: `defect-${stage}-${name}`, name, type: 'line' as const, ...pointStyle, lineStyle: { width: 2, color: palette[index % palette.length] }, itemStyle: { color: palette[index % palette.length] }, data: rows.map(row => { const defect = row[stage].defects.find(item => item.name === name); return rateNumber(defectWeightRate(defect?.weight, row[stage].totalWeight)); }) })), series: names.map((name, index) => ({ id: `defect-${stage}-${name}`, name, type: 'line' as const, ...pointStyle, lineStyle: { width: 2, color: palette[index % palette.length] }, itemStyle: { color: palette[index % palette.length] }, data: rows.map(row => { const defect = row[stage].defects.find(item => item.name === name); return rateNumber(defectWeightRate(defect?.weight, row[stage].totalWeight)); }) })),
}; };
} }
+23
View File
@@ -17,6 +17,22 @@
body, button, input, textarea, select { font-family: var(--font-ui); } body, button, input, textarea, select { font-family: var(--font-ui); }
/* 查询区在既有缩放下保留可读正文,避免指标与明细的字号反差过大。 */
.query-page {
--font-control: 13px;
--font-table: 13px;
--font-body: 13px;
--font-note: 12px;
--font-section: 14px;
--font-metric: 30px;
--font-metric-primary: 32px;
}
.query-page .metric-label,
.query-page .metric-card.primary .metric-label {
font-size: var(--font-body);
font-weight: 600;
}
/* Component content inherits this tier instead of Ant Design's mixed sizes. */ /* Component content inherits this tier instead of Ant Design's mixed sizes. */
.app-shell :is(.ant-btn,.ant-input,.ant-input-number,.ant-select,.ant-segmented,.ant-tag,.ant-pagination), .app-shell :is(.ant-btn,.ant-input,.ant-input-number,.ant-select,.ant-segmented,.ant-tag,.ant-pagination),
:is(.management-modal,.management-drawer,.structured-config-modal) :is(.ant-btn,.ant-input,.ant-input-number,.ant-select,.ant-segmented,.ant-tag) { :is(.management-modal,.management-drawer,.structured-config-modal) :is(.ant-btn,.ant-input,.ant-input-number,.ant-select,.ant-segmented,.ant-tag) {
@@ -28,3 +44,10 @@ body, button, input, textarea, select { font-family: var(--font-ui); }
.app-shell .ant-tabs-tab { font-size: var(--font-body); } .app-shell .ant-tabs-tab { font-size: var(--font-body); }
.ant-modal-title,.ant-drawer-title { font-size: var(--font-dialog-title); } .ant-modal-title,.ant-drawer-title { font-size: var(--font-dialog-title); }
.ant-tooltip-inner { font-size: var(--font-note); } .ant-tooltip-inner { font-size: var(--font-note); }
/* 柏拉图标题与同级趋势区块标题使用同一字号。 */
.query-page .defect-pareto-heading strong { font-size: var(--font-section); }
.query-page .defect-stage-title { font-size: var(--font-section); font-weight: 600; }
.query-page .defect-name { font-size: var(--font-body); font-weight: 500; }
.query-page .defect-header { font-size: var(--font-note); font-weight: 500; }
.query-page :is(.defect-weight, .defect-rate) { font-size: var(--font-table); }