优化:协调查询页与底部图表字体大小
This commit is contained in:
+40
-19
@@ -52,7 +52,18 @@ import { downloadMetricWorkbook } from './metricWorkbook';
|
||||
echarts.use([BarChart, LineChart, GraphicComponent, GridComponent, LegendComponent, MarkLineComponent, TooltipComponent, SVGRenderer]);
|
||||
|
||||
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 SUMMARY_PAGE_SIZE = 15;
|
||||
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]);
|
||||
|
||||
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'] });
|
||||
return () => observer.disconnect();
|
||||
const compact = window.matchMedia('(max-width: 760px)');
|
||||
compact.addEventListener('change', refresh);
|
||||
return () => { observer.disconnect(); compact.removeEventListener('change', refresh); };
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -1006,7 +1020,9 @@ export function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUna
|
||||
const instance = chart.current;
|
||||
if (!instance) 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 line = styles.getPropertyValue('--line').trim() || '#dfe5ef';
|
||||
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));
|
||||
});
|
||||
const option: echarts.EChartsCoreOption = {
|
||||
textStyle: { color: ink, fontFamily, fontSize },
|
||||
animationDuration: 420,
|
||||
animationDurationUpdate: 520,
|
||||
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: {
|
||||
trigger: 'axis',
|
||||
axisPointer: { type: 'shadow' },
|
||||
backgroundColor: surface,
|
||||
borderColor: line,
|
||||
textStyle: { color: ink },
|
||||
textStyle: { color: ink, fontFamily, fontSize: tooltipFontSize },
|
||||
formatter: (rawParams: unknown) => {
|
||||
const list = (Array.isArray(rawParams) ? rawParams : [rawParams]) as Array<{ dataIndex?: number }>;
|
||||
const index = Number(list[0]?.dataIndex);
|
||||
@@ -1040,13 +1057,13 @@ export function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUna
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
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 } },
|
||||
axisTick: { alignWithLabel: true, lineStyle: { color: line } },
|
||||
},
|
||||
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: '累计占比', 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: '报废重量 / 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 }, axisLabel: { color: ink, fontFamily: numericFamily, fontSize, formatter: '{value}%' }, splitLine: { show: false } },
|
||||
],
|
||||
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 } })) },
|
||||
@@ -1221,9 +1238,12 @@ export function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedP
|
||||
}, []);
|
||||
|
||||
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'] });
|
||||
return () => observer.disconnect();
|
||||
const compact = window.matchMedia('(max-width: 760px)');
|
||||
compact.addEventListener('change', refresh);
|
||||
return () => { observer.disconnect(); compact.removeEventListener('change', refresh); };
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -1262,6 +1282,7 @@ export function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedP
|
||||
const instance = chart.current;
|
||||
if (!instance || !container.current) return;
|
||||
const css = getComputedStyle(container.current);
|
||||
const { fontFamily, numericFamily, fontSize, tooltipFontSize } = queryChartTypography(container.current);
|
||||
const ink = css.getPropertyValue('--ink').trim() || '#111111';
|
||||
const blue = css.getPropertyValue('--blue').trim() || '#5368d7';
|
||||
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 = {
|
||||
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 },
|
||||
legend: { type: 'scroll', top: 0, left: 9, right: 9, itemWidth: 14, itemHeight: 7, itemGap: 20, textStyle: { color: ink, fontSize: CHART_FONT_SIZE } },
|
||||
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') },
|
||||
xAxis: { type: 'category', data: labels, triggerEvent: true, axisLine: { lineStyle: { color: line } }, axisLabel: { color: ink, margin: 12 }, axisTick: { show: false } },
|
||||
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, 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, fontFamily, fontSize, margin: 12 }, axisTick: { show: false } },
|
||||
};
|
||||
let option: echarts.EChartsCoreOption;
|
||||
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,
|
||||
symbol: 'none',
|
||||
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 }],
|
||||
} };
|
||||
option = {
|
||||
...base,
|
||||
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: '合格率 / %', 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: '重量 / 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 }, axisLabel: { color: ink, formatter: '{value}%', fontFamily: numericFamily, fontSize }, axisLine: { show: false }, axisTick: { show: false }, splitLine: { show: false } },
|
||||
],
|
||||
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') },
|
||||
@@ -1323,7 +1344,7 @@ export function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedP
|
||||
const palette = [blue, teal, '#bf7d58', '#9278bf', '#598eae'];
|
||||
option = {
|
||||
...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)); }) })),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -17,6 +17,22 @@
|
||||
|
||||
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. */
|
||||
.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) {
|
||||
@@ -28,3 +44,10 @@ body, button, input, textarea, select { font-family: var(--font-ui); }
|
||||
.app-shell .ant-tabs-tab { font-size: var(--font-body); }
|
||||
.ant-modal-title,.ant-drawer-title { font-size: var(--font-dialog-title); }
|
||||
.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); }
|
||||
|
||||
Reference in New Issue
Block a user