cwhi-gantt 1.2.4 → 1.2.6

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/dist/gantt.js CHANGED
@@ -905,8 +905,49 @@
905
905
  }));
906
906
  }
907
907
 
908
- var ROW_GAP = 2; // 任务条与基线之间的间距
908
+ function getTime(val) {
909
+ if (!val) return null;
910
+ return typeof val.getTime === 'function' ? val.getTime() : val;
911
+ }
912
+
913
+ // 根据 status 和日期计算活动条颜色
914
+ // status: 1=未开始 2=已完成 3=已开始
915
+ function getBarColors(v, current, styles) {
916
+ var status = v.status;
917
+ var blFinish = getTime(v.baselineEnd);
918
+ var actualFinish = getTime(v.end);
919
+
920
+ // 已完成:整个进度条绿色
921
+ if (status === 2) {
922
+ return {
923
+ front: styles.completedGreen,
924
+ back: styles.completedGreen
925
+ };
926
+ }
909
927
 
928
+ // 未完成:已完成部分深蓝,未完成部分根据情况
929
+ if (status === 1 || status === 3) {
930
+ var doneStyle = styles.doneBlue;
931
+ var undoneStyle = styles.undoneLightGreen;
932
+ if (blFinish != null) {
933
+ var isDelayed = actualFinish != null ? actualFinish > blFinish : current > blFinish;
934
+ var isExpectedOverdue = current < blFinish && actualFinish != null && actualFinish > blFinish;
935
+ var isExpectedOnTime = current < blFinish && (actualFinish == null || actualFinish <= blFinish);
936
+ if (isDelayed) {
937
+ undoneStyle = styles.undoneRed;
938
+ } else if (isExpectedOverdue) {
939
+ undoneStyle = styles.undoneYellow;
940
+ } else if (isExpectedOnTime) {
941
+ undoneStyle = styles.undoneLightGreen;
942
+ }
943
+ }
944
+ return {
945
+ front: doneStyle,
946
+ back: undoneStyle
947
+ };
948
+ }
949
+ return null;
950
+ }
910
951
  function Bar(_ref) {
911
952
  var styles = _ref.styles,
912
953
  data = _ref.data,
@@ -917,13 +958,15 @@
917
958
  showDelay = _ref.showDelay,
918
959
  rowHeight = _ref.rowHeight,
919
960
  barHeight = _ref.barHeight,
961
+ baselineHeight = _ref.baselineHeight,
920
962
  _ref$rowPadding = _ref.rowPadding,
921
- rowPadding = _ref$rowPadding === void 0 ? 5 : _ref$rowPadding,
963
+ rowPadding = _ref$rowPadding === void 0 ? 10 : _ref$rowPadding,
964
+ _ref$rowGap = _ref.rowGap,
965
+ rowGap = _ref$rowGap === void 0 ? 2 : _ref$rowGap,
922
966
  maxTextWidth = _ref.maxTextWidth,
923
967
  current = _ref.current,
924
968
  onClick = _ref.onClick;
925
969
  var x0 = maxTextWidth;
926
- var partHeight = barHeight;
927
970
  var cur = x0 + (current - minTime) / unit;
928
971
  return h("g", null, current > minTime ? h("line", {
929
972
  x1: cur,
@@ -936,7 +979,7 @@
936
979
  return onClick(v);
937
980
  };
938
981
  var y = offsetY + i * rowHeight + rowPadding;
939
- var cy = y + partHeight / 2;
982
+ var cy = y + barHeight / 2;
940
983
  var hasStartEnd = v.start && v.end;
941
984
  var hasBaselineOnly = !hasStartEnd && v.baselineStart && v.baselineEnd;
942
985
 
@@ -945,7 +988,7 @@
945
988
  var _baselineWidth = (v.baselineEnd - v.baselineStart) / unit;
946
989
  if (_baselineWidth <= 0) return null;
947
990
  var _bx = x0 + (v.baselineStart - minTime) / unit;
948
- var _baselineCy = y + partHeight + ROW_GAP + partHeight / 2;
991
+ var _baselineCy = y + barHeight + rowGap + baselineHeight / 2;
949
992
  return h("g", {
950
993
  key: i,
951
994
  "class": "gantt-bar",
@@ -963,9 +1006,9 @@
963
1006
  style: styles.text2
964
1007
  }, formatDay(v.baselineEnd)), h("rect", {
965
1008
  x: _bx,
966
- y: y + partHeight + ROW_GAP,
1009
+ y: y + barHeight + rowGap,
967
1010
  width: _baselineWidth,
968
- height: partHeight,
1011
+ height: baselineHeight,
969
1012
  rx: 1.2,
970
1013
  ry: 1.2,
971
1014
  style: styles.baseline,
@@ -979,7 +1022,7 @@
979
1022
  }
980
1023
  var x = x0 + (v.start - minTime) / unit;
981
1024
  if (v.type === 'milestone') {
982
- var size = partHeight / 2;
1025
+ var size = barHeight / 2;
983
1026
  var points = [[x, cy - size], [x + size, cy], [x, cy + size], [x - size, cy]].map(function (p) {
984
1027
  return "".concat(p[0], ",").concat(p[1]);
985
1028
  }).join(' ');
@@ -1009,25 +1052,34 @@
1009
1052
  if (w1 <= 0) {
1010
1053
  return null;
1011
1054
  }
1012
- var bar = v.type === 'group' ? {
1013
- back: styles.groupBack,
1014
- front: styles.groupFront
1015
- } : {
1016
- back: styles.taskBack,
1017
- front: styles.taskFront
1018
- };
1019
- if (showDelay) {
1020
- if (x + w2 < cur && v.percent < 0.999999) {
1021
- bar.back = styles.warning;
1022
- }
1023
- if (x + w1 < cur && v.percent < 0.999999) {
1024
- bar.back = styles.danger;
1055
+ var bar;
1056
+ var statusColors = v.status != null ? getBarColors(v, current, styles) : null;
1057
+ if (statusColors) {
1058
+ bar = {
1059
+ back: statusColors.back,
1060
+ front: statusColors.front
1061
+ };
1062
+ } else {
1063
+ bar = v.type === 'group' ? {
1064
+ back: styles.groupBack,
1065
+ front: styles.groupFront
1066
+ } : {
1067
+ back: styles.taskBack,
1068
+ front: styles.taskFront
1069
+ };
1070
+ if (showDelay) {
1071
+ if (x + w2 < cur && v.percent < 0.999999) {
1072
+ bar.back = styles.warning;
1073
+ }
1074
+ if (x + w1 < cur && v.percent < 0.999999) {
1075
+ bar.back = styles.danger;
1076
+ }
1025
1077
  }
1026
1078
  }
1027
- // 基线渲染 - 与进度条等高,位于任务条下方,并显示基线开始/结束时间
1079
+ // 基线渲染 - 位于任务条下方,高度为进度条的1/2,并显示基线开始/结束时间
1028
1080
  var baselineWidth = (v.baselineEnd - v.baselineStart) / unit;
1029
1081
  var bx = x0 + (v.baselineStart - minTime) / unit;
1030
- var baselineCy = y + partHeight + ROW_GAP + partHeight / 2;
1082
+ var baselineCy = y + barHeight + rowGap + baselineHeight / 2;
1031
1083
  var baseline = v.baselineStart && v.baselineEnd && baselineWidth > 0 ? h("g", null, h("text", {
1032
1084
  x: bx - 4,
1033
1085
  y: baselineCy,
@@ -1038,9 +1090,9 @@
1038
1090
  style: styles.text2
1039
1091
  }, formatDay(v.baselineEnd)), h("rect", {
1040
1092
  x: bx,
1041
- y: y + partHeight + ROW_GAP,
1093
+ y: y + barHeight + rowGap,
1042
1094
  width: baselineWidth,
1043
- height: partHeight,
1095
+ height: baselineHeight,
1044
1096
  rx: 1.2,
1045
1097
  ry: 1.2,
1046
1098
  style: styles.baseline
@@ -1064,7 +1116,7 @@
1064
1116
  x: x,
1065
1117
  y: y,
1066
1118
  width: w1,
1067
- height: partHeight,
1119
+ height: barHeight,
1068
1120
  rx: 1.8,
1069
1121
  ry: 1.8,
1070
1122
  style: bar.back,
@@ -1073,7 +1125,7 @@
1073
1125
  x: x,
1074
1126
  y: y,
1075
1127
  width: w2,
1076
- height: partHeight,
1128
+ height: barHeight,
1077
1129
  rx: 1.8,
1078
1130
  ry: 1.8,
1079
1131
  style: bar.front
@@ -1135,6 +1187,16 @@
1135
1187
  link = _ref2$link === void 0 ? '#ffa011' : _ref2$link,
1136
1188
  _ref2$baseline = _ref2.baseline,
1137
1189
  baseline = _ref2$baseline === void 0 ? '#3c3c3c' : _ref2$baseline,
1190
+ _ref2$completedGreen = _ref2.completedGreen,
1191
+ completedGreen = _ref2$completedGreen === void 0 ? '#52c41a' : _ref2$completedGreen,
1192
+ _ref2$doneBlue = _ref2.doneBlue,
1193
+ doneBlue = _ref2$doneBlue === void 0 ? '#1565c0' : _ref2$doneBlue,
1194
+ _ref2$undoneRed = _ref2.undoneRed,
1195
+ undoneRed = _ref2$undoneRed === void 0 ? '#f5222d' : _ref2$undoneRed,
1196
+ _ref2$undoneYellow = _ref2.undoneYellow,
1197
+ undoneYellow = _ref2$undoneYellow === void 0 ? '#faad14' : _ref2$undoneYellow,
1198
+ _ref2$undoneLightGree = _ref2.undoneLightGreen,
1199
+ undoneLightGreen = _ref2$undoneLightGree === void 0 ? '#95de64' : _ref2$undoneLightGree,
1138
1200
  _ref2$textColor = _ref2.textColor,
1139
1201
  textColor = _ref2$textColor === void 0 ? '#222' : _ref2$textColor,
1140
1202
  _ref2$lightTextColor = _ref2.lightTextColor,
@@ -1233,6 +1295,21 @@
1233
1295
  critical: {
1234
1296
  fill: critical
1235
1297
  },
1298
+ completedGreen: {
1299
+ fill: completedGreen
1300
+ },
1301
+ doneBlue: {
1302
+ fill: doneBlue
1303
+ },
1304
+ undoneRed: {
1305
+ fill: undoneRed
1306
+ },
1307
+ undoneYellow: {
1308
+ fill: undoneYellow
1309
+ },
1310
+ undoneLightGreen: {
1311
+ fill: undoneLightGreen
1312
+ },
1236
1313
  baseline: {
1237
1314
  fill: baseline,
1238
1315
  opacity: 0.5
@@ -1284,9 +1361,12 @@
1284
1361
  var box = "0 0 ".concat(width, " ").concat(height);
1285
1362
  var current = Date.now();
1286
1363
  var styles = getStyles(styleOptions);
1287
- // 基线与进度条等高,上下留白,总高度不变
1364
+ // 基线:进度条 = 1:2,保持相同间距,总高度不变
1288
1365
  var rowPadding = 10;
1289
- var partHeight = Math.floor((rowHeight - rowPadding * 2 - 2) / 2); // 2=gap
1366
+ var ROW_GAP = 2;
1367
+ var usable = rowHeight - rowPadding * 2 - ROW_GAP;
1368
+ var progressBarHeight = Math.floor(usable * 2 / 3); // 进度条高度
1369
+ var baselineHeight = Math.floor(usable / 3); // 基线高度
1290
1370
 
1291
1371
  return h("svg", {
1292
1372
  width: width,
@@ -1345,7 +1425,7 @@
1345
1425
  offsetY: offsetY,
1346
1426
  minTime: minTime,
1347
1427
  rowHeight: rowHeight,
1348
- barHeight: partHeight,
1428
+ barHeight: progressBarHeight,
1349
1429
  maxTextWidth: maxTextWidth
1350
1430
  }) : null, h(Bar, {
1351
1431
  styles: styles,
@@ -1358,8 +1438,10 @@
1358
1438
  onClick: onClick,
1359
1439
  showDelay: showDelay,
1360
1440
  rowHeight: rowHeight,
1361
- barHeight: partHeight,
1441
+ barHeight: progressBarHeight,
1442
+ baselineHeight: baselineHeight,
1362
1443
  rowPadding: rowPadding,
1444
+ rowGap: ROW_GAP,
1363
1445
  maxTextWidth: maxTextWidth
1364
1446
  }));
1365
1447
  }
package/dist/gantt.min.js CHANGED
@@ -1 +1 @@
1
- (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define(["exports"],factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,factory(global.Gantt={}))})(this,function(exports){"use strict";function getDefaultExportFromCjs(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x["default"]:x}function createCommonjsModule(fn,basedir,module){return module={path:basedir,exports:{},require:function(path,base){return commonjsRequire(path,base===undefined||base===null?module.path:base)}},fn(module,module.exports),module.exports}function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var _extends_1=createCommonjsModule(function(module){function _extends(){return module.exports=_extends=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},module.exports.__esModule=true,module.exports["default"]=module.exports,_extends.apply(null,arguments)}module.exports=_extends,module.exports.__esModule=true,module.exports["default"]=module.exports});var _extends=getDefaultExportFromCjs(_extends_1);var _typeof_1=createCommonjsModule(function(module){function _typeof(o){"@babel/helpers - typeof";return module.exports=_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},module.exports.__esModule=true,module.exports["default"]=module.exports,_typeof(o)}module.exports=_typeof,module.exports.__esModule=true,module.exports["default"]=module.exports});var _typeof=getDefaultExportFromCjs(_typeof_1);var toPrimitive_1=createCommonjsModule(function(module){var _typeof=_typeof_1["default"];function toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}module.exports=toPrimitive,module.exports.__esModule=true,module.exports["default"]=module.exports});var toPropertyKey_1=createCommonjsModule(function(module){var _typeof=_typeof_1["default"];function toPropertyKey(t){var i=toPrimitive_1(t,"string");return"symbol"==_typeof(i)?i:i+""}module.exports=toPropertyKey,module.exports.__esModule=true,module.exports["default"]=module.exports});var defineProperty=createCommonjsModule(function(module){function _defineProperty(e,r,t){return(r=toPropertyKey_1(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}module.exports=_defineProperty,module.exports.__esModule=true,module.exports["default"]=module.exports});var _defineProperty=getDefaultExportFromCjs(defineProperty);var classCallCheck=createCommonjsModule(function(module){function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}module.exports=_classCallCheck,module.exports.__esModule=true,module.exports["default"]=module.exports});var _classCallCheck=getDefaultExportFromCjs(classCallCheck);var createClass=createCommonjsModule(function(module){function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,toPropertyKey_1(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}module.exports=_createClass,module.exports.__esModule=true,module.exports["default"]=module.exports});var _createClass=getDefaultExportFromCjs(createClass);function ownKeys$5(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread$5(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys$5(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys$5(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function addChild(c,childNodes){if(c===null||c===undefined)return;if(typeof c==="string"||typeof c==="number"){childNodes.push(c.toString())}else if(Array.isArray(c)){for(var i=0;i<c.length;i++){addChild(c[i],childNodes)}}else{childNodes.push(c)}}function h(tag,props){var childNodes=[];for(var _len=arguments.length,children=new Array(_len>2?_len-2:0),_key=2;_key<_len;_key++){children[_key-2]=arguments[_key]}addChild(children,childNodes);if(typeof tag==="function"){return tag(_objectSpread$5(_objectSpread$5({},props),{},{children:childNodes}))}return{tag:tag,props:props,children:childNodes}}function ownKeys$4(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread$4(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys$4(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys$4(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}var DAY=24*3600*1e3;function addDays(date,days){var d=new Date(date.valueOf());d.setDate(d.getDate()+days);return d}function getDates(begin,end){var dates=[];var s=new Date(begin);s.setHours(24,0,0,0);while(s.getTime()<=end){dates.push(s.getTime());s=addDays(s,1)}return dates}var ctx=null;function textWidth(text,font,pad){ctx=ctx||document.createElement("canvas").getContext("2d");ctx.font=font;return ctx.measureText(text).width+pad}function formatMonth(date){var y=date.getFullYear();var m=date.getMonth()+1;return"".concat(y,"/").concat(m>9?m:"0".concat(m))}function formatDay(date){var m=date.getMonth()+1;var d=date.getDate();return"".concat(m,"/").concat(d)}function minDate(a,b){if(a&&b){return a>b?b:a}return a||b}function maxDate(a,b){if(a&&b){return a<b?b:a}return a||b}function max(list,defaultValue){if(list.length){return Math.max.apply(null,list)}return defaultValue}function p2s(arr){return arr.map(function(p){return"".concat(p[0],",").concat(p[1])}).join(" ")}function s2p(str){return str.split(" ").map(function(s){var p=s.split(",");return[parseFloat(p[0]),parseFloat(p[1])]})}function walkLevel(nodes,level){for(var i=0;i<nodes.length;i++){var node=nodes[i];node.level="".concat(level).concat(i+1);node.text="".concat(node.level," ").concat(node.name);walkLevel(node.children,"".concat(node.level,"."))}}function walkDates(nodes){var start=null;var end=null;var baselineStart=null;var baselineEnd=null;var percent=0;for(var i=0;i<nodes.length;i++){var node=nodes[i];if(node.children.length){var tmp=walkDates(node.children);node.start=tmp.start;node.end=tmp.end;node.baselineStart=tmp.baselineStart;node.baselineEnd=tmp.baselineEnd;node.percent=tmp.percent;if(node.start&&node.end){node.duration=(node.end-node.start)/DAY}else{node.duration=0}if(node.baselineStart&&node.baselineEnd){node.baselineDuration=(node.baselineEnd-node.baselineStart)/DAY}else{node.baselineDuration=0}}else{node.percent=node.percent||0;if(node.start&&node.end!=null){node.end=addDays(node.start,node.duration||0)}if(node.baselineStart&&node.baselineDuration!=null){node.baselineEnd=addDays(node.baselineStart,node.baselineDuration)}if(node.type==="milestone"){node.baselineEnd=node.baselineStart;node.end=node.start}}start=minDate(start,node.start);end=maxDate(end,node.end);baselineStart=minDate(baselineStart,node.baselineStart);baselineEnd=maxDate(baselineEnd,node.baselineEnd);percent+=node.percent}if(nodes.length){percent/=nodes.length}return{start:start,end:end,baselineStart:baselineStart,baselineEnd:baselineEnd,percent:percent}}function formatData(tasks,links,walk){var map={};var tmp=tasks.map(function(t,i){map[t.id]=i;return _objectSpread$4(_objectSpread$4({},t),{},{children:[],links:[]})});var roots=[];tmp.forEach(function(t){var parent=tmp[map[t.parent]];if(parent){parent.children.push(t)}else{roots.push(t)}});links.forEach(function(l){var s=tmp[map[l.source]];var t=tmp[map[l.target]];if(s&&t){s.links.push(l)}});walkLevel(roots,"");walkDates(roots);if(walk){walk(roots)}var list=[];roots.forEach(function(r){var stack=[];stack.push(r);while(stack.length){var node=stack.pop();var len=node.children.length;if(len){node.type="group"}list.push(node);for(var i=len-1;i>=0;i--){stack.push(node.children[i])}}});return list}function hasPath(vmap,a,b){var stack=[];stack.push(vmap[a]);while(stack.length){var v=stack.pop();if(v.id===b){return true}for(var i=0;i<v.links.length;i++){stack.push(v.links[i])}}return false}function toposort(links){var vmap={};links.forEach(function(l){var init=function init(id){return{id:id,out:[],in:0}};vmap[l.source]=init(l.source);vmap[l.target]=init(l.target)});for(var i=0;i<links.length;i++){var l=links[i];vmap[l.target]["in"]++;vmap[l.source].out.push(i)}var s=Object.keys(vmap).map(function(k){return vmap[k].id}).filter(function(id){return!vmap[id]["in"]});var sorted=[];while(s.length){var id=s.pop();sorted.push(id);for(var _i=0;_i<vmap[id].out.length;_i++){var index=vmap[id].out[_i];var v=vmap[links[index].target];v["in"]--;if(!v["in"]){s.push(v.id)}}}return sorted}function autoSchedule(tasks,links){var lockMilestone=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var vmap={};links.forEach(function(l){vmap[l.source]={id:l.source,links:[]};vmap[l.target]={id:l.target,links:[]}});var dag=[];links.forEach(function(l){var source=l.source,target=l.target;if(!hasPath(vmap,target,source)){dag.push(l);vmap[source].links.push(vmap[target])}});var sorted=toposort(dag);var tmap={};for(var i=0;i<tasks.length;i++){var task=tasks[i];if(task.type==="milestone"){task.duration=0}tmap[task.id]=i}var ins={};sorted.forEach(function(id){ins[id]=[]});dag.forEach(function(l){ins[l.target].push(l)});sorted.forEach(function(id){var task=tasks[tmap[id]];if(!task)return;var days=task.duration||0;if(lockMilestone&&task.type==="milestone"){return}var start=null;var end=null;for(var _i2=0;_i2<ins[id].length;_i2++){var l=ins[id][_i2];var v=tasks[tmap[l.source]];if(v&&v.start){var s=addDays(v.start,l.lag||0);var e=addDays(s,v.duration||0);if(l.type==="SS"){start=maxDate(start,s)}if(l.type==="FS"){start=maxDate(start,e)}if(l.type==="SF"){end=maxDate(end,s)}if(l.type==="FF"){end=maxDate(end,e)}}}if(end){task.start=addDays(end,-days)}if(start){task.start=start;task.end=addDays(task.start,days)}})}var utils=Object.freeze({__proto__:null,DAY:DAY,addDays:addDays,getDates:getDates,textWidth:textWidth,formatMonth:formatMonth,formatDay:formatDay,minDate:minDate,maxDate:maxDate,max:max,p2s:p2s,s2p:s2p,formatData:formatData,hasPath:hasPath,toposort:toposort,autoSchedule:autoSchedule});function Layout(_ref){var styles=_ref.styles,width=_ref.width,height=_ref.height,offsetY=_ref.offsetY,thickWidth=_ref.thickWidth,maxTextWidth=_ref.maxTextWidth;var x0=thickWidth/2;var W=width-thickWidth;var H=height-thickWidth;return h("g",null,h("rect",{x:x0,y:x0,width:W,height:H,style:styles.box}),h("line",{x1:0,x2:width,y1:offsetY-x0,y2:offsetY-x0,style:styles.bline}),h("line",{x1:maxTextWidth,x2:width,y1:offsetY/2,y2:offsetY/2,style:styles.line}))}function YearMonth(_ref){var styles=_ref.styles,dates=_ref.dates,unit=_ref.unit,offsetY=_ref.offsetY,minTime=_ref.minTime,maxTime=_ref.maxTime,maxTextWidth=_ref.maxTextWidth;var months=dates.filter(function(v){return new Date(v).getDate()===1});months.unshift(minTime);months.push(maxTime);var ticks=[];var x0=maxTextWidth;var y2=offsetY/2;var len=months.length-1;for(var i=0;i<len;i++){var cur=new Date(months[i]);var str=formatMonth(cur);var x=x0+(months[i]-minTime)/unit;var t=(months[i+1]-months[i])/unit;ticks.push(h("g",null,h("line",{x1:x,x2:x,y1:0,y2:y2,style:styles.line}),t>50?h("text",{x:x+t/2,y:offsetY*.25,style:styles.text3},str):null))}return h("g",null,ticks)}function DayHeader(_ref){var styles=_ref.styles,unit=_ref.unit,minTime=_ref.minTime,maxTime=_ref.maxTime,height=_ref.height,offsetY=_ref.offsetY,maxTextWidth=_ref.maxTextWidth;var dates=getDates(minTime,maxTime);var ticks=[];var x0=maxTextWidth;var y0=offsetY/2;var RH=height-y0;var len=dates.length-1;for(var i=0;i<len;i++){var cur=new Date(dates[i]);var day=cur.getDay();var x=x0+(dates[i]-minTime)/unit;var t=(dates[i+1]-dates[i])/unit;ticks.push(h("g",null,day===0||day===6?h("rect",{x:x,y:y0,width:t,height:RH,style:styles.week}):null,h("line",{x1:x,x2:x,y1:y0,y2:offsetY,style:styles.line}),h("text",{x:x+t/2,y:offsetY*.75,style:styles.text3},cur.getDate()),i===len-1?h("line",{x1:x+t,x2:x+t,y1:y0,y2:offsetY,style:styles.line}):null))}return h("g",null,h(YearMonth,{styles:styles,unit:unit,dates:dates,offsetY:offsetY,minTime:minTime,maxTime:maxTime,maxTextWidth:maxTextWidth}),ticks)}function WeekHeader(_ref){var styles=_ref.styles,unit=_ref.unit,minTime=_ref.minTime,maxTime=_ref.maxTime,height=_ref.height,offsetY=_ref.offsetY,maxTextWidth=_ref.maxTextWidth;var dates=getDates(minTime,maxTime);var weeks=dates.filter(function(v){return new Date(v).getDay()===0});weeks.push(maxTime);var ticks=[];var x0=maxTextWidth;var y0=offsetY;var RH=height-y0;var d=DAY/unit;var len=weeks.length-1;for(var i=0;i<len;i++){var cur=new Date(weeks[i]);var x=x0+(weeks[i]-minTime)/unit;var curDay=cur.getDate();var prevDay=addDays(cur,-1).getDate();ticks.push(h("g",null,h("rect",{x:x-d,y:y0,width:d*2,height:RH,style:styles.week}),h("line",{x1:x,x2:x,y1:offsetY/2,y2:offsetY,style:styles.line}),h("text",{x:x+3,y:offsetY*.75,style:styles.text2},curDay),x-x0>28?h("text",{x:x-3,y:offsetY*.75,style:styles.text1},prevDay):null))}return h("g",null,h(YearMonth,{styles:styles,unit:unit,dates:dates,offsetY:offsetY,minTime:minTime,maxTime:maxTime,maxTextWidth:maxTextWidth}),ticks)}function Year(_ref){var styles=_ref.styles,months=_ref.months,unit=_ref.unit,offsetY=_ref.offsetY,minTime=_ref.minTime,maxTime=_ref.maxTime,maxTextWidth=_ref.maxTextWidth;var years=months.filter(function(v){return new Date(v).getMonth()===0});years.unshift(minTime);years.push(maxTime);var ticks=[];var x0=maxTextWidth;var y2=offsetY/2;var len=years.length-1;for(var i=0;i<len;i++){var cur=new Date(years[i]);var x=x0+(years[i]-minTime)/unit;var t=(years[i+1]-years[i])/unit;ticks.push(h("g",null,h("line",{x1:x,x2:x,y1:0,y2:y2,style:styles.line}),t>35?h("text",{x:x+t/2,y:offsetY*.25,style:styles.text3},cur.getFullYear()):null))}return h("g",null,ticks)}function MonthHeader(_ref){var styles=_ref.styles,unit=_ref.unit,minTime=_ref.minTime,maxTime=_ref.maxTime,offsetY=_ref.offsetY,maxTextWidth=_ref.maxTextWidth;var MONTH=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];var dates=getDates(minTime,maxTime);var months=dates.filter(function(v){return new Date(v).getDate()===1});months.unshift(minTime);months.push(maxTime);var ticks=[];var x0=maxTextWidth;var y0=offsetY/2;var len=months.length-1;for(var i=0;i<len;i++){var cur=new Date(months[i]);var month=cur.getMonth();var x=x0+(months[i]-minTime)/unit;var t=(months[i+1]-months[i])/unit;ticks.push(h("g",null,h("line",{x1:x,x2:x,y1:y0,y2:offsetY,style:styles.line}),t>30?h("text",{x:x+t/2,y:offsetY*.75,style:styles.text3},MONTH[month]):null))}return h("g",null,h(Year,{styles:styles,unit:unit,months:months,offsetY:offsetY,minTime:minTime,maxTime:maxTime,maxTextWidth:maxTextWidth}),ticks)}function Grid(_ref){var styles=_ref.styles,data=_ref.data,width=_ref.width,height=_ref.height,offsetY=_ref.offsetY,rowHeight=_ref.rowHeight,maxTextWidth=_ref.maxTextWidth;return h("g",null,data.map(function(v,i){var y=(i+1)*rowHeight+offsetY;return h("line",{key:i,x1:0,x2:width,y1:y,y2:y,style:styles.line})}),h("line",{x1:maxTextWidth,x2:maxTextWidth,y1:0,y2:height,style:styles.bline}))}function Labels(_ref){var styles=_ref.styles,data=_ref.data,_onClick=_ref.onClick,rowHeight=_ref.rowHeight,offsetY=_ref.offsetY;return h("g",null,data.map(function(v,i){return h("text",{key:i,x:10,y:(i+.5)*rowHeight+offsetY,class:"gantt-label",style:styles.label,onClick:function onClick(){return _onClick(v)}},v.text)}))}function LinkLine(_ref){var styles=_ref.styles,data=_ref.data,unit=_ref.unit,offsetY=_ref.offsetY,minTime=_ref.minTime,rowHeight=_ref.rowHeight,barHeight=_ref.barHeight,maxTextWidth=_ref.maxTextWidth;var x0=maxTextWidth;var y0=rowHeight/2+offsetY;var map={};data.forEach(function(v,i){map[v.id]=i});return h("g",null,data.map(function(s,i){if(!s.end||!s.start||!s.links){return null}return s.links.map(function(l){var j=map[l.target];var e=data[j];if(!e||!e.start||!e.end)return null;var gap=12;var arrow=6;var mgap=e.type==="milestone"?barHeight/2:0;var y1=y0+i*rowHeight;var y2=y0+j*rowHeight;var vgap=barHeight/2+4;if(y1>y2){vgap=-vgap}if(l.type==="FS"){var x1=x0+(s.end-minTime)/unit;var x2=x0+(e.start-minTime)/unit-mgap;var p1=[[x1,y1],[x1+gap,y1]];if(x2-x1>=2*gap){p1.push([x1+gap,y2])}else{p1.push([x1+gap,y2-vgap]);p1.push([x2-gap,y2-vgap]);p1.push([x2-gap,y2])}p1.push([x2-arrow,y2]);var p2=[[x2-arrow,y2-arrow],[x2,y2],[x2-arrow,y2+arrow]];return h("g",null,h("polyline",{points:p2s(p1),style:styles.link}),h("polygon",{points:p2s(p2),style:styles.linkArrow}))}if(l.type==="FF"){var _x=x0+(s.end-minTime)/unit;var _x2=x0+(e.end-minTime)/unit+mgap;var _p=[[_x,y1],[_x+gap,y1]];if(_x2<=_x){_p.push([_x+gap,y2])}else{_p.push([_x+gap,y2-vgap]);_p.push([_x2+gap,y2-vgap]);_p.push([_x2+gap,y2])}_p.push([_x2+arrow,y2]);var _p2=[[_x2+arrow,y2-arrow],[_x2,y2],[_x2+arrow,y2+arrow]];return h("g",null,h("polyline",{points:p2s(_p),style:styles.link}),h("polygon",{points:p2s(_p2),style:styles.linkArrow}))}if(l.type==="SS"){var _x3=x0+(s.start-minTime)/unit;var _x4=x0+(e.start-minTime)/unit-mgap;var _p3=[[_x3,y1],[_x3-gap,y1]];if(_x3<=_x4){_p3.push([_x3-gap,y2])}else{_p3.push([_x3-gap,y2-vgap]);_p3.push([_x4-gap,y2-vgap]);_p3.push([_x4-gap,y2])}_p3.push([_x4-arrow,y2]);var _p4=[[_x4-arrow,y2-arrow],[_x4,y2],[_x4-arrow,y2+arrow]];return h("g",null,h("polyline",{points:p2s(_p3),style:styles.link}),h("polygon",{points:p2s(_p4),style:styles.linkArrow}))}if(l.type==="SF"){var _x5=x0+(s.start-minTime)/unit;var _x6=x0+(e.end-minTime)/unit+mgap;var _p5=[[_x5,y1],[_x5-gap,y1]];if(_x5-_x6>=2*gap){_p5.push([_x5-gap,y2])}else{_p5.push([_x5-gap,y2-vgap]);_p5.push([_x6+gap,y2-vgap]);_p5.push([_x6+gap,y2])}_p5.push([_x6+arrow,y2]);var _p6=[[_x6+arrow,y2-arrow],[_x6,y2],[_x6+arrow,y2+arrow]];return h("g",null,h("polyline",{points:p2s(_p5),style:styles.link}),h("polygon",{points:p2s(_p6),style:styles.linkArrow}))}return null})}))}var ROW_GAP=2;function Bar(_ref){var styles=_ref.styles,data=_ref.data,unit=_ref.unit,height=_ref.height,offsetY=_ref.offsetY,minTime=_ref.minTime,showDelay=_ref.showDelay,rowHeight=_ref.rowHeight,barHeight=_ref.barHeight,_ref$rowPadding=_ref.rowPadding,rowPadding=_ref$rowPadding===void 0?5:_ref$rowPadding,maxTextWidth=_ref.maxTextWidth,current=_ref.current,onClick=_ref.onClick;var x0=maxTextWidth;var partHeight=barHeight;var cur=x0+(current-minTime)/unit;return h("g",null,current>minTime?h("line",{x1:cur,x2:cur,y1:offsetY,y2:height,style:styles.cline}):null,data.map(function(v,i){var handler=function handler(){return onClick(v)};var y=offsetY+i*rowHeight+rowPadding;var cy=y+partHeight/2;var hasStartEnd=v.start&&v.end;var hasBaselineOnly=!hasStartEnd&&v.baselineStart&&v.baselineEnd;if(hasBaselineOnly){var _baselineWidth=(v.baselineEnd-v.baselineStart)/unit;if(_baselineWidth<=0)return null;var _bx=x0+(v.baselineStart-minTime)/unit;var _baselineCy=y+partHeight+ROW_GAP+partHeight/2;return h("g",{key:i,class:"gantt-bar",style:{cursor:"pointer"},onClick:handler},h("text",{x:_bx-4,y:_baselineCy,style:styles.text1},formatDay(v.baselineStart)),h("text",{x:_bx+_baselineWidth+4,y:_baselineCy,style:styles.text2},formatDay(v.baselineEnd)),h("rect",{x:_bx,y:y+partHeight+ROW_GAP,width:_baselineWidth,height:partHeight,rx:1.2,ry:1.2,style:styles.baseline,onClick:handler}))}if(!v.end||!v.start){return null}var x=x0+(v.start-minTime)/unit;if(v.type==="milestone"){var size=partHeight/2;var points=[[x,cy-size],[x+size,cy],[x,cy+size],[x-size,cy]].map(function(p){return"".concat(p[0],",").concat(p[1])}).join(" ");return h("g",{key:i,class:"gantt-bar",style:{cursor:"pointer"},onClick:handler},h("polygon",{points:points,style:styles.milestone,onClick:handler}),h("circle",{class:"gantt-ctrl-start","data-id":v.id,cx:x,cy:cy,r:6,style:styles.ctrl}))}var w1=(v.end-v.start)/unit;var w2=w1*v.percent;if(w1<=0){return null}var bar=v.type==="group"?{back:styles.groupBack,front:styles.groupFront}:{back:styles.taskBack,front:styles.taskFront};if(showDelay){if(x+w2<cur&&v.percent<.999999){bar.back=styles.warning}if(x+w1<cur&&v.percent<.999999){bar.back=styles.danger}}var baselineWidth=(v.baselineEnd-v.baselineStart)/unit;var bx=x0+(v.baselineStart-minTime)/unit;var baselineCy=y+partHeight+ROW_GAP+partHeight/2;var baseline=v.baselineStart&&v.baselineEnd&&baselineWidth>0?h("g",null,h("text",{x:bx-4,y:baselineCy,style:styles.text1},formatDay(v.baselineStart)),h("text",{x:bx+baselineWidth+4,y:baselineCy,style:styles.text2},formatDay(v.baselineEnd)),h("rect",{x:bx,y:y+partHeight+ROW_GAP,width:baselineWidth,height:partHeight,rx:1.2,ry:1.2,style:styles.baseline})):null;return h("g",{key:i,class:"gantt-bar",style:{cursor:"pointer"},onClick:handler},h("text",{x:x-4,y:cy,style:styles.text1},formatDay(v.start)),h("text",{x:x+w1+4,y:cy,style:styles.text2},formatDay(v.end)),h("rect",{x:x,y:y,width:w1,height:partHeight,rx:1.8,ry:1.8,style:bar.back,onClick:handler}),w2>1e-6?h("rect",{x:x,y:y,width:w2,height:partHeight,rx:1.8,ry:1.8,style:bar.front}):null,baseline,v.type==="group"?null:h("g",null,h("circle",{class:"gantt-ctrl-start","data-id":v.id,cx:x-12,cy:cy,r:6,style:styles.ctrl}),h("circle",{class:"gantt-ctrl-finish","data-id":v.id,cx:x+w1+12,cy:cy,r:6,style:styles.ctrl})))}))}function ownKeys$3(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread$3(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys$3(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys$3(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}var SIZE="14px";var TYPE='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';function getFont(_ref){var _ref$fontSize=_ref.fontSize,fontSize=_ref$fontSize===void 0?SIZE:_ref$fontSize,_ref$fontFamily=_ref.fontFamily,fontFamily=_ref$fontFamily===void 0?TYPE:_ref$fontFamily;return"bold ".concat(fontSize," ").concat(fontFamily)}function getStyles(_ref2){var _ref2$bgColor=_ref2.bgColor,bgColor=_ref2$bgColor===void 0?"#fff":_ref2$bgColor,_ref2$lineColor=_ref2.lineColor,lineColor=_ref2$lineColor===void 0?"#eee":_ref2$lineColor,_ref2$redLineColor=_ref2.redLineColor,redLineColor=_ref2$redLineColor===void 0?"#f04134":_ref2$redLineColor,_ref2$groupBack=_ref2.groupBack,groupBack=_ref2$groupBack===void 0?"#3db9d3":_ref2$groupBack,_ref2$groupFront=_ref2.groupFront,groupFront=_ref2$groupFront===void 0?"#299cb4":_ref2$groupFront,_ref2$taskBack=_ref2.taskBack,taskBack=_ref2$taskBack===void 0?"#65c16f":_ref2$taskBack,_ref2$taskFront=_ref2.taskFront,taskFront=_ref2$taskFront===void 0?"#46ad51":_ref2$taskFront,_ref2$taskProgress=_ref2.taskProgress,taskProgress=_ref2$taskProgress===void 0?"#1890ff":_ref2$taskProgress,_ref2$milestone=_ref2.milestone,milestone=_ref2$milestone===void 0?"#d33daf":_ref2$milestone,_ref2$warning=_ref2.warning,warning=_ref2$warning===void 0?"#faad14":_ref2$warning,_ref2$danger=_ref2.danger,danger=_ref2$danger===void 0?"#f5222d":_ref2$danger,_ref2$critical=_ref2.critical,critical=_ref2$critical===void 0?"#ff4d4f":_ref2$critical,_ref2$link=_ref2.link,link=_ref2$link===void 0?"#ffa011":_ref2$link,_ref2$baseline=_ref2.baseline,baseline=_ref2$baseline===void 0?"#3c3c3c":_ref2$baseline,_ref2$textColor=_ref2.textColor,textColor=_ref2$textColor===void 0?"#222":_ref2$textColor,_ref2$lightTextColor=_ref2.lightTextColor,lightTextColor=_ref2$lightTextColor===void 0?"#999":_ref2$lightTextColor,_ref2$lineWidth=_ref2.lineWidth,lineWidth=_ref2$lineWidth===void 0?"1px":_ref2$lineWidth,_ref2$thickLineWidth=_ref2.thickLineWidth,thickLineWidth=_ref2$thickLineWidth===void 0?"1.4px":_ref2$thickLineWidth,_ref2$fontSize=_ref2.fontSize,fontSize=_ref2$fontSize===void 0?SIZE:_ref2$fontSize,_ref2$smallFontSize=_ref2.smallFontSize,smallFontSize=_ref2$smallFontSize===void 0?"12px":_ref2$smallFontSize,_ref2$fontFamily=_ref2.fontFamily,fontFamily=_ref2$fontFamily===void 0?TYPE:_ref2$fontFamily,_ref2$whiteSpace=_ref2.whiteSpace,whiteSpace=_ref2$whiteSpace===void 0?"pre":_ref2$whiteSpace;var line={stroke:lineColor,"stroke-width":lineWidth};var redLine={stroke:redLineColor,"stroke-width":lineWidth};var thickLine={stroke:lineColor,"stroke-width":thickLineWidth};var text={fill:textColor,"dominant-baseline":"central","font-size":fontSize,"font-family":fontFamily,"white-space":whiteSpace};var smallText={fill:lightTextColor,"font-size":smallFontSize};return{week:{fill:"rgba(252, 248, 227, .6)"},box:_objectSpread$3(_objectSpread$3({},thickLine),{},{fill:bgColor}),line:line,cline:redLine,bline:thickLine,label:text,groupLabel:_objectSpread$3(_objectSpread$3({},text),{},{"font-weight":"600"}),text1:_objectSpread$3(_objectSpread$3(_objectSpread$3({},text),smallText),{},{"text-anchor":"end"}),text2:_objectSpread$3(_objectSpread$3({},text),smallText),text3:_objectSpread$3(_objectSpread$3(_objectSpread$3({},text),smallText),{},{"text-anchor":"middle"}),link:{stroke:link,"stroke-width":"1.5px",fill:"none"},linkArrow:{fill:link},milestone:{fill:milestone},groupBack:{fill:groupBack},groupFront:{fill:groupFront},groupProgress:{fill:groupFront},taskBack:{fill:taskBack},taskFront:{fill:taskFront},taskProgress:{fill:taskProgress},warning:{fill:warning},danger:{fill:danger},critical:{fill:critical},baseline:{fill:baseline,opacity:.5},ctrl:{display:"none",fill:"#f0f0f0",stroke:"#929292","stroke-width":"1px"}}}var UNIT={day:DAY/28,week:7*DAY/56,month:30*DAY/56};function NOOP(){}function Gantt(_ref){var _ref$data=_ref.data,data=_ref$data===void 0?[]:_ref$data,_ref$onClick=_ref.onClick,onClick=_ref$onClick===void 0?NOOP:_ref$onClick,_ref$viewMode=_ref.viewMode,viewMode=_ref$viewMode===void 0?"week":_ref$viewMode,_ref$maxTextWidth=_ref.maxTextWidth,maxTextWidth=_ref$maxTextWidth===void 0?140:_ref$maxTextWidth,_ref$offsetY=_ref.offsetY,offsetY=_ref$offsetY===void 0?60:_ref$offsetY,_ref$rowHeight=_ref.rowHeight,rowHeight=_ref$rowHeight===void 0?40:_ref$rowHeight;_ref.barHeight;var _ref$thickWidth=_ref.thickWidth,thickWidth=_ref$thickWidth===void 0?1.4:_ref$thickWidth,_ref$styleOptions=_ref.styleOptions,styleOptions=_ref$styleOptions===void 0?{}:_ref$styleOptions,_ref$showLinks=_ref.showLinks,showLinks=_ref$showLinks===void 0?true:_ref$showLinks,_ref$showDelay=_ref.showDelay,showDelay=_ref$showDelay===void 0?true:_ref$showDelay,start=_ref.start,end=_ref.end;var unit=UNIT[viewMode];var minTime=start.getTime()-unit*48;var maxTime=end.getTime()+unit*48;var width=(maxTime-minTime)/unit+maxTextWidth;var height=data.length*rowHeight+offsetY;var box="0 0 ".concat(width," ").concat(height);var current=Date.now();var styles=getStyles(styleOptions);var rowPadding=10;var partHeight=Math.floor((rowHeight-rowPadding*2-2)/2);return h("svg",{width:width,height:height,viewBox:box},h(Layout,{styles:styles,width:width,height:height,offsetY:offsetY,thickWidth:thickWidth,maxTextWidth:maxTextWidth}),viewMode==="day"?h(DayHeader,{styles:styles,unit:unit,height:height,offsetY:offsetY,minTime:minTime,maxTime:maxTime,maxTextWidth:maxTextWidth}):null,viewMode==="week"?h(WeekHeader,{styles:styles,unit:unit,height:height,offsetY:offsetY,minTime:minTime,maxTime:maxTime,maxTextWidth:maxTextWidth}):null,viewMode==="month"?h(MonthHeader,{styles:styles,unit:unit,offsetY:offsetY,minTime:minTime,maxTime:maxTime,maxTextWidth:maxTextWidth}):null,h(Grid,{styles:styles,data:data,width:width,height:height,offsetY:offsetY,rowHeight:rowHeight,maxTextWidth:maxTextWidth}),maxTextWidth>0?h(Labels,{styles:styles,data:data,onClick:onClick,offsetY:offsetY,rowHeight:rowHeight}):null,showLinks?h(LinkLine,{styles:styles,data:data,unit:unit,height:height,current:current,offsetY:offsetY,minTime:minTime,rowHeight:rowHeight,barHeight:partHeight,maxTextWidth:maxTextWidth}):null,h(Bar,{styles:styles,data:data,unit:unit,height:height,current:current,offsetY:offsetY,minTime:minTime,onClick:onClick,showDelay:showDelay,rowHeight:rowHeight,barHeight:partHeight,rowPadding:rowPadding,maxTextWidth:maxTextWidth}))}var NS="http://www.w3.org/2000/svg";var doc=document;function applyProperties(node,props){Object.keys(props).forEach(function(k){var v=props[k];if(k==="style"&&_typeof(v)==="object"){Object.keys(v).forEach(function(sk){node.style[sk]=v[sk]})}else if(k==="onClick"){if(typeof v==="function"){node.addEventListener("click",v)}}else{node.setAttribute(k,v)}})}function render$2(vnode,ctx){var tag=vnode.tag,props=vnode.props,children=vnode.children;var node=doc.createElementNS(NS,tag);if(props){applyProperties(node,props)}children.forEach(function(v){node.appendChild(typeof v==="string"?doc.createTextNode(v):render$2(v))});return node}function ownKeys$2(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread$2(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys$2(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys$2(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}var SVGGantt=function(){function SVGGantt(element,data){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};_classCallCheck(this,SVGGantt);this.dom=typeof element==="string"?document.querySelector(element):element;this.format(data);this.options=options;this.render()}return _createClass(SVGGantt,[{key:"format",value:function format(data){this.data=data;var start=null;var end=null;data.forEach(function(v){start=minDate(start,v.start);end=maxDate(end,v.end);if(v.baselineStart){start=minDate(start,v.baselineStart)}if(v.baselineEnd){end=maxDate(end,v.baselineEnd)}});this.start=start||new Date;this.end=end||new Date}},{key:"setData",value:function setData(data){this.format(data);this.render()}},{key:"setOptions",value:function setOptions(options){this.options=_objectSpread$2(_objectSpread$2({},this.options),options);this.render()}},{key:"render",value:function render(){var data=this.data,start=this.start,end=this.end,options=this.options;if(this.tree){this.dom.removeChild(this.tree)}if(options.maxTextWidth===undefined){var font=getFont(options.styleOptions||{});var w=function w(v){return textWidth(v.text,font,20)};options.maxTextWidth=max(data.map(w),0)}var props=_objectSpread$2(_objectSpread$2({},options),{},{start:start,end:end});this.tree=render$2(h(Gantt,_extends({data:data},props)));this.dom.appendChild(this.tree)}}])}();function render$1(vnode,ctx,e){var tag=vnode.tag,props=vnode.props,children=vnode.children;if(tag==="svg"){var width=props.width,height=props.height;ctx.width=width;ctx.height=height}if(tag==="line"){var x1=props.x1,x2=props.x2,y1=props.y1,y2=props.y2,_props$style=props.style,style=_props$style===void 0?{}:_props$style;if(style.stroke){ctx.strokeStyle=style.stroke;ctx.lineWidth=parseFloat(style["stroke-width"]||1)}ctx.beginPath();ctx.moveTo(x1,y1);ctx.lineTo(x2,y2);ctx.stroke()}if(tag==="polyline"||tag==="polygon"){var points=props.points,_props$style2=props.style,_style=_props$style2===void 0?{}:_props$style2;var p=s2p(points);if(_style.stroke){ctx.strokeStyle=_style.stroke;ctx.lineWidth=parseFloat(_style["stroke-width"]||1)}if(_style.fill){ctx.fillStyle=_style.fill}ctx.beginPath();ctx.moveTo(p[0][0],p[0][1]);for(var i=1;i<p.length;i++){ctx.lineTo(p[i][0],p[i][1])}if(tag==="polyline"){ctx.stroke()}else{ctx.fill()}}if(tag==="rect"){var x=props.x,y=props.y,_width=props.width,_height=props.height,_props$rx=props.rx,rx=_props$rx===void 0?0:_props$rx,_props$ry=props.ry,ry=_props$ry===void 0?0:_props$ry,onClick=props.onClick,_props$style3=props.style,_style2=_props$style3===void 0?{}:_props$style3;ctx.beginPath();ctx.moveTo(x+rx,y);ctx.lineTo(x+_width-rx,y);ctx.quadraticCurveTo(x+_width,y,x+_width,y+ry);ctx.lineTo(x+_width,y+_height-ry);ctx.quadraticCurveTo(x+_width,y+_height,x+_width-rx,y+_height);ctx.lineTo(x+rx,y+_height);ctx.quadraticCurveTo(x,y+_height,x,y+_height-ry);ctx.lineTo(x,y+ry);ctx.quadraticCurveTo(x,y,x+rx,y);if(e&&onClick&&ctx.isPointInPath(e.x,e.y)){onClick()}ctx.closePath();if(_style2.fill){ctx.fillStyle=_style2.fill}ctx.fill();if(_style2.stroke){ctx.strokeStyle=_style2.stroke;ctx.lineWidth=parseFloat(_style2["stroke-width"]||1);ctx.stroke()}}if(tag==="text"){var _x=props.x,_y=props.y,_style3=props.style;if(_style3){ctx.fillStyle=_style3.fill;var BL={central:"middle",middle:"middle",hanging:"hanging",alphabetic:"alphabetic",ideographic:"ideographic"};var AL={start:"start",middle:"center",end:"end"};ctx.textBaseline=BL[_style3["dominant-baseline"]]||"alphabetic";ctx.textAlign=AL[_style3["text-anchor"]]||"start";ctx.font="".concat(_style3["font-weight"]||""," ").concat(_style3["font-size"]," ").concat(_style3["font-family"])}ctx.fillText(children.join(""),_x,_y)}children.forEach(function(v){if(typeof v!=="string"){render$1(v,ctx,e)}})}function createContext(dom){var canvas=typeof dom==="string"?document.querySelector(dom):dom;var ctx=canvas.getContext("2d");var backingStore=ctx.webkitBackingStorePixelRatio||ctx.mozBackingStorePixelRatio||ctx.msBackingStorePixelRatio||ctx.oBackingStorePixelRatio||ctx.backingStorePixelRatio||1;var ratio=(window.devicePixelRatio||1)/backingStore;["width","height"].forEach(function(key){Object.defineProperty(ctx,key,{get:function get(){return canvas[key]/ratio},set:function set(v){canvas[key]=v*ratio;canvas.style[key]="".concat(v,"px");ctx.scale(ratio,ratio)},enumerable:true,configurable:true})});canvas.addEventListener("click",function(e){if(!ctx.onClick)return;var rect=canvas.getBoundingClientRect();ctx.onClick({x:(e.clientX-rect.left)*ratio,y:(e.clientY-rect.top)*ratio})});return ctx}function ownKeys$1(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread$1(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys$1(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys$1(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}var CanvasGantt=function(){function CanvasGantt(element,data){var _this=this;var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};_classCallCheck(this,CanvasGantt);this.ctx=createContext(element);this.format(data);this.options=options;this.render();this.ctx.onClick=function(e){return _this.render(e)}}return _createClass(CanvasGantt,[{key:"format",value:function format(data){this.data=data;var start=null;var end=null;data.forEach(function(v){start=minDate(start,v.start);end=maxDate(end,v.end);if(v.baselineStart){start=minDate(start,v.baselineStart)}if(v.baselineEnd){end=maxDate(end,v.baselineEnd)}});this.start=start||new Date;this.end=end||new Date}},{key:"setData",value:function setData(data){this.format(data);this.render()}},{key:"setOptions",value:function setOptions(options){this.options=_objectSpread$1(_objectSpread$1({},this.options),options);this.render()}},{key:"render",value:function render(e){var data=this.data,start=this.start,end=this.end,options=this.options;if(options.maxTextWidth===undefined){var font=getFont(options.styleOptions||{});var w=function w(v){return textWidth(v.text,font,20)};options.maxTextWidth=max(data.map(w),0)}var props=_objectSpread$1(_objectSpread$1({},options),{},{start:start,end:end});render$1(h(Gantt,_extends({data:data},props)),this.ctx,e)}}])}();function attrEscape(str){return String(str).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/\t/g,"&#x9;").replace(/\n/g,"&#xA;").replace(/\r/g,"&#xD;")}function escape(str){return String(str).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r/g,"&#xD;")}function render(vnode,ctx){var tag=vnode.tag,props=vnode.props,children=vnode.children;var tokens=[];tokens.push("<".concat(tag));Object.keys(props||{}).forEach(function(k){var v=props[k];if(k==="onClick")return;if(k==="style"&&_typeof(v)==="object"){v=Object.keys(v).map(function(i){return"".concat(i,":").concat(v[i],";")}).join("")}tokens.push(" ".concat(k,'="').concat(attrEscape(v),'"'))});if(!children||!children.length){tokens.push(" />");return tokens.join("")}tokens.push(">");children.forEach(function(v){if(typeof v==="string"){tokens.push(escape(v))}else{tokens.push(render(v))}});tokens.push("</".concat(tag,">"));return tokens.join("")}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}var StrGantt=function(){function StrGantt(data){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,StrGantt);this.format(data);this.options=options}return _createClass(StrGantt,[{key:"format",value:function format(data){this.data=data;var start=null;var end=null;data.forEach(function(v){start=minDate(start,v.start);end=maxDate(end,v.end);if(v.baselineStart){start=minDate(start,v.baselineStart)}if(v.baselineEnd){end=maxDate(end,v.baselineEnd)}});this.start=start||new Date;this.end=end||new Date}},{key:"setData",value:function setData(data){this.format(data)}},{key:"setOptions",value:function setOptions(options){this.options=_objectSpread(_objectSpread({},this.options),options)}},{key:"render",value:function render$1(){var data=this.data,start=this.start,end=this.end,options=this.options;var props=_objectSpread(_objectSpread({},options),{},{start:start,end:end});return render(h(Gantt,_extends({data:data},props)))}}])}();exports.CanvasGantt=CanvasGantt;exports.SVGGantt=SVGGantt;exports.StrGantt=StrGantt;exports["default"]=CanvasGantt;exports.utils=utils;Object.defineProperty(exports,"__esModule",{value:true})});
1
+ (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define(["exports"],factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,factory(global.Gantt={}))})(this,function(exports){"use strict";function getDefaultExportFromCjs(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x["default"]:x}function createCommonjsModule(fn,basedir,module){return module={path:basedir,exports:{},require:function(path,base){return commonjsRequire(path,base===undefined||base===null?module.path:base)}},fn(module,module.exports),module.exports}function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var _extends_1=createCommonjsModule(function(module){function _extends(){return module.exports=_extends=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},module.exports.__esModule=true,module.exports["default"]=module.exports,_extends.apply(null,arguments)}module.exports=_extends,module.exports.__esModule=true,module.exports["default"]=module.exports});var _extends=getDefaultExportFromCjs(_extends_1);var _typeof_1=createCommonjsModule(function(module){function _typeof(o){"@babel/helpers - typeof";return module.exports=_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},module.exports.__esModule=true,module.exports["default"]=module.exports,_typeof(o)}module.exports=_typeof,module.exports.__esModule=true,module.exports["default"]=module.exports});var _typeof=getDefaultExportFromCjs(_typeof_1);var toPrimitive_1=createCommonjsModule(function(module){var _typeof=_typeof_1["default"];function toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}module.exports=toPrimitive,module.exports.__esModule=true,module.exports["default"]=module.exports});var toPropertyKey_1=createCommonjsModule(function(module){var _typeof=_typeof_1["default"];function toPropertyKey(t){var i=toPrimitive_1(t,"string");return"symbol"==_typeof(i)?i:i+""}module.exports=toPropertyKey,module.exports.__esModule=true,module.exports["default"]=module.exports});var defineProperty=createCommonjsModule(function(module){function _defineProperty(e,r,t){return(r=toPropertyKey_1(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}module.exports=_defineProperty,module.exports.__esModule=true,module.exports["default"]=module.exports});var _defineProperty=getDefaultExportFromCjs(defineProperty);var classCallCheck=createCommonjsModule(function(module){function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}module.exports=_classCallCheck,module.exports.__esModule=true,module.exports["default"]=module.exports});var _classCallCheck=getDefaultExportFromCjs(classCallCheck);var createClass=createCommonjsModule(function(module){function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,toPropertyKey_1(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}module.exports=_createClass,module.exports.__esModule=true,module.exports["default"]=module.exports});var _createClass=getDefaultExportFromCjs(createClass);function ownKeys$5(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread$5(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys$5(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys$5(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function addChild(c,childNodes){if(c===null||c===undefined)return;if(typeof c==="string"||typeof c==="number"){childNodes.push(c.toString())}else if(Array.isArray(c)){for(var i=0;i<c.length;i++){addChild(c[i],childNodes)}}else{childNodes.push(c)}}function h(tag,props){var childNodes=[];for(var _len=arguments.length,children=new Array(_len>2?_len-2:0),_key=2;_key<_len;_key++){children[_key-2]=arguments[_key]}addChild(children,childNodes);if(typeof tag==="function"){return tag(_objectSpread$5(_objectSpread$5({},props),{},{children:childNodes}))}return{tag:tag,props:props,children:childNodes}}function ownKeys$4(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread$4(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys$4(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys$4(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}var DAY=24*3600*1e3;function addDays(date,days){var d=new Date(date.valueOf());d.setDate(d.getDate()+days);return d}function getDates(begin,end){var dates=[];var s=new Date(begin);s.setHours(24,0,0,0);while(s.getTime()<=end){dates.push(s.getTime());s=addDays(s,1)}return dates}var ctx=null;function textWidth(text,font,pad){ctx=ctx||document.createElement("canvas").getContext("2d");ctx.font=font;return ctx.measureText(text).width+pad}function formatMonth(date){var y=date.getFullYear();var m=date.getMonth()+1;return"".concat(y,"/").concat(m>9?m:"0".concat(m))}function formatDay(date){var m=date.getMonth()+1;var d=date.getDate();return"".concat(m,"/").concat(d)}function minDate(a,b){if(a&&b){return a>b?b:a}return a||b}function maxDate(a,b){if(a&&b){return a<b?b:a}return a||b}function max(list,defaultValue){if(list.length){return Math.max.apply(null,list)}return defaultValue}function p2s(arr){return arr.map(function(p){return"".concat(p[0],",").concat(p[1])}).join(" ")}function s2p(str){return str.split(" ").map(function(s){var p=s.split(",");return[parseFloat(p[0]),parseFloat(p[1])]})}function walkLevel(nodes,level){for(var i=0;i<nodes.length;i++){var node=nodes[i];node.level="".concat(level).concat(i+1);node.text="".concat(node.level," ").concat(node.name);walkLevel(node.children,"".concat(node.level,"."))}}function walkDates(nodes){var start=null;var end=null;var baselineStart=null;var baselineEnd=null;var percent=0;for(var i=0;i<nodes.length;i++){var node=nodes[i];if(node.children.length){var tmp=walkDates(node.children);node.start=tmp.start;node.end=tmp.end;node.baselineStart=tmp.baselineStart;node.baselineEnd=tmp.baselineEnd;node.percent=tmp.percent;if(node.start&&node.end){node.duration=(node.end-node.start)/DAY}else{node.duration=0}if(node.baselineStart&&node.baselineEnd){node.baselineDuration=(node.baselineEnd-node.baselineStart)/DAY}else{node.baselineDuration=0}}else{node.percent=node.percent||0;if(node.start&&node.end!=null){node.end=addDays(node.start,node.duration||0)}if(node.baselineStart&&node.baselineDuration!=null){node.baselineEnd=addDays(node.baselineStart,node.baselineDuration)}if(node.type==="milestone"){node.baselineEnd=node.baselineStart;node.end=node.start}}start=minDate(start,node.start);end=maxDate(end,node.end);baselineStart=minDate(baselineStart,node.baselineStart);baselineEnd=maxDate(baselineEnd,node.baselineEnd);percent+=node.percent}if(nodes.length){percent/=nodes.length}return{start:start,end:end,baselineStart:baselineStart,baselineEnd:baselineEnd,percent:percent}}function formatData(tasks,links,walk){var map={};var tmp=tasks.map(function(t,i){map[t.id]=i;return _objectSpread$4(_objectSpread$4({},t),{},{children:[],links:[]})});var roots=[];tmp.forEach(function(t){var parent=tmp[map[t.parent]];if(parent){parent.children.push(t)}else{roots.push(t)}});links.forEach(function(l){var s=tmp[map[l.source]];var t=tmp[map[l.target]];if(s&&t){s.links.push(l)}});walkLevel(roots,"");walkDates(roots);if(walk){walk(roots)}var list=[];roots.forEach(function(r){var stack=[];stack.push(r);while(stack.length){var node=stack.pop();var len=node.children.length;if(len){node.type="group"}list.push(node);for(var i=len-1;i>=0;i--){stack.push(node.children[i])}}});return list}function hasPath(vmap,a,b){var stack=[];stack.push(vmap[a]);while(stack.length){var v=stack.pop();if(v.id===b){return true}for(var i=0;i<v.links.length;i++){stack.push(v.links[i])}}return false}function toposort(links){var vmap={};links.forEach(function(l){var init=function init(id){return{id:id,out:[],in:0}};vmap[l.source]=init(l.source);vmap[l.target]=init(l.target)});for(var i=0;i<links.length;i++){var l=links[i];vmap[l.target]["in"]++;vmap[l.source].out.push(i)}var s=Object.keys(vmap).map(function(k){return vmap[k].id}).filter(function(id){return!vmap[id]["in"]});var sorted=[];while(s.length){var id=s.pop();sorted.push(id);for(var _i=0;_i<vmap[id].out.length;_i++){var index=vmap[id].out[_i];var v=vmap[links[index].target];v["in"]--;if(!v["in"]){s.push(v.id)}}}return sorted}function autoSchedule(tasks,links){var lockMilestone=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var vmap={};links.forEach(function(l){vmap[l.source]={id:l.source,links:[]};vmap[l.target]={id:l.target,links:[]}});var dag=[];links.forEach(function(l){var source=l.source,target=l.target;if(!hasPath(vmap,target,source)){dag.push(l);vmap[source].links.push(vmap[target])}});var sorted=toposort(dag);var tmap={};for(var i=0;i<tasks.length;i++){var task=tasks[i];if(task.type==="milestone"){task.duration=0}tmap[task.id]=i}var ins={};sorted.forEach(function(id){ins[id]=[]});dag.forEach(function(l){ins[l.target].push(l)});sorted.forEach(function(id){var task=tasks[tmap[id]];if(!task)return;var days=task.duration||0;if(lockMilestone&&task.type==="milestone"){return}var start=null;var end=null;for(var _i2=0;_i2<ins[id].length;_i2++){var l=ins[id][_i2];var v=tasks[tmap[l.source]];if(v&&v.start){var s=addDays(v.start,l.lag||0);var e=addDays(s,v.duration||0);if(l.type==="SS"){start=maxDate(start,s)}if(l.type==="FS"){start=maxDate(start,e)}if(l.type==="SF"){end=maxDate(end,s)}if(l.type==="FF"){end=maxDate(end,e)}}}if(end){task.start=addDays(end,-days)}if(start){task.start=start;task.end=addDays(task.start,days)}})}var utils=Object.freeze({__proto__:null,DAY:DAY,addDays:addDays,getDates:getDates,textWidth:textWidth,formatMonth:formatMonth,formatDay:formatDay,minDate:minDate,maxDate:maxDate,max:max,p2s:p2s,s2p:s2p,formatData:formatData,hasPath:hasPath,toposort:toposort,autoSchedule:autoSchedule});function Layout(_ref){var styles=_ref.styles,width=_ref.width,height=_ref.height,offsetY=_ref.offsetY,thickWidth=_ref.thickWidth,maxTextWidth=_ref.maxTextWidth;var x0=thickWidth/2;var W=width-thickWidth;var H=height-thickWidth;return h("g",null,h("rect",{x:x0,y:x0,width:W,height:H,style:styles.box}),h("line",{x1:0,x2:width,y1:offsetY-x0,y2:offsetY-x0,style:styles.bline}),h("line",{x1:maxTextWidth,x2:width,y1:offsetY/2,y2:offsetY/2,style:styles.line}))}function YearMonth(_ref){var styles=_ref.styles,dates=_ref.dates,unit=_ref.unit,offsetY=_ref.offsetY,minTime=_ref.minTime,maxTime=_ref.maxTime,maxTextWidth=_ref.maxTextWidth;var months=dates.filter(function(v){return new Date(v).getDate()===1});months.unshift(minTime);months.push(maxTime);var ticks=[];var x0=maxTextWidth;var y2=offsetY/2;var len=months.length-1;for(var i=0;i<len;i++){var cur=new Date(months[i]);var str=formatMonth(cur);var x=x0+(months[i]-minTime)/unit;var t=(months[i+1]-months[i])/unit;ticks.push(h("g",null,h("line",{x1:x,x2:x,y1:0,y2:y2,style:styles.line}),t>50?h("text",{x:x+t/2,y:offsetY*.25,style:styles.text3},str):null))}return h("g",null,ticks)}function DayHeader(_ref){var styles=_ref.styles,unit=_ref.unit,minTime=_ref.minTime,maxTime=_ref.maxTime,height=_ref.height,offsetY=_ref.offsetY,maxTextWidth=_ref.maxTextWidth;var dates=getDates(minTime,maxTime);var ticks=[];var x0=maxTextWidth;var y0=offsetY/2;var RH=height-y0;var len=dates.length-1;for(var i=0;i<len;i++){var cur=new Date(dates[i]);var day=cur.getDay();var x=x0+(dates[i]-minTime)/unit;var t=(dates[i+1]-dates[i])/unit;ticks.push(h("g",null,day===0||day===6?h("rect",{x:x,y:y0,width:t,height:RH,style:styles.week}):null,h("line",{x1:x,x2:x,y1:y0,y2:offsetY,style:styles.line}),h("text",{x:x+t/2,y:offsetY*.75,style:styles.text3},cur.getDate()),i===len-1?h("line",{x1:x+t,x2:x+t,y1:y0,y2:offsetY,style:styles.line}):null))}return h("g",null,h(YearMonth,{styles:styles,unit:unit,dates:dates,offsetY:offsetY,minTime:minTime,maxTime:maxTime,maxTextWidth:maxTextWidth}),ticks)}function WeekHeader(_ref){var styles=_ref.styles,unit=_ref.unit,minTime=_ref.minTime,maxTime=_ref.maxTime,height=_ref.height,offsetY=_ref.offsetY,maxTextWidth=_ref.maxTextWidth;var dates=getDates(minTime,maxTime);var weeks=dates.filter(function(v){return new Date(v).getDay()===0});weeks.push(maxTime);var ticks=[];var x0=maxTextWidth;var y0=offsetY;var RH=height-y0;var d=DAY/unit;var len=weeks.length-1;for(var i=0;i<len;i++){var cur=new Date(weeks[i]);var x=x0+(weeks[i]-minTime)/unit;var curDay=cur.getDate();var prevDay=addDays(cur,-1).getDate();ticks.push(h("g",null,h("rect",{x:x-d,y:y0,width:d*2,height:RH,style:styles.week}),h("line",{x1:x,x2:x,y1:offsetY/2,y2:offsetY,style:styles.line}),h("text",{x:x+3,y:offsetY*.75,style:styles.text2},curDay),x-x0>28?h("text",{x:x-3,y:offsetY*.75,style:styles.text1},prevDay):null))}return h("g",null,h(YearMonth,{styles:styles,unit:unit,dates:dates,offsetY:offsetY,minTime:minTime,maxTime:maxTime,maxTextWidth:maxTextWidth}),ticks)}function Year(_ref){var styles=_ref.styles,months=_ref.months,unit=_ref.unit,offsetY=_ref.offsetY,minTime=_ref.minTime,maxTime=_ref.maxTime,maxTextWidth=_ref.maxTextWidth;var years=months.filter(function(v){return new Date(v).getMonth()===0});years.unshift(minTime);years.push(maxTime);var ticks=[];var x0=maxTextWidth;var y2=offsetY/2;var len=years.length-1;for(var i=0;i<len;i++){var cur=new Date(years[i]);var x=x0+(years[i]-minTime)/unit;var t=(years[i+1]-years[i])/unit;ticks.push(h("g",null,h("line",{x1:x,x2:x,y1:0,y2:y2,style:styles.line}),t>35?h("text",{x:x+t/2,y:offsetY*.25,style:styles.text3},cur.getFullYear()):null))}return h("g",null,ticks)}function MonthHeader(_ref){var styles=_ref.styles,unit=_ref.unit,minTime=_ref.minTime,maxTime=_ref.maxTime,offsetY=_ref.offsetY,maxTextWidth=_ref.maxTextWidth;var MONTH=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];var dates=getDates(minTime,maxTime);var months=dates.filter(function(v){return new Date(v).getDate()===1});months.unshift(minTime);months.push(maxTime);var ticks=[];var x0=maxTextWidth;var y0=offsetY/2;var len=months.length-1;for(var i=0;i<len;i++){var cur=new Date(months[i]);var month=cur.getMonth();var x=x0+(months[i]-minTime)/unit;var t=(months[i+1]-months[i])/unit;ticks.push(h("g",null,h("line",{x1:x,x2:x,y1:y0,y2:offsetY,style:styles.line}),t>30?h("text",{x:x+t/2,y:offsetY*.75,style:styles.text3},MONTH[month]):null))}return h("g",null,h(Year,{styles:styles,unit:unit,months:months,offsetY:offsetY,minTime:minTime,maxTime:maxTime,maxTextWidth:maxTextWidth}),ticks)}function Grid(_ref){var styles=_ref.styles,data=_ref.data,width=_ref.width,height=_ref.height,offsetY=_ref.offsetY,rowHeight=_ref.rowHeight,maxTextWidth=_ref.maxTextWidth;return h("g",null,data.map(function(v,i){var y=(i+1)*rowHeight+offsetY;return h("line",{key:i,x1:0,x2:width,y1:y,y2:y,style:styles.line})}),h("line",{x1:maxTextWidth,x2:maxTextWidth,y1:0,y2:height,style:styles.bline}))}function Labels(_ref){var styles=_ref.styles,data=_ref.data,_onClick=_ref.onClick,rowHeight=_ref.rowHeight,offsetY=_ref.offsetY;return h("g",null,data.map(function(v,i){return h("text",{key:i,x:10,y:(i+.5)*rowHeight+offsetY,class:"gantt-label",style:styles.label,onClick:function onClick(){return _onClick(v)}},v.text)}))}function LinkLine(_ref){var styles=_ref.styles,data=_ref.data,unit=_ref.unit,offsetY=_ref.offsetY,minTime=_ref.minTime,rowHeight=_ref.rowHeight,barHeight=_ref.barHeight,maxTextWidth=_ref.maxTextWidth;var x0=maxTextWidth;var y0=rowHeight/2+offsetY;var map={};data.forEach(function(v,i){map[v.id]=i});return h("g",null,data.map(function(s,i){if(!s.end||!s.start||!s.links){return null}return s.links.map(function(l){var j=map[l.target];var e=data[j];if(!e||!e.start||!e.end)return null;var gap=12;var arrow=6;var mgap=e.type==="milestone"?barHeight/2:0;var y1=y0+i*rowHeight;var y2=y0+j*rowHeight;var vgap=barHeight/2+4;if(y1>y2){vgap=-vgap}if(l.type==="FS"){var x1=x0+(s.end-minTime)/unit;var x2=x0+(e.start-minTime)/unit-mgap;var p1=[[x1,y1],[x1+gap,y1]];if(x2-x1>=2*gap){p1.push([x1+gap,y2])}else{p1.push([x1+gap,y2-vgap]);p1.push([x2-gap,y2-vgap]);p1.push([x2-gap,y2])}p1.push([x2-arrow,y2]);var p2=[[x2-arrow,y2-arrow],[x2,y2],[x2-arrow,y2+arrow]];return h("g",null,h("polyline",{points:p2s(p1),style:styles.link}),h("polygon",{points:p2s(p2),style:styles.linkArrow}))}if(l.type==="FF"){var _x=x0+(s.end-minTime)/unit;var _x2=x0+(e.end-minTime)/unit+mgap;var _p=[[_x,y1],[_x+gap,y1]];if(_x2<=_x){_p.push([_x+gap,y2])}else{_p.push([_x+gap,y2-vgap]);_p.push([_x2+gap,y2-vgap]);_p.push([_x2+gap,y2])}_p.push([_x2+arrow,y2]);var _p2=[[_x2+arrow,y2-arrow],[_x2,y2],[_x2+arrow,y2+arrow]];return h("g",null,h("polyline",{points:p2s(_p),style:styles.link}),h("polygon",{points:p2s(_p2),style:styles.linkArrow}))}if(l.type==="SS"){var _x3=x0+(s.start-minTime)/unit;var _x4=x0+(e.start-minTime)/unit-mgap;var _p3=[[_x3,y1],[_x3-gap,y1]];if(_x3<=_x4){_p3.push([_x3-gap,y2])}else{_p3.push([_x3-gap,y2-vgap]);_p3.push([_x4-gap,y2-vgap]);_p3.push([_x4-gap,y2])}_p3.push([_x4-arrow,y2]);var _p4=[[_x4-arrow,y2-arrow],[_x4,y2],[_x4-arrow,y2+arrow]];return h("g",null,h("polyline",{points:p2s(_p3),style:styles.link}),h("polygon",{points:p2s(_p4),style:styles.linkArrow}))}if(l.type==="SF"){var _x5=x0+(s.start-minTime)/unit;var _x6=x0+(e.end-minTime)/unit+mgap;var _p5=[[_x5,y1],[_x5-gap,y1]];if(_x5-_x6>=2*gap){_p5.push([_x5-gap,y2])}else{_p5.push([_x5-gap,y2-vgap]);_p5.push([_x6+gap,y2-vgap]);_p5.push([_x6+gap,y2])}_p5.push([_x6+arrow,y2]);var _p6=[[_x6+arrow,y2-arrow],[_x6,y2],[_x6+arrow,y2+arrow]];return h("g",null,h("polyline",{points:p2s(_p5),style:styles.link}),h("polygon",{points:p2s(_p6),style:styles.linkArrow}))}return null})}))}function getTime(val){if(!val)return null;return typeof val.getTime==="function"?val.getTime():val}function getBarColors(v,current,styles){var status=v.status;var blFinish=getTime(v.baselineEnd);var actualFinish=getTime(v.end);if(status===2){return{front:styles.completedGreen,back:styles.completedGreen}}if(status===1||status===3){var doneStyle=styles.doneBlue;var undoneStyle=styles.undoneLightGreen;if(blFinish!=null){var isDelayed=actualFinish!=null?actualFinish>blFinish:current>blFinish;var isExpectedOverdue=current<blFinish&&actualFinish!=null&&actualFinish>blFinish;var isExpectedOnTime=current<blFinish&&(actualFinish==null||actualFinish<=blFinish);if(isDelayed){undoneStyle=styles.undoneRed}else if(isExpectedOverdue){undoneStyle=styles.undoneYellow}else if(isExpectedOnTime){undoneStyle=styles.undoneLightGreen}}return{front:doneStyle,back:undoneStyle}}return null}function Bar(_ref){var styles=_ref.styles,data=_ref.data,unit=_ref.unit,height=_ref.height,offsetY=_ref.offsetY,minTime=_ref.minTime,showDelay=_ref.showDelay,rowHeight=_ref.rowHeight,barHeight=_ref.barHeight,baselineHeight=_ref.baselineHeight,_ref$rowPadding=_ref.rowPadding,rowPadding=_ref$rowPadding===void 0?10:_ref$rowPadding,_ref$rowGap=_ref.rowGap,rowGap=_ref$rowGap===void 0?2:_ref$rowGap,maxTextWidth=_ref.maxTextWidth,current=_ref.current,onClick=_ref.onClick;var x0=maxTextWidth;var cur=x0+(current-minTime)/unit;return h("g",null,current>minTime?h("line",{x1:cur,x2:cur,y1:offsetY,y2:height,style:styles.cline}):null,data.map(function(v,i){var handler=function handler(){return onClick(v)};var y=offsetY+i*rowHeight+rowPadding;var cy=y+barHeight/2;var hasStartEnd=v.start&&v.end;var hasBaselineOnly=!hasStartEnd&&v.baselineStart&&v.baselineEnd;if(hasBaselineOnly){var _baselineWidth=(v.baselineEnd-v.baselineStart)/unit;if(_baselineWidth<=0)return null;var _bx=x0+(v.baselineStart-minTime)/unit;var _baselineCy=y+barHeight+rowGap+baselineHeight/2;return h("g",{key:i,class:"gantt-bar",style:{cursor:"pointer"},onClick:handler},h("text",{x:_bx-4,y:_baselineCy,style:styles.text1},formatDay(v.baselineStart)),h("text",{x:_bx+_baselineWidth+4,y:_baselineCy,style:styles.text2},formatDay(v.baselineEnd)),h("rect",{x:_bx,y:y+barHeight+rowGap,width:_baselineWidth,height:baselineHeight,rx:1.2,ry:1.2,style:styles.baseline,onClick:handler}))}if(!v.end||!v.start){return null}var x=x0+(v.start-minTime)/unit;if(v.type==="milestone"){var size=barHeight/2;var points=[[x,cy-size],[x+size,cy],[x,cy+size],[x-size,cy]].map(function(p){return"".concat(p[0],",").concat(p[1])}).join(" ");return h("g",{key:i,class:"gantt-bar",style:{cursor:"pointer"},onClick:handler},h("polygon",{points:points,style:styles.milestone,onClick:handler}),h("circle",{class:"gantt-ctrl-start","data-id":v.id,cx:x,cy:cy,r:6,style:styles.ctrl}))}var w1=(v.end-v.start)/unit;var w2=w1*v.percent;if(w1<=0){return null}var bar;var statusColors=v.status!=null?getBarColors(v,current,styles):null;if(statusColors){bar={back:statusColors.back,front:statusColors.front}}else{bar=v.type==="group"?{back:styles.groupBack,front:styles.groupFront}:{back:styles.taskBack,front:styles.taskFront};if(showDelay){if(x+w2<cur&&v.percent<.999999){bar.back=styles.warning}if(x+w1<cur&&v.percent<.999999){bar.back=styles.danger}}}var baselineWidth=(v.baselineEnd-v.baselineStart)/unit;var bx=x0+(v.baselineStart-minTime)/unit;var baselineCy=y+barHeight+rowGap+baselineHeight/2;var baseline=v.baselineStart&&v.baselineEnd&&baselineWidth>0?h("g",null,h("text",{x:bx-4,y:baselineCy,style:styles.text1},formatDay(v.baselineStart)),h("text",{x:bx+baselineWidth+4,y:baselineCy,style:styles.text2},formatDay(v.baselineEnd)),h("rect",{x:bx,y:y+barHeight+rowGap,width:baselineWidth,height:baselineHeight,rx:1.2,ry:1.2,style:styles.baseline})):null;return h("g",{key:i,class:"gantt-bar",style:{cursor:"pointer"},onClick:handler},h("text",{x:x-4,y:cy,style:styles.text1},formatDay(v.start)),h("text",{x:x+w1+4,y:cy,style:styles.text2},formatDay(v.end)),h("rect",{x:x,y:y,width:w1,height:barHeight,rx:1.8,ry:1.8,style:bar.back,onClick:handler}),w2>1e-6?h("rect",{x:x,y:y,width:w2,height:barHeight,rx:1.8,ry:1.8,style:bar.front}):null,baseline,v.type==="group"?null:h("g",null,h("circle",{class:"gantt-ctrl-start","data-id":v.id,cx:x-12,cy:cy,r:6,style:styles.ctrl}),h("circle",{class:"gantt-ctrl-finish","data-id":v.id,cx:x+w1+12,cy:cy,r:6,style:styles.ctrl})))}))}function ownKeys$3(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread$3(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys$3(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys$3(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}var SIZE="14px";var TYPE='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';function getFont(_ref){var _ref$fontSize=_ref.fontSize,fontSize=_ref$fontSize===void 0?SIZE:_ref$fontSize,_ref$fontFamily=_ref.fontFamily,fontFamily=_ref$fontFamily===void 0?TYPE:_ref$fontFamily;return"bold ".concat(fontSize," ").concat(fontFamily)}function getStyles(_ref2){var _ref2$bgColor=_ref2.bgColor,bgColor=_ref2$bgColor===void 0?"#fff":_ref2$bgColor,_ref2$lineColor=_ref2.lineColor,lineColor=_ref2$lineColor===void 0?"#eee":_ref2$lineColor,_ref2$redLineColor=_ref2.redLineColor,redLineColor=_ref2$redLineColor===void 0?"#f04134":_ref2$redLineColor,_ref2$groupBack=_ref2.groupBack,groupBack=_ref2$groupBack===void 0?"#3db9d3":_ref2$groupBack,_ref2$groupFront=_ref2.groupFront,groupFront=_ref2$groupFront===void 0?"#299cb4":_ref2$groupFront,_ref2$taskBack=_ref2.taskBack,taskBack=_ref2$taskBack===void 0?"#65c16f":_ref2$taskBack,_ref2$taskFront=_ref2.taskFront,taskFront=_ref2$taskFront===void 0?"#46ad51":_ref2$taskFront,_ref2$taskProgress=_ref2.taskProgress,taskProgress=_ref2$taskProgress===void 0?"#1890ff":_ref2$taskProgress,_ref2$milestone=_ref2.milestone,milestone=_ref2$milestone===void 0?"#d33daf":_ref2$milestone,_ref2$warning=_ref2.warning,warning=_ref2$warning===void 0?"#faad14":_ref2$warning,_ref2$danger=_ref2.danger,danger=_ref2$danger===void 0?"#f5222d":_ref2$danger,_ref2$critical=_ref2.critical,critical=_ref2$critical===void 0?"#ff4d4f":_ref2$critical,_ref2$link=_ref2.link,link=_ref2$link===void 0?"#ffa011":_ref2$link,_ref2$baseline=_ref2.baseline,baseline=_ref2$baseline===void 0?"#3c3c3c":_ref2$baseline,_ref2$completedGreen=_ref2.completedGreen,completedGreen=_ref2$completedGreen===void 0?"#52c41a":_ref2$completedGreen,_ref2$doneBlue=_ref2.doneBlue,doneBlue=_ref2$doneBlue===void 0?"#1565c0":_ref2$doneBlue,_ref2$undoneRed=_ref2.undoneRed,undoneRed=_ref2$undoneRed===void 0?"#f5222d":_ref2$undoneRed,_ref2$undoneYellow=_ref2.undoneYellow,undoneYellow=_ref2$undoneYellow===void 0?"#faad14":_ref2$undoneYellow,_ref2$undoneLightGree=_ref2.undoneLightGreen,undoneLightGreen=_ref2$undoneLightGree===void 0?"#95de64":_ref2$undoneLightGree,_ref2$textColor=_ref2.textColor,textColor=_ref2$textColor===void 0?"#222":_ref2$textColor,_ref2$lightTextColor=_ref2.lightTextColor,lightTextColor=_ref2$lightTextColor===void 0?"#999":_ref2$lightTextColor,_ref2$lineWidth=_ref2.lineWidth,lineWidth=_ref2$lineWidth===void 0?"1px":_ref2$lineWidth,_ref2$thickLineWidth=_ref2.thickLineWidth,thickLineWidth=_ref2$thickLineWidth===void 0?"1.4px":_ref2$thickLineWidth,_ref2$fontSize=_ref2.fontSize,fontSize=_ref2$fontSize===void 0?SIZE:_ref2$fontSize,_ref2$smallFontSize=_ref2.smallFontSize,smallFontSize=_ref2$smallFontSize===void 0?"12px":_ref2$smallFontSize,_ref2$fontFamily=_ref2.fontFamily,fontFamily=_ref2$fontFamily===void 0?TYPE:_ref2$fontFamily,_ref2$whiteSpace=_ref2.whiteSpace,whiteSpace=_ref2$whiteSpace===void 0?"pre":_ref2$whiteSpace;var line={stroke:lineColor,"stroke-width":lineWidth};var redLine={stroke:redLineColor,"stroke-width":lineWidth};var thickLine={stroke:lineColor,"stroke-width":thickLineWidth};var text={fill:textColor,"dominant-baseline":"central","font-size":fontSize,"font-family":fontFamily,"white-space":whiteSpace};var smallText={fill:lightTextColor,"font-size":smallFontSize};return{week:{fill:"rgba(252, 248, 227, .6)"},box:_objectSpread$3(_objectSpread$3({},thickLine),{},{fill:bgColor}),line:line,cline:redLine,bline:thickLine,label:text,groupLabel:_objectSpread$3(_objectSpread$3({},text),{},{"font-weight":"600"}),text1:_objectSpread$3(_objectSpread$3(_objectSpread$3({},text),smallText),{},{"text-anchor":"end"}),text2:_objectSpread$3(_objectSpread$3({},text),smallText),text3:_objectSpread$3(_objectSpread$3(_objectSpread$3({},text),smallText),{},{"text-anchor":"middle"}),link:{stroke:link,"stroke-width":"1.5px",fill:"none"},linkArrow:{fill:link},milestone:{fill:milestone},groupBack:{fill:groupBack},groupFront:{fill:groupFront},groupProgress:{fill:groupFront},taskBack:{fill:taskBack},taskFront:{fill:taskFront},taskProgress:{fill:taskProgress},warning:{fill:warning},danger:{fill:danger},critical:{fill:critical},completedGreen:{fill:completedGreen},doneBlue:{fill:doneBlue},undoneRed:{fill:undoneRed},undoneYellow:{fill:undoneYellow},undoneLightGreen:{fill:undoneLightGreen},baseline:{fill:baseline,opacity:.5},ctrl:{display:"none",fill:"#f0f0f0",stroke:"#929292","stroke-width":"1px"}}}var UNIT={day:DAY/28,week:7*DAY/56,month:30*DAY/56};function NOOP(){}function Gantt(_ref){var _ref$data=_ref.data,data=_ref$data===void 0?[]:_ref$data,_ref$onClick=_ref.onClick,onClick=_ref$onClick===void 0?NOOP:_ref$onClick,_ref$viewMode=_ref.viewMode,viewMode=_ref$viewMode===void 0?"week":_ref$viewMode,_ref$maxTextWidth=_ref.maxTextWidth,maxTextWidth=_ref$maxTextWidth===void 0?140:_ref$maxTextWidth,_ref$offsetY=_ref.offsetY,offsetY=_ref$offsetY===void 0?60:_ref$offsetY,_ref$rowHeight=_ref.rowHeight,rowHeight=_ref$rowHeight===void 0?40:_ref$rowHeight;_ref.barHeight;var _ref$thickWidth=_ref.thickWidth,thickWidth=_ref$thickWidth===void 0?1.4:_ref$thickWidth,_ref$styleOptions=_ref.styleOptions,styleOptions=_ref$styleOptions===void 0?{}:_ref$styleOptions,_ref$showLinks=_ref.showLinks,showLinks=_ref$showLinks===void 0?true:_ref$showLinks,_ref$showDelay=_ref.showDelay,showDelay=_ref$showDelay===void 0?true:_ref$showDelay,start=_ref.start,end=_ref.end;var unit=UNIT[viewMode];var minTime=start.getTime()-unit*48;var maxTime=end.getTime()+unit*48;var width=(maxTime-minTime)/unit+maxTextWidth;var height=data.length*rowHeight+offsetY;var box="0 0 ".concat(width," ").concat(height);var current=Date.now();var styles=getStyles(styleOptions);var rowPadding=10;var ROW_GAP=2;var usable=rowHeight-rowPadding*2-ROW_GAP;var progressBarHeight=Math.floor(usable*2/3);var baselineHeight=Math.floor(usable/3);return h("svg",{width:width,height:height,viewBox:box},h(Layout,{styles:styles,width:width,height:height,offsetY:offsetY,thickWidth:thickWidth,maxTextWidth:maxTextWidth}),viewMode==="day"?h(DayHeader,{styles:styles,unit:unit,height:height,offsetY:offsetY,minTime:minTime,maxTime:maxTime,maxTextWidth:maxTextWidth}):null,viewMode==="week"?h(WeekHeader,{styles:styles,unit:unit,height:height,offsetY:offsetY,minTime:minTime,maxTime:maxTime,maxTextWidth:maxTextWidth}):null,viewMode==="month"?h(MonthHeader,{styles:styles,unit:unit,offsetY:offsetY,minTime:minTime,maxTime:maxTime,maxTextWidth:maxTextWidth}):null,h(Grid,{styles:styles,data:data,width:width,height:height,offsetY:offsetY,rowHeight:rowHeight,maxTextWidth:maxTextWidth}),maxTextWidth>0?h(Labels,{styles:styles,data:data,onClick:onClick,offsetY:offsetY,rowHeight:rowHeight}):null,showLinks?h(LinkLine,{styles:styles,data:data,unit:unit,height:height,current:current,offsetY:offsetY,minTime:minTime,rowHeight:rowHeight,barHeight:progressBarHeight,maxTextWidth:maxTextWidth}):null,h(Bar,{styles:styles,data:data,unit:unit,height:height,current:current,offsetY:offsetY,minTime:minTime,onClick:onClick,showDelay:showDelay,rowHeight:rowHeight,barHeight:progressBarHeight,baselineHeight:baselineHeight,rowPadding:rowPadding,rowGap:ROW_GAP,maxTextWidth:maxTextWidth}))}var NS="http://www.w3.org/2000/svg";var doc=document;function applyProperties(node,props){Object.keys(props).forEach(function(k){var v=props[k];if(k==="style"&&_typeof(v)==="object"){Object.keys(v).forEach(function(sk){node.style[sk]=v[sk]})}else if(k==="onClick"){if(typeof v==="function"){node.addEventListener("click",v)}}else{node.setAttribute(k,v)}})}function render$2(vnode,ctx){var tag=vnode.tag,props=vnode.props,children=vnode.children;var node=doc.createElementNS(NS,tag);if(props){applyProperties(node,props)}children.forEach(function(v){node.appendChild(typeof v==="string"?doc.createTextNode(v):render$2(v))});return node}function ownKeys$2(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread$2(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys$2(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys$2(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}var SVGGantt=function(){function SVGGantt(element,data){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};_classCallCheck(this,SVGGantt);this.dom=typeof element==="string"?document.querySelector(element):element;this.format(data);this.options=options;this.render()}return _createClass(SVGGantt,[{key:"format",value:function format(data){this.data=data;var start=null;var end=null;data.forEach(function(v){start=minDate(start,v.start);end=maxDate(end,v.end);if(v.baselineStart){start=minDate(start,v.baselineStart)}if(v.baselineEnd){end=maxDate(end,v.baselineEnd)}});this.start=start||new Date;this.end=end||new Date}},{key:"setData",value:function setData(data){this.format(data);this.render()}},{key:"setOptions",value:function setOptions(options){this.options=_objectSpread$2(_objectSpread$2({},this.options),options);this.render()}},{key:"render",value:function render(){var data=this.data,start=this.start,end=this.end,options=this.options;if(this.tree){this.dom.removeChild(this.tree)}if(options.maxTextWidth===undefined){var font=getFont(options.styleOptions||{});var w=function w(v){return textWidth(v.text,font,20)};options.maxTextWidth=max(data.map(w),0)}var props=_objectSpread$2(_objectSpread$2({},options),{},{start:start,end:end});this.tree=render$2(h(Gantt,_extends({data:data},props)));this.dom.appendChild(this.tree)}}])}();function render$1(vnode,ctx,e){var tag=vnode.tag,props=vnode.props,children=vnode.children;if(tag==="svg"){var width=props.width,height=props.height;ctx.width=width;ctx.height=height}if(tag==="line"){var x1=props.x1,x2=props.x2,y1=props.y1,y2=props.y2,_props$style=props.style,style=_props$style===void 0?{}:_props$style;if(style.stroke){ctx.strokeStyle=style.stroke;ctx.lineWidth=parseFloat(style["stroke-width"]||1)}ctx.beginPath();ctx.moveTo(x1,y1);ctx.lineTo(x2,y2);ctx.stroke()}if(tag==="polyline"||tag==="polygon"){var points=props.points,_props$style2=props.style,_style=_props$style2===void 0?{}:_props$style2;var p=s2p(points);if(_style.stroke){ctx.strokeStyle=_style.stroke;ctx.lineWidth=parseFloat(_style["stroke-width"]||1)}if(_style.fill){ctx.fillStyle=_style.fill}ctx.beginPath();ctx.moveTo(p[0][0],p[0][1]);for(var i=1;i<p.length;i++){ctx.lineTo(p[i][0],p[i][1])}if(tag==="polyline"){ctx.stroke()}else{ctx.fill()}}if(tag==="rect"){var x=props.x,y=props.y,_width=props.width,_height=props.height,_props$rx=props.rx,rx=_props$rx===void 0?0:_props$rx,_props$ry=props.ry,ry=_props$ry===void 0?0:_props$ry,onClick=props.onClick,_props$style3=props.style,_style2=_props$style3===void 0?{}:_props$style3;ctx.beginPath();ctx.moveTo(x+rx,y);ctx.lineTo(x+_width-rx,y);ctx.quadraticCurveTo(x+_width,y,x+_width,y+ry);ctx.lineTo(x+_width,y+_height-ry);ctx.quadraticCurveTo(x+_width,y+_height,x+_width-rx,y+_height);ctx.lineTo(x+rx,y+_height);ctx.quadraticCurveTo(x,y+_height,x,y+_height-ry);ctx.lineTo(x,y+ry);ctx.quadraticCurveTo(x,y,x+rx,y);if(e&&onClick&&ctx.isPointInPath(e.x,e.y)){onClick()}ctx.closePath();if(_style2.fill){ctx.fillStyle=_style2.fill}ctx.fill();if(_style2.stroke){ctx.strokeStyle=_style2.stroke;ctx.lineWidth=parseFloat(_style2["stroke-width"]||1);ctx.stroke()}}if(tag==="text"){var _x=props.x,_y=props.y,_style3=props.style;if(_style3){ctx.fillStyle=_style3.fill;var BL={central:"middle",middle:"middle",hanging:"hanging",alphabetic:"alphabetic",ideographic:"ideographic"};var AL={start:"start",middle:"center",end:"end"};ctx.textBaseline=BL[_style3["dominant-baseline"]]||"alphabetic";ctx.textAlign=AL[_style3["text-anchor"]]||"start";ctx.font="".concat(_style3["font-weight"]||""," ").concat(_style3["font-size"]," ").concat(_style3["font-family"])}ctx.fillText(children.join(""),_x,_y)}children.forEach(function(v){if(typeof v!=="string"){render$1(v,ctx,e)}})}function createContext(dom){var canvas=typeof dom==="string"?document.querySelector(dom):dom;var ctx=canvas.getContext("2d");var backingStore=ctx.webkitBackingStorePixelRatio||ctx.mozBackingStorePixelRatio||ctx.msBackingStorePixelRatio||ctx.oBackingStorePixelRatio||ctx.backingStorePixelRatio||1;var ratio=(window.devicePixelRatio||1)/backingStore;["width","height"].forEach(function(key){Object.defineProperty(ctx,key,{get:function get(){return canvas[key]/ratio},set:function set(v){canvas[key]=v*ratio;canvas.style[key]="".concat(v,"px");ctx.scale(ratio,ratio)},enumerable:true,configurable:true})});canvas.addEventListener("click",function(e){if(!ctx.onClick)return;var rect=canvas.getBoundingClientRect();ctx.onClick({x:(e.clientX-rect.left)*ratio,y:(e.clientY-rect.top)*ratio})});return ctx}function ownKeys$1(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread$1(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys$1(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys$1(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}var CanvasGantt=function(){function CanvasGantt(element,data){var _this=this;var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};_classCallCheck(this,CanvasGantt);this.ctx=createContext(element);this.format(data);this.options=options;this.render();this.ctx.onClick=function(e){return _this.render(e)}}return _createClass(CanvasGantt,[{key:"format",value:function format(data){this.data=data;var start=null;var end=null;data.forEach(function(v){start=minDate(start,v.start);end=maxDate(end,v.end);if(v.baselineStart){start=minDate(start,v.baselineStart)}if(v.baselineEnd){end=maxDate(end,v.baselineEnd)}});this.start=start||new Date;this.end=end||new Date}},{key:"setData",value:function setData(data){this.format(data);this.render()}},{key:"setOptions",value:function setOptions(options){this.options=_objectSpread$1(_objectSpread$1({},this.options),options);this.render()}},{key:"render",value:function render(e){var data=this.data,start=this.start,end=this.end,options=this.options;if(options.maxTextWidth===undefined){var font=getFont(options.styleOptions||{});var w=function w(v){return textWidth(v.text,font,20)};options.maxTextWidth=max(data.map(w),0)}var props=_objectSpread$1(_objectSpread$1({},options),{},{start:start,end:end});render$1(h(Gantt,_extends({data:data},props)),this.ctx,e)}}])}();function attrEscape(str){return String(str).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/\t/g,"&#x9;").replace(/\n/g,"&#xA;").replace(/\r/g,"&#xD;")}function escape(str){return String(str).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r/g,"&#xD;")}function render(vnode,ctx){var tag=vnode.tag,props=vnode.props,children=vnode.children;var tokens=[];tokens.push("<".concat(tag));Object.keys(props||{}).forEach(function(k){var v=props[k];if(k==="onClick")return;if(k==="style"&&_typeof(v)==="object"){v=Object.keys(v).map(function(i){return"".concat(i,":").concat(v[i],";")}).join("")}tokens.push(" ".concat(k,'="').concat(attrEscape(v),'"'))});if(!children||!children.length){tokens.push(" />");return tokens.join("")}tokens.push(">");children.forEach(function(v){if(typeof v==="string"){tokens.push(escape(v))}else{tokens.push(render(v))}});tokens.push("</".concat(tag,">"));return tokens.join("")}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}var StrGantt=function(){function StrGantt(data){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,StrGantt);this.format(data);this.options=options}return _createClass(StrGantt,[{key:"format",value:function format(data){this.data=data;var start=null;var end=null;data.forEach(function(v){start=minDate(start,v.start);end=maxDate(end,v.end);if(v.baselineStart){start=minDate(start,v.baselineStart)}if(v.baselineEnd){end=maxDate(end,v.baselineEnd)}});this.start=start||new Date;this.end=end||new Date}},{key:"setData",value:function setData(data){this.format(data)}},{key:"setOptions",value:function setOptions(options){this.options=_objectSpread(_objectSpread({},this.options),options)}},{key:"render",value:function render$1(){var data=this.data,start=this.start,end=this.end,options=this.options;var props=_objectSpread(_objectSpread({},options),{},{start:start,end:end});return render(h(Gantt,_extends({data:data},props)))}}])}();exports.CanvasGantt=CanvasGantt;exports.SVGGantt=SVGGantt;exports.StrGantt=StrGantt;exports["default"]=CanvasGantt;exports.utils=utils;Object.defineProperty(exports,"__esModule",{value:true})});
package/es/gantt/Bar.js CHANGED
@@ -1,7 +1,48 @@
1
1
  import h from '../h';
2
2
  import { formatDay } from '../utils';
3
- var ROW_GAP = 2; // 任务条与基线之间的间距
3
+ function getTime(val) {
4
+ if (!val) return null;
5
+ return typeof val.getTime === 'function' ? val.getTime() : val;
6
+ }
4
7
 
8
+ // 根据 status 和日期计算活动条颜色
9
+ // status: 1=未开始 2=已完成 3=已开始
10
+ function getBarColors(v, current, styles) {
11
+ var status = v.status;
12
+ var blFinish = getTime(v.baselineEnd);
13
+ var actualFinish = getTime(v.end);
14
+
15
+ // 已完成:整个进度条绿色
16
+ if (status === 2) {
17
+ return {
18
+ front: styles.completedGreen,
19
+ back: styles.completedGreen
20
+ };
21
+ }
22
+
23
+ // 未完成:已完成部分深蓝,未完成部分根据情况
24
+ if (status === 1 || status === 3) {
25
+ var doneStyle = styles.doneBlue;
26
+ var undoneStyle = styles.undoneLightGreen;
27
+ if (blFinish != null) {
28
+ var isDelayed = actualFinish != null ? actualFinish > blFinish : current > blFinish;
29
+ var isExpectedOverdue = current < blFinish && actualFinish != null && actualFinish > blFinish;
30
+ var isExpectedOnTime = current < blFinish && (actualFinish == null || actualFinish <= blFinish);
31
+ if (isDelayed) {
32
+ undoneStyle = styles.undoneRed;
33
+ } else if (isExpectedOverdue) {
34
+ undoneStyle = styles.undoneYellow;
35
+ } else if (isExpectedOnTime) {
36
+ undoneStyle = styles.undoneLightGreen;
37
+ }
38
+ }
39
+ return {
40
+ front: doneStyle,
41
+ back: undoneStyle
42
+ };
43
+ }
44
+ return null;
45
+ }
5
46
  export default function Bar(_ref) {
6
47
  var styles = _ref.styles,
7
48
  data = _ref.data,
@@ -12,13 +53,15 @@ export default function Bar(_ref) {
12
53
  showDelay = _ref.showDelay,
13
54
  rowHeight = _ref.rowHeight,
14
55
  barHeight = _ref.barHeight,
56
+ baselineHeight = _ref.baselineHeight,
15
57
  _ref$rowPadding = _ref.rowPadding,
16
- rowPadding = _ref$rowPadding === void 0 ? 5 : _ref$rowPadding,
58
+ rowPadding = _ref$rowPadding === void 0 ? 10 : _ref$rowPadding,
59
+ _ref$rowGap = _ref.rowGap,
60
+ rowGap = _ref$rowGap === void 0 ? 2 : _ref$rowGap,
17
61
  maxTextWidth = _ref.maxTextWidth,
18
62
  current = _ref.current,
19
63
  onClick = _ref.onClick;
20
64
  var x0 = maxTextWidth;
21
- var partHeight = barHeight;
22
65
  var cur = x0 + (current - minTime) / unit;
23
66
  return h("g", null, current > minTime ? h("line", {
24
67
  x1: cur,
@@ -31,7 +74,7 @@ export default function Bar(_ref) {
31
74
  return onClick(v);
32
75
  };
33
76
  var y = offsetY + i * rowHeight + rowPadding;
34
- var cy = y + partHeight / 2;
77
+ var cy = y + barHeight / 2;
35
78
  var hasStartEnd = v.start && v.end;
36
79
  var hasBaselineOnly = !hasStartEnd && v.baselineStart && v.baselineEnd;
37
80
 
@@ -40,7 +83,7 @@ export default function Bar(_ref) {
40
83
  var _baselineWidth = (v.baselineEnd - v.baselineStart) / unit;
41
84
  if (_baselineWidth <= 0) return null;
42
85
  var _bx = x0 + (v.baselineStart - minTime) / unit;
43
- var _baselineCy = y + partHeight + ROW_GAP + partHeight / 2;
86
+ var _baselineCy = y + barHeight + rowGap + baselineHeight / 2;
44
87
  return h("g", {
45
88
  key: i,
46
89
  "class": "gantt-bar",
@@ -58,9 +101,9 @@ export default function Bar(_ref) {
58
101
  style: styles.text2
59
102
  }, formatDay(v.baselineEnd)), h("rect", {
60
103
  x: _bx,
61
- y: y + partHeight + ROW_GAP,
104
+ y: y + barHeight + rowGap,
62
105
  width: _baselineWidth,
63
- height: partHeight,
106
+ height: baselineHeight,
64
107
  rx: 1.2,
65
108
  ry: 1.2,
66
109
  style: styles.baseline,
@@ -74,7 +117,7 @@ export default function Bar(_ref) {
74
117
  }
75
118
  var x = x0 + (v.start - minTime) / unit;
76
119
  if (v.type === 'milestone') {
77
- var size = partHeight / 2;
120
+ var size = barHeight / 2;
78
121
  var points = [[x, cy - size], [x + size, cy], [x, cy + size], [x - size, cy]].map(function (p) {
79
122
  return "".concat(p[0], ",").concat(p[1]);
80
123
  }).join(' ');
@@ -104,25 +147,34 @@ export default function Bar(_ref) {
104
147
  if (w1 <= 0) {
105
148
  return null;
106
149
  }
107
- var bar = v.type === 'group' ? {
108
- back: styles.groupBack,
109
- front: styles.groupFront
110
- } : {
111
- back: styles.taskBack,
112
- front: styles.taskFront
113
- };
114
- if (showDelay) {
115
- if (x + w2 < cur && v.percent < 0.999999) {
116
- bar.back = styles.warning;
117
- }
118
- if (x + w1 < cur && v.percent < 0.999999) {
119
- bar.back = styles.danger;
150
+ var bar;
151
+ var statusColors = v.status != null ? getBarColors(v, current, styles) : null;
152
+ if (statusColors) {
153
+ bar = {
154
+ back: statusColors.back,
155
+ front: statusColors.front
156
+ };
157
+ } else {
158
+ bar = v.type === 'group' ? {
159
+ back: styles.groupBack,
160
+ front: styles.groupFront
161
+ } : {
162
+ back: styles.taskBack,
163
+ front: styles.taskFront
164
+ };
165
+ if (showDelay) {
166
+ if (x + w2 < cur && v.percent < 0.999999) {
167
+ bar.back = styles.warning;
168
+ }
169
+ if (x + w1 < cur && v.percent < 0.999999) {
170
+ bar.back = styles.danger;
171
+ }
120
172
  }
121
173
  }
122
- // 基线渲染 - 与进度条等高,位于任务条下方,并显示基线开始/结束时间
174
+ // 基线渲染 - 位于任务条下方,高度为进度条的1/2,并显示基线开始/结束时间
123
175
  var baselineWidth = (v.baselineEnd - v.baselineStart) / unit;
124
176
  var bx = x0 + (v.baselineStart - minTime) / unit;
125
- var baselineCy = y + partHeight + ROW_GAP + partHeight / 2;
177
+ var baselineCy = y + barHeight + rowGap + baselineHeight / 2;
126
178
  var baseline = v.baselineStart && v.baselineEnd && baselineWidth > 0 ? h("g", null, h("text", {
127
179
  x: bx - 4,
128
180
  y: baselineCy,
@@ -133,9 +185,9 @@ export default function Bar(_ref) {
133
185
  style: styles.text2
134
186
  }, formatDay(v.baselineEnd)), h("rect", {
135
187
  x: bx,
136
- y: y + partHeight + ROW_GAP,
188
+ y: y + barHeight + rowGap,
137
189
  width: baselineWidth,
138
- height: partHeight,
190
+ height: baselineHeight,
139
191
  rx: 1.2,
140
192
  ry: 1.2,
141
193
  style: styles.baseline
@@ -159,7 +211,7 @@ export default function Bar(_ref) {
159
211
  x: x,
160
212
  y: y,
161
213
  width: w1,
162
- height: partHeight,
214
+ height: barHeight,
163
215
  rx: 1.8,
164
216
  ry: 1.8,
165
217
  style: bar.back,
@@ -168,7 +220,7 @@ export default function Bar(_ref) {
168
220
  x: x,
169
221
  y: y,
170
222
  width: w2,
171
- height: partHeight,
223
+ height: barHeight,
172
224
  rx: 1.8,
173
225
  ry: 1.8,
174
226
  style: bar.front
package/es/gantt/index.js CHANGED
@@ -48,9 +48,12 @@ export default function Gantt(_ref) {
48
48
  var box = "0 0 ".concat(width, " ").concat(height);
49
49
  var current = Date.now();
50
50
  var styles = getStyles(styleOptions);
51
- // 基线与进度条等高,上下留白,总高度不变
51
+ // 基线:进度条 = 1:2,保持相同间距,总高度不变
52
52
  var rowPadding = 10;
53
- var partHeight = Math.floor((rowHeight - rowPadding * 2 - 2) / 2); // 2=gap
53
+ var ROW_GAP = 2;
54
+ var usable = rowHeight - rowPadding * 2 - ROW_GAP;
55
+ var progressBarHeight = Math.floor(usable * 2 / 3); // 进度条高度
56
+ var baselineHeight = Math.floor(usable / 3); // 基线高度
54
57
 
55
58
  return h("svg", {
56
59
  width: width,
@@ -109,7 +112,7 @@ export default function Gantt(_ref) {
109
112
  offsetY: offsetY,
110
113
  minTime: minTime,
111
114
  rowHeight: rowHeight,
112
- barHeight: partHeight,
115
+ barHeight: progressBarHeight,
113
116
  maxTextWidth: maxTextWidth
114
117
  }) : null, h(Bar, {
115
118
  styles: styles,
@@ -122,8 +125,10 @@ export default function Gantt(_ref) {
122
125
  onClick: onClick,
123
126
  showDelay: showDelay,
124
127
  rowHeight: rowHeight,
125
- barHeight: partHeight,
128
+ barHeight: progressBarHeight,
129
+ baselineHeight: baselineHeight,
126
130
  rowPadding: rowPadding,
131
+ rowGap: ROW_GAP,
127
132
  maxTextWidth: maxTextWidth
128
133
  }));
129
134
  }
@@ -42,6 +42,16 @@ export default function getStyles(_ref2) {
42
42
  link = _ref2$link === void 0 ? '#ffa011' : _ref2$link,
43
43
  _ref2$baseline = _ref2.baseline,
44
44
  baseline = _ref2$baseline === void 0 ? '#3c3c3c' : _ref2$baseline,
45
+ _ref2$completedGreen = _ref2.completedGreen,
46
+ completedGreen = _ref2$completedGreen === void 0 ? '#52c41a' : _ref2$completedGreen,
47
+ _ref2$doneBlue = _ref2.doneBlue,
48
+ doneBlue = _ref2$doneBlue === void 0 ? '#1565c0' : _ref2$doneBlue,
49
+ _ref2$undoneRed = _ref2.undoneRed,
50
+ undoneRed = _ref2$undoneRed === void 0 ? '#f5222d' : _ref2$undoneRed,
51
+ _ref2$undoneYellow = _ref2.undoneYellow,
52
+ undoneYellow = _ref2$undoneYellow === void 0 ? '#faad14' : _ref2$undoneYellow,
53
+ _ref2$undoneLightGree = _ref2.undoneLightGreen,
54
+ undoneLightGreen = _ref2$undoneLightGree === void 0 ? '#95de64' : _ref2$undoneLightGree,
45
55
  _ref2$textColor = _ref2.textColor,
46
56
  textColor = _ref2$textColor === void 0 ? '#222' : _ref2$textColor,
47
57
  _ref2$lightTextColor = _ref2.lightTextColor,
@@ -140,6 +150,21 @@ export default function getStyles(_ref2) {
140
150
  critical: {
141
151
  fill: critical
142
152
  },
153
+ completedGreen: {
154
+ fill: completedGreen
155
+ },
156
+ doneBlue: {
157
+ fill: doneBlue
158
+ },
159
+ undoneRed: {
160
+ fill: undoneRed
161
+ },
162
+ undoneYellow: {
163
+ fill: undoneYellow
164
+ },
165
+ undoneLightGreen: {
166
+ fill: undoneLightGreen
167
+ },
143
168
  baseline: {
144
169
  fill: baseline,
145
170
  opacity: 0.5
package/lib/gantt/Bar.js CHANGED
@@ -7,8 +7,49 @@ exports["default"] = Bar;
7
7
  var _h = _interopRequireDefault(require("../h"));
8
8
  var _utils = require("../utils");
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
- var ROW_GAP = 2; // 任务条与基线之间的间距
10
+ function getTime(val) {
11
+ if (!val) return null;
12
+ return typeof val.getTime === 'function' ? val.getTime() : val;
13
+ }
11
14
 
15
+ // 根据 status 和日期计算活动条颜色
16
+ // status: 1=未开始 2=已完成 3=已开始
17
+ function getBarColors(v, current, styles) {
18
+ var status = v.status;
19
+ var blFinish = getTime(v.baselineEnd);
20
+ var actualFinish = getTime(v.end);
21
+
22
+ // 已完成:整个进度条绿色
23
+ if (status === 2) {
24
+ return {
25
+ front: styles.completedGreen,
26
+ back: styles.completedGreen
27
+ };
28
+ }
29
+
30
+ // 未完成:已完成部分深蓝,未完成部分根据情况
31
+ if (status === 1 || status === 3) {
32
+ var doneStyle = styles.doneBlue;
33
+ var undoneStyle = styles.undoneLightGreen;
34
+ if (blFinish != null) {
35
+ var isDelayed = actualFinish != null ? actualFinish > blFinish : current > blFinish;
36
+ var isExpectedOverdue = current < blFinish && actualFinish != null && actualFinish > blFinish;
37
+ var isExpectedOnTime = current < blFinish && (actualFinish == null || actualFinish <= blFinish);
38
+ if (isDelayed) {
39
+ undoneStyle = styles.undoneRed;
40
+ } else if (isExpectedOverdue) {
41
+ undoneStyle = styles.undoneYellow;
42
+ } else if (isExpectedOnTime) {
43
+ undoneStyle = styles.undoneLightGreen;
44
+ }
45
+ }
46
+ return {
47
+ front: doneStyle,
48
+ back: undoneStyle
49
+ };
50
+ }
51
+ return null;
52
+ }
12
53
  function Bar(_ref) {
13
54
  var styles = _ref.styles,
14
55
  data = _ref.data,
@@ -19,13 +60,15 @@ function Bar(_ref) {
19
60
  showDelay = _ref.showDelay,
20
61
  rowHeight = _ref.rowHeight,
21
62
  barHeight = _ref.barHeight,
63
+ baselineHeight = _ref.baselineHeight,
22
64
  _ref$rowPadding = _ref.rowPadding,
23
- rowPadding = _ref$rowPadding === void 0 ? 5 : _ref$rowPadding,
65
+ rowPadding = _ref$rowPadding === void 0 ? 10 : _ref$rowPadding,
66
+ _ref$rowGap = _ref.rowGap,
67
+ rowGap = _ref$rowGap === void 0 ? 2 : _ref$rowGap,
24
68
  maxTextWidth = _ref.maxTextWidth,
25
69
  current = _ref.current,
26
70
  onClick = _ref.onClick;
27
71
  var x0 = maxTextWidth;
28
- var partHeight = barHeight;
29
72
  var cur = x0 + (current - minTime) / unit;
30
73
  return (0, _h["default"])("g", null, current > minTime ? (0, _h["default"])("line", {
31
74
  x1: cur,
@@ -38,7 +81,7 @@ function Bar(_ref) {
38
81
  return onClick(v);
39
82
  };
40
83
  var y = offsetY + i * rowHeight + rowPadding;
41
- var cy = y + partHeight / 2;
84
+ var cy = y + barHeight / 2;
42
85
  var hasStartEnd = v.start && v.end;
43
86
  var hasBaselineOnly = !hasStartEnd && v.baselineStart && v.baselineEnd;
44
87
 
@@ -47,7 +90,7 @@ function Bar(_ref) {
47
90
  var _baselineWidth = (v.baselineEnd - v.baselineStart) / unit;
48
91
  if (_baselineWidth <= 0) return null;
49
92
  var _bx = x0 + (v.baselineStart - minTime) / unit;
50
- var _baselineCy = y + partHeight + ROW_GAP + partHeight / 2;
93
+ var _baselineCy = y + barHeight + rowGap + baselineHeight / 2;
51
94
  return (0, _h["default"])("g", {
52
95
  key: i,
53
96
  "class": "gantt-bar",
@@ -65,9 +108,9 @@ function Bar(_ref) {
65
108
  style: styles.text2
66
109
  }, (0, _utils.formatDay)(v.baselineEnd)), (0, _h["default"])("rect", {
67
110
  x: _bx,
68
- y: y + partHeight + ROW_GAP,
111
+ y: y + barHeight + rowGap,
69
112
  width: _baselineWidth,
70
- height: partHeight,
113
+ height: baselineHeight,
71
114
  rx: 1.2,
72
115
  ry: 1.2,
73
116
  style: styles.baseline,
@@ -81,7 +124,7 @@ function Bar(_ref) {
81
124
  }
82
125
  var x = x0 + (v.start - minTime) / unit;
83
126
  if (v.type === 'milestone') {
84
- var size = partHeight / 2;
127
+ var size = barHeight / 2;
85
128
  var points = [[x, cy - size], [x + size, cy], [x, cy + size], [x - size, cy]].map(function (p) {
86
129
  return "".concat(p[0], ",").concat(p[1]);
87
130
  }).join(' ');
@@ -111,25 +154,34 @@ function Bar(_ref) {
111
154
  if (w1 <= 0) {
112
155
  return null;
113
156
  }
114
- var bar = v.type === 'group' ? {
115
- back: styles.groupBack,
116
- front: styles.groupFront
117
- } : {
118
- back: styles.taskBack,
119
- front: styles.taskFront
120
- };
121
- if (showDelay) {
122
- if (x + w2 < cur && v.percent < 0.999999) {
123
- bar.back = styles.warning;
124
- }
125
- if (x + w1 < cur && v.percent < 0.999999) {
126
- bar.back = styles.danger;
157
+ var bar;
158
+ var statusColors = v.status != null ? getBarColors(v, current, styles) : null;
159
+ if (statusColors) {
160
+ bar = {
161
+ back: statusColors.back,
162
+ front: statusColors.front
163
+ };
164
+ } else {
165
+ bar = v.type === 'group' ? {
166
+ back: styles.groupBack,
167
+ front: styles.groupFront
168
+ } : {
169
+ back: styles.taskBack,
170
+ front: styles.taskFront
171
+ };
172
+ if (showDelay) {
173
+ if (x + w2 < cur && v.percent < 0.999999) {
174
+ bar.back = styles.warning;
175
+ }
176
+ if (x + w1 < cur && v.percent < 0.999999) {
177
+ bar.back = styles.danger;
178
+ }
127
179
  }
128
180
  }
129
- // 基线渲染 - 与进度条等高,位于任务条下方,并显示基线开始/结束时间
181
+ // 基线渲染 - 位于任务条下方,高度为进度条的1/2,并显示基线开始/结束时间
130
182
  var baselineWidth = (v.baselineEnd - v.baselineStart) / unit;
131
183
  var bx = x0 + (v.baselineStart - minTime) / unit;
132
- var baselineCy = y + partHeight + ROW_GAP + partHeight / 2;
184
+ var baselineCy = y + barHeight + rowGap + baselineHeight / 2;
133
185
  var baseline = v.baselineStart && v.baselineEnd && baselineWidth > 0 ? (0, _h["default"])("g", null, (0, _h["default"])("text", {
134
186
  x: bx - 4,
135
187
  y: baselineCy,
@@ -140,9 +192,9 @@ function Bar(_ref) {
140
192
  style: styles.text2
141
193
  }, (0, _utils.formatDay)(v.baselineEnd)), (0, _h["default"])("rect", {
142
194
  x: bx,
143
- y: y + partHeight + ROW_GAP,
195
+ y: y + barHeight + rowGap,
144
196
  width: baselineWidth,
145
- height: partHeight,
197
+ height: baselineHeight,
146
198
  rx: 1.2,
147
199
  ry: 1.2,
148
200
  style: styles.baseline
@@ -166,7 +218,7 @@ function Bar(_ref) {
166
218
  x: x,
167
219
  y: y,
168
220
  width: w1,
169
- height: partHeight,
221
+ height: barHeight,
170
222
  rx: 1.8,
171
223
  ry: 1.8,
172
224
  style: bar.back,
@@ -175,7 +227,7 @@ function Bar(_ref) {
175
227
  x: x,
176
228
  y: y,
177
229
  width: w2,
178
- height: partHeight,
230
+ height: barHeight,
179
231
  rx: 1.8,
180
232
  ry: 1.8,
181
233
  style: bar.front
@@ -55,9 +55,12 @@ function Gantt(_ref) {
55
55
  var box = "0 0 ".concat(width, " ").concat(height);
56
56
  var current = Date.now();
57
57
  var styles = (0, _styles["default"])(styleOptions);
58
- // 基线与进度条等高,上下留白,总高度不变
58
+ // 基线:进度条 = 1:2,保持相同间距,总高度不变
59
59
  var rowPadding = 10;
60
- var partHeight = Math.floor((rowHeight - rowPadding * 2 - 2) / 2); // 2=gap
60
+ var ROW_GAP = 2;
61
+ var usable = rowHeight - rowPadding * 2 - ROW_GAP;
62
+ var progressBarHeight = Math.floor(usable * 2 / 3); // 进度条高度
63
+ var baselineHeight = Math.floor(usable / 3); // 基线高度
61
64
 
62
65
  return (0, _h["default"])("svg", {
63
66
  width: width,
@@ -116,7 +119,7 @@ function Gantt(_ref) {
116
119
  offsetY: offsetY,
117
120
  minTime: minTime,
118
121
  rowHeight: rowHeight,
119
- barHeight: partHeight,
122
+ barHeight: progressBarHeight,
120
123
  maxTextWidth: maxTextWidth
121
124
  }) : null, (0, _h["default"])(_Bar["default"], {
122
125
  styles: styles,
@@ -129,8 +132,10 @@ function Gantt(_ref) {
129
132
  onClick: onClick,
130
133
  showDelay: showDelay,
131
134
  rowHeight: rowHeight,
132
- barHeight: partHeight,
135
+ barHeight: progressBarHeight,
136
+ baselineHeight: baselineHeight,
133
137
  rowPadding: rowPadding,
138
+ rowGap: ROW_GAP,
134
139
  maxTextWidth: maxTextWidth
135
140
  }));
136
141
  }
@@ -49,6 +49,16 @@ function getStyles(_ref2) {
49
49
  link = _ref2$link === void 0 ? '#ffa011' : _ref2$link,
50
50
  _ref2$baseline = _ref2.baseline,
51
51
  baseline = _ref2$baseline === void 0 ? '#3c3c3c' : _ref2$baseline,
52
+ _ref2$completedGreen = _ref2.completedGreen,
53
+ completedGreen = _ref2$completedGreen === void 0 ? '#52c41a' : _ref2$completedGreen,
54
+ _ref2$doneBlue = _ref2.doneBlue,
55
+ doneBlue = _ref2$doneBlue === void 0 ? '#1565c0' : _ref2$doneBlue,
56
+ _ref2$undoneRed = _ref2.undoneRed,
57
+ undoneRed = _ref2$undoneRed === void 0 ? '#f5222d' : _ref2$undoneRed,
58
+ _ref2$undoneYellow = _ref2.undoneYellow,
59
+ undoneYellow = _ref2$undoneYellow === void 0 ? '#faad14' : _ref2$undoneYellow,
60
+ _ref2$undoneLightGree = _ref2.undoneLightGreen,
61
+ undoneLightGreen = _ref2$undoneLightGree === void 0 ? '#95de64' : _ref2$undoneLightGree,
52
62
  _ref2$textColor = _ref2.textColor,
53
63
  textColor = _ref2$textColor === void 0 ? '#222' : _ref2$textColor,
54
64
  _ref2$lightTextColor = _ref2.lightTextColor,
@@ -147,6 +157,21 @@ function getStyles(_ref2) {
147
157
  critical: {
148
158
  fill: critical
149
159
  },
160
+ completedGreen: {
161
+ fill: completedGreen
162
+ },
163
+ doneBlue: {
164
+ fill: doneBlue
165
+ },
166
+ undoneRed: {
167
+ fill: undoneRed
168
+ },
169
+ undoneYellow: {
170
+ fill: undoneYellow
171
+ },
172
+ undoneLightGreen: {
173
+ fill: undoneLightGreen
174
+ },
150
175
  baseline: {
151
176
  fill: baseline,
152
177
  opacity: 0.5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cwhi-gantt",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "CWHI Gantt chart library using jsx support SVG, Canvas and SSR,It`s from gantt 3.1.1",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
package/src/gantt/Bar.js CHANGED
@@ -1,13 +1,51 @@
1
1
  import h from '../h';
2
2
  import { formatDay } from '../utils';
3
3
 
4
- const ROW_GAP = 2; // 任务条与基线之间的间距
4
+ function getTime(val) {
5
+ if (!val) return null;
6
+ return typeof val.getTime === 'function' ? val.getTime() : val;
7
+ }
8
+
9
+ // 根据 status 和日期计算活动条颜色
10
+ // status: 1=未开始 2=已完成 3=已开始
11
+ function getBarColors(v, current, styles) {
12
+ const status = v.status;
13
+ const blFinish = getTime(v.baselineEnd);
14
+ const actualFinish = getTime(v.end);
15
+
16
+ // 已完成:整个进度条绿色
17
+ if (status === 2) {
18
+ return { front: styles.completedGreen, back: styles.completedGreen };
19
+ }
20
+
21
+ // 未完成:已完成部分深蓝,未完成部分根据情况
22
+ if (status === 1 || status === 3) {
23
+ const doneStyle = styles.doneBlue;
24
+ let undoneStyle = styles.undoneLightGreen;
25
+
26
+ if (blFinish != null) {
27
+ const isDelayed = actualFinish != null ? actualFinish > blFinish : current > blFinish;
28
+ const isExpectedOverdue = current < blFinish && actualFinish != null && actualFinish > blFinish;
29
+ const isExpectedOnTime = current < blFinish && (actualFinish == null || actualFinish <= blFinish);
30
+
31
+ if (isDelayed) {
32
+ undoneStyle = styles.undoneRed;
33
+ } else if (isExpectedOverdue) {
34
+ undoneStyle = styles.undoneYellow;
35
+ } else if (isExpectedOnTime) {
36
+ undoneStyle = styles.undoneLightGreen;
37
+ }
38
+ }
39
+ return { front: doneStyle, back: undoneStyle };
40
+ }
41
+
42
+ return null;
43
+ }
5
44
 
6
45
  export default function Bar({
7
- styles, data, unit, height, offsetY, minTime, showDelay, rowHeight, barHeight, rowPadding = 5, maxTextWidth, current, onClick
46
+ styles, data, unit, height, offsetY, minTime, showDelay, rowHeight, barHeight, baselineHeight, rowPadding = 10, rowGap = 2, maxTextWidth, current, onClick
8
47
  }) {
9
48
  const x0 = maxTextWidth;
10
- const partHeight = barHeight;
11
49
  const cur = x0 + (current - minTime) / unit;
12
50
  return (
13
51
  <g>
@@ -17,7 +55,7 @@ export default function Bar({
17
55
  {data.map((v, i) => {
18
56
  const handler = () => onClick(v);
19
57
  const y = offsetY + i * rowHeight + rowPadding;
20
- const cy = y + partHeight / 2;
58
+ const cy = y + barHeight / 2;
21
59
  const hasStartEnd = v.start && v.end;
22
60
  const hasBaselineOnly = !hasStartEnd && v.baselineStart && v.baselineEnd;
23
61
 
@@ -26,16 +64,16 @@ export default function Bar({
26
64
  const baselineWidth = (v.baselineEnd - v.baselineStart) / unit;
27
65
  if (baselineWidth <= 0) return null;
28
66
  const bx = x0 + (v.baselineStart - minTime) / unit;
29
- const baselineCy = y + partHeight + ROW_GAP + partHeight / 2;
67
+ const baselineCy = y + barHeight + rowGap + baselineHeight / 2;
30
68
  return (
31
69
  <g key={i} class="gantt-bar" style={{ cursor: 'pointer' }} onClick={handler}>
32
70
  <text x={bx - 4} y={baselineCy} style={styles.text1}>{formatDay(v.baselineStart)}</text>
33
71
  <text x={bx + baselineWidth + 4} y={baselineCy} style={styles.text2}>{formatDay(v.baselineEnd)}</text>
34
72
  <rect
35
73
  x={bx}
36
- y={y + partHeight + ROW_GAP}
74
+ y={y + barHeight + rowGap}
37
75
  width={baselineWidth}
38
- height={partHeight}
76
+ height={baselineHeight}
39
77
  rx={1.2}
40
78
  ry={1.2}
41
79
  style={styles.baseline}
@@ -51,7 +89,7 @@ export default function Bar({
51
89
  }
52
90
  const x = x0 + (v.start - minTime) / unit;
53
91
  if (v.type === 'milestone') {
54
- const size = partHeight / 2;
92
+ const size = barHeight / 2;
55
93
  const points = [
56
94
  [x, cy - size],
57
95
  [x + size, cy],
@@ -71,34 +109,40 @@ export default function Bar({
71
109
  if (w1 <= 0) {
72
110
  return null;
73
111
  }
74
- const bar = v.type === 'group' ? {
75
- back: styles.groupBack,
76
- front: styles.groupFront
77
- } : {
78
- back: styles.taskBack,
79
- front: styles.taskFront
80
- };
81
- if (showDelay) {
82
- if ((x + w2) < cur && v.percent < 0.999999) {
83
- bar.back = styles.warning;
84
- }
85
- if ((x + w1) < cur && v.percent < 0.999999) {
86
- bar.back = styles.danger;
112
+ let bar;
113
+ const statusColors = v.status != null ? getBarColors(v, current, styles) : null;
114
+ if (statusColors) {
115
+ bar = { back: statusColors.back, front: statusColors.front };
116
+ } else {
117
+ bar = v.type === 'group' ? {
118
+ back: styles.groupBack,
119
+ front: styles.groupFront
120
+ } : {
121
+ back: styles.taskBack,
122
+ front: styles.taskFront
123
+ };
124
+ if (showDelay) {
125
+ if ((x + w2) < cur && v.percent < 0.999999) {
126
+ bar.back = styles.warning;
127
+ }
128
+ if ((x + w1) < cur && v.percent < 0.999999) {
129
+ bar.back = styles.danger;
130
+ }
87
131
  }
88
132
  }
89
- // 基线渲染 - 与进度条等高,位于任务条下方,并显示基线开始/结束时间
133
+ // 基线渲染 - 位于任务条下方,高度为进度条的1/2,并显示基线开始/结束时间
90
134
  const baselineWidth = (v.baselineEnd - v.baselineStart) / unit;
91
135
  const bx = x0 + (v.baselineStart - minTime) / unit;
92
- const baselineCy = y + partHeight + ROW_GAP + partHeight / 2;
136
+ const baselineCy = y + barHeight + rowGap + baselineHeight / 2;
93
137
  const baseline = v.baselineStart && v.baselineEnd && baselineWidth > 0 ? (
94
138
  <g>
95
139
  <text x={bx - 4} y={baselineCy} style={styles.text1}>{formatDay(v.baselineStart)}</text>
96
140
  <text x={bx + baselineWidth + 4} y={baselineCy} style={styles.text2}>{formatDay(v.baselineEnd)}</text>
97
141
  <rect
98
142
  x={bx}
99
- y={y + partHeight + ROW_GAP}
143
+ y={y + barHeight + rowGap}
100
144
  width={baselineWidth}
101
- height={partHeight}
145
+ height={baselineHeight}
102
146
  rx={1.2}
103
147
  ry={1.2}
104
148
  style={styles.baseline}
@@ -109,8 +153,8 @@ export default function Bar({
109
153
  <g key={i} class="gantt-bar" style={{ cursor: 'pointer' }} onClick={handler}>
110
154
  <text x={x - 4} y={cy} style={styles.text1}>{formatDay(v.start)}</text>
111
155
  <text x={x + w1 + 4} y={cy} style={styles.text2}>{formatDay(v.end)}</text>
112
- <rect x={x} y={y} width={w1} height={partHeight} rx={1.8} ry={1.8} style={bar.back} onClick={handler} />
113
- {w2 > 0.000001 ? <rect x={x} y={y} width={w2} height={partHeight} rx={1.8} ry={1.8} style={bar.front} /> : null}
156
+ <rect x={x} y={y} width={w1} height={barHeight} rx={1.8} ry={1.8} style={bar.back} onClick={handler} />
157
+ {w2 > 0.000001 ? <rect x={x} y={y} width={w2} height={barHeight} rx={1.8} ry={1.8} style={bar.front} /> : null}
114
158
  {baseline}
115
159
  {v.type === 'group' ? null : (
116
160
  <g>
@@ -41,9 +41,12 @@ export default function Gantt({
41
41
  const box = `0 0 ${width} ${height}`;
42
42
  const current = Date.now();
43
43
  const styles = getStyles(styleOptions);
44
- // 基线与进度条等高,上下留白,总高度不变
44
+ // 基线:进度条 = 1:2,保持相同间距,总高度不变
45
45
  const rowPadding = 10;
46
- const partHeight = Math.floor((rowHeight - rowPadding * 2 - 2) / 2); // 2=gap
46
+ const ROW_GAP = 2;
47
+ const usable = rowHeight - rowPadding * 2 - ROW_GAP;
48
+ const progressBarHeight = Math.floor((usable * 2) / 3); // 进度条高度
49
+ const baselineHeight = Math.floor(usable / 3); // 基线高度
47
50
 
48
51
  return (
49
52
  <svg width={width} height={height} viewBox={box}>
@@ -115,7 +118,7 @@ export default function Gantt({
115
118
  offsetY={offsetY}
116
119
  minTime={minTime}
117
120
  rowHeight={rowHeight}
118
- barHeight={partHeight}
121
+ barHeight={progressBarHeight}
119
122
  maxTextWidth={maxTextWidth}
120
123
  />
121
124
  ) : null}
@@ -130,8 +133,10 @@ export default function Gantt({
130
133
  onClick={onClick}
131
134
  showDelay={showDelay}
132
135
  rowHeight={rowHeight}
133
- barHeight={partHeight}
136
+ barHeight={progressBarHeight}
137
+ baselineHeight={baselineHeight}
134
138
  rowPadding={rowPadding}
139
+ rowGap={ROW_GAP}
135
140
  maxTextWidth={maxTextWidth}
136
141
  />
137
142
  </svg>
@@ -23,6 +23,12 @@ export default function getStyles({
23
23
  critical = '#ff4d4f',
24
24
  link = '#ffa011',
25
25
  baseline = '#3c3c3c',
26
+ // 活动状态颜色:status=1未开始 status=2已完成 status=3已开始
27
+ completedGreen = '#52c41a', // 已完成-绿色
28
+ doneBlue = '#1565c0', // 未完成-已完成部分-深蓝
29
+ undoneRed = '#f5222d', // 未完成已滞后-未完成部分-红
30
+ undoneYellow = '#faad14', // 未完成预期超期-未完成部分-黄
31
+ undoneLightGreen = '#95de64', // 未完成预期不超期-未完成部分-浅绿
26
32
  textColor = '#222',
27
33
  lightTextColor = '#999',
28
34
  lineWidth = '1px',
@@ -123,6 +129,11 @@ export default function getStyles({
123
129
  critical: {
124
130
  fill: critical
125
131
  },
132
+ completedGreen: { fill: completedGreen },
133
+ doneBlue: { fill: doneBlue },
134
+ undoneRed: { fill: undoneRed },
135
+ undoneYellow: { fill: undoneYellow },
136
+ undoneLightGreen: { fill: undoneLightGreen },
126
137
  baseline: {
127
138
  fill: baseline,
128
139
  opacity: 0.5