@lee576/vue3-gantt 1.0.0 → 1.0.2

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/README.en-US.md CHANGED
@@ -39,6 +39,7 @@ A feature-rich, highly customizable Vue 3 Gantt chart component that supports ta
39
39
 
40
40
  - **Multiple View Modes** - Month, Day, Week, and Hour time granularity views
41
41
  - **Task Dependencies** - Support for FS, SS, FF, SF dependency types
42
+ - **Milestone Support** - Diamond markers for key project milestones with dependency support
42
43
  - **Theme System** - 5 built-in themes with custom theme support
43
44
  - **Internationalization** - Built-in 8 languages, easily extensible
44
45
  - **Progress Management** - Visual progress bars with drag-to-adjust
@@ -48,9 +49,24 @@ A feature-rich, highly customizable Vue 3 Gantt chart component that supports ta
48
49
 
49
50
  ## Installation
50
51
 
52
+ ### Option 1: Install via npm (Recommended)
53
+
54
+ ```bash
55
+ # Using npm
56
+ npm install @lee576/vue3-gantt
57
+
58
+ # Or using yarn
59
+ yarn add @lee576/vue3-gantt
60
+
61
+ # Or using pnpm
62
+ pnpm add @lee576/vue3-gantt
63
+ ```
64
+
65
+ ### Option 2: Build from Source
66
+
51
67
  ```bash
52
68
  # Clone repository
53
- git clone <repository-url>
69
+ git clone https://github.com/lee576/vue3-gantt.git
54
70
 
55
71
  # Install dependencies
56
72
  npm install
@@ -70,6 +86,110 @@ npm run dev
70
86
 
71
87
  ## Basic Usage
72
88
 
89
+ ### 1. Import Component and Styles
90
+
91
+ ```typescript
92
+ import { ref, onMounted } from 'vue';
93
+ import dayjs from 'dayjs';
94
+ // Import Gantt component and types
95
+ import Gantt, {
96
+ type DataConfig,
97
+ type StyleConfig,
98
+ type EventConfig
99
+ } from '@lee576/vue3-gantt';
100
+ // Import styles
101
+ import '@lee576/vue3-gantt/style.css';
102
+ import { LinkType } from '@lee576/vue3-gantt';
103
+ ```
104
+
105
+ ### 2. Configure Container Height (Important!)
106
+
107
+ **The component requires an explicit container height to display properly**. Here are several recommended configuration methods:
108
+
109
+ #### Method 1: Using Viewport Height (Simplest)
110
+
111
+ ```vue
112
+ <template>
113
+ <div class="gantt-container">
114
+ <gantt
115
+ :styleConfig="styleConfig"
116
+ :dataConfig="dataConfig"
117
+ :eventConfig="eventConfig"
118
+ />
119
+ </div>
120
+ </template>
121
+
122
+ <style scoped>
123
+ .gantt-container {
124
+ height: 100vh; /* Use viewport height directly */
125
+ }
126
+ </style>
127
+ ```
128
+
129
+ #### Method 2: Using Percentage Height (Requires html/body Configuration)
130
+
131
+ ```vue
132
+ <template>
133
+ <div id="app">
134
+ <gantt
135
+ :styleConfig="styleConfig"
136
+ :dataConfig="dataConfig"
137
+ :eventConfig="eventConfig"
138
+ />
139
+ </div>
140
+ </template>
141
+
142
+ <style>
143
+ /* Global styles: Ensure html and body have height */
144
+ html, body {
145
+ height: 100%;
146
+ margin: 0;
147
+ padding: 0;
148
+ }
149
+
150
+ #app {
151
+ height: 100%; /* Now 100% works properly */
152
+ }
153
+ </style>
154
+ ```
155
+
156
+ #### Method 3: Using Fixed Pixel Value
157
+
158
+ ```vue
159
+ <style scoped>
160
+ .gantt-container {
161
+ height: 800px; /* Fixed height */
162
+ }
163
+ </style>
164
+ ```
165
+
166
+ #### Method 4: Using Flex Layout
167
+
168
+ ```vue
169
+ <template>
170
+ <div class="page-wrapper">
171
+ <div class="header">Header</div>
172
+ <div class="gantt-container">
173
+ <gantt ... />
174
+ </div>
175
+ </div>
176
+ </template>
177
+
178
+ <style scoped>
179
+ .page-wrapper {
180
+ display: flex;
181
+ flex-direction: column;
182
+ height: 100vh;
183
+ }
184
+
185
+ .gantt-container {
186
+ flex: 1; /* Auto-fill remaining space */
187
+ }
188
+ </style>
189
+ ```
190
+
191
+ ### 3. Configure Component
192
+
73
193
  ```vue
74
194
  <template>
75
195
  <gantt
@@ -80,17 +200,7 @@ npm run dev
80
200
  </template>
81
201
  ```
82
202
 
83
-
84
203
  ```typescript
85
- import { ref, onMounted } from 'vue';
86
- import dayjs from 'dayjs';
87
- import Gantt, {
88
- type DataConfig,
89
- type StyleConfig,
90
- type EventConfig
91
- } from './components/gantt/Gantt.vue';
92
- import { LinkType } from './components/gantt/Types';
93
-
94
204
  // Style configuration
95
205
  const styleConfig = ref<StyleConfig>({
96
206
  headersHeight: 100, // Header height
@@ -234,6 +344,8 @@ interface ProgressUpdateDetail {
234
344
 
235
345
  ## Task Data Format
236
346
 
347
+ ### Regular Task
348
+
237
349
  ```typescript
238
350
  {
239
351
  id: '1', // Task ID
@@ -247,6 +359,29 @@ interface ProgressUpdateDetail {
247
359
  }
248
360
  ```
249
361
 
362
+ ### Milestone Task
363
+
364
+ Milestones are key project checkpoints, displayed with diamond icons. The key characteristic is **start date equals end date**:
365
+
366
+ ```typescript
367
+ {
368
+ id: 'milestone-1', // Milestone ID
369
+ pid: '0', // Parent task ID
370
+ taskNo: '🎯 Requirements Complete', // Milestone name
371
+ level: 'Urgent', // Priority
372
+ start_date: '2024-12-02 18:00:00', // Start time
373
+ end_date: '2024-12-02 18:00:00', // End time (same as start)
374
+ job_progress: '1.0', // Milestones are usually 100%
375
+ spend_time: null,
376
+ type: 'milestone' // Optional: explicitly mark as milestone
377
+ }
378
+ ```
379
+
380
+ **Milestone Recognition Rules**:
381
+ 1. **Auto-detection**: Automatically displayed as diamond when `start_date === end_date`
382
+ 2. **Explicit marking**: Set `type: 'milestone'` field
383
+ 3. **Custom function**: Custom logic via `styleConfig.setTaskType`
384
+
250
385
  ## Task Dependencies
251
386
 
252
387
  ```
@@ -273,6 +408,8 @@ Finish-Start (FS) Start-Start (SS) Finish-Finish (FF) Start-Finish (SF)
273
408
 
274
409
  ### Configuration Example
275
410
 
411
+ #### Regular Task Dependencies
412
+
276
413
  ```typescript
277
414
  import { LinkType } from './components/gantt/Types';
278
415
 
@@ -280,14 +417,34 @@ dependencies: [
280
417
  // Task 2 starts after Task 1 finishes
281
418
  { sourceTaskId: '1', targetTaskId: '2', type: LinkType.FINISH_TO_START },
282
419
 
283
- // Task 3 and Task 4 start simultaneously
420
+ // Task 3 and Task 4 start together
284
421
  { sourceTaskId: '3', targetTaskId: '4', type: LinkType.START_TO_START },
285
422
 
286
- // Task 5 and Task 6 must finish simultaneously
423
+ // Task 5 and Task 6 must finish together
287
424
  { sourceTaskId: '5', targetTaskId: '6', type: LinkType.FINISH_TO_FINISH },
288
425
  ]
289
426
  ```
290
427
 
428
+ #### Milestone Dependencies
429
+
430
+ Milestones support being **source** or **target** in dependency relationships:
431
+
432
+ ```typescript
433
+ dependencies: [
434
+ // Task completion → Milestone
435
+ { sourceTaskId: 'task-5', targetTaskId: 'milestone-1', type: LinkType.FINISH_TO_START },
436
+
437
+ // Milestone → Task starts
438
+ { sourceTaskId: 'milestone-1', targetTaskId: 'task-6', type: LinkType.FINISH_TO_START },
439
+
440
+ // Multiple tasks → Same milestone
441
+ { sourceTaskId: 'frontend-dev', targetTaskId: 'milestone-2', type: LinkType.FINISH_TO_START },
442
+ { sourceTaskId: 'backend-dev', targetTaskId: 'milestone-2', type: LinkType.FINISH_TO_START },
443
+ ]
444
+ ```
445
+
446
+ ```
447
+
291
448
  ## View Modes
292
449
 
293
450
  | Mode | Time Unit | Header Example | Use Case |
package/README.md CHANGED
@@ -21,19 +21,9 @@
21
21
 
22
22
  ## 界面预览
23
23
 
24
- ```
25
- ┌─────────────────────────────────────────────────────────────────────────────┐
26
- │ Vue3 Gantt 专业组件 │
27
- ├─────────────────┬───────────────────────────────────────────────────────────┤
28
- │ 任务名称 │ 12/01 12/02 12/03 12/04 12/05 12/06 12/07 12/08 │
29
- ├─────────────────┼───────────────────────────────────────────────────────────┤
30
- │ 主任务1 - 项目规划│ ████████████████████████████████████████████ 85% │
31
- │ 子任务1.1 - 需求│ ████████████ 100% │
32
- │ 主任务2 - 开发阶段│ ████████████████████████████ 60% │
33
- │ 主任务3 - 测试阶段│ ████████████████ 45% │
34
- │ 主任务4 - 部署上线│ ████████ 30% │
35
- │ 主任务5 - 维护优化│ ████ 0% │
36
- └─────────────────┴───────────────────────────────────────────────────────────┘
24
+ <img width="1913" height="923" alt="image" src="https://github.com/user-attachments/assets/34562bf8-0709-44aa-a05d-6e970ea8b57f" />
25
+ <img width="1915" height="916" alt="image" src="https://github.com/user-attachments/assets/d6a60ba1-9f5b-479a-b402-68014ec7c935" />
26
+
37
27
  ```
38
28
 
39
29
  **主要特点:**
@@ -48,6 +38,7 @@
48
38
 
49
39
  - **多视图模式** - 支持月、日、周、时四种时间粒度视图
50
40
  - **任务依赖关系** - 支持 FS、SS、FF、SF 四种依赖类型
41
+ - **里程碑功能** - 菱形图标标记项目关键节点,支持作为依赖源和目标
51
42
  - **主题系统** - 内置 5 种主题,支持自定义主题
52
43
  - **国际化支持** - 内置 8 种语言,可扩展更多语言
53
44
  - **进度管理** - 可视化进度条,支持拖拽调整进度
@@ -57,9 +48,24 @@
57
48
 
58
49
  ## 安装
59
50
 
51
+ ### 方式一:通过 npm 安装(推荐)
52
+
53
+ ```bash
54
+ # 使用 npm 安装
55
+ npm install @lee576/vue3-gantt
56
+
57
+ # 或使用 yarn
58
+ yarn add @lee576/vue3-gantt
59
+
60
+ # 或使用 pnpm
61
+ pnpm add @lee576/vue3-gantt
62
+ ```
63
+
64
+ ### 方式二:从源码构建
65
+
60
66
  ```bash
61
67
  # 克隆项目
62
- git clone <repository-url>
68
+ git clone https://github.com/lee576/vue3-gantt.git
63
69
 
64
70
  # 安装依赖
65
71
  npm install
@@ -79,6 +85,110 @@ npm run dev
79
85
 
80
86
  ## 基本使用
81
87
 
88
+ ### 1. 引入组件和样式
89
+
90
+ ```typescript
91
+ import { ref, onMounted } from 'vue';
92
+ import dayjs from 'dayjs';
93
+ // 引入甘特图组件和类型
94
+ import Gantt, {
95
+ type DataConfig,
96
+ type StyleConfig,
97
+ type EventConfig
98
+ } from '@lee576/vue3-gantt';
99
+ // 引入样式文件
100
+ import '@lee576/vue3-gantt/style.css';
101
+ import { LinkType } from '@lee576/vue3-gantt';
102
+ ```
103
+
104
+ ### 2. 配置容器高度(重要!)
105
+
106
+ **组件必须有明确的容器高度才能正常显示**。以下是几种推荐的配置方式:
107
+
108
+ #### 方式 1:使用视口高度(最简单)
109
+
110
+ ```vue
111
+ <template>
112
+ <div class="gantt-container">
113
+ <gantt
114
+ :styleConfig="styleConfig"
115
+ :dataConfig="dataConfig"
116
+ :eventConfig="eventConfig"
117
+ />
118
+ </div>
119
+ </template>
120
+
121
+ <style scoped>
122
+ .gantt-container {
123
+ height: 100vh; /* 直接使用视口高度 */
124
+ }
125
+ </style>
126
+ ```
127
+
128
+ #### 方式 2:使用百分比高度(需要配置 html/body)
129
+
130
+ ```vue
131
+ <template>
132
+ <div id="app">
133
+ <gantt
134
+ :styleConfig="styleConfig"
135
+ :dataConfig="dataConfig"
136
+ :eventConfig="eventConfig"
137
+ />
138
+ </div>
139
+ </template>
140
+
141
+ <style>
142
+ /* 全局样式:确保 html 和 body 有高度 */
143
+ html, body {
144
+ height: 100%;
145
+ margin: 0;
146
+ padding: 0;
147
+ }
148
+
149
+ #app {
150
+ height: 100%; /* 现在 100% 就能正常工作了 */
151
+ }
152
+ </style>
153
+ ```
154
+
155
+ #### 方式 3:使用固定像素值
156
+
157
+ ```vue
158
+ <style scoped>
159
+ .gantt-container {
160
+ height: 800px; /* 固定高度 */
161
+ }
162
+ </style>
163
+ ```
164
+
165
+ #### 方式 4:使用 Flex 布局
166
+
167
+ ```vue
168
+ <template>
169
+ <div class="page-wrapper">
170
+ <div class="header">Header</div>
171
+ <div class="gantt-container">
172
+ <gantt ... />
173
+ </div>
174
+ </div>
175
+ </template>
176
+
177
+ <style scoped>
178
+ .page-wrapper {
179
+ display: flex;
180
+ flex-direction: column;
181
+ height: 100vh;
182
+ }
183
+
184
+ .gantt-container {
185
+ flex: 1; /* 自动填充剩余空间 */
186
+ }
187
+ </style>
188
+ ```
189
+
190
+ ### 3. 配置组件
191
+
82
192
  ```vue
83
193
  <template>
84
194
  <gantt
@@ -89,17 +199,7 @@ npm run dev
89
199
  </template>
90
200
  ```
91
201
 
92
-
93
202
  ```typescript
94
- import { ref, onMounted } from 'vue';
95
- import dayjs from 'dayjs';
96
- import Gantt, {
97
- type DataConfig,
98
- type StyleConfig,
99
- type EventConfig
100
- } from './components/gantt/Gantt.vue';
101
- import { LinkType } from './components/gantt/Types';
102
-
103
203
  // 样式配置
104
204
  const styleConfig = ref<StyleConfig>({
105
205
  headersHeight: 100, // 表头高度
@@ -243,6 +343,8 @@ interface ProgressUpdateDetail {
243
343
 
244
344
  ## 任务数据格式
245
345
 
346
+ ### 普通任务
347
+
246
348
  ```typescript
247
349
  {
248
350
  id: '1', // 任务ID
@@ -256,6 +358,29 @@ interface ProgressUpdateDetail {
256
358
  }
257
359
  ```
258
360
 
361
+ ### 里程碑任务
362
+
363
+ 里程碑是项目中的关键节点,使用菱形图标显示,特点是**开始日期等于结束日期**:
364
+
365
+ ```typescript
366
+ {
367
+ id: 'milestone-1', // 里程碑ID
368
+ pid: '0', // 父任务ID
369
+ taskNo: '🎯 需求分析完成', // 里程碑名称
370
+ level: '紧急', // 优先级
371
+ start_date: '2024-12-02 18:00:00', // 开始时间
372
+ end_date: '2024-12-02 18:00:00', // 结束时间(与开始时间相同)
373
+ job_progress: '1.0', // 里程碑通常为100%
374
+ spend_time: null,
375
+ type: 'milestone' // 可选:显式标记为里程碑
376
+ }
377
+ ```
378
+
379
+ **里程碑识别规则**:
380
+ 1. **自动识别**:当 `start_date === end_date` 时自动显示为菱形
381
+ 2. **显式标记**:设置 `type: 'milestone'` 字段
382
+ 3. **自定义函数**:通过 `styleConfig.setTaskType` 自定义判断逻辑
383
+
259
384
  ## 任务依赖关系
260
385
 
261
386
  ```
@@ -281,6 +406,8 @@ interface ProgressUpdateDetail {
281
406
 
282
407
  ### 配置示例
283
408
 
409
+ #### 普通任务依赖
410
+
284
411
  ```typescript
285
412
  import { LinkType } from './components/gantt/Types';
286
413
 
@@ -296,6 +423,24 @@ dependencies: [
296
423
  ]
297
424
  ```
298
425
 
426
+ #### 里程碑依赖
427
+
428
+ 里程碑支持作为依赖关系的**源**或**目标**:
429
+
430
+ ```typescript
431
+ dependencies: [
432
+ // 任务完成 → 里程碑
433
+ { sourceTaskId: 'task-5', targetTaskId: 'milestone-1', type: LinkType.FINISH_TO_START },
434
+
435
+ // 里程碑 → 任务开始
436
+ { sourceTaskId: 'milestone-1', targetTaskId: 'task-6', type: LinkType.FINISH_TO_START },
437
+
438
+ // 多个任务 → 同一个里程碑
439
+ { sourceTaskId: 'frontend-dev', targetTaskId: 'milestone-2', type: LinkType.FINISH_TO_START },
440
+ { sourceTaskId: 'backend-dev', targetTaskId: 'milestone-2', type: LinkType.FINISH_TO_START },
441
+ ]
442
+ ```
443
+
299
444
  ## 视图模式
300
445
 
301
446
  | 模式 | 时间单位 | 表头示例 | 适用场景 |
@@ -702,6 +847,7 @@ A feature-rich, highly customizable Vue 3 Gantt chart component that supports ta
702
847
 
703
848
  - **Multiple View Modes** - Month, Day, Week, and Hour time granularity views
704
849
  - **Task Dependencies** - Support for FS, SS, FF, SF dependency types
850
+ - **Milestone Support** - Diamond markers for key project milestones with dependency support
705
851
  - **Theme System** - 5 built-in themes with custom theme support
706
852
  - **Internationalization** - Built-in 8 languages, easily extensible
707
853
  - **Progress Management** - Visual progress bars with drag-to-adjust