@worktile/gantt 12.0.0 → 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.all-contributorsrc +53 -0
- package/.angulardoc.json +4 -0
- package/.circleci/config.yml +17 -0
- package/.coveralls.yml +1 -0
- package/.docgenirc.js +64 -0
- package/.editorconfig +22 -0
- package/.prettierrc +24 -0
- package/.travis.yml +23 -0
- package/CHANGELOG.md +564 -0
- package/Dockerfile +4 -0
- package/LICENSE +21 -0
- package/README.md +116 -13
- package/angular.json +136 -0
- package/docs/guides/basic/components.md +54 -0
- package/docs/guides/basic/event.md +70 -0
- package/docs/guides/basic/index.md +4 -0
- package/docs/guides/basic/style.md +68 -0
- package/docs/guides/basic/type.md +70 -0
- package/docs/guides/basic/usage.md +189 -0
- package/docs/guides/index.md +5 -0
- package/docs/guides/intro/getting-started.md +79 -0
- package/docs/guides/intro/index.md +51 -0
- package/docs/index.md +0 -0
- package/example/browserslist +12 -0
- package/example/src/app/app-routing.module.ts +26 -0
- package/example/src/app/app.component.html +2 -0
- package/example/src/app/app.component.ts +11 -0
- package/example/src/app/app.module.ts +57 -0
- package/example/src/app/components/components.component.html +6 -0
- package/example/src/app/components/components.component.ts +33 -0
- package/example/src/app/configuration/parameters/api/zh-cn.js +350 -0
- package/example/src/app/configuration/parameters/doc/zh-cn.md +5 -0
- package/example/src/app/gantt/gantt.component.html +51 -0
- package/example/src/app/gantt/gantt.component.ts +119 -0
- package/example/src/app/gantt-advanced/component/flat.component.html +30 -0
- package/example/src/app/gantt-advanced/component/flat.component.ts +72 -0
- package/example/src/app/gantt-advanced/component/flat.scss +31 -0
- package/example/src/app/gantt-advanced/gantt-advanced.component.html +32 -0
- package/example/src/app/gantt-advanced/gantt-advanced.component.ts +34 -0
- package/example/src/app/gantt-advanced/mocks.ts +158 -0
- package/example/src/app/gantt-groups/gantt-groups.component.html +42 -0
- package/example/src/app/gantt-groups/gantt-groups.component.ts +62 -0
- package/example/src/app/gantt-range/gantt-range.component.html +66 -0
- package/example/src/app/gantt-range/gantt-range.component.ts +67 -0
- package/example/src/app/gantt-range/mocks.ts +150 -0
- package/example/src/app/helper.ts +38 -0
- package/example/src/assets/.gitkeep +0 -0
- package/example/src/environments/environment.prod.ts +3 -0
- package/example/src/environments/environment.ts +16 -0
- package/example/src/favicon.ico +0 -0
- package/example/src/index.html +13 -0
- package/example/src/main.ts +12 -0
- package/example/src/polyfills.ts +63 -0
- package/example/src/styles.scss +56 -0
- package/example/tsconfig.app.json +18 -0
- package/nginx.conf +17 -0
- package/package.json +113 -17
- package/packages/gantt/README.md +24 -0
- package/packages/gantt/karma.conf.js +46 -0
- package/packages/gantt/ng-package.json +7 -0
- package/packages/gantt/ng-package.prod.json +7 -0
- package/packages/gantt/package.json +16 -0
- package/packages/gantt/src/class/date-point.ts +14 -0
- package/{class/event.d.ts → packages/gantt/src/class/event.ts} +12 -6
- package/packages/gantt/src/class/group.ts +36 -0
- package/{class/index.d.ts → packages/gantt/src/class/index.ts} +0 -0
- package/packages/gantt/src/class/item.ts +129 -0
- package/packages/gantt/src/class/test/group.spec.ts +21 -0
- package/packages/gantt/src/class/test/item.spec.ts +102 -0
- package/packages/gantt/src/class/view-type.ts +7 -0
- package/packages/gantt/src/components/bar/bar-drag.ts +298 -0
- package/packages/gantt/src/components/bar/bar.component.html +17 -0
- package/packages/gantt/src/components/bar/bar.component.scss +169 -0
- package/packages/gantt/src/components/bar/bar.component.ts +109 -0
- package/packages/gantt/src/components/bar/test/bar.component.spec.ts +54 -0
- package/packages/gantt/src/components/bar/test/bar.drag.spec.ts +196 -0
- package/packages/gantt/src/components/calendar/calendar.component.html +52 -0
- package/packages/gantt/src/components/calendar/calendar.component.scss +77 -0
- package/packages/gantt/src/components/calendar/calendar.component.ts +100 -0
- package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.html +6 -0
- package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.scss +48 -0
- package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.ts +13 -0
- package/packages/gantt/src/components/icon/icon.component.scss +13 -0
- package/packages/gantt/src/components/icon/icon.component.ts +28 -0
- package/packages/gantt/src/components/icon/icons.ts +86 -0
- package/packages/gantt/src/components/links/links.component.html +19 -0
- package/packages/gantt/src/components/links/links.component.scss +27 -0
- package/packages/gantt/src/components/links/links.component.ts +263 -0
- package/packages/gantt/src/components/main/gantt-main.component.html +35 -0
- package/packages/gantt/src/components/main/gantt-main.component.ts +35 -0
- package/packages/gantt/src/components/range/range.component.html +8 -0
- package/packages/gantt/src/components/range/range.component.scss +35 -0
- package/packages/gantt/src/components/range/range.component.ts +27 -0
- package/packages/gantt/src/components/range/test/range.component.spec.ts +80 -0
- package/packages/gantt/src/components/table/gantt-table.component.html +105 -0
- package/packages/gantt/src/components/table/gantt-table.component.scss +144 -0
- package/packages/gantt/src/components/table/gantt-table.component.ts +166 -0
- package/packages/gantt/src/components/table/test/table.spec.ts +129 -0
- package/packages/gantt/src/gantt-abstract.ts +14 -0
- package/packages/gantt/src/gantt-dom.service.ts +134 -0
- package/packages/gantt/src/gantt-drag-container.ts +73 -0
- package/packages/gantt/src/gantt-item-upper.ts +50 -0
- package/packages/gantt/src/gantt-print.service.ts +104 -0
- package/packages/gantt/src/gantt-upper.ts +289 -0
- package/packages/gantt/src/gantt.component.html +18 -0
- package/packages/gantt/src/gantt.component.scss +77 -0
- package/packages/gantt/src/gantt.component.ts +134 -0
- package/packages/gantt/src/gantt.module.ts +47 -0
- package/packages/gantt/src/gantt.pipe.ts +31 -0
- package/packages/gantt/src/gantt.styles.ts +28 -0
- package/{public-api.d.ts → packages/gantt/src/public-api.ts} +6 -0
- package/packages/gantt/src/root.component.html +12 -0
- package/packages/gantt/src/root.component.ts +121 -0
- package/packages/gantt/src/styles/index.scss +9 -0
- package/packages/gantt/src/styles/variables.scss +46 -0
- package/packages/gantt/src/table/gantt-column.component.ts +25 -0
- package/packages/gantt/src/table/gantt-table.component.ts +14 -0
- package/packages/gantt/src/table/test/table.spec.ts +56 -0
- package/packages/gantt/src/test/gantt.component.spec.ts +404 -0
- package/packages/gantt/src/test/mocks/data.ts +303 -0
- package/packages/gantt/src/test.ts +21 -0
- package/packages/gantt/src/utils/date.ts +276 -0
- package/packages/gantt/src/utils/helpers.ts +66 -0
- package/packages/gantt/src/utils/test/date.spec.ts +105 -0
- package/packages/gantt/src/utils/test/helpers.spec.ts +73 -0
- package/packages/gantt/src/utils/testing.ts +64 -0
- package/packages/gantt/src/views/day.ts +74 -0
- package/packages/gantt/src/views/factory.ts +25 -0
- package/packages/gantt/src/views/month.ts +66 -0
- package/packages/gantt/src/views/quarter.ts +68 -0
- package/packages/gantt/src/views/test/day.spec.ts +45 -0
- package/packages/gantt/src/views/test/factory.spec.ts +41 -0
- package/packages/gantt/src/views/test/mock.ts +14 -0
- package/packages/gantt/src/views/test/month.spec.ts +45 -0
- package/packages/gantt/src/views/test/quarter.spec.ts +45 -0
- package/packages/gantt/src/views/test/view.spec.ts +144 -0
- package/packages/gantt/src/views/test/week.spec.ts +45 -0
- package/packages/gantt/src/views/test/year.spec.ts +45 -0
- package/packages/gantt/src/views/view.ts +186 -0
- package/packages/gantt/src/views/week.ts +66 -0
- package/packages/gantt/src/views/year.ts +62 -0
- package/packages/gantt/tsconfig.lib.json +20 -0
- package/packages/gantt/tsconfig.lib.prod.json +9 -0
- package/packages/gantt/tsconfig.schematics.json +25 -0
- package/packages/gantt/tsconfig.spec.json +17 -0
- package/packages/gantt/tslint.json +18 -0
- package/scss-bundle.config.json +7 -0
- package/tsconfig.json +26 -0
- package/tslint.json +51 -0
- package/bundles/worktile-gantt.umd.js +0 -3128
- package/bundles/worktile-gantt.umd.js.map +0 -1
- package/class/date-point.d.ts +0 -15
- package/class/group.d.ts +0 -22
- package/class/item.d.ts +0 -70
- package/class/view-type.d.ts +0 -7
- package/components/bar/bar-drag.d.ts +0 -34
- package/components/bar/bar.component.d.ts +0 -23
- package/components/calendar/calendar.component.d.ts +0 -25
- package/components/drag-backdrop/drag-backdrop.component.d.ts +0 -6
- package/components/icon/icon.component.d.ts +0 -10
- package/components/icon/icons.d.ts +0 -8
- package/components/links/links.component.d.ts +0 -44
- package/components/main/gantt-main.component.d.ts +0 -18
- package/components/range/range.component.d.ts +0 -10
- package/components/table/gantt-table.component.d.ts +0 -31
- package/esm2015/class/date-point.js +0 -10
- package/esm2015/class/event.js +0 -13
- package/esm2015/class/group.js +0 -17
- package/esm2015/class/index.js +0 -6
- package/esm2015/class/item.js +0 -78
- package/esm2015/class/view-type.js +0 -9
- package/esm2015/components/bar/bar-drag.js +0 -266
- package/esm2015/components/bar/bar.component.js +0 -91
- package/esm2015/components/calendar/calendar.component.js +0 -82
- package/esm2015/components/drag-backdrop/drag-backdrop.component.js +0 -18
- package/esm2015/components/icon/icon.component.js +0 -36
- package/esm2015/components/icon/icons.js +0 -87
- package/esm2015/components/links/links.component.js +0 -207
- package/esm2015/components/main/gantt-main.component.js +0 -35
- package/esm2015/components/range/range.component.js +0 -32
- package/esm2015/components/table/gantt-table.component.js +0 -125
- package/esm2015/gantt-dom.service.js +0 -101
- package/esm2015/gantt-drag-container.js +0 -57
- package/esm2015/gantt-item-upper.js +0 -55
- package/esm2015/gantt-print.service.js +0 -92
- package/esm2015/gantt-upper.js +0 -231
- package/esm2015/gantt.component.js +0 -105
- package/esm2015/gantt.module.js +0 -43
- package/esm2015/gantt.pipe.js +0 -33
- package/esm2015/gantt.styles.js +0 -15
- package/esm2015/public-api.js +0 -16
- package/esm2015/root.component.js +0 -111
- package/esm2015/table/gantt-column.component.js +0 -28
- package/esm2015/table/gantt-table.component.js +0 -18
- package/esm2015/utils/date.js +0 -160
- package/esm2015/utils/helpers.js +0 -45
- package/esm2015/views/day.js +0 -54
- package/esm2015/views/factory.js +0 -23
- package/esm2015/views/month.js +0 -48
- package/esm2015/views/quarter.js +0 -51
- package/esm2015/views/view.js +0 -121
- package/esm2015/views/week.js +0 -49
- package/esm2015/views/year.js +0 -50
- package/esm2015/worktile-gantt.js +0 -16
- package/fesm2015/worktile-gantt.js +0 -2488
- package/fesm2015/worktile-gantt.js.map +0 -1
- package/gantt-dom.service.d.ts +0 -29
- package/gantt-drag-container.d.ts +0 -20
- package/gantt-item-upper.d.ts +0 -17
- package/gantt-print.service.d.ts +0 -10
- package/gantt-upper.d.ts +0 -62
- package/gantt.component.d.ts +0 -28
- package/gantt.module.d.ts +0 -2
- package/gantt.pipe.d.ts +0 -11
- package/gantt.styles.d.ts +0 -15
- package/main.bundle.scss +0 -645
- package/root.component.d.ts +0 -25
- package/table/gantt-column.component.d.ts +0 -12
- package/table/gantt-table.component.d.ts +0 -7
- package/utils/date.d.ts +0 -59
- package/utils/helpers.d.ts +0 -11
- package/views/day.d.ts +0 -14
- package/views/factory.d.ts +0 -8
- package/views/month.d.ts +0 -12
- package/views/quarter.d.ts +0 -12
- package/views/view.d.ts +0 -56
- package/views/week.d.ts +0 -12
- package/views/year.d.ts +0 -12
- package/worktile-gantt.d.ts +0 -15
- package/worktile-gantt.metadata.json +0 -1
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 如何使用
|
|
3
|
+
path: usage
|
|
4
|
+
order: 10
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 基本使用
|
|
8
|
+
|
|
9
|
+
一般情况下最基本的使用我们只需要定义 `items` 数据传入组件中,如需要左侧的表格展示,则还需要定义表格的 column
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ngx-gantt #gantt [items]="items">
|
|
13
|
+
<ngx-gantt-table>
|
|
14
|
+
<ngx-gantt-column name="标题" width="300px">
|
|
15
|
+
<ng-template #cell let-item="item"> {{ item.title }} </ng-template>
|
|
16
|
+
</ngx-gantt-column>
|
|
17
|
+
</ngx-gantt-table>
|
|
18
|
+
</ngx-gantt>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
export class AppGanttExampleComponent {
|
|
23
|
+
items: GanttItem[] = [
|
|
24
|
+
{ id: '000000', title: 'Task 0', start: 1627729997, end: 1628421197, expandable: true },
|
|
25
|
+
{ id: '000001', title: 'Task 1', start: 1617361997, end: 1625483597, links: ['000003', '000004', '000000'], expandable: true },
|
|
26
|
+
{ id: '000002', title: 'Task 2', start: 1610536397, end: 1610622797 },
|
|
27
|
+
{ id: '000003', title: 'Task 3', start: 1628507597, end: 1633345997, expandable: true }
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 如何设置分组
|
|
33
|
+
|
|
34
|
+
分组模式下我们还需要传入一个 `groups` 的数组,并且保证我们传入的 `items` 数据中设置了每个数据项的 `group_id`
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<ngx-gantt #gantt [groups]="groups" [items]="items">
|
|
38
|
+
<ngx-gantt-table>
|
|
39
|
+
<ngx-gantt-column name="标题" width="300px">
|
|
40
|
+
<ng-template #cell let-item="item"> {{ item.title }} </ng-template>
|
|
41
|
+
</ngx-gantt-column>
|
|
42
|
+
</ngx-gantt-table>
|
|
43
|
+
</ngx-gantt>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
export class AppGanttExampleComponent {
|
|
48
|
+
groups: GanttGroup[] = [
|
|
49
|
+
{ id: '000000', title: 'Group-0' },
|
|
50
|
+
{ id: '000001', title: 'Group-1' }
|
|
51
|
+
];
|
|
52
|
+
items: GanttItem[] = [
|
|
53
|
+
{ id: '000000', title: 'Task 0', start: 1627729997, end: 1628421197, group_id: '000000' },
|
|
54
|
+
{ id: '000001', title: 'Task 1', start: 1617361997, end: 1625483597, group_id: '000001' }
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 树形结构展示
|
|
60
|
+
|
|
61
|
+
`GanttItem` 类型包含 `children` 属性,默认情况下只要我们传入了 `children` 属性则就就会展示为树形结构。
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
export class AppGanttExampleComponent {
|
|
65
|
+
items: GanttItem[] = [
|
|
66
|
+
{
|
|
67
|
+
id: '000000',
|
|
68
|
+
title: 'Task 0',
|
|
69
|
+
children: [
|
|
70
|
+
{ id: '000000-01', title: 'Task 0-1' },
|
|
71
|
+
{ id: '000000-02', title: 'Task 0-2' }
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
如果需要异步加载子数据,我们需要设置将组件的 `async` 设置为 `true` 然后设置加载子数据的 Resolve 函数 `childrenResolve`,最后我们还需要指定哪些数据是可展开的。
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<ngx-gantt #gantt [items]="items" [async]="true" [childrenResolve]="childrenResolve"> ... </ngx-gantt>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
export class AppGanttExampleComponent {
|
|
86
|
+
// 设置 expandable 为true 指定数据是可展开的
|
|
87
|
+
items: GanttItem[] = [
|
|
88
|
+
{ id: '000000', title: 'Task 0', start: 1627729997, end: 1628421197, expandable: true },
|
|
89
|
+
{ id: '000001', title: 'Task 1', start: 1617361997, end: 1625483597, expandable: true }
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
// 设置加载子数据的 Resolve 函数,返回值必须是一个可观察对象 Observable
|
|
93
|
+
childrenResolve = (item: GanttItem) => {
|
|
94
|
+
const children = randomItems(random(1, 5), item);
|
|
95
|
+
return of(children).pipe(delay(1000));
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 依赖
|
|
101
|
+
|
|
102
|
+
如果我们需要展示数据项的依赖关系,则需要设置 `GanttItem` 中的 `links` 属性,设置需要关联的 id,如果需要拖拽创建关联关系,则需要设置 `[linkable] = true`,在某些场景下可能我们需要设置某一条数据开启拖拽创建关联,我们也可以通过设置 item 数据的 `linkable` 来实现。
|
|
103
|
+
|
|
104
|
+
```html
|
|
105
|
+
<ngx-gantt #gantt [items]="items" [linkable]="true" (linkDragEnded)="linkDragEnded($event)"> ... </ngx-gantt>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
export class AppGanttExampleComponent {
|
|
110
|
+
items: GanttItem[] = [
|
|
111
|
+
{ id: '000000', title: 'Task 0', start: 1627729997, end: 1628421197, links: ['000001', '000002'] },
|
|
112
|
+
{ id: '000001', title: 'Task 1', start: 1617361997, end: 1625483597, links: ['000003'] },
|
|
113
|
+
{ id: '000002', title: 'Task 2', start: 1617361997, end: 1625483597, linkable: false }
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
linkDragEnded($event: GanttLinkDragEvent) {
|
|
117
|
+
this.http
|
|
118
|
+
.post(`/api/item/deps`, {
|
|
119
|
+
source: event.source,
|
|
120
|
+
target: event.target
|
|
121
|
+
})
|
|
122
|
+
.subscribe((items) => {});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## 滚动加载
|
|
128
|
+
|
|
129
|
+
为了保证组件的性能,默认情况下只会展示一定周期的时间(不同的视图周期不同),所以组件默认开启了滚动加载。如果不需要滚动加载可以通过设置 `[disabledLoadOnScroll]=true` 来禁用。
|
|
130
|
+
|
|
131
|
+
```html
|
|
132
|
+
<ngx-gantt #gantt [items]="items" (loadOnScroll)="loadOnScroll($event)"> ... </ngx-gantt>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
export class AppGanttExampleComponent {
|
|
137
|
+
items: GanttItem[] = [
|
|
138
|
+
{ id: '000000', title: 'Task 0', start: 1627729997, end: 1628421197 },
|
|
139
|
+
{ id: '000001', title: 'Task 1', start: 1617361997, end: 1625483597 },
|
|
140
|
+
{ id: '000002', title: 'Task 2', start: 1617361997, end: 1625483597 }
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
loadOnScroll(event: GanttLoadOnScrollEvent) {
|
|
144
|
+
this.http.get(`/api/items?start=${event.start}&end=${event.end}`).subscribe((items) => {
|
|
145
|
+
this.items = [...this.items, ...items];
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## 拖拽
|
|
152
|
+
|
|
153
|
+
通过设置 `[draggable]=true` 来启用拖拽功能,支持 `(dragStarted)`、`(dragEnded)` 事件。
|
|
154
|
+
|
|
155
|
+
```html
|
|
156
|
+
<ngx-gantt #gantt [items]="items" [draggable]="true" (dragEnded)="dragEnded($event)"> ... </ngx-gantt>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
```javascript
|
|
160
|
+
export class AppGanttExampleComponent {
|
|
161
|
+
dragEnded($event: GanttDragEvent) {
|
|
162
|
+
this.http
|
|
163
|
+
.put(`/api/item/${$event.item.id}`, {
|
|
164
|
+
start: $event.item.start,
|
|
165
|
+
end: $event.item.end
|
|
166
|
+
})
|
|
167
|
+
.subscribe((items) => {});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## 导出为图片
|
|
173
|
+
|
|
174
|
+
如需要导出图片功能,我们需要在使用组件时注入图片打印服务 `GanttPrintService`
|
|
175
|
+
|
|
176
|
+
```javascript
|
|
177
|
+
@Component({
|
|
178
|
+
selector: 'app-gantt-example',
|
|
179
|
+
templateUrl: './gantt.component.html',
|
|
180
|
+
providers: [GanttPrintService]
|
|
181
|
+
})
|
|
182
|
+
export class AppGanttExampleComponent {
|
|
183
|
+
@ViewChild('gantt') ganttComponent: NgxGanttComponent;
|
|
184
|
+
|
|
185
|
+
exportImage() {
|
|
186
|
+
ganttComponent.print('image name');
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 快速开始
|
|
3
|
+
path: 'getting-started'
|
|
4
|
+
order: 2
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 安装
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
$ npm i @worktile/gantt --save
|
|
11
|
+
# or
|
|
12
|
+
$ yarn add @worktile/gantt
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
# 使用
|
|
16
|
+
|
|
17
|
+
### 导入模块
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { NgModule } from '@angular/core';
|
|
21
|
+
import { NgxGanttModule } from '@worktile/gantt';
|
|
22
|
+
|
|
23
|
+
@NgModule({
|
|
24
|
+
...
|
|
25
|
+
imports: [ NgxGanttModule, ... ]
|
|
26
|
+
...
|
|
27
|
+
})
|
|
28
|
+
export class AppModule {
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
<br/>
|
|
34
|
+
|
|
35
|
+
### 引入样式
|
|
36
|
+
在 angular.json 中引入
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"styles": [
|
|
40
|
+
"node_modules/@worktile/gantt/main.bundle.scss"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
在style.scss中引入预构建样式文件
|
|
45
|
+
```
|
|
46
|
+
@import "~@worktile/gantt/main.bundle.scss";
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 组件中使用
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<!-- component.html -->
|
|
54
|
+
<ngx-gantt #gantt [items]="items">
|
|
55
|
+
<ngx-gantt-table>
|
|
56
|
+
<ngx-gantt-column name="标题" width="300px">
|
|
57
|
+
<ng-template #cell let-item="item"> {{ item.title }} </ng-template>
|
|
58
|
+
</ngx-gantt-column>
|
|
59
|
+
</ngx-gantt-table>
|
|
60
|
+
</ngx-gantt>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
// component.ts
|
|
65
|
+
@Component({
|
|
66
|
+
selector: 'app-gantt-example',
|
|
67
|
+
templateUrl: './gantt.component.html'
|
|
68
|
+
})
|
|
69
|
+
export class AppGanttExampleComponent {
|
|
70
|
+
items: GanttItem[] = [
|
|
71
|
+
{ id: '000000', title: 'Task 0', start: 1627729997, end: 1628421197, expandable: true },
|
|
72
|
+
{ id: '000001', title: 'Task 1', start: 1617361997, end: 1625483597, links: ['000003', '000004', '000000'], expandable: true },
|
|
73
|
+
{ id: '000002', title: 'Task 2', start: 1610536397, end: 1610622797 },
|
|
74
|
+
{ id: '000003', title: 'Task 3', start: 1628507597, end: 1633345997, expandable: true }
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
constructor() {}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 介绍
|
|
3
|
+
path: 'intro'
|
|
4
|
+
order: 1
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 一句话介绍
|
|
8
|
+
|
|
9
|
+
`ngx-gantt` 是一款基于 Angular 框架的甘特图组件,支持多种视图展示并支持多种高级的特性,能快速的帮助开发者搭建自己的甘特图应用。
|
|
10
|
+
|
|
11
|
+
# 特性
|
|
12
|
+
|
|
13
|
+
- 5 种视图(日、周、月、季、年)
|
|
14
|
+
- 任务分组展示
|
|
15
|
+
- 树形结构数据展示并支持异步加载
|
|
16
|
+
- 任务前后置依赖关联及展示
|
|
17
|
+
- 任务拖拽更改时间
|
|
18
|
+
- 表格自定义
|
|
19
|
+
- 滚动加载数据
|
|
20
|
+
- 导出为图片
|
|
21
|
+
- 可定制化开发
|
|
22
|
+
|
|
23
|
+
# 动机
|
|
24
|
+
|
|
25
|
+
2020 年,[PingCode](https://pingcode.com) 准备做一款项目集管理的产品 Plan,Plan 这款产品包含多项目路线图管理,进度管理,资源跟踪以及里程碑管理,其中涉及到路线图,里程碑等功能都需要基于甘特图来实现,随后我们开始调研 Github 中开源的一些甘特图的组件,最终都因为不能满足我们的需求而 pass,其中主要的原因有以下几点:
|
|
26
|
+
|
|
27
|
+
- 不能很好的支持 Angular
|
|
28
|
+
- 有一些功能强大的库依旧依赖 JQuery
|
|
29
|
+
- 不支持多层级展示
|
|
30
|
+
- 默认支持的视图不满足我们的场景
|
|
31
|
+
- 不够灵活
|
|
32
|
+
|
|
33
|
+
基于上述原因,我们决定自己造轮子,做一款基于 Angular 的甘特图组件。
|
|
34
|
+
|
|
35
|
+
## 当前版本
|
|
36
|
+
|
|
37
|
+
[](https://www.npmjs.com/package/@worktile/gantt)
|
|
38
|
+
|
|
39
|
+
## 支持 Angular 版本
|
|
40
|
+
|
|
41
|
+
`ngx-gantt` 与 `@angular/core` 保持相同的主版本号,目前支持 Angular ^12.0.0 版本。
|
|
42
|
+
|
|
43
|
+
## 依赖第三方库
|
|
44
|
+
|
|
45
|
+
- Components Dev Kit (Angular CDK)
|
|
46
|
+
- date-fns
|
|
47
|
+
- html2canvas
|
|
48
|
+
|
|
49
|
+
# 参与贡献
|
|
50
|
+
|
|
51
|
+
Gantt 目前还处于开发中,欢迎一起参与贡献 https://github.com/worktile/ngx-gantt 。
|
package/docs/index.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
|
|
2
|
+
# For additional information regarding the format and rule options, please see:
|
|
3
|
+
# https://github.com/browserslist/browserslist#queries
|
|
4
|
+
|
|
5
|
+
# You can see what browsers were selected by your queries by running:
|
|
6
|
+
# npx browserslist
|
|
7
|
+
|
|
8
|
+
> 0.5%
|
|
9
|
+
last 2 versions
|
|
10
|
+
Firefox ESR
|
|
11
|
+
not dead
|
|
12
|
+
not IE 9-11 # For IE 9-11 support, remove 'not'.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { Routes, RouterModule } from '@angular/router';
|
|
3
|
+
import { AppGanttExampleComponent } from './gantt/gantt.component';
|
|
4
|
+
import { AppGanttAdvancedExampleComponent } from './gantt-advanced/gantt-advanced.component';
|
|
5
|
+
import { AppGanttRangeExampleComponent } from './gantt-range/gantt-range.component';
|
|
6
|
+
import { AppExampleComponentsComponent } from './components/components.component';
|
|
7
|
+
import { AppGanttGroupsExampleComponent } from './gantt-groups/gantt-groups.component';
|
|
8
|
+
|
|
9
|
+
const routes: Routes = [
|
|
10
|
+
{
|
|
11
|
+
path: 'components',
|
|
12
|
+
component: AppExampleComponentsComponent,
|
|
13
|
+
children: [
|
|
14
|
+
{ path: '', redirectTo: 'basic', pathMatch: 'full' },
|
|
15
|
+
{ path: 'basic', component: AppGanttExampleComponent },
|
|
16
|
+
{ path: 'groups', component: AppGanttGroupsExampleComponent },
|
|
17
|
+
{ path: 'advanced', component: AppGanttAdvancedExampleComponent }
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
@NgModule({
|
|
23
|
+
imports: [RouterModule.forRoot(routes)],
|
|
24
|
+
exports: [RouterModule]
|
|
25
|
+
})
|
|
26
|
+
export class AppRoutingModule {}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Component, HostBinding } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'example-root',
|
|
5
|
+
templateUrl: `./app.component.html`,
|
|
6
|
+
styles: [],
|
|
7
|
+
})
|
|
8
|
+
export class AppComponent {
|
|
9
|
+
@HostBinding(`class.dg-main`) isRoot = true;
|
|
10
|
+
title = 'example';
|
|
11
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ThyLayoutModule } from 'ngx-tethys/layout';
|
|
2
|
+
import { setPrintErrorWhenIconNotFound } from 'ngx-tethys/icon';
|
|
3
|
+
import { ThyNavModule } from 'ngx-tethys/nav';
|
|
4
|
+
import { ThyButtonModule } from 'ngx-tethys/button';
|
|
5
|
+
import { ThyCheckboxModule } from 'ngx-tethys/checkbox';
|
|
6
|
+
import { ThyNotifyModule } from 'ngx-tethys/notify';
|
|
7
|
+
import { NgModule } from '@angular/core';
|
|
8
|
+
import { RouterModule } from '@angular/router';
|
|
9
|
+
import { NgxGanttModule } from 'ngx-gantt';
|
|
10
|
+
import { AppComponent } from './app.component';
|
|
11
|
+
import { AppGanttExampleComponent } from './gantt/gantt.component';
|
|
12
|
+
import { AppRoutingModule } from './app-routing.module';
|
|
13
|
+
import { CommonModule } from '@angular/common';
|
|
14
|
+
import { AppGanttAdvancedExampleComponent } from './gantt-advanced/gantt-advanced.component';
|
|
15
|
+
import { AppGanttRangeExampleComponent } from './gantt-range/gantt-range.component';
|
|
16
|
+
import { DOCGENI_SITE_PROVIDERS } from './content/index';
|
|
17
|
+
import { DocgeniTemplateModule } from '@docgeni/template';
|
|
18
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
19
|
+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
20
|
+
import { AppGanttFlatComponent } from './gantt-advanced/component/flat.component';
|
|
21
|
+
import { EXAMPLE_MODULES } from './content/example-modules';
|
|
22
|
+
import { AppExampleComponentsComponent } from './components/components.component';
|
|
23
|
+
import { AppGanttGroupsExampleComponent } from './gantt-groups/gantt-groups.component';
|
|
24
|
+
|
|
25
|
+
@NgModule({
|
|
26
|
+
declarations: [
|
|
27
|
+
AppComponent,
|
|
28
|
+
AppExampleComponentsComponent,
|
|
29
|
+
AppGanttExampleComponent,
|
|
30
|
+
AppGanttAdvancedExampleComponent,
|
|
31
|
+
AppGanttGroupsExampleComponent,
|
|
32
|
+
AppGanttRangeExampleComponent,
|
|
33
|
+
AppGanttFlatComponent
|
|
34
|
+
],
|
|
35
|
+
imports: [
|
|
36
|
+
BrowserModule,
|
|
37
|
+
BrowserAnimationsModule,
|
|
38
|
+
CommonModule,
|
|
39
|
+
DocgeniTemplateModule,
|
|
40
|
+
NgxGanttModule,
|
|
41
|
+
AppRoutingModule,
|
|
42
|
+
RouterModule.forRoot([]),
|
|
43
|
+
ThyButtonModule,
|
|
44
|
+
ThyNavModule,
|
|
45
|
+
ThyLayoutModule,
|
|
46
|
+
ThyCheckboxModule,
|
|
47
|
+
ThyNotifyModule,
|
|
48
|
+
...EXAMPLE_MODULES
|
|
49
|
+
],
|
|
50
|
+
providers: [...DOCGENI_SITE_PROVIDERS],
|
|
51
|
+
bootstrap: [AppComponent]
|
|
52
|
+
})
|
|
53
|
+
export class AppModule {
|
|
54
|
+
constructor() {
|
|
55
|
+
setPrintErrorWhenIconNotFound(false);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Component, OnInit } from '@angular/core';
|
|
2
|
+
import { DocItem } from '@docgeni/template';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'app-example-components',
|
|
6
|
+
templateUrl: './components.component.html'
|
|
7
|
+
})
|
|
8
|
+
export class AppExampleComponentsComponent implements OnInit {
|
|
9
|
+
menus: DocItem[] = [
|
|
10
|
+
{
|
|
11
|
+
id: 'basic',
|
|
12
|
+
title: '基本使用',
|
|
13
|
+
subtitle: 'Basic',
|
|
14
|
+
path: 'basic'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: 'groups',
|
|
18
|
+
title: '分组展示',
|
|
19
|
+
subtitle: 'Groups',
|
|
20
|
+
path: 'groups'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'advanced',
|
|
24
|
+
title: '高级使用',
|
|
25
|
+
subtitle: 'Advanced',
|
|
26
|
+
path: 'advanced'
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
constructor() {}
|
|
31
|
+
|
|
32
|
+
ngOnInit() {}
|
|
33
|
+
}
|