优化:趋势柱形采用01轻度加深并同步六主题
This commit is contained in:
+11
-5
@@ -1,3 +1,5 @@
|
||||
import { trendBarPalette } from './trendBarPalette';
|
||||
import { getWorkspaceTheme } from './ui-themes';
|
||||
import { queryScrapWeight, queryTotalScrapWeight, type QueryRateBasis } from './queryMetricValues';
|
||||
import { BusinessValue } from './BusinessValue';
|
||||
import { usePageCache } from './pageCache';
|
||||
@@ -1281,13 +1283,17 @@ export function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedP
|
||||
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';
|
||||
const bars = trendBarPalette(getWorkspaceTheme(document.documentElement.dataset.workspaceTheme).id);
|
||||
const barColor = bars.qualified;
|
||||
const teal = css.getPropertyValue('--teal').trim() || '#008f7d';
|
||||
const line = css.getPropertyValue('--line').trim() || '#dfe5ef';
|
||||
const surface = css.getPropertyValue('--surface').trim() || '#ffffff';
|
||||
const labels = rows.map(row => row.periodLabel || String(row.month));
|
||||
const barData = (field: 'qualifiedWeight' | 'scrapWeight') => rows.map(row => ({
|
||||
value: hasStageRows(row, stage) ? stageValue(row, stage, field, rateBasis) : null,
|
||||
itemStyle: { color: field === 'qualifiedWeight'
|
||||
? (String(row.period ?? row.month) === selectedPeriod ? bars.selectedQualified : bars.qualified)
|
||||
: (String(row.period ?? row.month) === selectedPeriod ? bars.selectedScrap : bars.scrap) },
|
||||
}));
|
||||
const formatTooltip = (params: unknown, onlyRates = false) => {
|
||||
const items: ChartTooltipParam[] = Array.isArray(params) ? params as ChartTooltipParam[] : [params as ChartTooltipParam];
|
||||
@@ -1328,8 +1334,8 @@ export function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedP
|
||||
{ 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') },
|
||||
{ id: 'scrap-weight', name: `${stageName}报废重量`, type: 'bar', z: 1, stack: 'weight', yAxisIndex: 0, barWidth, itemStyle: { color: '#edaa83' }, emphasis: { itemStyle: { color: '#e58e5d' } }, data: barData('scrapWeight') },
|
||||
{ id: 'qualified-weight', name: `${stageName}合格重量`, type: 'bar', z: 1, stack: 'weight', yAxisIndex: 0, barWidth, itemStyle: { color: barColor }, emphasis: { itemStyle: { color: bars.hoverQualified } }, data: barData('qualifiedWeight') },
|
||||
{ id: 'scrap-weight', name: `${stageName}报废重量`, type: 'bar', z: 1, stack: 'weight', yAxisIndex: 0, barWidth, itemStyle: { color: bars.scrap }, emphasis: { itemStyle: { color: bars.hoverScrap } }, data: barData('scrapWeight') },
|
||||
{ id: 'composite-rate', name: '综合合格率', type: 'line', yAxisIndex: 1, ...pointStyle, ...targetLine, lineStyle: { width: 2.5, color: blue }, itemStyle: { color: blue, borderColor: surface, borderWidth: 1.5 }, data: rows.map(row => rateNumber(visibleCompositeRate(row, rateBasis))) },
|
||||
{ id: 'black-rate', name: '黑片合格率', type: 'line', yAxisIndex: 1, ...pointStyle, lineStyle: { width: 1.8, color: '#9278bf' }, itemStyle: { color: '#9278bf', borderColor: surface, borderWidth: 1 }, data: rows.map(row => rateNumber(visibleStageRate(row, 'black'))) },
|
||||
{ id: 'bright-rate', name: '亮片合格率', type: 'line', yAxisIndex: 1, ...pointStyle, lineStyle: { width: 1.8, color: teal }, itemStyle: { color: teal, borderColor: surface, borderWidth: 1 }, data: rows.map(row => rateNumber(visibleStageRate(row, 'bright', rateBasis))) },
|
||||
@@ -1350,7 +1356,7 @@ export function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedP
|
||||
}
|
||||
instance.setOption(option, { replaceMerge: ['series', 'yAxis'], lazyUpdate: false });
|
||||
refreshBarMasks();
|
||||
}, [rows, mode, stage, rateBasis, targetRate, themeRevision, refreshBarMasks, onlyStage]);
|
||||
}, [rows, mode, stage, rateBasis, targetRate, themeRevision, refreshBarMasks, onlyStage, selectedPeriod]);
|
||||
|
||||
const dimmedPeriod = selectedPeriod === lineSelectedPeriod ? undefined : selectedPeriod;
|
||||
|
||||
@@ -1373,7 +1379,7 @@ export function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedP
|
||||
const dimmed = dimmedPeriod != null && mask.period !== dimmedPeriod;
|
||||
return [
|
||||
{ id: `wash-${mask.period}`, type: 'rect', silent: true, z: 2, transition: ['shape'],
|
||||
shape: { x: mask.left, y: mask.top, width: mask.width, height: dimmed ? mask.height : 0 }, style: { fill: surface, opacity: .72 } },
|
||||
shape: { x: mask.left, y: mask.top, width: mask.width, height: dimmed ? mask.height : 0 }, style: { fill: surface, opacity: trendBarPalette(getWorkspaceTheme(document.documentElement.dataset.workspaceTheme).id).wash } },
|
||||
{ id: `focus-${mask.period}`, type: 'rect', silent: true, z: 3, transition: ['style'],
|
||||
shape: { x: mask.left, y: mask.top, width: mask.width, height: mask.height },
|
||||
style: { fill: 'transparent', stroke: 'rgba(137,165,255,.7)', lineWidth: 1, shadowBlur: 11, shadowColor: 'rgba(117,151,255,.26)', opacity: dimmedPeriod === mask.period ? 1 : 0 } },
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import {getWorkspaceTheme,type WorkspaceThemeId} from './ui-themes';
|
||||
export type BarPalette={qualified:string;scrap:string;selectedQualified:string;selectedScrap:string;hoverQualified:string;hoverScrap:string;wash:number};
|
||||
const selected:BarPalette={qualified:'#99A8E3',scrap:'#E49A70',selectedQualified:'#7F92DA',selectedScrap:'#DB8656',hoverQualified:'#6078CE',hoverScrap:'#CD7546',wash:.50};
|
||||
export const blend=(front:string,back:string,alpha:number)=>'#'+[0,2,4].map(offset=>Math.round(parseInt(front.slice(1+offset,3+offset),16)*alpha+parseInt(back.slice(1+offset,3+offset),16)*(1-alpha)).toString(16).padStart(2,'0')).join('').toUpperCase();
|
||||
/** 已确认的 01 轻度加深:沿用各主题蓝色方向及原有交互。 */
|
||||
export function trendBarPalette(themeId:WorkspaceThemeId):BarPalette {
|
||||
const p=selected,theme=getWorkspaceTheme(themeId);
|
||||
if(themeId==='light')return p;
|
||||
if(themeId==='dark'){
|
||||
const qualified='#6076A7';
|
||||
return {...p,qualified,selectedQualified:blend(qualified,'#B8C8FF',.72),hoverQualified:blend(qualified,'#CCD8FF',.60),scrap:'#E6A171',selectedScrap:blend(p.selectedScrap,'#FFD1A6',.56),hoverScrap:blend(p.hoverScrap,'#FFCC9A',.54)};
|
||||
}
|
||||
return {...p,qualified:blend(theme.muted,theme.primary,.76),selectedQualified:blend(theme.muted,theme.primary,.50),hoverQualified:blend(theme.primary,'#263451',.94)};
|
||||
}
|
||||
Reference in New Issue
Block a user