Skip to content
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
22 changes: 22 additions & 0 deletions docs/assets/api/en/GanttAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@ Update a specific data record
updateTaskRecord(record: any, task_index: number, sub_task_index: number): void;
```

### getBaselineInfoByTaskListIndex(Function)

Get baseline information (baseline start/end date and baseline days) for the task at the specified list index. If the task has no baseline or it is outside the current date range, the returned dates are `null` and days is `0`.

```
getBaselineInfoByTaskListIndex(
taskShowIndex: number,
sub_task_index?: number | number[]
): {
baselineStartDate: Date | null;
baselineEndDate: Date | null;
baselineDays: number;
}
```

Example:

```
const info = ganttInstance.getBaselineInfoByTaskListIndex(0);
// info.baselineStartDate / info.baselineEndDate / info.baselineDays
```

### release(Function)

Release the Gantt instance
Expand Down
22 changes: 22 additions & 0 deletions docs/assets/api/zh/GanttAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,28 @@ ITimelineScale的类型参考[配置文档]:https://visactor.com/vtable/option/G
updateTaskRecord(record: any, task_index: number, sub_task_index: number): void;
```

### getBaselineInfoByTaskListIndex(Function)

获取指定任务在列表中的基线信息(基线开始/结束日期与基线天数)。当任务未配置基线或超出当前日期范围时,返回的日期为 `null`,天数为 `0`。

```
getBaselineInfoByTaskListIndex(
taskShowIndex: number,
sub_task_index?: number | number[]
): {
baselineStartDate: Date | null;
baselineEndDate: Date | null;
baselineDays: number;
}
```

示例:

```
const info = ganttInstance.getBaselineInfoByTaskListIndex(0);
// info.baselineStartDate / info.baselineEndDate / info.baselineDays
```

### release(Function)

释放 Gantt 实例
Expand Down
190 changes: 190 additions & 0 deletions docs/assets/demo/en/gantt/gantt-baseline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
---
category: examples
group: gantt
title: Gantt Baseline Bar
cover: https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/gantt/gantt-baseline-preview.png
link: gantt/gantt_baseline
option: Gantt#taskBar.baselineStartDateField
---

# Gantt Baseline Bar

This example shows how to configure baselines for tasks and control drawing via `baselinePosition`, and `baselineStyle`. See guide: [Gantt Baseline](../../guide/en/gantt/gantt_baseline).

## Key Options

- `taskBar.baselineStartDateField` / `taskBar.baselineEndDateField`
- `taskBar.baselineStyle`

## Demo

```javascript livedemo template=vtable
// import * as VTableGantt from '@visactor/vtable-gantt';
let ganttInstance;
const records = [
{
id: 1,
title: '项目规划',
developer: '张三',
startDate: '2024-07-05',
endDate: '2024-07-14',
baselineStartDate: '2024-07-01',
baselineEndDate: '2024-07-10',
progress: 80
},
{
id: 2,
title: '需求分析',
developer: '李四',
startDate: '2024-07-08',
endDate: '2024-07-12',
baselineStartDate: '2024-07-03',
baselineEndDate: '2024-07-08',
progress: 100
},
{
id: 3,
title: '设计阶段',
developer: '王五',
startDate: '2024-07-15',
endDate: '2024-07-25',
baselineStartDate: '2024-07-11',
baselineEndDate: '2024-07-20',
progress: 40
},
{
id: 4,
title: '开发阶段',
developer: '赵六',
startDate: '2024-07-20',
endDate: '2024-08-10',
baselineStartDate: '2024-07-18',
baselineEndDate: '2024-08-05',
progress: 30
},
{
id: 5,
title: '测试阶段',
developer: '钱七',
startDate: '2024-08-05',
endDate: '2024-08-20',
baselineStartDate: '2024-08-01',
baselineEndDate: '2024-08-15',
progress: 0
},
{
id: 6,
title: '部署上线',
developer: '孙八',
startDate: '2024-08-18',
endDate: '2024-08-25',
baselineStartDate: '2024-08-15',
baselineEndDate: '2024-08-22',
progress: 0
}
];

const columns = [
{
field: 'title',
title: '任务名称',
width: 180
},
{
field: 'developer',
title: '负责人',
width: 120
},
{
field: 'progress',
title: '进度',
width: 80,
format: (val) => `${val}%`
}
];

const option = {
records,
taskListTable: {
columns: columns,
tableWidth: 'auto',
minTableWidth: 300,
maxTableWidth: 500
},
headerRowHeight: 50,
rowHeight: 90,
taskBar: {
startDateField: 'startDate',
endDateField: 'endDate',
progressField: 'progress',
baselineStartDateField: 'baselineStartDate',
baselineEndDateField: 'baselineEndDate',
// baselinePosition: 'top',
labelText: '{title}',
labelTextStyle: {
fontFamily: 'Arial',
fontSize: 14,
color: '#ffffff'
},
barStyle: {
// paddingTop: 50,
width: 25,
barColor: '#3498db',
completedBarColor: '#27ae60',
cornerRadius: 5
},
baselineStyle: {
// paddingTop: 0,
width: 15,
barColor: 'gray',
cornerRadius: 5
}
},
timelineHeader: {
verticalLine: {
lineWidth: 1,
lineColor: '#e1e4e8'
},
horizontalLine: {
lineWidth: 1,
lineColor: '#e1e4e8'
},
backgroundColor: '#EEF1F5',
colWidth: 50,
scales: [
{
unit: 'month',
step: 1
},
{
unit: 'week',
step: 1,
startOfWeek: 'monday',
format(date) {
return `W${date.dateIndex}`;
}
},
{
unit: 'day',
step: 1,
format(date) {
return date.dateIndex.toString();
}
}
]
},
minDate: '2024-06-25',
maxDate: '2024-09-01',
grid: {
horizontalLine: {
lineWidth: 1,
lineColor: '#e1e4e8'
}
},
overscrollBehavior: 'none'
};
ganttInstance = new VTableGantt.Gantt(document.getElementById(CONTAINER_ID), option);
window['ganttInstance'] = ganttInstance;

```

10 changes: 9 additions & 1 deletion docs/assets/demo/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,14 @@
"en": "Gantt DataZoomAxis Scrollbar"
}
}
,
{
"path": "gantt-baseline",
"title": {
"zh": "甘特图基线任务条",
"en": "Gantt Baseline Bar"
}
}
]
},
{
Expand Down Expand Up @@ -1837,4 +1845,4 @@
]
}
]
}
}
Loading
Loading