Skip to content

Commit 7c7e9c2

Browse files
committed
feat: add barMarkInBar style config in progressbar #3616
1 parent 9a237a0 commit 7c7e9c2

6 files changed

Lines changed: 39 additions & 4 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@visactor/vtable",
5+
"comment": "feat: add barMarkInBar style config in progressbar #3616",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@visactor/vtable"
10+
}

docs/assets/option/en/common/style.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ Progress bar mark width
235235

236236
Progress bar mark position, can be set to `'right' | 'bottom'`, default is `'right'`.
237237

238+
#${prefix} barMarkInBar(boolean)
239+
240+
Progress bar mark shows inside of bar, default is `true`
241+
238242
{{ /if }}
239243

240244
{{ if: ${isCheckbox} }}

docs/assets/option/zh/common/style.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@
236236

237237
进度条标记位置,可设置`'right' | 'bottom'`,默认`'right'`
238238

239+
#${prefix} barMarkInBar(boolean)
240+
241+
进度条标记是否显示在进度条内侧,默认`true`
242+
239243
{{ /if }}
240244

241245
{{ if: ${isCheckbox} }}

packages/vtable/src/body-helper/style/ProgressBarStyle.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class ProgressBarStyle extends Style {
3535
private _barMarkWidth: number;
3636
private _barMarkPosition: 'right' | 'bottom';
3737
private _barRightToLeft: boolean;
38+
private _barMarkInBar: boolean;
3839

3940
static get DEFAULT(): ProgressBarStyle {
4041
return defaultStyle ? defaultStyle : (defaultStyle = new ProgressBarStyle());
@@ -57,6 +58,7 @@ export class ProgressBarStyle extends Style {
5758
this._barMarkWidth = style.barMarkWidth ?? 2;
5859
this._barMarkPosition = style.barMarkPosition ?? 'right';
5960
this._barRightToLeft = style.barRightToLeft ?? false;
61+
this._barMarkInBar = style.barMarkInBar ?? true;
6062
}
6163
get showBar(): boolean | ((args: StylePropertyFunctionArg) => boolean) {
6264
return this._showBar;
@@ -163,6 +165,13 @@ export class ProgressBarStyle extends Style {
163165
this._barRightToLeft = value;
164166
//this.doChangeStyle();
165167
}
168+
get barMarkInBar(): boolean {
169+
return this._barMarkInBar;
170+
}
171+
set barMarkInBar(value: boolean) {
172+
this._barMarkInBar = value;
173+
//this.doChangeStyle();
174+
}
166175
clone(): ProgressBarStyle {
167176
return new ProgressBarStyle(this, null);
168177
}

packages/vtable/src/scenegraph/group-creater/cell-type/progress-bar-cell.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ export function createProgressBarCell(
100100
barMarkPositiveColor,
101101
barMarkNegativeColor,
102102
barMarkWidth,
103-
barMarkPosition
103+
barMarkPosition,
104+
barMarkInBar
104105
} = style;
105106
let { barHeight, barBottom, barPadding } = style;
106107
// const { col, row, dataValue: originalValue } = context;
@@ -128,9 +129,14 @@ export function createProgressBarCell(
128129

129130
const borderWidth = getQuadProps(getProp('borderLineWidth', style, col, row, table));
130131
const barPaddingTop = Math.max((barPadding as number[])[0], Math.ceil(borderWidth[0] / 2));
131-
const barPaddingRight = Math.max((barPadding as number[])[1], Math.floor(borderWidth[1] / 2));
132+
let barPaddingRight = Math.max((barPadding as number[])[1], Math.floor(borderWidth[1] / 2));
132133
const barPaddingBottom = Math.max((barPadding as number[])[2], Math.floor(borderWidth[2] / 2));
133-
const barPaddingLeft = Math.max((barPadding as number[])[3], Math.ceil(borderWidth[3] / 2));
134+
let barPaddingLeft = Math.max((barPadding as number[])[3], Math.ceil(borderWidth[3] / 2));
135+
136+
if (showBarMark && barMarkWidth > 0 && barMarkPosition === 'right' && barMarkInBar === false) {
137+
barPaddingRight += barMarkWidth;
138+
barPaddingLeft += barMarkWidth;
139+
}
134140

135141
contentWidth -= barPaddingRight + barPaddingLeft;
136142
contentHeight -= barPaddingBottom + barPaddingTop;
@@ -395,7 +401,7 @@ export function createProgressBarCell(
395401
if (barMarkPosition === 'right') {
396402
const markLeft = barRightToLeft
397403
? barRectPosi.left + barMarkWidth / 2
398-
: barRectPosi.left + barRectPosi.width - barMarkWidth / 2;
404+
: barRectPosi.left + barRectPosi.width + (barMarkInBar ? -barMarkWidth / 2 : barMarkWidth / 2);
399405
points.push({ x: markLeft, y: barRectPosi.top });
400406
points.push({ x: markLeft, y: barRectPosi.top + barRectPosi.height });
401407
} else if (barMarkPosition === 'bottom') {

packages/vtable/src/ts-types/column/style.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ export interface ProgressBarStyleOption extends IStyleOption {
180180
barMarkWidth?: number;
181181
// 进度条标记位置
182182
barMarkPosition?: 'right' | 'bottom';
183+
// 进度条标记是否在进度条内
184+
barMarkInBar?: boolean;
183185
}
184186

185187
export type CheckboxStyleOption = {

0 commit comments

Comments
 (0)