@lee576/vue3-gantt 1.0.2 → 1.0.4

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
@@ -12,6 +12,14 @@ A feature-rich, highly customizable Vue 3 Gantt chart component that supports ta
12
12
 
13
13
  ## Interface Preview
14
14
 
15
+ <div align="center">
16
+ <img src="https://github.com/user-attachments/assets/34562bf8-0709-44aa-a05d-6e970ea8b57f" alt="Vue3 Gantt Chart - Light Theme" />
17
+ <p><em>Light Theme - Complete Task Management Interface</em></p>
18
+
19
+ <img src="https://github.com/user-attachments/assets/d6a60ba1-9f5b-479a-b402-68014ec7c935" alt="Vue3 Gantt Chart - Dark Theme" />
20
+ <p><em>Dark Theme - Eye-friendly Mode</em></p>
21
+ </div>
22
+
15
23
  ```
16
24
  ┌─────────────────────────────────────────────────────────────────────────────┐
17
25
  │ Vue3 Gantt Professional Component │
@@ -27,27 +35,63 @@ A feature-rich, highly customizable Vue 3 Gantt chart component that supports ta
27
35
  └─────────────────┴───────────────────────────────────────────────────────────┘
28
36
  ```
29
37
 
30
- **Key Features:**
31
- - 🎯 Left task list + Right Gantt chart timeline
32
- - 📊 Visual progress bars showing task completion
33
- - 🔗 Task dependency relationship lines
34
- - 🎨 Multi-theme support (Light/Dark/Colorful, etc.)
35
- - 🖱️ Drag to adjust task time and progress
36
- - 🌍 Multi-language support (Chinese/English/Japanese/Korean/French/German/Spanish/Russian)
37
-
38
- ## Features
39
-
40
- - **Multiple View Modes** - Month, Day, Week, and Hour time granularity views
41
- - **Task Dependencies** - Support for FS, SS, FF, SF dependency types
42
- - **Milestone Support** - Diamond markers for key project milestones with dependency support
43
- - **Theme System** - 5 built-in themes with custom theme support
44
- - **Internationalization** - Built-in 8 languages, easily extensible
45
- - **Progress Management** - Visual progress bars with drag-to-adjust
46
- - **Interactive Operations** - Task dragging, resizing, parent-child linkage
47
- - **Responsive Design** - Adjustable split panel ratio
48
- - **High Performance** - Virtual scrolling optimization for large datasets
49
-
50
- ## Installation
38
+ **Key Highlights:**
39
+ - 🎯 **Dual-Column Layout** - Left task list + Right Gantt timeline, clear information at a glance
40
+ - 📊 **Visual Progress** - Real-time progress bars with drag-to-adjust completion
41
+ - 🔗 **Smart Dependencies** - Four dependency types (FS/SS/FF/SF) with auto-drawn links
42
+ - 🎨 **Multi-Theme** - 5 built-in themes, dark mode and custom theme support
43
+ - 🖱️ **Rich Interactions** - Drag move, resize, parent-child task linkage
44
+ - 🌍 **Internationalization** - Built-in 8 languages, easily extensible
45
+ - ⚡ **High Performance** - Virtual scrolling, handles massive task data effortlessly
46
+ - 💎 **Milestones** - Diamond markers for key nodes with dependency support
47
+
48
+ ## Core Features
49
+
50
+ ### 📅 Multiple View Modes
51
+ Four time granularities for different scenarios:
52
+ - **Month View** - Long-term project planning, displayed by day
53
+ - **Week View** - Medium-term project tracking, displayed by week
54
+ - **Day View** - Short-term task management, precise to day
55
+ - **Hour View** - Fine task scheduling, displayed by hour
56
+
57
+ ### 🔗 Task Dependency Management
58
+ - **Finish-to-Start (FS)** - Successor task starts after predecessor finishes
59
+ - **Start-to-Start (SS)** - Both tasks start simultaneously
60
+ - **Finish-to-Finish (FF)** - Both tasks finish simultaneously
61
+ - **Start-to-Finish (SF)** - Predecessor finishes after successor starts
62
+
63
+ ### 💎 Milestone Features
64
+ - Diamond icon markers for project key nodes
65
+ - Support as dependency source and target
66
+ - Auto-detect (start time = end time) or manual marking
67
+
68
+ ### 🎨 Theme System
69
+ - 5 beautiful built-in themes (Metro/Dark/Modern/Classic/Colorful)
70
+ - Dark mode support, eye-friendly
71
+ - Complete CSS variable support, easy customization
72
+ - Theme settings auto-saved to browser
73
+
74
+ ### 🌍 Internationalization
75
+ - Built-in 8 languages (CN/EN/JP/KR/FR/DE/ES/RU)
76
+ - Instant switching, no page refresh needed
77
+ - All UI elements fully translated
78
+ - Timeline headers auto-localized
79
+ - Easy to extend new languages
80
+
81
+ ### 🖱️ Interactive Operations
82
+ - **Drag Move** - Modify task start and end dates
83
+ - **Resize** - Drag edges to adjust task duration
84
+ - **Progress Adjust** - Drag triangle slider to adjust completion
85
+ - **Parent-Child Linkage** - Child tasks follow when parent moves
86
+ - **Split Panel** - Adjustable left-right area ratio
87
+
88
+ ### ⚡ Performance Optimization
89
+ - Virtual scroll rendering, supports massive task data
90
+ - Throttled updates, avoids frequent redraws
91
+ - Cached computations, improves response speed
92
+ - On-demand link rendering, optimized drawing performance
93
+
94
+ ## 🚀 Installation
51
95
 
52
96
  ### Option 1: Install via npm (Recommended)
53
97
 
@@ -67,6 +111,7 @@ pnpm add @lee576/vue3-gantt
67
111
  ```bash
68
112
  # Clone repository
69
113
  git clone https://github.com/lee576/vue3-gantt.git
114
+ cd vue3-gantt
70
115
 
71
116
  # Install dependencies
72
117
  npm install
@@ -75,151 +120,118 @@ npm install
75
120
  npm run dev
76
121
  ```
77
122
 
78
- ## Dependencies
123
+ ## 📚 Quick Start
79
124
 
80
- - @vueuse/core ^13.0.0
81
- - dayjs ^1.11.13
82
- - interactjs ^1.10.27
83
- - svg.js ^2.7.1
84
- - vue ^3.5.13
85
- - zod ^3.24.2
125
+ ### 1️⃣ Import Component
126
+
127
+ ```typescript
128
+ import { createApp } from 'vue';
129
+ import Gantt from '@lee576/vue3-gantt';
130
+ import '@lee576/vue3-gantt/style.css';
86
131
 
87
- ## Basic Usage
132
+ const app = createApp(App);
133
+ app.use(Gantt); // Global registration
134
+ ```
88
135
 
89
- ### 1. Import Component and Styles
136
+ Or import in component:
90
137
 
91
- ```typescript
92
- import { ref, onMounted } from 'vue';
93
- import dayjs from 'dayjs';
94
- // Import Gantt component and types
138
+ ```vue
139
+ <script setup lang="ts">
140
+ import { ref } from 'vue';
95
141
  import Gantt, {
96
142
  type DataConfig,
97
143
  type StyleConfig,
98
- type EventConfig
144
+ type EventConfig,
145
+ LinkType
99
146
  } from '@lee576/vue3-gantt';
100
- // Import styles
101
147
  import '@lee576/vue3-gantt/style.css';
102
- import { LinkType } from '@lee576/vue3-gantt';
148
+ </script>
103
149
  ```
104
150
 
105
- ### 2. Configure Container Height (Important!)
151
+ ### 2️⃣ Configure Container Height (Important!)
106
152
 
107
- **The component requires an explicit container height to display properly**. Here are several recommended configuration methods:
153
+ > ⚠️ **Important**: The component **must have an explicit container height** to display properly.
108
154
 
109
- #### Method 1: Using Viewport Height (Simplest)
155
+ **Recommended methods (choose one):**
110
156
 
111
157
  ```vue
158
+ <!-- Method 1: Use viewport height (Easiest) -->
112
159
  <template>
113
- <div class="gantt-container">
114
- <gantt
115
- :styleConfig="styleConfig"
116
- :dataConfig="dataConfig"
117
- :eventConfig="eventConfig"
118
- />
160
+ <div style="height: 100vh;">
161
+ <gantt :dataConfig="dataConfig" :styleConfig="styleConfig" />
119
162
  </div>
120
163
  </template>
121
164
 
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
165
+ <!-- Method 2: Use fixed height -->
132
166
  <template>
133
- <div id="app">
134
- <gantt
135
- :styleConfig="styleConfig"
136
- :dataConfig="dataConfig"
137
- :eventConfig="eventConfig"
138
- />
167
+ <div style="height: 800px;">
168
+ <gantt :dataConfig="dataConfig" :styleConfig="styleConfig" />
139
169
  </div>
140
170
  </template>
141
171
 
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
172
+ <!-- Method 3: Flex layout -->
169
173
  <template>
170
- <div class="page-wrapper">
171
- <div class="header">Header</div>
172
- <div class="gantt-container">
173
- <gantt ... />
174
+ <div style="display: flex; flex-direction: column; height: 100vh;">
175
+ <div>Header</div>
176
+ <div style="flex: 1;"> <!-- Auto-fill remaining space -->
177
+ <gantt :dataConfig="dataConfig" :styleConfig="styleConfig" />
174
178
  </div>
175
179
  </div>
176
180
  </template>
181
+ ```
177
182
 
178
- <style scoped>
179
- .page-wrapper {
180
- display: flex;
181
- flex-direction: column;
182
- height: 100vh;
183
- }
183
+ <details>
184
+ <summary>💡 Why set height?</summary>
184
185
 
185
- .gantt-container {
186
- flex: 1; /* Auto-fill remaining space */
187
- }
188
- </style>
189
- ```
186
+ The component uses `height: 100%` internally. According to CSS specifications, percentage height requires the parent element to have an explicit height to calculate. Without a height on the parent container, the component will collapse.
187
+
188
+ **Solutions:**
189
+ - Use `100vh` (viewport height)
190
+ - Use fixed pixel value (e.g., `800px`)
191
+ - Use Flex layout's `flex: 1`
192
+ - Configure `html, body { height: 100%; }` then use `100%`
190
193
 
191
- ### 3. Configure Component
194
+ </details>
195
+
196
+ ### 3️⃣ Basic Configuration
192
197
 
193
198
  ```vue
194
199
  <template>
195
- <gantt
196
- :styleConfig="styleConfig"
197
- :dataConfig="dataConfig"
198
- :eventConfig="eventConfig"
199
- />
200
+ <div style="height: 100vh;">
201
+ <gantt
202
+ :dataConfig="dataConfig"
203
+ :styleConfig="styleConfig"
204
+ :eventConfig="eventConfig"
205
+ />
206
+ </div>
200
207
  </template>
201
- ```
202
208
 
203
- ```typescript
204
- // Style configuration
209
+ <script setup lang="ts">
210
+ import { ref, onMounted } from 'vue';
211
+ import dayjs from 'dayjs';
212
+ import Gantt, {
213
+ type DataConfig,
214
+ type StyleConfig,
215
+ type EventConfig,
216
+ LinkType
217
+ } from '@lee576/vue3-gantt';
218
+ import '@lee576/vue3-gantt/style.css';
219
+
220
+ // 🎨 Style Configuration
205
221
  const styleConfig = ref<StyleConfig>({
206
222
  headersHeight: 100, // Header height
207
223
  rowHeight: 60, // Row height
208
224
  setBarColor: (row) => {
209
- // Custom task bar color
210
- const colorMap = {
211
- 'urgent': 'red',
212
- 'important': 'blue',
213
- 'normal': 'gray'
214
- };
215
- return colorMap[row.level] ?? 'black';
225
+ // Custom task bar colors
226
+ const colorMap = { 'urgent': '#ef4444', 'important': '#3b82f6', 'normal': '#6b7280' };
227
+ return colorMap[row.level] ?? '#000';
216
228
  }
217
229
  });
218
230
 
219
- // Data configuration
231
+ // 📊 Data Configuration
220
232
  const dataConfig = ref<DataConfig>({
221
- queryStartDate: '',
222
- queryEndDate: '',
233
+ queryStartDate: dayjs().startOf('month').format('YYYY-MM-DD'),
234
+ queryEndDate: dayjs().endOf('month').format('YYYY-MM-DD'),
223
235
  dataSource: [],
224
236
  dependencies: [],
225
237
  mapFields: {
@@ -234,42 +246,39 @@ const dataConfig = ref<DataConfig>({
234
246
  },
235
247
  taskHeaders: [
236
248
  { title: 'No.', width: 80, property: 'no', show: true },
237
- { title: 'Task Name', width: 190, property: 'task', show: true },
249
+ { title: 'Task Name', width: 200, property: 'task', show: true },
238
250
  { title: 'Priority', width: 90, property: 'priority', show: true },
239
251
  { title: 'Start Date', width: 150, property: 'startdate', show: true },
240
252
  { title: 'End Date', width: 150, property: 'enddate', show: true },
241
- { title: 'Duration', width: 90, property: 'takestime', show: true }
242
253
  ]
243
254
  });
244
255
 
245
- // Event configuration
256
+ // Event Configuration
246
257
  const eventConfig = ref<EventConfig>({
247
- addRootTask: (row) => console.log('Add root task', row),
248
- addSubTask: (task) => console.log('Add subtask', task),
249
- removeTask: (task) => console.log('Remove task', task),
250
- editTask: (task) => console.log('Edit task', task),
251
258
  queryTask: async (startDate, endDate, mode) => {
252
259
  // Query task data
253
- dataConfig.value.dataSource = await fetchTasks(startDate, endDate);
260
+ const tasks = await fetchTasks(startDate, endDate);
261
+ dataConfig.value.dataSource = tasks;
254
262
  },
255
263
  barDate: (id, startDate, endDate) => {
256
- console.log('Task date changed', id, startDate, endDate);
257
- },
258
- allowChangeTaskDate: (allow) => {
259
- console.log('Allow date change', allow);
264
+ console.log('Task date changed', { id, startDate, endDate });
260
265
  },
261
266
  updateProgress: (detail) => {
262
267
  console.log('Progress updated', detail);
263
268
  }
264
269
  });
265
270
 
271
+ // Initialize and load data
266
272
  onMounted(() => {
267
- const startDate = dayjs().startOf('month').format('YYYY-MM-DD');
268
- const endDate = dayjs().endOf('month').format('YYYY-MM-DD');
269
- eventConfig.value.queryTask(startDate, endDate, 'Month');
273
+ const start = dayjs().startOf('month').format('YYYY-MM-DD');
274
+ const end = dayjs().endOf('month').format('YYYY-MM-DD');
275
+ eventConfig.value.queryTask?.(start, end, 'month');
270
276
  });
277
+ </script>
271
278
  ```
272
279
 
280
+ ## 📖 Configuration Guide
281
+
273
282
  ## Configuration Details
274
283
 
275
284
  ### StyleConfig