diff --git a/packages/vtable/examples/pivot/pivot-basic.ts b/packages/vtable/examples/pivot/pivot-basic.ts index a202d1691..14feb6c0a 100644 --- a/packages/vtable/examples/pivot/pivot-basic.ts +++ b/packages/vtable/examples/pivot/pivot-basic.ts @@ -15,7 +15,7 @@ function generatePivotDataSource(num, colCount) { return array; } const DEFAULT_BAR_COLOR = data => { - const num = (data.rate ?? 0) * 100; + const num = (data.percentile ?? 0) * 100; if (num > 80) { return '#20a8d8'; } @@ -216,8 +216,8 @@ export function createTable() { // barBgColor: '#aaa', // barColor: '#444', barBgColor: data => { - return `rgb(${100 + 100 * (1 - (data.rate ?? 0))},${100 + 100 * (1 - (data.rate ?? 0))},${ - 255 * (1 - (data.rate ?? 0)) + return `rgb(${100 + 100 * (1 - (data.percentile ?? 0))},${100 + 100 * (1 - (data.percentile ?? 0))},${ + 255 * (1 - (data.percentile ?? 0)) })`; }, barColor: 'transparent' diff --git a/packages/vtable/examples/pivot/pivot-header-title.ts b/packages/vtable/examples/pivot/pivot-header-title.ts index fc9dbbaac..e4ea270cf 100644 --- a/packages/vtable/examples/pivot/pivot-header-title.ts +++ b/packages/vtable/examples/pivot/pivot-header-title.ts @@ -14,7 +14,7 @@ function generatePivotDataSource(num, colCount) { return array; } const DEFAULT_BAR_COLOR = data => { - const num = (data.rate ?? 0) * 100; + const num = (data.percentile ?? 0) * 100; if (num > 80) { return '#20a8d8'; } @@ -215,8 +215,8 @@ export function createTable() { // barBgColor: '#aaa', // barColor: '#444', barBgColor: data => { - return `rgb(${100 + 100 * (1 - (data.rate ?? 0))},${100 + 100 * (1 - (data.rate ?? 0))},${ - 255 * (1 - (data.rate ?? 0)) + return `rgb(${100 + 100 * (1 - (data.percentile ?? 0))},${100 + 100 * (1 - (data.percentile ?? 0))},${ + 255 * (1 - (data.percentile ?? 0)) })`; }, barColor: 'transparent' diff --git a/packages/vtable/examples/stack-text/stack-pivot.ts b/packages/vtable/examples/stack-text/stack-pivot.ts index 5ec2c43a1..e05ba8092 100644 --- a/packages/vtable/examples/stack-text/stack-pivot.ts +++ b/packages/vtable/examples/stack-text/stack-pivot.ts @@ -14,7 +14,7 @@ function generatePivotDataSource(num, colCount) { return array; } const DEFAULT_BAR_COLOR = data => { - const num = (data.rate ?? 0) * 100; + const num = (data.percentile ?? 0) * 100; if (num > 80) { return '#20a8d8'; } @@ -188,8 +188,8 @@ export function createTable() { // barBgColor: '#aaa', // barColor: '#444', barBgColor: data => { - return `rgb(${100 + 100 * (1 - (data.rate ?? 0))},${100 + 100 * (1 - (data.rate ?? 0))},${ - 255 * (1 - (data.rate ?? 0)) + return `rgb(${100 + 100 * (1 - (data.percentile ?? 0))},${100 + 100 * (1 - (data.percentile ?? 0))},${ + 255 * (1 - (data.percentile ?? 0)) })`; }, barColor: 'transparent' diff --git a/packages/vtable/examples/style/auto-wrap-text.ts b/packages/vtable/examples/style/auto-wrap-text.ts index fc46f531f..3b9fafb86 100644 --- a/packages/vtable/examples/style/auto-wrap-text.ts +++ b/packages/vtable/examples/style/auto-wrap-text.ts @@ -14,7 +14,7 @@ function generatePivotDataSource(num, colCount) { return array; } const DEFAULT_BAR_COLOR = data => { - const num = data.rate * 100; + const num = data.percentile * 100; if (num > 80) { return '#20a8d8'; } @@ -333,7 +333,9 @@ export function createTable() { // barBgColor: '#aaa', // barColor: '#444', barBgColor: data => { - return `rgb(${100 + 100 * (1 - data.rate)},${100 + 100 * (1 - data.rate)},${255 * (1 - data.rate)})`; + return `rgb(${100 + 100 * (1 - data.percentile)},${100 + 100 * (1 - data.percentile)},${ + 255 * (1 - data.percentile) + })`; }, barColor: 'transparent', autoWrapText: true diff --git a/packages/vtable/examples/style/function.ts b/packages/vtable/examples/style/function.ts index be1e5871b..20e0ac569 100644 --- a/packages/vtable/examples/style/function.ts +++ b/packages/vtable/examples/style/function.ts @@ -14,7 +14,7 @@ function generatePivotDataSource(num, colCount) { return array; } const DEFAULT_BAR_COLOR = data => { - const num = data.rate * 100; + const num = data.percentile * 100; if (num > 80) { return '#20a8d8'; } @@ -340,7 +340,9 @@ export function createTable() { // barBgColor: '#aaa', // barColor: '#444', barBgColor: data => { - return `rgb(${100 + 100 * (1 - data.rate)},${100 + 100 * (1 - data.rate)},${255 * (1 - data.rate)})`; + return `rgb(${100 + 100 * (1 - data.percentile)},${100 + 100 * (1 - data.percentile)},${ + 255 * (1 - data.percentile) + })`; }, barColor: 'transparent' }), diff --git a/packages/vtable/examples/type/progress-bar.ts b/packages/vtable/examples/type/progress-bar.ts index 1f485e8b1..de373e6dd 100644 --- a/packages/vtable/examples/type/progress-bar.ts +++ b/packages/vtable/examples/type/progress-bar.ts @@ -78,8 +78,8 @@ export function createTable() { // barBgColor: '#aaa', // barColor: '#444', barBgColor: data => { - return `rgb(${100 + 100 * (1 - Number(data.rate))},${100 + 100 * (1 - Number(data.rate))},${ - 255 * (1 - Number(data.rate)) + return `rgb(${100 + 100 * (1 - Number(data.percentile))},${100 + 100 * (1 - Number(data.percentile))},${ + 255 * (1 - Number(data.percentile)) })`; }, barColor: 'transparent' @@ -91,8 +91,8 @@ export function createTable() { width: 120, columnType: 'progressbar', style: { - barBgColor: data => (Number(data.rate) > 0.5 ? '#faa' : '#aaa'), - barColor: data => (Number(data.rate) > 0.5 ? '#f44' : '#444') + barBgColor: data => (Number(data.percentile) > 0.5 ? '#faa' : '#aaa'), + barColor: data => (Number(data.percentile) > 0.5 ? '#f44' : '#444') } }, { diff --git a/packages/vtable/src/scenegraph/group-creater/cell-type/progress-bar-cell.ts b/packages/vtable/src/scenegraph/group-creater/cell-type/progress-bar-cell.ts index 0eeb8f011..5cf57af98 100644 --- a/packages/vtable/src/scenegraph/group-creater/cell-type/progress-bar-cell.ts +++ b/packages/vtable/src/scenegraph/group-creater/cell-type/progress-bar-cell.ts @@ -134,7 +134,7 @@ export function createProgressBarCell( } if ((progressBarDefine.barType ?? 'default') === 'default') { - const rate = + const percentile = num < progressBarDefine.min ? 0 : num > progressBarDefine.max @@ -152,7 +152,7 @@ export function createProgressBarCell( context: null, value, dataValue, - rate + percentile }); if (bgFillColor) { @@ -166,7 +166,7 @@ export function createProgressBarCell( percentCompleteBarGroup.addChild(barBack); } - const barSize = Math.min(barMaxWidth * rate, barMaxWidth); + const barSize = Math.min(barMaxWidth * percentile, barMaxWidth); const fillColor = getOrApply(barColor as any, { col, @@ -175,7 +175,7 @@ export function createProgressBarCell( context: null, value, dataValue, - rate + percentile }) || '#20a8d8'; const barMain = createRect({ x: barLeft, @@ -210,7 +210,7 @@ export function createProgressBarCell( context: null, value, dataValue, - rate: positiveRate + percentile: positiveRate }); if (bgFillColor) { const barBack = createRect({ @@ -249,7 +249,7 @@ export function createProgressBarCell( context: null, value, dataValue, - rate: negativeRate + percentile: negativeRate }) || '#20a8d8'; const barNega = createRect({ x: barRectNega.left, @@ -283,7 +283,7 @@ export function createProgressBarCell( context: null, value, dataValue, - rate: positiveRate + percentile: positiveRate }) || '#20a8d8'; const barPosi = createRect({ x: barRectPosi.left, @@ -324,7 +324,7 @@ export function createProgressBarCell( context: null, value, dataValue, - rate: positiveRate + percentile: positiveRate }) || '#20a8d8'; if (barMarkPosition === 'right') { const markLeft = barRightToLeft @@ -351,7 +351,7 @@ export function createProgressBarCell( context: null, value, dataValue, - rate: negativeRate + percentile: negativeRate }) || '#20a8d8'; if (barMarkPosition === 'right') { const markLeft = barRightToLeft @@ -387,12 +387,12 @@ export function createProgressBarCell( const range = Math.max(_negativeRange, _positiveRange); // 计算rate - const rate = range === 0 ? 0 : Math.abs(num) / range; + const percentile = range === 0 ? 0 : Math.abs(num) / range; // 绘制 // 绘制背景 const barMaxWidth = width - barPaddingLeft - barPaddingRight - 1; /*罫線*/ - const barSize = Math.min(barMaxWidth * rate, barMaxWidth); + const barSize = Math.min(barMaxWidth * percentile, barMaxWidth); const barTop = bottom - barPaddingBottom - (barHeight as number) - (barBottom as number) - 1; /*罫線*/ const barLeft = barRightToLeft ? right - barPaddingRight - barSize : left + barPaddingLeft; const barBgFillColor = @@ -403,7 +403,7 @@ export function createProgressBarCell( context: null, value, dataValue, - rate + percentile }) || '#f0f3f5'; const barBg = createRect({ x: barLeft, @@ -430,7 +430,7 @@ export function createProgressBarCell( table, context: null, value, - rate, + percentile, dataValue }) || '#20a8d8'; } else { @@ -442,7 +442,7 @@ export function createProgressBarCell( context: null, value, dataValue, - rate + percentile }) || '#20a8d8'; } const bar = createRect({ @@ -468,7 +468,7 @@ export function createProgressBarCell( context: null, value, dataValue, - rate + percentile }) || '#20a8d8'; } else { barMarkStrokeColor = @@ -479,7 +479,7 @@ export function createProgressBarCell( context: null, value, dataValue, - rate + percentile }) || '#20a8d8'; } if (barMarkPosition === 'right') { diff --git a/packages/vtable/src/ts-types/style-define.ts b/packages/vtable/src/ts-types/style-define.ts index 37cd06585..a85f475d6 100644 --- a/packages/vtable/src/ts-types/style-define.ts +++ b/packages/vtable/src/ts-types/style-define.ts @@ -16,7 +16,7 @@ export interface StylePropertyFunctionArg { /**原始值 */ dataValue: string; /** progressbar类型特有,表示当前数值在总体数据范围的比例 */ - rate?: number; + percentile?: number; /** 单元格的表头路径信息 */ cellHeaderPaths: ICellHeaderPaths; }