@xpyjs/gantt-core 0.0.3 → 0.1.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xpyjs/gantt-core",
3
3
  "private": false,
4
- "version": "0.0.3",
4
+ "version": "0.1.1",
5
5
  "description": "A powerful and flexible Gantt chart component library for modern web applications with TypeScript support",
6
6
  "type": "module",
7
7
  "main": "./dist/x-gantt.umd.cjs",
@@ -87,5 +87,11 @@ export declare enum ErrorType {
87
87
  /** 无效参数 */
88
88
  LINK_INVALID_ARG = "LINK_INVALID_ARG",
89
89
  /** 检测到环 */
90
- LINK_CYCLE = "LINK_CYCLE"
90
+ LINK_CYCLE = "LINK_CYCLE",
91
+ /** 移动目标无效 */
92
+ MOVE_INVALID_TARGET = "MOVE_INVALID_TARGET",
93
+ /** 移动产生循环依赖 */
94
+ MOVE_CIRCULAR_DEPENDENCY = "MOVE_CIRCULAR_DEPENDENCY",
95
+ /** 移动层级无效 */
96
+ MOVE_INVALID_HIERARCHY = "MOVE_INVALID_HIERARCHY"
91
97
  }
package/types/index.d.ts CHANGED
@@ -9,5 +9,5 @@ import type { IOptions, IOptionConfig, EmitData } from "./types";
9
9
  import type { EventMap } from "./types/event";
10
10
  import type { ILink, DataChain, LinkType } from "./types/link";
11
11
  import type { ErrorType } from "./event";
12
- import type { XGanttUnit } from "./types/options";
13
- export type { IOptions, IOptionConfig, EmitData, EventMap, ILink, ErrorType, XGanttUnit, DataChain, LinkType };
12
+ import type { XGanttUnit, DurationUnit, IScaleConfig, IScaleConfigBase, IScaleConfigBottom, ScaleUnit } from "./types/options";
13
+ export type { IOptions, IOptionConfig, EmitData, EventMap, ILink, ErrorType, XGanttUnit, DurationUnit, IScaleConfig, IScaleConfigBase, IScaleConfigBottom, ScaleUnit, DataChain, LinkType };
@@ -1,7 +1,6 @@
1
1
  import type { Dayjs } from "dayjs";
2
2
  import { type EventBus } from "../event";
3
3
  import { TaskType } from "../types/options";
4
- import { EmitData } from "@/types";
5
4
  import { Store } from "@/store";
6
5
  export declare class Task {
7
6
  private store;
@@ -56,9 +55,12 @@ export declare class Task {
56
55
  */
57
56
  flatIndex: number;
58
57
  /**
59
- * 时间持续间隔
58
+ * 工时持续时长
59
+ *
60
+ * @description 优先取原始 data 中的 duration
61
+ * @description 若原始数据未提供,则由 endTime - startTime 计算,仅保存在内部,不回填原始数据
60
62
  */
61
- private duration;
63
+ private _duration;
62
64
  /**
63
65
  * 原始数据
64
66
  */
@@ -66,12 +68,38 @@ export declare class Task {
66
68
  private fields;
67
69
  constructor(store: Store, event: EventBus, data: any, parent?: Task, _id?: string);
68
70
  getField(field: string): any;
69
- /** 切换展示模式时,需要调整时间 */
71
+ /** 切换展示模式时,需要调整展示长度 */
70
72
  updateMode(): boolean;
71
73
  updateData(data: any): void;
72
- updateTime(startTime: Dayjs, endTime: Dayjs): void;
74
+ /**
75
+ * 更新 Task 时间并修改原始 data
76
+ */
77
+ updateTime(startTime: Dayjs, endTime: Dayjs, updateDuration?: boolean): void;
78
+ /**
79
+ * 更新 Task 持续时间并修改原始 data
80
+ */
81
+ updateDuration(startTime: Dayjs, endTime: Dayjs): void;
82
+ /**
83
+ * 按照规则,适配任务时间
84
+ *
85
+ * 规则:
86
+ * - 根据 direction 判断移动内容:left - 开始时间,right - 结束时间,both - 起止时间
87
+ * - 同时缺失 endTime、duration 的话,直接返回
88
+ * - 根据 duration 重新计算 endTime
89
+ * - 启用了跳过非工作日模式,自动调整任务时间,使其落在工作日上
90
+ */
91
+ fitWork(direction?: "left" | "right" | "both", options?: {
92
+ start?: Dayjs;
93
+ end?: Dayjs;
94
+ }): void;
95
+ /** 获取当前 duration */
96
+ get duration(): number;
73
97
  clone(): Task;
74
- getEmitData(): EmitData;
98
+ getEmitData(): {
99
+ data: any;
100
+ $index: number;
101
+ level: number;
102
+ };
75
103
  getAllChildren(): Task[];
76
104
  isMilestone(): boolean;
77
105
  isSummary(): boolean;
@@ -10,6 +10,7 @@ export declare class Renderer {
10
10
  private table;
11
11
  private chart;
12
12
  private middleLine;
13
+ private guideLine;
13
14
  private renderScheduler;
14
15
  private _id;
15
16
  private width;
@@ -18,6 +18,15 @@ export declare class BodyGroup {
18
18
  private highlightRect;
19
19
  private selectedRowId;
20
20
  private selectedRect;
21
+ private boundHandleMouseMove;
22
+ private boundHandleMouseLeave;
23
+ private boundHandleClick;
24
+ private boundHandleDblClick;
25
+ private boundHandleContextMenu;
26
+ private onRowHighlight;
27
+ private onRowUnhighlight;
28
+ private onTaskSelected;
29
+ private onTaskUnselected;
21
30
  constructor(context: IContext, stage: Konva.Stage, layer: Konva.Layer, bgLayer: Konva.Layer);
22
31
  /**
23
32
  * 调整大小
@@ -9,6 +9,10 @@ export declare class GridGroup {
9
9
  private height;
10
10
  private offsetX;
11
11
  private offsetY;
12
+ private renderedColStart;
13
+ private renderedColEnd;
14
+ private renderedRowStart;
15
+ private renderedRowEnd;
12
16
  constructor(context: IContext, layer: Konva.Layer);
13
17
  /**
14
18
  * 调整网格大小
@@ -4,9 +4,13 @@ export declare class HeaderLayer {
4
4
  private context;
5
5
  private layer;
6
6
  private background;
7
- private groupHeader;
8
- private cellHeader;
7
+ private headerGroups;
8
+ private separatorLines;
9
9
  private cellCache;
10
+ private renderedStartX;
11
+ private renderedEndX;
12
+ /** 缓冲区比例:视口宽度的30%,左右各多渲染这么宽 */
13
+ private static readonly BUFFER_FACTOR;
10
14
  private width;
11
15
  private height;
12
16
  private offsetX;
@@ -29,9 +33,15 @@ export declare class HeaderLayer {
29
33
  */
30
34
  render(): void;
31
35
  /**
32
- * 计算并绘制表头
36
+ * 构建表头结构(headerGroups + 分隔线)
37
+ * 仅在 resize 或数据变化时调用
33
38
  */
34
- private calculateHeader;
39
+ private buildStructure;
40
+ /**
41
+ * 渲染表头 cell 内容(带缓冲区的可视范围裁剪)
42
+ * 滚动超出缓冲区时调用,重建 cells 但保留 group 结构
43
+ */
44
+ private renderCells;
35
45
  private createCell;
36
46
  /**
37
47
  * 清除表头内容
@@ -13,6 +13,8 @@ export declare class HolidayGroup {
13
13
  private offsetY;
14
14
  private holidayGroup;
15
15
  private patternImage;
16
+ /** 渲染版本号,用于丢弃过期的异步结果 */
17
+ private renderVersion;
16
18
  constructor(context: IContext, layer: Konva.Layer);
17
19
  /**
18
20
  * 调整假期大小
@@ -40,6 +40,8 @@ export declare class ChartSlider {
40
40
  private bindEvents;
41
41
  /**
42
42
  * 移动后更新任务时间
43
+ * - 整体移动:锚定 startTime,duration 不变,用 duration 算 endTime
44
+ * - 单侧移动:锚定另一侧,重新计算 duration
43
45
  */
44
46
  private emitUpdate;
45
47
  private handleDragStart;
@@ -59,4 +61,8 @@ export declare class ChartSlider {
59
61
  private handleBarHighlight;
60
62
  /** 闪烁 */
61
63
  private handleBarBlink;
64
+ /**
65
+ * 销毁滑块,清理所有定时器和资源
66
+ */
67
+ destroy(): void;
62
68
  }
@@ -1,5 +1,4 @@
1
1
  import Konva from "konva";
2
- import dayjs from "../../utils/time";
3
2
  import { IContext } from "@/types/render";
4
3
  /**
5
4
  * 周末周末渲染
@@ -14,11 +13,9 @@ export declare class WeekendGroup {
14
13
  private offsetY;
15
14
  private weekendGroup;
16
15
  private patternImage;
16
+ /** 渲染版本号,用于丢弃过期的异步结果 */
17
+ private renderVersion;
17
18
  constructor(context: IContext, layer: Konva.Layer);
18
- /**
19
- * 检查日期是否为周末
20
- */
21
- isWeekend(date: dayjs.Dayjs): boolean;
22
19
  /**
23
20
  * 调整周末大小
24
21
  */
@@ -8,6 +8,10 @@ export declare class GuideLine {
8
8
  private element;
9
9
  private container;
10
10
  private visible;
11
+ private onShowGuideline;
12
+ private onHideGuideline;
13
+ private onMoveGuideline;
14
+ private onOptionsUpdate;
11
15
  /**
12
16
  * @param container 指示线的容器元素
13
17
  */
@@ -51,4 +55,8 @@ export declare class GuideLine {
51
55
  * 更新参数
52
56
  */
53
57
  updateOptions(): void;
58
+ /**
59
+ * 销毁指示线,清理事件监听
60
+ */
61
+ destroy(): void;
54
62
  }
@@ -17,10 +17,13 @@ export declare class DragHandler {
17
17
  private rowElement;
18
18
  constructor(context: IContext, container?: HTMLDivElement | undefined, task?: Task | undefined);
19
19
  private createElement;
20
+ private handleSelectStart;
20
21
  private bindEvents;
21
22
  private handleMouseDown;
22
23
  private handleMouseMove;
23
24
  private handleMouseUp;
25
+ /** ESC 取消拖拽的 keydown */
26
+ private handleKeyDown;
24
27
  /**
25
28
  * 创建拖拽跟随影像
26
29
  */
@@ -7,6 +7,15 @@ export declare class TableRow {
7
7
  private top;
8
8
  element: HTMLDivElement;
9
9
  private cells;
10
+ private handleMouseEnter;
11
+ private handleMouseLeave;
12
+ private handleClick;
13
+ private handleDblClick;
14
+ private handleContextMenu;
15
+ private onRowHighlight;
16
+ private onRowUnhighlight;
17
+ private onTaskSelected;
18
+ private onTaskUnselected;
10
19
  /**
11
20
  * 创建表格行
12
21
  * @param context 上下文
@@ -11,5 +11,8 @@ export declare class Table {
11
11
  refresh(top: number, tasks: Task[]): void;
12
12
  updateWidth(): void;
13
13
  updateTask(task: Task): void;
14
+ private onUpdateTableHeader;
15
+ private onUpdateTableBody;
14
16
  private listenEvents;
17
+ destroy(): void;
15
18
  }
@@ -108,6 +108,10 @@ export declare class DataManager {
108
108
  * 更新子任务的层级
109
109
  */
110
110
  private updateChildrenLevel;
111
+ /**
112
+ * 重新计算所有任务的最大层级
113
+ */
114
+ private recalculateDataLevel;
111
115
  /**
112
116
  * 使缓存失效,标记需要重新生成扁平化任务列表
113
117
  */
@@ -138,6 +142,10 @@ export declare class DataManager {
138
142
  toggleAllChecked(checked: boolean): void;
139
143
  isTaskChecked(task: Task): boolean;
140
144
  updateTaskTime(task: Task, startTime: Dayjs, endTime: Dayjs, direction?: "left" | "right" | "both", oldTasks?: Task[]): void;
145
+ /**
146
+ * 基于某个任务进行时间适配的调整,并联动其子任务
147
+ */
148
+ fitTaskTime(task: Task, direction: "left" | "right" | "both", oldTasks?: Task[]): void;
141
149
  setBaselines(baselines: any[]): void;
142
150
  getBaselines(): Baseline[];
143
151
  /** 根据ID获取基线 */
@@ -1,6 +1,30 @@
1
1
  import dayjs, { type Dayjs } from "../utils/time";
2
- import { IGanttOptions } from "@/types/options";
3
- /** 表头项 */
2
+ import { DurationUnit, IGanttOptions } from "@/types/options";
3
+ /** 内部标准化后的 scale 配置 */
4
+ export interface ParsedScale {
5
+ unit: DurationUnit;
6
+ step: number;
7
+ format?: string | ((date: Date, unit: DurationUnit, step: number) => string);
8
+ cellWidth?: number;
9
+ height?: number;
10
+ }
11
+ /** 时间线单元格项 */
12
+ export interface TimelineCellItem {
13
+ /** 时间对象 */
14
+ date: Dayjs;
15
+ /** 展示的文本 */
16
+ label: string;
17
+ /** 跨越多少个最小渲染单位 */
18
+ span: number;
19
+ /** 是否隐藏 */
20
+ hide?: boolean;
21
+ }
22
+ /** 时间线层 */
23
+ export interface TimelineLayer {
24
+ scale: ParsedScale;
25
+ items: TimelineCellItem[];
26
+ }
27
+ /** 表头项(旧接口,保持兼容) */
4
28
  export interface TimelineItem {
5
29
  /** 时间对象 */
6
30
  date: Dayjs;
@@ -22,25 +46,52 @@ export declare class TimeAxis {
22
46
  private strictEnd;
23
47
  /** 是否自适应宽度 */
24
48
  private isAuto;
25
- /** 表头的日期列表 */
26
- private timeline;
27
- private headerGroupFormat?;
28
- private headerCellFormat?;
49
+ /** N 层时间线缓存 */
50
+ private timelineLayers;
29
51
  private isDirty;
30
52
  /** 是否第一次赋值,如果第一次赋值,允许全部赋值 */
31
53
  private isFirstTime;
32
54
  /** 总宽度 */
33
55
  private allWidth;
34
- /** 每一格的宽度 */
35
- private cellWidth;
36
- /** 用户设定的单位 */
56
+ /** 内部标准化后的 scales */
57
+ private scales;
58
+ /** 是否旧模式(未使用 scaleUnit) */
59
+ private isLegacyMode;
60
+ /** 旧模式下的 cellWidth 映射 */
61
+ private legacyCellWidthMap;
62
+ /** 新模式下的 cellWidth(px/最小渲染单位) */
63
+ private _resolvedCellWidth;
64
+ /** 各层解析后的行高(px) */
65
+ private _resolvedLayerHeights;
66
+ /** 解析后的实际 header 高度(可能因 scaleUnit.height 溢出而扩展) */
67
+ private _resolvedHeaderHeight;
68
+ /** 旧模式记录的 unit */
37
69
  private unit;
70
+ /** 旧模式的 headerGroupFormat / headerCellFormat */
71
+ private headerGroupFormat?;
72
+ private headerCellFormat?;
38
73
  constructor();
39
74
  getStartTime(): dayjs.Dayjs;
40
75
  getEndTime(): dayjs.Dayjs;
76
+ /** 获取每个最小渲染单位的像素宽度(语义不变) */
41
77
  getCellWidth(): number;
78
+ /** 获取底层 timeline 的总 cell 数 */
42
79
  getCellCount(): number;
43
- getCellUnit(): "day" | "hour";
80
+ /** 获取最小渲染单位 */
81
+ getCellUnit(): "hour" | "day";
82
+ /** 获取内部标准化后的 scales */
83
+ getScales(): ParsedScale[];
84
+ /** 获取底层 scale */
85
+ getBottomScale(): ParsedScale;
86
+ /** 获取各层解析后的行高(px) */
87
+ getLayerHeights(): number[];
88
+ /** 获取解析后的实际 header 高度 */
89
+ getResolvedHeaderHeight(): number;
90
+ /**
91
+ * 获取底层一格的像素宽度
92
+ * 用于 ChartHeader/Grid 绘制底层 cell 的宽度
93
+ */
94
+ getBottomCellWidth(date?: Dayjs): number;
44
95
  setAllWidth(width: number): void;
45
96
  getTimeLeft(time: Dayjs): number;
46
97
  /**
@@ -52,25 +103,9 @@ export declare class TimeAxis {
52
103
  init(options: IGanttOptions, isFirstTime?: boolean): void;
53
104
  update(options: IGanttOptions): void;
54
105
  setDate(start?: Dayjs, end?: Dayjs): void;
55
- /** 获取表头的日期列表 */
56
- getTimeline(): TimelineItem[];
106
+ /** 获取 N 层时间线数据 */
107
+ getTimeline(): TimelineLayer[];
57
108
  clear(): void;
58
- /**
59
- * 缓存失效标记
60
- */
61
- private invalidateCache;
62
- /** 获取细粒度单位 */
63
- private getFinelyUnit;
64
- /** 获取下层单位 */
65
- private getChildUnit;
66
- /** 获取上层单位 */
67
- private getGroupUnit;
68
- /** 格式化上层文本 */
69
- private formatterGroupLabel;
70
- /**
71
- * 格式化下层文本
72
- */
73
- private formatterCellLabel;
74
109
  /**
75
110
  * 获取时间轴的总宽度
76
111
  * @returns 时间轴总宽度(像素)
@@ -83,4 +118,50 @@ export declare class TimeAxis {
83
118
  * @returns 是否在时间轴上
84
119
  */
85
120
  isInTimeAxis(time: Dayjs): boolean;
121
+ /**
122
+ * 计算一个 scale cell 包含多少个最小渲染单位
123
+ * @param scale scale 配置
124
+ * @param date 日期(用于月/季度等变长单位)
125
+ */
126
+ getUnitsPerCell(scale: ParsedScale, date?: Dayjs): number;
127
+ /** 缓存失效标记 */
128
+ private invalidateCache;
129
+ /** 获取最小渲染单位:scales 中含 hour/minute → 'hour',否则 → 'day' */
130
+ private getMinimumUnit;
131
+ /** 旧 unit → 内部 scales 自动转换 */
132
+ private legacyUnitToScales;
133
+ /** 每层最小行高 */
134
+ private static readonly MIN_SCALE_ROW_HEIGHT;
135
+ /**
136
+ * 解析各层行高。
137
+ *
138
+ * 规则:
139
+ * - 未指定 height 的层平分剩余空间
140
+ * - 指定的 height < MIN_SCALE_ROW_HEIGHT 时钳位
141
+ * - 所有指定层的 height 之和超过 headerHeight 时,自动扩展 headerHeight
142
+ * - 所有层均指定 height 且总和 < headerHeight 时,上对齐,底部留空白
143
+ */
144
+ private resolveLayerHeights;
145
+ /** 从 chart.cellWidth 解析新模式下的 cellWidth 值 */
146
+ private resolveCellWidthFromChart;
147
+ /**
148
+ * 将 cursor 对齐到 scale 的自然步进边界。
149
+ *
150
+ * step=1 时,直接 startOf(unit)。
151
+ * step>1 时,以"父周期"为锚点,向前找到最近的 step 整数倍边界。
152
+ * 例如 { unit:"hour", step:8 } → 一天内的自然边界为 0:00 / 8:00 / 16:00,
153
+ * cursor=15:00 时对齐到 8:00,首格 8:00→16:00 会被 calculateSpan 裁剪为
154
+ * startTime→16:00 的不完整格,后续格保持不变。
155
+ */
156
+ private alignToScaleStart;
157
+ /** 推进 cursor 到下一个 cell */
158
+ private advanceCursor;
159
+ /** 计算 cursor 到 cellEnd 之间跨越了多少个最小渲染单位 */
160
+ private calculateSpan;
161
+ /** 格式化标签 */
162
+ private formatLabel;
163
+ /** 获取默认格式化 */
164
+ private getDefaultFormat;
165
+ /** 获取一个季度的天数 */
166
+ private getQuarterDays;
86
167
  }
@@ -6,6 +6,7 @@ import { TimeAxis } from "./TimeAxis";
6
6
  import { Dayjs } from "dayjs";
7
7
  import { IContext } from "@/types/render";
8
8
  import { IOptionConfig, IOptions } from "@/types";
9
+ import { WorkCalendar } from "./workCalendar";
9
10
  export declare class Store {
10
11
  private context;
11
12
  private optionManager;
@@ -13,8 +14,10 @@ export declare class Store {
13
14
  private columnManager;
14
15
  private linkManager;
15
16
  private timeAxis;
17
+ private workCalendar;
16
18
  constructor(context: IContext, options?: IOptions);
17
19
  getOptionManager(): OptionManager;
20
+ getWorkCalendar(): WorkCalendar;
18
21
  getDataManager(): DataManager;
19
22
  getColumnManager(): ColumnManager;
20
23
  getLinkManager(): LinkManager;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * 工作日引擎工具。提供周末、节假日的判定函数,以及工作日计算能力
3
+ */
4
+ import { type Dayjs } from '../utils/time';
5
+ import type { IHolidayOpts, IWeekendOpts, IWorkTimeOpts } from '../types/calendar';
6
+ /**
7
+ * 工作日历统一管理类
8
+ *
9
+ * @description 统一管理所有日期属性。可以判定、计算工作日、节假日、周末等
10
+ */
11
+ export declare class WorkCalendar {
12
+ private weekendOpts?;
13
+ private holidayOpts?;
14
+ private workTimeOpts?;
15
+ constructor(weekendOpts?: IWeekendOpts, holidayOpts?: IHolidayOpts, workTimeOpts?: IWorkTimeOpts);
16
+ update(opts: {
17
+ weekendOpts?: IWeekendOpts;
18
+ holidayOpts?: IHolidayOpts;
19
+ workTimeOpts?: IWorkTimeOpts;
20
+ }): void;
21
+ /** 只有显式置条件判定为周末的,才会标记为周末。完整判定需要与其他方法共同完成 */
22
+ private _isWeekend;
23
+ /** 只有显式条件判定为节假日的,才会标记为节假日。完整判定需要与其他方法共同完成 */
24
+ private _isHoliday;
25
+ /** 只做特殊日期的标记,对于普通未标记的日期返回 undefined。完整判定需要与其他方法共同完成 */
26
+ private _isWorkTime;
27
+ /**
28
+ * 判断日期是否为工作时间
29
+ *
30
+ * @description 优先级:isWorkTime 钩子 > 节假日 > 周末
31
+ */
32
+ isWorkTime(date: Date | Dayjs): boolean;
33
+ /**
34
+ * 判断日期是否为周末
35
+ *
36
+ * @description 判定优先级: isWeekend 钩子 > days > 默认 [0, 6]
37
+ */
38
+ isWeekend(date: Date | Dayjs): boolean;
39
+ /**
40
+ * 判断日期是否为节假日
41
+ *
42
+ * @description 判定优先级: isHoliday 钩子 > holidays 列表
43
+ */
44
+ isHoliday(date: Date | Dayjs): boolean;
45
+ /**
46
+ * 基于一个日期,获取指定时长后的工作日期
47
+ *
48
+ * @param start - 起始日期
49
+ * @param n - 工作日时长(正数向后,负数向前,可为分数)
50
+ * @returns 目标日期
51
+ */
52
+ workOffset(start: Date | Dayjs, n: number): Dayjs;
53
+ /**
54
+ * 基于两个日期,计算之间的工作日时长
55
+ *
56
+ * @param start - 起始日期
57
+ * @param end - 结束日期
58
+ */
59
+ workDiff(start: Date | Dayjs, end: Date | Dayjs): number;
60
+ /**
61
+ * 基于两个日期,计算其中包含的非工作天数
62
+ */
63
+ restDays(start: Date | Dayjs, end: Date | Dayjs): number;
64
+ /**
65
+ * 基于某个日期获取最近的工作日(默认向后)
66
+ */
67
+ currentWorkTime(date: Date | Dayjs, direction?: 'after' | 'before'): Dayjs;
68
+ }
@@ -0,0 +1,97 @@
1
+ import { IPattern } from "./styles";
2
+
3
+ /**
4
+ * 周末配置选项
5
+ */
6
+ export interface IWeekendOpts {
7
+ /**
8
+ * 自定义周末日期。默认周六、周日为周末
9
+ *
10
+ * @description 0=周日, 1=周一, ..., 6=周六(dayjs.day() 语义)
11
+ * @default [0, 6](周六、周日)
12
+ *
13
+ * @example
14
+ * // 周五、周六为周末
15
+ * days: [5, 6]
16
+ *
17
+ * @example
18
+ * // 没有周末
19
+ * days: []
20
+ */
21
+ days?: number[];
22
+ /**
23
+ * 完全自定义周末的判定方法
24
+ *
25
+ * @description 优先级最高
26
+ * @description 返回 true 表示这天是周末。没有被判定的日期可以置空
27
+ */
28
+ isWeekend?: (date: Date) => boolean | undefined;
29
+ }
30
+
31
+ /**
32
+ * 节假日配置选项
33
+ */
34
+ export interface IHolidayOpts {
35
+ /**
36
+ * 配置节假日期。可以针对不同节假日配置不同的背景颜色。默认使用统一配置颜色
37
+ */
38
+ holidays?: Array<
39
+ {
40
+ date: Date | number | string | Array<Date | number | string>;
41
+ backgroundColor?: string;
42
+ opacity?: number;
43
+ /**
44
+ * 自定义节假日期的文本
45
+ */
46
+ text?: {
47
+ /** 是否显示文本 */
48
+ show?: boolean;
49
+ /** 文本内容 */
50
+ content?: string;
51
+ /** 文本颜色 */
52
+ color?: string;
53
+ /** 背景颜色 */
54
+ backgroundColor?: string;
55
+ /** 透明度 */
56
+ opacity?: number;
57
+ /** 文本字体大小 */
58
+ fontSize?: number;
59
+ /** 文本字体 */
60
+ fontFamily?: string;
61
+ }
62
+ } & IPattern
63
+ >;
64
+ /**
65
+ * 完全自定义节假日的判定方法
66
+ *
67
+ * @description 优先级高于 holidays 列表
68
+ * @description 返回 true 表示这天是节假日。没有被判定的日期可以置空
69
+ */
70
+ isHoliday?: (date: Date) => boolean | undefined;
71
+ }
72
+
73
+ /**
74
+ * 工时引擎配置选项
75
+ */
76
+ export interface IWorkTimeOpts {
77
+ /**
78
+ * 计算日期周期时,是否跳过周末
79
+ * @default false
80
+ * @description 当置为 true 时,任务周期会自动跳过周末。此时可能 duration 时长与 startTime - endTime 长度不一致
81
+ */
82
+ skipWeekends?: boolean;
83
+ /**
84
+ * 计算日期周期时,是否跳过节假日
85
+ * @default false
86
+ * @description 当置为 true 时,任务周期会自动跳过节假日。此时可能 duration 时长与 startTime - endTime 长度不一致
87
+ */
88
+ skipHolidays?: boolean;
89
+
90
+ /**
91
+ * 完全自定义工作日的判定方法
92
+ *
93
+ * @description 优先级高于节假日和周末。如果将某个日期判定为工作日,那么它不会再被 holiday 与 weekend 捕获。
94
+ * @returns 返回 true 表示这天是工作日。没有被判定的日期可以置空
95
+ */
96
+ isWorkTime?: (date: Date) => boolean | undefined;
97
+ }
@@ -1,6 +1,15 @@
1
1
  import { XGanttUnit } from "./options";
2
2
 
3
3
  export interface IChartOptions {
4
+ /**
5
+ * 是否显示垂直网格线
6
+ *
7
+ * @default false
8
+ *
9
+ * @description 仅对 scaleUnit 参数生效。其余仍然为默认情况。
10
+ */
11
+ showVerticalLine?: boolean;
12
+
4
13
  /**
5
14
  * 开始时间。强制设置开始时间,覆盖数据中的开始时间。
6
15
  *