Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2920 feature vtable gantt taskbar position #2970

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "docs: add getTaskBarRelativeRect api #2920\n\n",
"type": "none",
"packageName": "@visactor/vtable"
}
],
"packageName": "@visactor/vtable",
"email": "[email protected]"
}
21 changes: 21 additions & 0 deletions docs/assets/api/en/GanttAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,27 @@ deleteLink: (link: ITaskLink) => void

```

### scrollTop

Get or set the vertical scroll value to a specified position.

### scrollLeft

Get or set the horizontal scroll value to a specified position.

### getTaskBarRelativeRect(Function)

Get the position of the task bar. The position relative to the top-left corner of the Gantt chart.

```
getTaskBarRelativeRect:(index: number) =>{
left: number;
top: number;
width: number;
height: number;
}
```

## Events

The Gantt chart event list allows you to listen to the required events and implement custom business logic as needed.
Expand Down
5 changes: 3 additions & 2 deletions docs/assets/api/en/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ Set the table data interface, which can be called as an update interface.

Basic table updates:

The basic table can also set the sorting status to sort the table data. Set sortState to null to clear the sorting status. If not set, the incoming data will be sorted according to the current sorting status.
The basic table can also set the sorting status to sort the table data. Set sortState to null to clear the sorting status. If not set, the incoming data will be sorted according to the current sorting status.In a scenario where internal sorting is disabled, be sure to clear the current sorting state before invoking the interface.

```
setRecords(
records: Array<any>,
option?: { sortState?: SortState | SortState[]}
option?: { sortState?: SortState | SortState[] | null }
): void;
```

Expand Down Expand Up @@ -1322,6 +1322,7 @@ setCanvasSize: (width: number, height: number) => void;
## setLoadingHierarchyState(Function)

Set the loading state of the tree expansion and collapse of the cell

```
/** Set the loading state of the tree expansion and collapse of the cell */
setLoadingHierarchyState: (col: number, row: number) => void;
Expand Down
21 changes: 21 additions & 0 deletions docs/assets/api/zh/GanttAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,27 @@

```

### scrollTop

竖向滚动到指定位置的滚动值获取或者设置

### scrollLeft

横向滚动到指定位置的滚动值获取或者设置

### getTaskBarRelativeRect(Function)

获取任务条的位置。相对应甘特图表左上角的位置。

```
getTaskBarRelativeRect:(index: number) =>{
left: number;
top: number;
width: number;
height: number;
}
```

## Events

甘特图事件列表,可以根据实际需要,监听所需事件,实现自定义业务。
Expand Down
6 changes: 3 additions & 3 deletions docs/assets/api/zh/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ tableInstance.renderWithRecreateCells();

基本表格更新:

基本表格可同时设置排序状态对表格数据排序,sortState 设置为 null 清空排序状态,如果不设置则按当前排序状态对传入数据排序。
基本表格可同时设置排序状态对表格数据排序,sortState 设置为 null 清空当前的排序状态,如果不设置则按当前排序状态对传入数据排序。如果是禁用内部排序的场景,请务必在调用该接口前清空当前的排序状态

```
setRecords(
records: Array<any>,
option?: { sortState?: SortState | SortState[] }
option?: { sortState?: SortState | SortState[] | null }
): void;
```

Expand Down Expand Up @@ -1319,7 +1319,7 @@ interface ISortedMapItem {

## setLoadingHierarchyState(Function)

设置单元格的树形展开收起状态为 loading
设置单元格的树形展开收起状态为 loading

```
/** 设置单元格的树形展开收起状态为 loading */
Expand Down
31 changes: 31 additions & 0 deletions packages/vtable-gantt/src/Gantt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,4 +828,35 @@ export class Gantt extends EventTarget {
this.scenegraph.updateNextFrame();
}
}
get scrollTop(): number {
return this.stateManager.scrollTop;
}
set scrollTop(value: number) {
this.stateManager.setScrollTop(value);
}
get scrollLeft(): number {
return this.stateManager.scrollLeft;
}
set scrollLeft(value: number) {
this.stateManager.setScrollLeft(value);
}
/** 获取任务条的位置。相对应甘特图表左上角的位置。 */
getTaskBarRelativeRect(index: number) {
const taskBarNode = this.scenegraph.taskBar.getTaskBarNodeByIndex(index);
const left =
taskBarNode.attribute.x +
this.taskListTableInstance.tableNoFrameWidth +
this.taskListTableInstance.tableX +
this.tableX -
this.scrollLeft;
const top = taskBarNode.attribute.y + this.tableY + this.headerHeight - this.scrollTop;
const width = taskBarNode.attribute.width;
const height = taskBarNode.attribute.height;
return {
left,
top,
width,
height
};
}
}
4 changes: 2 additions & 2 deletions packages/vtable/src/ListTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1096,9 +1096,9 @@ export class ListTable extends BaseTable implements ListTableAPI {
/**
* 设置表格数据 及排序状态
* @param records
* @param sort
* @param option 附近参数,其中的sortState为排序状态,如果设置null 将清除目前的排序状态
*/
setRecords(records: Array<any>, option?: { sortState?: SortState | SortState[] }): void {
setRecords(records: Array<any>, option?: { sortState?: SortState | SortState[] | null }): void {
// 释放事件 及 对象
this.internalProps.dataSource?.release();
// 过滤掉dataSource的引用
Expand Down
Loading