apexgantt 1.1.0 → 3.0.0

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.md CHANGED
@@ -52,9 +52,10 @@ The layout can be configured by either setting the properties in the table below
52
52
 
53
53
  | Options | Default | Description |
54
54
  | ------------------------- | ----------------------------- | --------------------------------------------------- |
55
- | width | `800` | The width of graph container |
56
- | height | `800` | The height of graph container |
55
+ | width | `100%` | The width of graph container |
56
+ | height | `500px` | The height of graph container |
57
57
  | series, | `[]` | Data for gantt. See format below |
58
+ | theme, | `light` | Built in light and dark theme for easy styling |
58
59
  | canvasStyle | `None` | The css styles for canvas root container |
59
60
  | viewMode | `ViewMode.Month` | View mode |
60
61
  | arrowColor | `#0D6EFD` | Color for the dependency arrows |
@@ -106,7 +107,7 @@ tooltipTemplate(task, dateFormat) {
106
107
  items.push(`
107
108
  <div>
108
109
  <strong>Start:</strong>
109
- <span>${getTaskTextByColumn(task, ColumnKey.StartTime, '')}</span>
110
+ <span>${getTaskTextByColumn(task, ColumnKey.StartTime, dateFormat)}</span>
110
111
  </div>
111
112
  <div>
112
113
  <strong>End:</strong>
@@ -125,7 +126,7 @@ tooltipTemplate(task, dateFormat) {
125
126
  items.push(`
126
127
  <div>
127
128
  <strong>Date:</strong>
128
- <span>${getTaskTextByColumn(task, ColumnKey.StartTime, '')}</span>
129
+ <span>${getTaskTextByColumn(task, ColumnKey.StartTime, dateFormat)}</span>
129
130
  </div>
130
131
  `);
131
132
  }
@@ -255,3 +256,67 @@ Zooms out the gantt based on current view mode. View mode direction for zoom in
255
256
  ```js
256
257
  ganttInstance.zoomOut();
257
258
  ```
259
+
260
+ ## Events
261
+
262
+ ApexGantt emits CustomEvents on the container element when tasks are updated through the dialog form.
263
+
264
+ | Event | When | Detail |
265
+ | --------------------- | ----------------------------- | --------------------------------------------- |
266
+ | `taskUpdate` | Task is being updated | `{ taskId, updates, updatedTask, timestamp }` |
267
+ | `taskUpdateSuccess` | Update completed successfully | `{ taskId, updatedTask, timestamp }` |
268
+ | `taskValidationError` | Form validation failed | `{ taskId, errors, timestamp }` |
269
+ | `taskUpdateError` | Update failed | `{ taskId, error, timestamp }` |
270
+
271
+ ### Events Usage
272
+
273
+ #### Vanilla JS
274
+
275
+ ```javascript
276
+ import ApexGantt, {GanttEvents} from 'apexgantt';
277
+
278
+ const container = document.getElementById('gantt');
279
+ const chart = new ApexGantt(container, {series: tasks});
280
+ chart.render();
281
+
282
+ // Hook into updates to save to your backend
283
+ container.addEventListener(GanttEvents.TASK_UPDATE_SUCCESS, async (e) => {
284
+ const {updatedTask} = e.detail;
285
+ /* use this updatedTask for any server operations */
286
+ });
287
+
288
+ // handle any errors
289
+ container.addEventListener(GanttEvents.TASK_UPDATE_ERROR, (e) => {
290
+ console.error('Update failed:', e.detail.error);
291
+ });
292
+ ```
293
+
294
+ #### React
295
+
296
+ ```jsx
297
+ import {useRef, useEffect} from 'react';
298
+ import ApexGantt, {GanttEvents} from 'apexgantt';
299
+
300
+ function GanttChart({tasks}) {
301
+ const containerRef = useRef(null);
302
+
303
+ useEffect(() => {
304
+ const chart = new ApexGantt(containerRef.current, {series: tasks});
305
+ chart.render();
306
+
307
+ const handleSuccess = async (e) => {
308
+ const {updatedTask} = e.detail;
309
+ /* use this updatedTask for any server operations */
310
+ };
311
+
312
+ containerRef.current.addEventListener(GanttEvents.TASK_UPDATE_SUCCESS, handleSuccess);
313
+
314
+ return () => {
315
+ containerRef.current?.removeEventListener(GanttEvents.TASK_UPDATE_SUCCESS, handleSuccess);
316
+ chart.destroy();
317
+ };
318
+ }, [tasks]);
319
+
320
+ return <div ref={containerRef} />;
321
+ }
322
+ ```