@visactor/vtable-gantt 1.5.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.
Files changed (190) hide show
  1. package/README.md +151 -0
  2. package/cjs/Gantt.d.ts +111 -0
  3. package/cjs/Gantt.js +244 -0
  4. package/cjs/Gantt.js.map +1 -0
  5. package/cjs/data/DataSource.d.ts +9 -0
  6. package/cjs/data/DataSource.js +30 -0
  7. package/cjs/data/DataSource.js.map +1 -0
  8. package/cjs/env.d.ts +19 -0
  9. package/cjs/env.js +48 -0
  10. package/cjs/env.js.map +1 -0
  11. package/cjs/event/EventHandler.d.ts +47 -0
  12. package/cjs/event/EventHandler.js +128 -0
  13. package/cjs/event/EventHandler.js.map +1 -0
  14. package/cjs/event/EventTarget.d.ts +12 -0
  15. package/cjs/event/EventTarget.js +67 -0
  16. package/cjs/event/EventTarget.js.map +1 -0
  17. package/cjs/event/event-manager.d.ts +15 -0
  18. package/cjs/event/event-manager.js +76 -0
  19. package/cjs/event/event-manager.js.map +1 -0
  20. package/cjs/event/scroll.d.ts +22 -0
  21. package/cjs/event/scroll.js +136 -0
  22. package/cjs/event/scroll.js.map +1 -0
  23. package/cjs/gantt-helper.d.ts +28 -0
  24. package/cjs/gantt-helper.js +225 -0
  25. package/cjs/gantt-helper.js.map +1 -0
  26. package/cjs/index.d.ts +7 -0
  27. package/cjs/index.js +48 -0
  28. package/cjs/index.js.map +1 -0
  29. package/cjs/register.d.ts +1 -0
  30. package/cjs/register.js +1 -0
  31. package/cjs/register.js.map +1 -0
  32. package/cjs/scenegraph/frame-border.d.ts +9 -0
  33. package/cjs/scenegraph/frame-border.js +42 -0
  34. package/cjs/scenegraph/frame-border.js.map +1 -0
  35. package/cjs/scenegraph/ganttNode.d.ts +7 -0
  36. package/cjs/scenegraph/ganttNode.js +16 -0
  37. package/cjs/scenegraph/ganttNode.js.map +1 -0
  38. package/cjs/scenegraph/grid.d.ts +30 -0
  39. package/cjs/scenegraph/grid.js +130 -0
  40. package/cjs/scenegraph/grid.js.map +1 -0
  41. package/cjs/scenegraph/mark-line.d.ts +15 -0
  42. package/cjs/scenegraph/mark-line.js +66 -0
  43. package/cjs/scenegraph/mark-line.js.map +1 -0
  44. package/cjs/scenegraph/scenegraph.d.ts +41 -0
  45. package/cjs/scenegraph/scenegraph.js +109 -0
  46. package/cjs/scenegraph/scenegraph.js.map +1 -0
  47. package/cjs/scenegraph/scroll-bar.d.ts +19 -0
  48. package/cjs/scenegraph/scroll-bar.js +150 -0
  49. package/cjs/scenegraph/scroll-bar.js.map +1 -0
  50. package/cjs/scenegraph/task-bar.d.ts +24 -0
  51. package/cjs/scenegraph/task-bar.js +188 -0
  52. package/cjs/scenegraph/task-bar.js.map +1 -0
  53. package/cjs/scenegraph/timeline-header.d.ts +10 -0
  54. package/cjs/scenegraph/timeline-header.js +134 -0
  55. package/cjs/scenegraph/timeline-header.js.map +1 -0
  56. package/cjs/state/gantt-table-sync.d.ts +7 -0
  57. package/cjs/state/gantt-table-sync.js +60 -0
  58. package/cjs/state/gantt-table-sync.js.map +1 -0
  59. package/cjs/state/state-manager.d.ts +58 -0
  60. package/cjs/state/state-manager.js +223 -0
  61. package/cjs/state/state-manager.js.map +1 -0
  62. package/cjs/themes.d.ts +1 -0
  63. package/cjs/themes.js +1 -0
  64. package/cjs/themes.js.map +1 -0
  65. package/cjs/tools/debounce.d.ts +1 -0
  66. package/cjs/tools/debounce.js +51 -0
  67. package/cjs/tools/debounce.js.map +1 -0
  68. package/cjs/tools/index.d.ts +2 -0
  69. package/cjs/tools/index.js +20 -0
  70. package/cjs/tools/index.js.map +1 -0
  71. package/cjs/tools/isx.d.ts +16 -0
  72. package/cjs/tools/isx.js +117 -0
  73. package/cjs/tools/isx.js.map +1 -0
  74. package/cjs/tools/pixel-ratio.d.ts +2 -0
  75. package/cjs/tools/pixel-ratio.js +16 -0
  76. package/cjs/tools/pixel-ratio.js.map +1 -0
  77. package/cjs/tools/util.d.ts +7 -0
  78. package/cjs/tools/util.js +87 -0
  79. package/cjs/tools/util.js.map +1 -0
  80. package/cjs/ts-types/EVENT_TYPE.d.ts +5 -0
  81. package/cjs/ts-types/EVENT_TYPE.js +9 -0
  82. package/cjs/ts-types/EVENT_TYPE.js.map +1 -0
  83. package/cjs/ts-types/common.d.ts +13 -0
  84. package/cjs/ts-types/common.js +14 -0
  85. package/cjs/ts-types/common.js.map +1 -0
  86. package/cjs/ts-types/events.d.ts +14 -0
  87. package/cjs/ts-types/events.js +6 -0
  88. package/cjs/ts-types/events.js.map +1 -0
  89. package/cjs/ts-types/gantt-engine.d.ts +163 -0
  90. package/cjs/ts-types/gantt-engine.js +6 -0
  91. package/cjs/ts-types/gantt-engine.js.map +1 -0
  92. package/cjs/ts-types/index.d.ts +4 -0
  93. package/cjs/ts-types/index.js +22 -0
  94. package/cjs/ts-types/index.js.map +1 -0
  95. package/dist/vtable-gantt.js +53942 -0
  96. package/dist/vtable-gantt.min.js +1 -0
  97. package/es/Gantt.d.ts +111 -0
  98. package/es/Gantt.js +246 -0
  99. package/es/Gantt.js.map +1 -0
  100. package/es/data/DataSource.d.ts +9 -0
  101. package/es/data/DataSource.js +22 -0
  102. package/es/data/DataSource.js.map +1 -0
  103. package/es/env.d.ts +19 -0
  104. package/es/env.js +42 -0
  105. package/es/env.js.map +1 -0
  106. package/es/event/EventHandler.d.ts +47 -0
  107. package/es/event/EventHandler.js +119 -0
  108. package/es/event/EventHandler.js.map +1 -0
  109. package/es/event/EventTarget.d.ts +12 -0
  110. package/es/event/EventTarget.js +58 -0
  111. package/es/event/EventTarget.js.map +1 -0
  112. package/es/event/event-manager.d.ts +15 -0
  113. package/es/event/event-manager.js +78 -0
  114. package/es/event/event-manager.js.map +1 -0
  115. package/es/event/scroll.d.ts +22 -0
  116. package/es/event/scroll.js +126 -0
  117. package/es/event/scroll.js.map +1 -0
  118. package/es/gantt-helper.d.ts +28 -0
  119. package/es/gantt-helper.js +220 -0
  120. package/es/gantt-helper.js.map +1 -0
  121. package/es/index.d.ts +7 -0
  122. package/es/index.js +10 -0
  123. package/es/index.js.map +1 -0
  124. package/es/register.d.ts +1 -0
  125. package/es/register.js +1 -0
  126. package/es/register.js.map +1 -0
  127. package/es/scenegraph/frame-border.d.ts +9 -0
  128. package/es/scenegraph/frame-border.js +34 -0
  129. package/es/scenegraph/frame-border.js.map +1 -0
  130. package/es/scenegraph/ganttNode.d.ts +7 -0
  131. package/es/scenegraph/ganttNode.js +8 -0
  132. package/es/scenegraph/ganttNode.js.map +1 -0
  133. package/es/scenegraph/grid.d.ts +30 -0
  134. package/es/scenegraph/grid.js +122 -0
  135. package/es/scenegraph/grid.js.map +1 -0
  136. package/es/scenegraph/mark-line.d.ts +15 -0
  137. package/es/scenegraph/mark-line.js +58 -0
  138. package/es/scenegraph/mark-line.js.map +1 -0
  139. package/es/scenegraph/scenegraph.d.ts +41 -0
  140. package/es/scenegraph/scenegraph.js +116 -0
  141. package/es/scenegraph/scenegraph.js.map +1 -0
  142. package/es/scenegraph/scroll-bar.d.ts +19 -0
  143. package/es/scenegraph/scroll-bar.js +144 -0
  144. package/es/scenegraph/scroll-bar.js.map +1 -0
  145. package/es/scenegraph/task-bar.d.ts +24 -0
  146. package/es/scenegraph/task-bar.js +188 -0
  147. package/es/scenegraph/task-bar.js.map +1 -0
  148. package/es/scenegraph/timeline-header.d.ts +10 -0
  149. package/es/scenegraph/timeline-header.js +130 -0
  150. package/es/scenegraph/timeline-header.js.map +1 -0
  151. package/es/state/gantt-table-sync.d.ts +7 -0
  152. package/es/state/gantt-table-sync.js +51 -0
  153. package/es/state/gantt-table-sync.js.map +1 -0
  154. package/es/state/state-manager.d.ts +58 -0
  155. package/es/state/state-manager.js +219 -0
  156. package/es/state/state-manager.js.map +1 -0
  157. package/es/themes.d.ts +1 -0
  158. package/es/themes.js +1 -0
  159. package/es/themes.js.map +1 -0
  160. package/es/tools/debounce.d.ts +1 -0
  161. package/es/tools/debounce.js +43 -0
  162. package/es/tools/debounce.js.map +1 -0
  163. package/es/tools/index.d.ts +2 -0
  164. package/es/tools/index.js +4 -0
  165. package/es/tools/index.js.map +1 -0
  166. package/es/tools/isx.d.ts +16 -0
  167. package/es/tools/isx.js +80 -0
  168. package/es/tools/isx.js.map +1 -0
  169. package/es/tools/pixel-ratio.d.ts +2 -0
  170. package/es/tools/pixel-ratio.js +12 -0
  171. package/es/tools/pixel-ratio.js.map +1 -0
  172. package/es/tools/util.d.ts +7 -0
  173. package/es/tools/util.js +78 -0
  174. package/es/tools/util.js.map +1 -0
  175. package/es/ts-types/EVENT_TYPE.d.ts +5 -0
  176. package/es/ts-types/EVENT_TYPE.js +5 -0
  177. package/es/ts-types/EVENT_TYPE.js.map +1 -0
  178. package/es/ts-types/common.d.ts +13 -0
  179. package/es/ts-types/common.js +13 -0
  180. package/es/ts-types/common.js.map +1 -0
  181. package/es/ts-types/events.d.ts +14 -0
  182. package/es/ts-types/events.js +2 -0
  183. package/es/ts-types/events.js.map +1 -0
  184. package/es/ts-types/gantt-engine.d.ts +163 -0
  185. package/es/ts-types/gantt-engine.js +2 -0
  186. package/es/ts-types/gantt-engine.js.map +1 -0
  187. package/es/ts-types/index.d.ts +4 -0
  188. package/es/ts-types/index.js +8 -0
  189. package/es/ts-types/index.js.map +1 -0
  190. package/package.json +122 -0
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.ScrollBarComponent = void 0;
6
+
7
+ const vtable_1 = require("@visactor/vtable"), vutils_1 = require("@visactor/vutils");
8
+
9
+ class ScrollBarComponent {
10
+ constructor(gantt) {
11
+ this._gantt = gantt, this.createScrollBar(gantt.tableNoFrameWidth, gantt.tableNoFrameHeight - gantt.getAllHeaderRowsHeight());
12
+ }
13
+ createScrollBar(tableWidth, tableHeight) {
14
+ var _a, _b;
15
+ const scrollRailColor = this._gantt.parsedOptions.scrollStyle.scrollRailColor, scrollSliderColor = this._gantt.parsedOptions.scrollStyle.scrollSliderColor, scrollSliderCornerRadius = this._gantt.parsedOptions.scrollStyle.scrollSliderCornerRadius, width = this._gantt.parsedOptions.scrollStyle.width;
16
+ let sliderStyle;
17
+ sliderStyle = (0, vutils_1.isValid)(scrollSliderCornerRadius) ? {
18
+ cornerRadius: scrollSliderCornerRadius,
19
+ fill: scrollSliderColor
20
+ } : {
21
+ fill: scrollSliderColor
22
+ };
23
+ null === (_a = this._gantt.parsedOptions.scrollStyle) || void 0 === _a || _a.visible,
24
+ null === (_b = this._gantt.parsedOptions.scrollStyle) || void 0 === _b || _b.hoverOn;
25
+ this.hScrollBar = new vtable_1.VRender.ScrollBar({
26
+ direction: "horizontal",
27
+ x: 2 * -tableWidth,
28
+ y: 2 * -tableHeight,
29
+ width: tableWidth,
30
+ height: width,
31
+ padding: 0,
32
+ railStyle: {
33
+ fill: scrollRailColor
34
+ },
35
+ sliderStyle: sliderStyle,
36
+ range: [ 0, .1 ],
37
+ visible: !1
38
+ }), this.hScrollBar.render(), this.hScrollBar.hideAll(), this.vScrollBar = new vtable_1.VRender.ScrollBar({
39
+ direction: "vertical",
40
+ x: 2 * -tableWidth,
41
+ y: 2 * -tableHeight,
42
+ width: width,
43
+ height: tableHeight,
44
+ padding: 0,
45
+ railStyle: {
46
+ fill: scrollRailColor
47
+ },
48
+ sliderStyle: sliderStyle,
49
+ range: [ 0, .1 ],
50
+ visible: !1
51
+ }), this.vScrollBar.render(), this.vScrollBar.hideAll();
52
+ }
53
+ refresh() {}
54
+ hideVerticalScrollBar() {
55
+ const visable = this._gantt.parsedOptions.scrollStyle.visible;
56
+ "focus" !== visable && "scrolling" !== visable || (this.vScrollBar.setAttribute("visible", !1),
57
+ this.vScrollBar.hideAll(), this._gantt.scenegraph.updateNextFrame());
58
+ }
59
+ showVerticalScrollBar(autoHide) {
60
+ const visable = this._gantt.parsedOptions.scrollStyle.visible;
61
+ "focus" !== visable && "scrolling" !== visable || (this.vScrollBar.setAttribute("visible", !0),
62
+ this.vScrollBar.showAll(), this._gantt.scenegraph.updateNextFrame(), autoHide && (clearTimeout(this._clearVerticalScrollBar),
63
+ this._clearVerticalScrollBar = setTimeout((() => {
64
+ this.hideVerticalScrollBar();
65
+ }), 1e3)));
66
+ }
67
+ hideHorizontalScrollBar() {
68
+ const visable = this._gantt.parsedOptions.scrollStyle.visible;
69
+ "focus" !== visable && "scrolling" !== visable || (this.hScrollBar.setAttribute("visible", !1),
70
+ this.hScrollBar.hideAll(), this._gantt.scenegraph.updateNextFrame());
71
+ }
72
+ showHorizontalScrollBar(autoHide) {
73
+ const visable = this._gantt.parsedOptions.scrollStyle.visible;
74
+ "focus" !== visable && "scrolling" !== visable || (this.hScrollBar.setAttribute("visible", !0),
75
+ this.hScrollBar.showAll(), this._gantt.scenegraph.updateNextFrame(), autoHide && (clearTimeout(this._clearHorizontalScrollBar),
76
+ this._clearHorizontalScrollBar = setTimeout((() => {
77
+ this.hideHorizontalScrollBar();
78
+ }), 1e3)));
79
+ }
80
+ updateVerticalScrollBarPos(topRatio) {
81
+ const range = this.vScrollBar.attribute.range, size = range[1] - range[0], range0 = topRatio * (1 - size);
82
+ this.vScrollBar.setAttribute("range", [ range0, range0 + size ]);
83
+ const bounds = this.vScrollBar.AABBBounds && this.vScrollBar.globalAABBBounds;
84
+ this.vScrollBar._viewPosition = {
85
+ x: bounds.x1,
86
+ y: bounds.y1
87
+ };
88
+ }
89
+ updateHorizontalScrollBarPos(leftRatio) {
90
+ const range = this.hScrollBar.attribute.range, size = range[1] - range[0], range0 = leftRatio * (1 - size);
91
+ this.hScrollBar.setAttribute("range", [ range0, range0 + size ]);
92
+ const bounds = this.hScrollBar.AABBBounds && this.hScrollBar.globalAABBBounds;
93
+ this.hScrollBar._viewPosition = {
94
+ x: bounds.x1,
95
+ y: bounds.y1
96
+ };
97
+ }
98
+ updateScrollBar() {
99
+ const oldHorizontalBarPos = this._gantt.stateManager.scroll.horizontalBarPos, oldVerticalBarPos = this._gantt.stateManager.scroll.verticalBarPos, scrollStyle = this._gantt.parsedOptions.scrollStyle, width = null == scrollStyle ? void 0 : scrollStyle.width, visible = null == scrollStyle ? void 0 : scrollStyle.visible, tableWidth = Math.ceil(this._gantt.scenegraph.tableGroup.attribute.width), tableHeight = Math.ceil(this._gantt.scenegraph.tableGroup.attribute.height), totalHeight = this._gantt.getAllRowsHeight(), totalWidth = this._gantt.getAllColsWidth(), frozenRowsHeight = this._gantt.getAllHeaderRowsHeight();
100
+ if (totalWidth > tableWidth) {
101
+ const y = Math.min(tableHeight, totalHeight), rangeEnd = Math.max(.05, tableWidth / totalWidth), hoverOn = scrollStyle.hoverOn;
102
+ let attrY = 0;
103
+ attrY = scrollStyle.barToSide ? this._gantt.tableNoFrameHeight - (hoverOn ? width : -this._gantt.scenegraph.tableGroup.attribute.y) + this._gantt.tableY : y - (hoverOn ? width : -this._gantt.scenegraph.tableGroup.attribute.y) + this._gantt.tableY,
104
+ this.hScrollBar.setAttributes({
105
+ x: hoverOn ? 0 : this._gantt.scenegraph.tableGroup.attribute.x,
106
+ y: attrY,
107
+ width: tableWidth,
108
+ range: [ 0, rangeEnd ],
109
+ visible: "always" === visible
110
+ });
111
+ const bounds = this.hScrollBar.AABBBounds && this.hScrollBar.globalAABBBounds;
112
+ this.hScrollBar._viewPosition = {
113
+ x: bounds.x1,
114
+ y: bounds.y1
115
+ }, "always" === visible && this.hScrollBar.showAll();
116
+ } else this.hScrollBar.setAttributes({
117
+ x: 2 * -this._gantt.tableNoFrameWidth,
118
+ y: 2 * -this._gantt.tableNoFrameHeight,
119
+ width: 0,
120
+ visible: !1
121
+ });
122
+ if (totalHeight > tableHeight) {
123
+ const x = Math.min(tableWidth, totalWidth), rangeEnd = Math.max(.05, (tableHeight - frozenRowsHeight) / (totalHeight - frozenRowsHeight));
124
+ let attrX = 0;
125
+ const hoverOn = this._gantt.parsedOptions.scrollStyle.hoverOn;
126
+ attrX = this._gantt.parsedOptions.scrollStyle.barToSide ? this._gantt.tableNoFrameWidth - (hoverOn ? width : -this._gantt.scenegraph.tableGroup.attribute.x) + this._gantt.tableX : x - (hoverOn ? width : -this._gantt.scenegraph.tableGroup.attribute.x),
127
+ this.vScrollBar.setAttributes({
128
+ x: attrX,
129
+ y: frozenRowsHeight + (hoverOn ? 0 : this._gantt.scenegraph.tableGroup.attribute.y) + this._gantt.tableY,
130
+ height: tableHeight - frozenRowsHeight,
131
+ range: [ 0, rangeEnd ],
132
+ visible: "always" === visible
133
+ });
134
+ const bounds = this.vScrollBar.AABBBounds && this.vScrollBar.globalAABBBounds;
135
+ this.vScrollBar._viewPosition = {
136
+ x: bounds.x1,
137
+ y: bounds.y1
138
+ }, "always" === visible && this.vScrollBar.showAll();
139
+ } else this.vScrollBar.setAttributes({
140
+ x: 2 * -this._gantt.tableNoFrameWidth,
141
+ y: 2 * -this._gantt.tableNoFrameHeight,
142
+ height: 0,
143
+ visible: !1
144
+ });
145
+ this._gantt.stateManager.setScrollLeft(oldHorizontalBarPos), this._gantt.stateManager.setScrollTop(oldVerticalBarPos);
146
+ }
147
+ }
148
+
149
+ exports.ScrollBarComponent = ScrollBarComponent;
150
+ //# sourceMappingURL=scroll-bar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/scenegraph/scroll-bar.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAC3C,6CAA2C;AAO3C,MAAa,kBAAkB;IAM7B,YAAY,KAAY;QACtB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,kBAAkB,GAAG,KAAK,CAAC,sBAAsB,EAAE,CAAC,CAAC;IAC3G,CAAC;IAED,eAAe,CAAC,UAAkB,EAAE,WAAmB;;QACrD,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC;QAC9E,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,iBAAiB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AAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC;YAC7E,IAAI,CAAC,UAAkB,CAAC,aAAa,GAAG;gBACvC,CAAC,EAAE,MAAM,CAAC,EAAE;gBACZ,CAAC,EAAE,MAAM,CAAC,EAAE;aACb,CAAC;YAEF,IAAI,OAAO,KAAK,QAAQ,EAAE;gBACxB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;aAC3B;SACF;aAAM;YACL,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;gBAC5B,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,GAAG,CAAC;gBACrC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,GAAG,CAAC;gBACtC,MAAM,EAAE,CAAC;gBACT,OAAO,EAAE,KAAK;aACf,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;IAC3D,CAAC;CACF;AAxPD,gDAwPC","file":"scroll-bar.js","sourcesContent":["import { VRender } from '@visactor/vtable';\nimport { isValid } from '@visactor/vutils';\nimport type { Gantt } from '../Gantt';\n/**\n * @description: 创建滚动条组件\n * @return {*}\n */\n\nexport class ScrollBarComponent {\n hScrollBar: VRender.ScrollBar;\n vScrollBar: VRender.ScrollBar;\n _gantt: Gantt;\n _clearHorizontalScrollBar: any;\n _clearVerticalScrollBar: any;\n constructor(gantt: Gantt) {\n this._gantt = gantt;\n this.createScrollBar(gantt.tableNoFrameWidth, gantt.tableNoFrameHeight - gantt.getAllHeaderRowsHeight());\n }\n\n createScrollBar(tableWidth: number, tableHeight: number) {\n const scrollRailColor = this._gantt.parsedOptions.scrollStyle.scrollRailColor;\n const scrollSliderColor = this._gantt.parsedOptions.scrollStyle.scrollSliderColor;\n const scrollSliderCornerRadius = this._gantt.parsedOptions.scrollStyle.scrollSliderCornerRadius;\n const width = this._gantt.parsedOptions.scrollStyle.width;\n\n let sliderStyle;\n if (isValid(scrollSliderCornerRadius)) {\n sliderStyle = {\n cornerRadius: scrollSliderCornerRadius,\n fill: scrollSliderColor\n };\n } else {\n sliderStyle = {\n fill: scrollSliderColor\n };\n }\n const visible = this._gantt.parsedOptions.scrollStyle?.visible as string;\n const hoverOn = this._gantt.parsedOptions.scrollStyle?.hoverOn as boolean;\n\n this.hScrollBar = new VRender.ScrollBar({\n direction: 'horizontal',\n x: -tableWidth * 2,\n y: -tableHeight * 2,\n width: tableWidth,\n height: width,\n padding: 0,\n railStyle: {\n fill: scrollRailColor\n },\n sliderStyle,\n range: [0, 0.1],\n // scrollRange: [0.4, 0.8]\n visible: false\n });\n // hack方案实现初始化隐藏滚动条,也可以add到stage之后执行hideAll\n (this.hScrollBar as any).render();\n this.hScrollBar.hideAll();\n\n this.vScrollBar = new VRender.ScrollBar({\n direction: 'vertical',\n x: -tableWidth * 2,\n y: -tableHeight * 2,\n width,\n height: tableHeight,\n padding: 0,\n railStyle: {\n fill: scrollRailColor\n },\n sliderStyle,\n range: [0, 0.1],\n visible: false\n });\n (this.vScrollBar as any).render();\n this.vScrollBar.hideAll();\n }\n refresh() {\n //\n }\n hideVerticalScrollBar() {\n const visable = this._gantt.parsedOptions.scrollStyle.visible;\n if (visable !== 'focus' && visable !== 'scrolling') {\n return;\n }\n this.vScrollBar.setAttribute('visible', false);\n this.vScrollBar.hideAll();\n this._gantt.scenegraph.updateNextFrame();\n }\n showVerticalScrollBar(autoHide?: boolean) {\n const visable = this._gantt.parsedOptions.scrollStyle.visible;\n if (visable !== 'focus' && visable !== 'scrolling') {\n return;\n }\n this.vScrollBar.setAttribute('visible', true);\n this.vScrollBar.showAll();\n this._gantt.scenegraph.updateNextFrame();\n if (autoHide) {\n // 滚轮触发滚动条显示后,异步隐藏\n clearTimeout(this._clearVerticalScrollBar);\n this._clearVerticalScrollBar = setTimeout(() => {\n this.hideVerticalScrollBar();\n }, 1000);\n }\n }\n hideHorizontalScrollBar() {\n const visable = this._gantt.parsedOptions.scrollStyle.visible;\n if (visable !== 'focus' && visable !== 'scrolling') {\n return;\n }\n this.hScrollBar.setAttribute('visible', false);\n this.hScrollBar.hideAll();\n this._gantt.scenegraph.updateNextFrame();\n }\n showHorizontalScrollBar(autoHide?: boolean) {\n const visable = this._gantt.parsedOptions.scrollStyle.visible;\n if (visable !== 'focus' && visable !== 'scrolling') {\n return;\n }\n this.hScrollBar.setAttribute('visible', true);\n this.hScrollBar.showAll();\n this._gantt.scenegraph.updateNextFrame();\n if (autoHide) {\n // 滚轮触发滚动条显示后,异步隐藏\n clearTimeout(this._clearHorizontalScrollBar);\n this._clearHorizontalScrollBar = setTimeout(() => {\n this.hideHorizontalScrollBar();\n }, 1000);\n }\n }\n updateVerticalScrollBarPos(topRatio: number) {\n const range = this.vScrollBar.attribute.range;\n const size = range[1] - range[0];\n const range0 = topRatio * (1 - size);\n this.vScrollBar.setAttribute('range', [range0, range0 + size]);\n const bounds = this.vScrollBar.AABBBounds && this.vScrollBar.globalAABBBounds;\n (this.vScrollBar as any)._viewPosition = {\n x: bounds.x1,\n y: bounds.y1\n };\n }\n updateHorizontalScrollBarPos(leftRatio: number) {\n const range = this.hScrollBar.attribute.range;\n const size = range[1] - range[0];\n const range0 = leftRatio * (1 - size);\n this.hScrollBar.setAttribute('range', [range0, range0 + size]);\n const bounds = this.hScrollBar.AABBBounds && this.hScrollBar.globalAABBBounds;\n (this.hScrollBar as any)._viewPosition = {\n x: bounds.x1,\n y: bounds.y1\n };\n }\n\n /**\n * @description: 更新滚动条尺寸\n * @return {*}\n */\n updateScrollBar() {\n const oldHorizontalBarPos = this._gantt.stateManager.scroll.horizontalBarPos;\n const oldVerticalBarPos = this._gantt.stateManager.scroll.verticalBarPos;\n\n const scrollStyle = this._gantt.parsedOptions.scrollStyle;\n const width = scrollStyle?.width as number;\n const visible = scrollStyle?.visible as string;\n // const hoverOn = theme.scrollStyle?.hoverOn as boolean;\n const tableWidth = Math.ceil(this._gantt.scenegraph.tableGroup.attribute.width);\n const tableHeight = Math.ceil(this._gantt.scenegraph.tableGroup.attribute.height);\n\n const totalHeight = this._gantt.getAllRowsHeight();\n const totalWidth = this._gantt.getAllColsWidth();\n const frozenRowsHeight = this._gantt.getAllHeaderRowsHeight();\n // const frozenColsWidth = this._gantt.getFrozenColsWidth();\n // const bottomFrozenRowsHeight = this._gantt.getBottomFrozenRowsHeight();\n // const rightFrozenColsWidth = this._gantt.getRightFrozenColsWidth();\n if (totalWidth > tableWidth) {\n const y = Math.min(tableHeight, totalHeight);\n const rangeEnd = Math.max(0.05, tableWidth / totalWidth);\n\n const hoverOn = scrollStyle.hoverOn;\n\n let attrY = 0;\n if (scrollStyle.barToSide) {\n attrY =\n this._gantt.tableNoFrameHeight -\n (hoverOn ? width : -this._gantt.scenegraph.tableGroup.attribute.y) +\n this._gantt.tableY;\n } else {\n attrY = y - (hoverOn ? width : -this._gantt.scenegraph.tableGroup.attribute.y) + this._gantt.tableY;\n }\n\n this.hScrollBar.setAttributes({\n x: !hoverOn ? this._gantt.scenegraph.tableGroup.attribute.x : 0,\n y: attrY,\n width: tableWidth,\n range: [0, rangeEnd],\n visible: visible === 'always'\n });\n const bounds = this.hScrollBar.AABBBounds && this.hScrollBar.globalAABBBounds;\n (this.hScrollBar as any)._viewPosition = {\n x: bounds.x1,\n y: bounds.y1\n };\n if (visible === 'always') {\n this.hScrollBar.showAll();\n }\n } else {\n this.hScrollBar.setAttributes({\n x: -this._gantt.tableNoFrameWidth * 2,\n y: -this._gantt.tableNoFrameHeight * 2,\n width: 0,\n visible: false\n });\n }\n\n if (totalHeight > tableHeight) {\n const x = Math.min(tableWidth, totalWidth);\n const rangeEnd = Math.max(0.05, (tableHeight - frozenRowsHeight) / (totalHeight - frozenRowsHeight));\n\n let attrX = 0;\n const hoverOn = this._gantt.parsedOptions.scrollStyle.hoverOn;\n\n if (this._gantt.parsedOptions.scrollStyle.barToSide) {\n attrX =\n this._gantt.tableNoFrameWidth -\n (hoverOn ? width : -this._gantt.scenegraph.tableGroup.attribute.x) +\n this._gantt.tableX;\n } else {\n attrX = x - (hoverOn ? width : -this._gantt.scenegraph.tableGroup.attribute.x);\n }\n\n this.vScrollBar.setAttributes({\n x: attrX,\n y: frozenRowsHeight + (!hoverOn ? this._gantt.scenegraph.tableGroup.attribute.y : 0) + this._gantt.tableY,\n height: tableHeight - frozenRowsHeight,\n range: [0, rangeEnd],\n visible: visible === 'always'\n });\n const bounds = this.vScrollBar.AABBBounds && this.vScrollBar.globalAABBBounds;\n (this.vScrollBar as any)._viewPosition = {\n x: bounds.x1,\n y: bounds.y1\n };\n\n if (visible === 'always') {\n this.vScrollBar.showAll();\n }\n } else {\n this.vScrollBar.setAttributes({\n x: -this._gantt.tableNoFrameWidth * 2,\n y: -this._gantt.tableNoFrameHeight * 2,\n height: 0,\n visible: false\n });\n }\n\n this._gantt.stateManager.setScrollLeft(oldHorizontalBarPos);\n this._gantt.stateManager.setScrollTop(oldVerticalBarPos);\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import { VRender } from '@visactor/vtable';
2
+ import type { Scenegraph } from './scenegraph';
3
+ import { GanttTaskBarNode } from './ganttNode';
4
+ export declare class TaskBar {
5
+ group: VRender.Group;
6
+ barContainer: VRender.Group;
7
+ hoverBarGroup: VRender.Group;
8
+ hoverBarLeftIcon: VRender.Image;
9
+ hoverBarRightIcon: VRender.Image;
10
+ _scene: Scenegraph;
11
+ width: number;
12
+ height: number;
13
+ constructor(scene: Scenegraph);
14
+ initBars(): void;
15
+ initBar(index: number): GanttTaskBarNode;
16
+ updateTaskBarNode(index: number): void;
17
+ initHoverBarIcons(): void;
18
+ setX(x: number): void;
19
+ setY(y: number): void;
20
+ refreshItems(): void;
21
+ resize(): void;
22
+ showHoverBar(x: number, y: number, width: number, height: number, target?: VRender.Group): void;
23
+ hideHoverBar(): void;
24
+ }
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.TaskBar = void 0;
6
+
7
+ const vtable_1 = require("@visactor/vtable"), util_1 = require("../tools/util"), vutils_1 = require("@visactor/vutils"), gantt_helper_1 = require("../gantt-helper"), ganttNode_1 = require("./ganttNode"), TASKBAR_HOVER_ICON = '<svg width="100" height="200" xmlns="http://www.w3.org/2000/svg">\n <line x1="30" y1="10" x2="30" y2="190" stroke="black" stroke-width="4"/>\n <line x1="70" y1="10" x2="70" y2="190" stroke="black" stroke-width="4"/>\n</svg>';
8
+
9
+ class TaskBar {
10
+ constructor(scene) {
11
+ this._scene = scene, this.width = scene._gantt.tableNoFrameWidth, this.height = scene._gantt.gridHeight,
12
+ this.group = new vtable_1.VRender.Group({
13
+ x: 0,
14
+ y: scene._gantt.getAllHeaderRowsHeight(),
15
+ width: this.width,
16
+ height: this.height,
17
+ pickable: !1,
18
+ clip: !0
19
+ }), this.group.name = "task-bar-container", scene.tableGroup.addChild(this.group),
20
+ this.initBars(), this.initHoverBarIcons();
21
+ }
22
+ initBars() {
23
+ this.barContainer = new vtable_1.VRender.Group({
24
+ x: 0,
25
+ y: 0,
26
+ width: this._scene._gantt.getAllColsWidth(),
27
+ height: this._scene._gantt.getAllGridHeight(),
28
+ pickable: !1,
29
+ clip: !0
30
+ }), this.group.appendChild(this.barContainer);
31
+ for (let i = 0; i < this._scene._gantt.itemCount; i++) {
32
+ const barGroup = this.initBar(i);
33
+ barGroup && this.barContainer.appendChild(barGroup);
34
+ }
35
+ }
36
+ initBar(index) {
37
+ var _a, _b;
38
+ const taskBarCustomLayout = this._scene._gantt.parsedOptions.taskBarCustomLayout, {startDate: startDate, endDate: endDate, taskDays: taskDays, progress: progress, taskRecord: taskRecord} = this._scene._gantt.getTaskInfoByTaskListIndex(index);
39
+ if (taskDays <= 0) return null;
40
+ const taskBarSize = this._scene._gantt.parsedOptions.colWidthPerDay * taskDays, taskbarHeight = this._scene._gantt.parsedOptions.taskBarStyle.width, minDate = new Date(this._scene._gantt.parsedOptions.minDate), barGroup = new ganttNode_1.GanttTaskBarNode({
41
+ x: this._scene._gantt.parsedOptions.colWidthPerDay * Math.ceil(Math.abs(startDate.getTime() - minDate.getTime()) / 864e5),
42
+ y: this._scene._gantt.parsedOptions.rowHeight * index + (this._scene._gantt.parsedOptions.rowHeight - taskbarHeight) / 2,
43
+ width: taskBarSize,
44
+ height: taskbarHeight,
45
+ cornerRadius: this._scene._gantt.parsedOptions.taskBarStyle.cornerRadius,
46
+ clip: !0
47
+ });
48
+ let rootContainer;
49
+ barGroup.name = "task-bar";
50
+ let renderDefaultBar = !0, renderDefaultText = !0;
51
+ if (taskBarCustomLayout) {
52
+ let customLayoutObj;
53
+ if ("function" == typeof taskBarCustomLayout) {
54
+ customLayoutObj = taskBarCustomLayout({
55
+ width: taskBarSize,
56
+ height: taskbarHeight,
57
+ index: index,
58
+ startDate: startDate,
59
+ endDate: endDate,
60
+ taskDays: taskDays,
61
+ progress: progress,
62
+ taskRecord: taskRecord,
63
+ ganttInstance: this._scene._gantt
64
+ });
65
+ } else customLayoutObj = taskBarCustomLayout;
66
+ customLayoutObj && (rootContainer = customLayoutObj.rootContainer, renderDefaultBar = null !== (_a = customLayoutObj.renderDefaultBar) && void 0 !== _a && _a,
67
+ renderDefaultText = null !== (_b = customLayoutObj.renderDefaultText) && void 0 !== _b && _b,
68
+ rootContainer.name = "task-bar-custom-render");
69
+ }
70
+ if (renderDefaultBar) {
71
+ const rect = vtable_1.VRender.createRect({
72
+ x: 0,
73
+ y: 0,
74
+ width: taskBarSize,
75
+ height: taskbarHeight,
76
+ fill: this._scene._gantt.parsedOptions.taskBarStyle.barColor,
77
+ pickable: !1
78
+ });
79
+ rect.name = "task-bar-rect", barGroup.appendChild(rect), barGroup.barRect = rect;
80
+ const progress_rect = vtable_1.VRender.createRect({
81
+ x: 0,
82
+ y: 0,
83
+ width: taskBarSize * progress / 100,
84
+ height: taskbarHeight,
85
+ fill: this._scene._gantt.parsedOptions.taskBarStyle.completedBarColor,
86
+ pickable: !1
87
+ });
88
+ progress_rect.name = "task-bar-progress-rect", barGroup.appendChild(progress_rect),
89
+ barGroup.progressRect = progress_rect;
90
+ }
91
+ if (rootContainer && barGroup.appendChild(rootContainer), renderDefaultText) {
92
+ const {textAlign: textAlign, textBaseline: textBaseline, fontSize: fontSize, fontFamily: fontFamily, textOverflow: textOverflow, color: color, padding: padding} = this._scene._gantt.parsedOptions.taskBarLabelStyle, position = (0,
93
+ gantt_helper_1.getTextPos)((0, util_1.toBoxArray)(padding), textAlign, textBaseline, taskBarSize, taskbarHeight), label = vtable_1.VRender.createText({
94
+ pickable: !1,
95
+ x: position.x,
96
+ y: position.y,
97
+ fontSize: fontSize,
98
+ fill: color,
99
+ fontFamily: fontFamily,
100
+ text: (0, util_1.parseStringTemplate)(this._scene._gantt.parsedOptions.taskBarLabelText, taskRecord),
101
+ maxLineWidth: taskBarSize - 20,
102
+ textBaseline: textBaseline,
103
+ textAlign: textAlign,
104
+ ellipsis: "clip" === textOverflow ? "" : "ellipsis" === textOverflow ? "..." : (0,
105
+ vutils_1.isValid)(textOverflow) ? textOverflow : void 0
106
+ });
107
+ barGroup.appendChild(label), barGroup.textLabel = label;
108
+ }
109
+ return barGroup;
110
+ }
111
+ updateTaskBarNode(index) {
112
+ var _a;
113
+ const taskbarGroup = null === (_a = this.barContainer.getChildren()) || void 0 === _a ? void 0 : _a[index];
114
+ if (taskbarGroup) {
115
+ this.barContainer.removeChild(taskbarGroup);
116
+ const barGroup = this.initBar(index);
117
+ barGroup && this.barContainer.insertInto(barGroup, index);
118
+ }
119
+ }
120
+ initHoverBarIcons() {
121
+ const hoverBarGroup = new vtable_1.VRender.Group({
122
+ x: 0,
123
+ y: 0,
124
+ width: 100,
125
+ height: 100,
126
+ clip: !0,
127
+ cursor: this._scene._gantt.parsedOptions.taskBarMoveable ? "grab" : "default",
128
+ pickable: !1,
129
+ cornerRadius: this._scene._gantt.parsedOptions.taskBarStyle.cornerRadius,
130
+ fill: this._scene._gantt.parsedOptions.taskBarHoverColor,
131
+ visibleAll: !1
132
+ });
133
+ if (this.hoverBarGroup = hoverBarGroup, hoverBarGroup.name = "task-bar-hover-shadow",
134
+ this._scene._gantt.parsedOptions.taskBarResizable) {
135
+ const icon = new vtable_1.VRender.Image({
136
+ x: 0,
137
+ y: 0,
138
+ width: 10,
139
+ height: 20,
140
+ image: TASKBAR_HOVER_ICON,
141
+ pickable: !0,
142
+ cursor: "col-resize"
143
+ });
144
+ icon.name = "task-bar-hover-shadow-left-icon", this.hoverBarLeftIcon = icon, hoverBarGroup.appendChild(icon);
145
+ const rightIcon = new vtable_1.VRender.Image({
146
+ x: 0,
147
+ y: 0,
148
+ width: 10,
149
+ height: 20,
150
+ image: TASKBAR_HOVER_ICON,
151
+ pickable: !0,
152
+ cursor: "col-resize"
153
+ });
154
+ rightIcon.name = "task-bar-hover-shadow-right-icon", this.hoverBarRightIcon = rightIcon,
155
+ hoverBarGroup.appendChild(rightIcon);
156
+ }
157
+ }
158
+ setX(x) {
159
+ this.barContainer.setAttribute("x", x);
160
+ }
161
+ setY(y) {
162
+ this.barContainer.setAttribute("y", y);
163
+ }
164
+ refreshItems() {
165
+ this.height = this._scene._gantt.gridHeight, this.group.setAttribute("height", this.height),
166
+ this.barContainer.removeAllChild(), this.group.removeChild(this.barContainer), this.initBars();
167
+ }
168
+ resize() {
169
+ this.width = this._scene._gantt.tableNoFrameWidth, this.height = this._scene._gantt.gridHeight,
170
+ this.group.setAttribute("width", this.width), this.group.setAttribute("height", this.height);
171
+ }
172
+ showHoverBar(x, y, width, height, target) {
173
+ target && "task-bar" === target.name && target.appendChild(this.hoverBarGroup),
174
+ this.hoverBarGroup.setAttribute("x", 0), this.hoverBarGroup.setAttribute("y", 0),
175
+ this.hoverBarGroup.setAttribute("width", width), this.hoverBarGroup.setAttribute("height", height),
176
+ this.hoverBarGroup.setAttribute("visibleAll", !0), this.hoverBarLeftIcon && (this.hoverBarLeftIcon.setAttribute("x", 0),
177
+ this.hoverBarLeftIcon.setAttribute("y", Math.ceil(height / 10)), this.hoverBarLeftIcon.setAttribute("width", 10),
178
+ this.hoverBarLeftIcon.setAttribute("height", height - 2 * Math.ceil(height / 10)),
179
+ this.hoverBarRightIcon.setAttribute("x", width - 10), this.hoverBarRightIcon.setAttribute("y", Math.ceil(height / 10)),
180
+ this.hoverBarRightIcon.setAttribute("width", 10), this.hoverBarRightIcon.setAttribute("height", height - 2 * Math.ceil(height / 10)));
181
+ }
182
+ hideHoverBar() {
183
+ this.hoverBarGroup.setAttribute("visibleAll", !1);
184
+ }
185
+ }
186
+
187
+ exports.TaskBar = TaskBar;
188
+ //# sourceMappingURL=task-bar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/scenegraph/task-bar.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAG3C,wCAAgE;AAChE,6CAA2C;AAC3C,kDAA6C;AAC7C,2CAA+C;AAE/C,MAAM,kBAAkB,GAAG;;;OAGpB,CAAC;AAER,MAAa,OAAO;IASlB,YAAY,KAAiB;QAC3B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC;QAC5C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC;QACtC,IAAI,CAAC,KAAK,GAAG,IAAI,gBAAO,CAAC,KAAK,CAAC;YAC7B,CAAC,EAAE,CAAC;YACJ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,sBAAsB,EAAE;YACxC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,KAAK;YACf,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,IAAI,GA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AC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;YAChE,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YAChD,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;YAClF,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,GAAG,EAAE,CAAC,CAAC;YACrD,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;YACjE,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACjD,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;SACpF;IACH,CAAC;IACD,YAAY;QACV,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;CACF;AArRD,0BAqRC","file":"task-bar.js","sourcesContent":["import { VRender } from '@visactor/vtable';\nimport type { Scenegraph } from './scenegraph';\n// import { Icon } from './icon';\nimport { parseStringTemplate, toBoxArray } from '../tools/util';\nimport { isValid } from '@visactor/vutils';\nimport { getTextPos } from '../gantt-helper';\nimport { GanttTaskBarNode } from './ganttNode';\n\nconst TASKBAR_HOVER_ICON = `<svg width=\"100\" height=\"200\" xmlns=\"http://www.w3.org/2000/svg\">\n <line x1=\"30\" y1=\"10\" x2=\"30\" y2=\"190\" stroke=\"black\" stroke-width=\"4\"/>\n <line x1=\"70\" y1=\"10\" x2=\"70\" y2=\"190\" stroke=\"black\" stroke-width=\"4\"/>\n</svg>`;\n\nexport class TaskBar {\n group: VRender.Group;\n barContainer: VRender.Group;\n hoverBarGroup: VRender.Group;\n hoverBarLeftIcon: VRender.Image;\n hoverBarRightIcon: VRender.Image;\n _scene: Scenegraph;\n width: number;\n height: number;\n constructor(scene: Scenegraph) {\n this._scene = scene;\n // const height = Math.min(scene._gantt.tableNoFrameHeight, scene._gantt.drawHeight);\n this.width = scene._gantt.tableNoFrameWidth;\n this.height = scene._gantt.gridHeight;\n this.group = new VRender.Group({\n x: 0,\n y: scene._gantt.getAllHeaderRowsHeight(),\n width: this.width,\n height: this.height,\n pickable: false,\n clip: true\n });\n this.group.name = 'task-bar-container';\n scene.tableGroup.addChild(this.group);\n this.initBars();\n this.initHoverBarIcons();\n }\n\n initBars() {\n this.barContainer = new VRender.Group({\n x: 0,\n y: 0,\n width: this._scene._gantt.getAllColsWidth(),\n height: this._scene._gantt.getAllGridHeight(),\n pickable: false,\n clip: true\n });\n this.group.appendChild(this.barContainer);\n\n for (let i = 0; i < this._scene._gantt.itemCount; i++) {\n const barGroup = this.initBar(i);\n if (barGroup) {\n this.barContainer.appendChild(barGroup);\n }\n }\n }\n initBar(index: number) {\n const taskBarCustomLayout = this._scene._gantt.parsedOptions.taskBarCustomLayout;\n const { startDate, endDate, taskDays, progress, taskRecord } = this._scene._gantt.getTaskInfoByTaskListIndex(index);\n if (taskDays <= 0) {\n return null;\n }\n const taskBarSize = this._scene._gantt.parsedOptions.colWidthPerDay * taskDays;\n const taskbarHeight = this._scene._gantt.parsedOptions.taskBarStyle.width;\n const minDate = new Date(this._scene._gantt.parsedOptions.minDate);\n const barGroup = new GanttTaskBarNode({\n x:\n this._scene._gantt.parsedOptions.colWidthPerDay *\n Math.ceil(Math.abs(startDate.getTime() - minDate.getTime()) / (1000 * 60 * 60 * 24)),\n // y: this._scene._gantt.parsedOptions.rowHeight * i,\n y:\n this._scene._gantt.parsedOptions.rowHeight * index +\n (this._scene._gantt.parsedOptions.rowHeight - taskbarHeight) / 2,\n width: taskBarSize,\n // height: this._scene._gantt.parsedOptions.rowHeight,\n height: taskbarHeight,\n cornerRadius: this._scene._gantt.parsedOptions.taskBarStyle.cornerRadius,\n clip: true\n });\n barGroup.name = 'task-bar';\n // this.barContainer.appendChild(barGroup);\n let rootContainer;\n let renderDefaultBar = true;\n let renderDefaultText = true;\n\n if (taskBarCustomLayout) {\n let customLayoutObj;\n if (typeof taskBarCustomLayout === 'function') {\n const arg = {\n width: taskBarSize,\n height: taskbarHeight,\n index,\n startDate,\n endDate,\n taskDays,\n progress,\n taskRecord,\n ganttInstance: this._scene._gantt\n };\n customLayoutObj = taskBarCustomLayout(arg);\n } else {\n customLayoutObj = taskBarCustomLayout;\n }\n if (customLayoutObj) {\n // if (customLayoutObj.rootContainer) {\n // customLayoutObj.rootContainer = decodeReactDom(customLayoutObj.rootContainer);\n // }\n rootContainer = customLayoutObj.rootContainer;\n renderDefaultBar = customLayoutObj.renderDefaultBar ?? false;\n renderDefaultText = customLayoutObj.renderDefaultText ?? false;\n rootContainer.name = 'task-bar-custom-render';\n }\n }\n\n if (renderDefaultBar) {\n // 创建整个任务条rect\n const rect = VRender.createRect({\n x: 0,\n y: 0, //this._scene._gantt.parsedOptions.rowHeight - taskbarHeight) / 2,\n width: taskBarSize,\n height: taskbarHeight,\n fill: this._scene._gantt.parsedOptions.taskBarStyle.barColor,\n pickable: false\n });\n rect.name = 'task-bar-rect';\n barGroup.appendChild(rect);\n barGroup.barRect = rect;\n // 创建已完成部分任务条rect\n const progress_rect = VRender.createRect({\n x: 0,\n y: 0, //(this._scene._gantt.parsedOptions.rowHeight - taskbarHeight) / 2,\n width: (taskBarSize * progress) / 100,\n height: taskbarHeight,\n fill: this._scene._gantt.parsedOptions.taskBarStyle.completedBarColor,\n pickable: false\n });\n progress_rect.name = 'task-bar-progress-rect';\n barGroup.appendChild(progress_rect);\n barGroup.progressRect = progress_rect;\n }\n\n rootContainer && barGroup.appendChild(rootContainer);\n if (renderDefaultText) {\n const { textAlign, textBaseline, fontSize, fontFamily, textOverflow, color, padding } =\n this._scene._gantt.parsedOptions.taskBarLabelStyle;\n const position = getTextPos(toBoxArray(padding), textAlign, textBaseline, taskBarSize, taskbarHeight);\n //创建label 文字\n const label = VRender.createText({\n // visible: false,\n pickable: false,\n x: position.x, //extAlign === 'center' ? taskBarSize / 2 : textAlign === 'left' ? 10 : taskBarSize - 10,\n y: position.y, //fontSize / 2,\n fontSize: fontSize, // 10\n fill: color,\n fontFamily: fontFamily,\n text: parseStringTemplate(this._scene._gantt.parsedOptions.taskBarLabelText as string, taskRecord),\n maxLineWidth: taskBarSize - 20,\n textBaseline,\n textAlign,\n ellipsis:\n textOverflow === 'clip'\n ? ''\n : textOverflow === 'ellipsis'\n ? '...'\n : isValid(textOverflow)\n ? textOverflow\n : undefined\n // dx: 12 + 4,\n // dy: this._scene._gantt.barLabelStyle.fontSize / 2\n });\n barGroup.appendChild(label);\n barGroup.textLabel = label;\n }\n return barGroup;\n }\n updateTaskBarNode(index: number) {\n const taskbarGroup = this.barContainer.getChildren()?.[index] as GanttTaskBarNode;\n if (taskbarGroup) {\n this.barContainer.removeChild(taskbarGroup);\n const barGroup = this.initBar(index);\n if (barGroup) {\n this.barContainer.insertInto(barGroup, index); //TODO\n }\n }\n }\n initHoverBarIcons() {\n // const target = this._scene._gantt.stateManager.hoverTaskBar.target;\n\n // const barGroup = new VRender.Group({\n // x: target.attribute.x,\n // y: target.attribute.y,\n // width: target.attribute.width,\n // height: target.attribute.height,\n // cornerRadius: target.attribute.cornerRadius,\n // clip: true,\n // cursor: 'grab'\n // });\n const hoverBarGroup = new VRender.Group({\n x: 0,\n y: 0,\n width: 100,\n height: 100,\n clip: true,\n cursor: this._scene._gantt.parsedOptions.taskBarMoveable ? 'grab' : 'default',\n pickable: false,\n cornerRadius: this._scene._gantt.parsedOptions.taskBarStyle.cornerRadius,\n fill: this._scene._gantt.parsedOptions.taskBarHoverColor,\n visibleAll: false\n });\n this.hoverBarGroup = hoverBarGroup;\n hoverBarGroup.name = 'task-bar-hover-shadow';\n // this.barContainer.appendChild(hoverBarGroup);\n // 创建左侧的icon\n if (this._scene._gantt.parsedOptions.taskBarResizable) {\n const icon = new VRender.Image({\n x: 0,\n y: 0, //this._scene._gantt.parsedOptions.rowHeight - taskbarHeight) / 2,\n width: 10,\n height: 20,\n image: TASKBAR_HOVER_ICON,\n pickable: true,\n cursor: 'col-resize'\n });\n icon.name = 'task-bar-hover-shadow-left-icon';\n this.hoverBarLeftIcon = icon;\n hoverBarGroup.appendChild(icon);\n\n // 创建右侧的icon\n const rightIcon = new VRender.Image({\n x: 0,\n y: 0, //this._scene._gantt.parsedOptions.rowHeight - taskbarHeight) / 2,\n width: 10,\n height: 20,\n image: TASKBAR_HOVER_ICON,\n pickable: true,\n cursor: 'col-resize'\n });\n rightIcon.name = 'task-bar-hover-shadow-right-icon';\n this.hoverBarRightIcon = rightIcon;\n hoverBarGroup.appendChild(rightIcon);\n }\n }\n setX(x: number) {\n this.barContainer.setAttribute('x', x);\n }\n setY(y: number) {\n this.barContainer.setAttribute('y', y);\n }\n /** 重新创建任务条节点 */\n refreshItems() {\n this.height = this._scene._gantt.gridHeight;\n this.group.setAttribute('height', this.height);\n this.barContainer.removeAllChild();\n this.group.removeChild(this.barContainer);\n this.initBars();\n }\n resize() {\n this.width = this._scene._gantt.tableNoFrameWidth;\n this.height = this._scene._gantt.gridHeight;\n this.group.setAttribute('width', this.width);\n this.group.setAttribute('height', this.height);\n }\n\n showHoverBar(x: number, y: number, width: number, height: number, target?: VRender.Group) {\n if (target && target.name === 'task-bar') {\n // this.hoverBarGroup.releatedTaskBar = target;\n target.appendChild(this.hoverBarGroup);\n }\n this.hoverBarGroup.setAttribute('x', 0);\n this.hoverBarGroup.setAttribute('y', 0);\n this.hoverBarGroup.setAttribute('width', width);\n this.hoverBarGroup.setAttribute('height', height);\n this.hoverBarGroup.setAttribute('visibleAll', true);\n if (this.hoverBarLeftIcon) {\n this.hoverBarLeftIcon.setAttribute('x', 0);\n this.hoverBarLeftIcon.setAttribute('y', Math.ceil(height / 10));\n this.hoverBarLeftIcon.setAttribute('width', 10);\n this.hoverBarLeftIcon.setAttribute('height', height - 2 * Math.ceil(height / 10));\n this.hoverBarRightIcon.setAttribute('x', width - 10);\n this.hoverBarRightIcon.setAttribute('y', Math.ceil(height / 10));\n this.hoverBarRightIcon.setAttribute('width', 10);\n this.hoverBarRightIcon.setAttribute('height', height - 2 * Math.ceil(height / 10));\n }\n }\n hideHoverBar() {\n this.hoverBarGroup.setAttribute('visibleAll', false);\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { Scenegraph } from './scenegraph';
2
+ import { VRender } from '@visactor/vtable';
3
+ export declare class TimelineHeader {
4
+ group: VRender.Group;
5
+ _scene: Scenegraph;
6
+ constructor(scene: Scenegraph);
7
+ setX(x: number): void;
8
+ setY(y: number): void;
9
+ resize(): void;
10
+ }
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.TimelineHeader = void 0;
6
+
7
+ const vutils_1 = require("@visactor/vutils"), gantt_helper_1 = require("../gantt-helper"), util_1 = require("../tools/util"), vtable_1 = require("@visactor/vtable");
8
+
9
+ class TimelineHeader {
10
+ constructor(scene) {
11
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
12
+ this._scene = scene;
13
+ const dateHeader = new vtable_1.VRender.Group({
14
+ x: 0,
15
+ y: 0,
16
+ width: scene._gantt.getAllColsWidth(),
17
+ height: scene._gantt.getAllHeaderRowsHeight(),
18
+ clip: !0,
19
+ pickable: !1
20
+ });
21
+ this.group = dateHeader, dateHeader.name = "date-header-container", scene.tableGroup.addChild(this.group);
22
+ let y = 0;
23
+ for (let i = 0; i < scene._gantt.headerLevel; i++) {
24
+ const rowHeader = new vtable_1.VRender.Group({
25
+ x: 0,
26
+ y: y,
27
+ width: scene._gantt.getAllColsWidth(),
28
+ height: Array.isArray(scene._gantt.parsedOptions.headerRowHeight) ? scene._gantt.parsedOptions.headerRowHeight[i] : scene._gantt.parsedOptions.headerRowHeight,
29
+ clip: !1
30
+ });
31
+ y += rowHeader.attribute.height, rowHeader.name = "row-header", dateHeader.addChild(rowHeader);
32
+ const {unit: unit, timelineDates: timelineDates, customLayout: customLayout} = scene._gantt.sortedTimelineScales[i];
33
+ let x = 0;
34
+ for (let j = 0; j < timelineDates.length; j++) {
35
+ const {days: days, endDate: endDate, startDate: startDate, title: title, dateIndex: dateIndex} = timelineDates[j], date = new vtable_1.VRender.Group({
36
+ x: x,
37
+ y: 0,
38
+ width: scene._gantt.parsedOptions.colWidthPerDay * days,
39
+ height: rowHeader.attribute.height,
40
+ clip: !1,
41
+ fill: scene._gantt.parsedOptions.timelineHeaderBackgroundColor
42
+ });
43
+ let rootContainer;
44
+ date.name = "date-cell";
45
+ let renderDefaultText = !0;
46
+ const width = scene._gantt.parsedOptions.colWidthPerDay * timelineDates[j].days, height = rowHeader.attribute.height;
47
+ if (customLayout) {
48
+ let customLayoutObj;
49
+ if ("function" == typeof customLayout) {
50
+ customLayoutObj = customLayout({
51
+ width: width,
52
+ height: height,
53
+ index: j,
54
+ startDate: startDate,
55
+ endDate: endDate,
56
+ days: days,
57
+ dateIndex: dateIndex,
58
+ title: title,
59
+ ganttInstance: this._scene._gantt
60
+ });
61
+ } else customLayoutObj = customLayout;
62
+ customLayoutObj && (rootContainer = customLayoutObj.rootContainer, renderDefaultText = null !== (_a = customLayoutObj.renderDefaultText) && void 0 !== _a && _a,
63
+ rootContainer.name = "task-bar-custom-render"), rootContainer && date.appendChild(rootContainer);
64
+ }
65
+ if (renderDefaultText) {
66
+ const {padding: padding, textAlign: textAlign, textBaseline: textBaseline, textOverflow: textOverflow, fontSize: fontSize, fontWeight: fontWeight, color: color, strokeColor: strokeColor} = scene._gantt.parsedOptions.timelineHeaderStyles[i], position = (0,
67
+ gantt_helper_1.getTextPos)((0, util_1.toBoxArray)(padding), textAlign, textBaseline, width, height), text = new vtable_1.VRender.Text({
68
+ x: position.x,
69
+ y: position.y,
70
+ maxLineWidth: width,
71
+ heightLimit: height,
72
+ pickable: !0,
73
+ text: title.toLocaleString(),
74
+ fontSize: fontSize,
75
+ fontWeight: fontWeight,
76
+ fill: color,
77
+ stroke: strokeColor,
78
+ lineWidth: 2,
79
+ textAlign: textAlign,
80
+ textBaseline: textBaseline,
81
+ ellipsis: "clip" === textOverflow ? "" : "ellipsis" === textOverflow ? "..." : (0,
82
+ vutils_1.isValid)(textOverflow) ? textOverflow : void 0
83
+ });
84
+ date.appendChild(text);
85
+ }
86
+ if (rowHeader.addChild(date), j > 0) {
87
+ const line = vtable_1.VRender.createLine({
88
+ pickable: !1,
89
+ stroke: null === (_b = scene._gantt.parsedOptions.timelineHeaderVerticalLineStyle) || void 0 === _b ? void 0 : _b.lineColor,
90
+ lineWidth: null === (_c = scene._gantt.parsedOptions.timelineHeaderVerticalLineStyle) || void 0 === _c ? void 0 : _c.lineWidth,
91
+ points: [ {
92
+ x: 1 & (null === (_d = scene._gantt.parsedOptions.timelineHeaderVerticalLineStyle) || void 0 === _d ? void 0 : _d.lineWidth) ? .5 : 0,
93
+ y: 0
94
+ }, {
95
+ x: 1 & (null === (_e = scene._gantt.parsedOptions.timelineHeaderVerticalLineStyle) || void 0 === _e ? void 0 : _e.lineWidth) ? .5 : 0,
96
+ y: rowHeader.attribute.height
97
+ } ]
98
+ });
99
+ date.appendChild(line);
100
+ }
101
+ x += width;
102
+ }
103
+ if (i > 0) {
104
+ const line = vtable_1.VRender.createLine({
105
+ pickable: !1,
106
+ stroke: null === (_f = scene._gantt.parsedOptions.timelineHeaderHorizontalLineStyle) || void 0 === _f ? void 0 : _f.lineColor,
107
+ lineWidth: null === (_g = scene._gantt.parsedOptions.timelineHeaderHorizontalLineStyle) || void 0 === _g ? void 0 : _g.lineWidth,
108
+ points: [ {
109
+ x: 0,
110
+ y: 1 & (null === (_h = scene._gantt.parsedOptions.timelineHeaderHorizontalLineStyle) || void 0 === _h ? void 0 : _h.lineWidth) ? .5 : 0
111
+ }, {
112
+ x: scene._gantt.getAllColsWidth(),
113
+ y: 1 & (null === (_j = scene._gantt.parsedOptions.timelineHeaderHorizontalLineStyle) || void 0 === _j ? void 0 : _j.lineWidth) ? .5 : 0
114
+ } ]
115
+ });
116
+ rowHeader.addChild(line);
117
+ }
118
+ }
119
+ }
120
+ setX(x) {
121
+ this.group.setAttribute("x", x);
122
+ }
123
+ setY(y) {
124
+ this.group.setAttribute("y", y);
125
+ }
126
+ resize() {
127
+ var _a, _b, _c, _d;
128
+ this.group.setAttribute("width", null !== (_b = null === (_a = this.group.attribute) || void 0 === _a ? void 0 : _a.width) && void 0 !== _b ? _b : 0),
129
+ this.group.setAttribute("height", null !== (_d = null === (_c = this.group.attribute) || void 0 === _c ? void 0 : _c.height) && void 0 !== _d ? _d : 0);
130
+ }
131
+ }
132
+
133
+ exports.TimelineHeader = TimelineHeader;
134
+ //# sourceMappingURL=timeline-header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/scenegraph/timeline-header.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAC3C,kDAA6C;AAC7C,wCAA2C;AAE3C,6CAA2C;AAC3C,MAAa,cAAc;IAGzB,YAAY,KAAiB;;QAC3B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,MAAM,UAAU,GAAG,IAAI,gBAAO,CAAC,KAAK,CAAC;YACnC,CAAC,EAAE,CAAC;YACJ,CAAC,EAAE,CAAC;YACJ,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,eAAe,EAAE;YACrC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,sBAAsB,EAAE;YAC7C,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,KAAK;SAIhB,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC;QACxB,UAAU,CAAC,IAAI,GAAG,uBAAuB,CAAC;QAC1C,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CA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CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;yBACzF;qBACF;iBACF,CAAC,CAAC;gBACH,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;aAC1B;SACF;IACH,CAAC;IACD,IAAI,CAAC,CAAS;QACZ,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAClC,CAAC;IACD,IAAI,CAAC,CAAS;QACZ,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAClC,CAAC;IACD,MAAM;;QACJ,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,MAAA,MAAA,IAAI,CAAC,KAAK,CAAC,SAAS,0CAAE,KAAK,mCAAI,CAAC,CAAC,CAAC;QACnE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAA,MAAA,IAAI,CAAC,KAAK,CAAC,SAAS,0CAAE,MAAM,mCAAI,CAAC,CAAC,CAAC;IACvE,CAAC;CACF;AAxKD,wCAwKC","file":"timeline-header.js","sourcesContent":["import { isValid } from '@visactor/vutils';\nimport { getTextPos } from '../gantt-helper';\nimport { toBoxArray } from '../tools/util';\nimport type { Scenegraph } from './scenegraph';\nimport { VRender } from '@visactor/vtable';\nexport class TimelineHeader {\n group: VRender.Group;\n _scene: Scenegraph;\n constructor(scene: Scenegraph) {\n this._scene = scene;\n const dateHeader = new VRender.Group({\n x: 0,\n y: 0,\n width: scene._gantt.getAllColsWidth(), //width - 2,\n height: scene._gantt.getAllHeaderRowsHeight(),\n clip: true,\n pickable: false\n // fill: 'purple',\n // stroke: 'green',\n // lineWidth: 2\n });\n this.group = dateHeader;\n dateHeader.name = 'date-header-container';\n scene.tableGroup.addChild(this.group);\n\n let y = 0;\n for (let i = 0; i < scene._gantt.headerLevel; i++) {\n const rowHeader = new VRender.Group({\n x: 0,\n y,\n width: scene._gantt.getAllColsWidth(),\n height: Array.isArray(scene._gantt.parsedOptions.headerRowHeight)\n ? scene._gantt.parsedOptions.headerRowHeight[i]\n : scene._gantt.parsedOptions.headerRowHeight,\n clip: false\n });\n y += rowHeader.attribute.height;\n rowHeader.name = 'row-header';\n dateHeader.addChild(rowHeader);\n\n const { unit, timelineDates, customLayout } = scene._gantt.sortedTimelineScales[i];\n let x = 0;\n for (let j = 0; j < timelineDates.length; j++) {\n const { days, endDate, startDate, title, dateIndex } = timelineDates[j];\n const date = new VRender.Group({\n x,\n y: 0,\n width: scene._gantt.parsedOptions.colWidthPerDay * days,\n height: rowHeader.attribute.height,\n clip: false,\n fill: scene._gantt.parsedOptions.timelineHeaderBackgroundColor\n });\n date.name = 'date-cell';\n // const rect = createRect({\n // x: 0,\n // y: 0,\n // width: scene._gantt.parsedOptions.colWidthPerDay * timelineDates[j].days,\n // height: scene._gantt.parsedOptions.headerRowHeight,\n // fill: scene._gantt.parsedOptions.timelineHeaderStyle?.backgroundColor\n // });\n // date.appendChild(rect);\n let rootContainer;\n let renderDefaultText = true;\n const width = scene._gantt.parsedOptions.colWidthPerDay * timelineDates[j].days;\n const height = rowHeader.attribute.height;\n if (customLayout) {\n let customLayoutObj;\n if (typeof customLayout === 'function') {\n const arg = {\n width,\n height,\n index: j,\n startDate,\n endDate,\n days,\n dateIndex,\n title,\n ganttInstance: this._scene._gantt\n };\n customLayoutObj = customLayout(arg);\n } else {\n customLayoutObj = customLayout;\n }\n if (customLayoutObj) {\n // if (customLayoutObj.rootContainer) {\n // customLayoutObj.rootContainer = decodeReactDom(customLayoutObj.rootContainer);\n // }\n rootContainer = customLayoutObj.rootContainer;\n renderDefaultText = customLayoutObj.renderDefaultText ?? false;\n rootContainer.name = 'task-bar-custom-render';\n }\n rootContainer && date.appendChild(rootContainer);\n }\n if (renderDefaultText) {\n const { padding, textAlign, textBaseline, textOverflow, fontSize, fontWeight, color, strokeColor } =\n scene._gantt.parsedOptions.timelineHeaderStyles[i];\n\n const position = getTextPos(toBoxArray(padding), textAlign, textBaseline, width, height);\n const text = new VRender.Text({\n x: position.x,\n y: position.y,\n maxLineWidth: width,\n // width: scene._gantt.parsedOptions.colWidthPerDay * timelineDates[j].days,\n heightLimit: height,\n // clip: true,\n pickable: true,\n text: title.toLocaleString(),\n fontSize: fontSize,\n\n fontWeight: fontWeight,\n fill: color,\n stroke: strokeColor,\n lineWidth: 2,\n textAlign,\n textBaseline,\n ellipsis:\n textOverflow === 'clip'\n ? ''\n : textOverflow === 'ellipsis'\n ? '...'\n : isValid(textOverflow)\n ? textOverflow\n : undefined\n });\n date.appendChild(text);\n }\n rowHeader.addChild(date);\n\n if (j > 0) {\n const line = VRender.createLine({\n pickable: false,\n stroke: scene._gantt.parsedOptions.timelineHeaderVerticalLineStyle?.lineColor,\n lineWidth: scene._gantt.parsedOptions.timelineHeaderVerticalLineStyle?.lineWidth,\n points: [\n { x: scene._gantt.parsedOptions.timelineHeaderVerticalLineStyle?.lineWidth & 1 ? 0.5 : 0, y: 0 },\n {\n x: scene._gantt.parsedOptions.timelineHeaderVerticalLineStyle?.lineWidth & 1 ? 0.5 : 0,\n y: rowHeader.attribute.height\n }\n ]\n });\n date.appendChild(line);\n }\n x += width;\n }\n //创建表头分割线 水平分割线 TODO\n if (i > 0) {\n const line = VRender.createLine({\n pickable: false,\n stroke: scene._gantt.parsedOptions.timelineHeaderHorizontalLineStyle?.lineColor,\n lineWidth: scene._gantt.parsedOptions.timelineHeaderHorizontalLineStyle?.lineWidth,\n points: [\n { x: 0, y: scene._gantt.parsedOptions.timelineHeaderHorizontalLineStyle?.lineWidth & 1 ? 0.5 : 0 },\n {\n x: scene._gantt.getAllColsWidth(),\n y: scene._gantt.parsedOptions.timelineHeaderHorizontalLineStyle?.lineWidth & 1 ? 0.5 : 0\n }\n ]\n });\n rowHeader.addChild(line);\n }\n }\n }\n setX(x: number) {\n this.group.setAttribute('x', x);\n }\n setY(y: number) {\n this.group.setAttribute('y', y);\n }\n resize() {\n this.group.setAttribute('width', this.group.attribute?.width ?? 0);\n this.group.setAttribute('height', this.group.attribute?.height ?? 0);\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import type { Gantt } from '../Gantt';
2
+ export declare function syncScrollStateToTable(gantt: Gantt): void;
3
+ export declare function syncScrollStateFromTable(gantt: Gantt): void;
4
+ export declare function syncResizeStateFromTable(gantt: Gantt): void;
5
+ export declare function syncEditCellFromTable(gantt: Gantt): void;
6
+ export declare function syncDragOrderFromTable(gantt: Gantt): void;
7
+ export declare function syncTreeChangeFromTable(gantt: Gantt): void;