cwhi-gantt 1.2.0 → 1.2.2

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
@@ -940,11 +940,12 @@
940
940
  var hasStartEnd = v.start && v.end;
941
941
  var hasBaselineOnly = !hasStartEnd && v.baselineStart && v.baselineEnd;
942
942
 
943
- // 仅有基线时:只显示基线条,样式与其他基线一致
943
+ // 仅有基线时:只显示基线条及基线开始/结束时间
944
944
  if (hasBaselineOnly) {
945
945
  var _baselineWidth = (v.baselineEnd - v.baselineStart) / unit;
946
946
  if (_baselineWidth <= 0) return null;
947
- var bx = x0 + (v.baselineStart - minTime) / unit;
947
+ var _bx = x0 + (v.baselineStart - minTime) / unit;
948
+ var _baselineCy = y + partHeight + ROW_GAP + partHeight / 2;
948
949
  return h("g", {
949
950
  key: i,
950
951
  "class": "gantt-bar",
@@ -953,15 +954,15 @@
953
954
  },
954
955
  onClick: handler
955
956
  }, h("text", {
956
- x: bx - 4,
957
- y: cy,
957
+ x: _bx - 4,
958
+ y: _baselineCy,
958
959
  style: styles.text1
959
960
  }, formatDay(v.baselineStart)), h("text", {
960
- x: bx + _baselineWidth + 4,
961
- y: cy,
961
+ x: _bx + _baselineWidth + 4,
962
+ y: _baselineCy,
962
963
  style: styles.text2
963
964
  }, formatDay(v.baselineEnd)), h("rect", {
964
- x: bx,
965
+ x: _bx,
965
966
  y: y + partHeight + ROW_GAP,
966
967
  width: _baselineWidth,
967
968
  height: partHeight,
@@ -1023,17 +1024,27 @@
1023
1024
  bar.back = styles.danger;
1024
1025
  }
1025
1026
  }
1026
- // 基线渲染 - 与进度条等高,位于任务条下方
1027
+ // 基线渲染 - 与进度条等高,位于任务条下方,并显示基线开始/结束时间
1027
1028
  var baselineWidth = (v.baselineEnd - v.baselineStart) / unit;
1028
- var baseline = v.baselineStart && v.baselineEnd && baselineWidth > 0 ? h("rect", {
1029
- x: x0 + (v.baselineStart - minTime) / unit,
1029
+ var bx = x0 + (v.baselineStart - minTime) / unit;
1030
+ var baselineCy = y + partHeight + ROW_GAP + partHeight / 2;
1031
+ var baseline = v.baselineStart && v.baselineEnd && baselineWidth > 0 ? h("g", null, h("text", {
1032
+ x: bx - 4,
1033
+ y: baselineCy,
1034
+ style: styles.text1
1035
+ }, formatDay(v.baselineStart)), h("text", {
1036
+ x: bx + baselineWidth + 4,
1037
+ y: baselineCy,
1038
+ style: styles.text2
1039
+ }, formatDay(v.baselineEnd)), h("rect", {
1040
+ x: bx,
1030
1041
  y: y + partHeight + ROW_GAP,
1031
1042
  width: baselineWidth,
1032
1043
  height: partHeight,
1033
1044
  rx: 1.2,
1034
1045
  ry: 1.2,
1035
1046
  style: styles.baseline
1036
- }) : null;
1047
+ })) : null;
1037
1048
  return h("g", {
1038
1049
  key: i,
1039
1050
  "class": "gantt-bar",
@@ -1123,7 +1134,7 @@
1123
1134
  _ref2$link = _ref2.link,
1124
1135
  link = _ref2$link === void 0 ? '#ffa011' : _ref2$link,
1125
1136
  _ref2$baseline = _ref2.baseline,
1126
- baseline = _ref2$baseline === void 0 ? '#EFA7BF' : _ref2$baseline,
1137
+ baseline = _ref2$baseline === void 0 ? '#b3a74e' : _ref2$baseline,
1127
1138
  _ref2$textColor = _ref2.textColor,
1128
1139
  textColor = _ref2$textColor === void 0 ? '#222' : _ref2$textColor,
1129
1140
  _ref2$lightTextColor = _ref2.lightTextColor,
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;return h("g",{key:i,class:"gantt-bar",style:{cursor:"pointer"},onClick:handler},h("text",{x:bx-4,y:cy,style:styles.text1},formatDay(v.baselineStart)),h("text",{x:bx+_baselineWidth+4,y:cy,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 baseline=v.baselineStart&&v.baselineEnd&&baselineWidth>0?h("rect",{x:x0+(v.baselineStart-minTime)/unit,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?"#EFA7BF":_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})}))}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?"#b3a74e":_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})});
package/es/gantt/Bar.js CHANGED
@@ -35,11 +35,12 @@ export default function Bar(_ref) {
35
35
  var hasStartEnd = v.start && v.end;
36
36
  var hasBaselineOnly = !hasStartEnd && v.baselineStart && v.baselineEnd;
37
37
 
38
- // 仅有基线时:只显示基线条,样式与其他基线一致
38
+ // 仅有基线时:只显示基线条及基线开始/结束时间
39
39
  if (hasBaselineOnly) {
40
40
  var _baselineWidth = (v.baselineEnd - v.baselineStart) / unit;
41
41
  if (_baselineWidth <= 0) return null;
42
- var bx = x0 + (v.baselineStart - minTime) / unit;
42
+ var _bx = x0 + (v.baselineStart - minTime) / unit;
43
+ var _baselineCy = y + partHeight + ROW_GAP + partHeight / 2;
43
44
  return h("g", {
44
45
  key: i,
45
46
  "class": "gantt-bar",
@@ -48,15 +49,15 @@ export default function Bar(_ref) {
48
49
  },
49
50
  onClick: handler
50
51
  }, h("text", {
51
- x: bx - 4,
52
- y: cy,
52
+ x: _bx - 4,
53
+ y: _baselineCy,
53
54
  style: styles.text1
54
55
  }, formatDay(v.baselineStart)), h("text", {
55
- x: bx + _baselineWidth + 4,
56
- y: cy,
56
+ x: _bx + _baselineWidth + 4,
57
+ y: _baselineCy,
57
58
  style: styles.text2
58
59
  }, formatDay(v.baselineEnd)), h("rect", {
59
- x: bx,
60
+ x: _bx,
60
61
  y: y + partHeight + ROW_GAP,
61
62
  width: _baselineWidth,
62
63
  height: partHeight,
@@ -118,17 +119,27 @@ export default function Bar(_ref) {
118
119
  bar.back = styles.danger;
119
120
  }
120
121
  }
121
- // 基线渲染 - 与进度条等高,位于任务条下方
122
+ // 基线渲染 - 与进度条等高,位于任务条下方,并显示基线开始/结束时间
122
123
  var baselineWidth = (v.baselineEnd - v.baselineStart) / unit;
123
- var baseline = v.baselineStart && v.baselineEnd && baselineWidth > 0 ? h("rect", {
124
- x: x0 + (v.baselineStart - minTime) / unit,
124
+ var bx = x0 + (v.baselineStart - minTime) / unit;
125
+ var baselineCy = y + partHeight + ROW_GAP + partHeight / 2;
126
+ var baseline = v.baselineStart && v.baselineEnd && baselineWidth > 0 ? h("g", null, h("text", {
127
+ x: bx - 4,
128
+ y: baselineCy,
129
+ style: styles.text1
130
+ }, formatDay(v.baselineStart)), h("text", {
131
+ x: bx + baselineWidth + 4,
132
+ y: baselineCy,
133
+ style: styles.text2
134
+ }, formatDay(v.baselineEnd)), h("rect", {
135
+ x: bx,
125
136
  y: y + partHeight + ROW_GAP,
126
137
  width: baselineWidth,
127
138
  height: partHeight,
128
139
  rx: 1.2,
129
140
  ry: 1.2,
130
141
  style: styles.baseline
131
- }) : null;
142
+ })) : null;
132
143
  return h("g", {
133
144
  key: i,
134
145
  "class": "gantt-bar",
@@ -41,7 +41,7 @@ export default function getStyles(_ref2) {
41
41
  _ref2$link = _ref2.link,
42
42
  link = _ref2$link === void 0 ? '#ffa011' : _ref2$link,
43
43
  _ref2$baseline = _ref2.baseline,
44
- baseline = _ref2$baseline === void 0 ? '#EFA7BF' : _ref2$baseline,
44
+ baseline = _ref2$baseline === void 0 ? '#b3a74e' : _ref2$baseline,
45
45
  _ref2$textColor = _ref2.textColor,
46
46
  textColor = _ref2$textColor === void 0 ? '#222' : _ref2$textColor,
47
47
  _ref2$lightTextColor = _ref2.lightTextColor,
package/lib/gantt/Bar.js CHANGED
@@ -42,11 +42,12 @@ function Bar(_ref) {
42
42
  var hasStartEnd = v.start && v.end;
43
43
  var hasBaselineOnly = !hasStartEnd && v.baselineStart && v.baselineEnd;
44
44
 
45
- // 仅有基线时:只显示基线条,样式与其他基线一致
45
+ // 仅有基线时:只显示基线条及基线开始/结束时间
46
46
  if (hasBaselineOnly) {
47
47
  var _baselineWidth = (v.baselineEnd - v.baselineStart) / unit;
48
48
  if (_baselineWidth <= 0) return null;
49
- var bx = x0 + (v.baselineStart - minTime) / unit;
49
+ var _bx = x0 + (v.baselineStart - minTime) / unit;
50
+ var _baselineCy = y + partHeight + ROW_GAP + partHeight / 2;
50
51
  return (0, _h["default"])("g", {
51
52
  key: i,
52
53
  "class": "gantt-bar",
@@ -55,15 +56,15 @@ function Bar(_ref) {
55
56
  },
56
57
  onClick: handler
57
58
  }, (0, _h["default"])("text", {
58
- x: bx - 4,
59
- y: cy,
59
+ x: _bx - 4,
60
+ y: _baselineCy,
60
61
  style: styles.text1
61
62
  }, (0, _utils.formatDay)(v.baselineStart)), (0, _h["default"])("text", {
62
- x: bx + _baselineWidth + 4,
63
- y: cy,
63
+ x: _bx + _baselineWidth + 4,
64
+ y: _baselineCy,
64
65
  style: styles.text2
65
66
  }, (0, _utils.formatDay)(v.baselineEnd)), (0, _h["default"])("rect", {
66
- x: bx,
67
+ x: _bx,
67
68
  y: y + partHeight + ROW_GAP,
68
69
  width: _baselineWidth,
69
70
  height: partHeight,
@@ -125,17 +126,27 @@ function Bar(_ref) {
125
126
  bar.back = styles.danger;
126
127
  }
127
128
  }
128
- // 基线渲染 - 与进度条等高,位于任务条下方
129
+ // 基线渲染 - 与进度条等高,位于任务条下方,并显示基线开始/结束时间
129
130
  var baselineWidth = (v.baselineEnd - v.baselineStart) / unit;
130
- var baseline = v.baselineStart && v.baselineEnd && baselineWidth > 0 ? (0, _h["default"])("rect", {
131
- x: x0 + (v.baselineStart - minTime) / unit,
131
+ var bx = x0 + (v.baselineStart - minTime) / unit;
132
+ var baselineCy = y + partHeight + ROW_GAP + partHeight / 2;
133
+ var baseline = v.baselineStart && v.baselineEnd && baselineWidth > 0 ? (0, _h["default"])("g", null, (0, _h["default"])("text", {
134
+ x: bx - 4,
135
+ y: baselineCy,
136
+ style: styles.text1
137
+ }, (0, _utils.formatDay)(v.baselineStart)), (0, _h["default"])("text", {
138
+ x: bx + baselineWidth + 4,
139
+ y: baselineCy,
140
+ style: styles.text2
141
+ }, (0, _utils.formatDay)(v.baselineEnd)), (0, _h["default"])("rect", {
142
+ x: bx,
132
143
  y: y + partHeight + ROW_GAP,
133
144
  width: baselineWidth,
134
145
  height: partHeight,
135
146
  rx: 1.2,
136
147
  ry: 1.2,
137
148
  style: styles.baseline
138
- }) : null;
149
+ })) : null;
139
150
  return (0, _h["default"])("g", {
140
151
  key: i,
141
152
  "class": "gantt-bar",
@@ -48,7 +48,7 @@ function getStyles(_ref2) {
48
48
  _ref2$link = _ref2.link,
49
49
  link = _ref2$link === void 0 ? '#ffa011' : _ref2$link,
50
50
  _ref2$baseline = _ref2.baseline,
51
- baseline = _ref2$baseline === void 0 ? '#EFA7BF' : _ref2$baseline,
51
+ baseline = _ref2$baseline === void 0 ? '#b3a74e' : _ref2$baseline,
52
52
  _ref2$textColor = _ref2.textColor,
53
53
  textColor = _ref2$textColor === void 0 ? '#222' : _ref2$textColor,
54
54
  _ref2$lightTextColor = _ref2.lightTextColor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cwhi-gantt",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
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
@@ -21,15 +21,16 @@ export default function Bar({
21
21
  const hasStartEnd = v.start && v.end;
22
22
  const hasBaselineOnly = !hasStartEnd && v.baselineStart && v.baselineEnd;
23
23
 
24
- // 仅有基线时:只显示基线条,样式与其他基线一致
24
+ // 仅有基线时:只显示基线条及基线开始/结束时间
25
25
  if (hasBaselineOnly) {
26
26
  const baselineWidth = (v.baselineEnd - v.baselineStart) / unit;
27
27
  if (baselineWidth <= 0) return null;
28
28
  const bx = x0 + (v.baselineStart - minTime) / unit;
29
+ const baselineCy = y + partHeight + ROW_GAP + partHeight / 2;
29
30
  return (
30
31
  <g key={i} class="gantt-bar" style={{ cursor: 'pointer' }} onClick={handler}>
31
- <text x={bx - 4} y={cy} style={styles.text1}>{formatDay(v.baselineStart)}</text>
32
- <text x={bx + baselineWidth + 4} y={cy} style={styles.text2}>{formatDay(v.baselineEnd)}</text>
32
+ <text x={bx - 4} y={baselineCy} style={styles.text1}>{formatDay(v.baselineStart)}</text>
33
+ <text x={bx + baselineWidth + 4} y={baselineCy} style={styles.text2}>{formatDay(v.baselineEnd)}</text>
33
34
  <rect
34
35
  x={bx}
35
36
  y={y + partHeight + ROW_GAP}
@@ -85,18 +86,24 @@ export default function Bar({
85
86
  bar.back = styles.danger;
86
87
  }
87
88
  }
88
- // 基线渲染 - 与进度条等高,位于任务条下方
89
+ // 基线渲染 - 与进度条等高,位于任务条下方,并显示基线开始/结束时间
89
90
  const baselineWidth = (v.baselineEnd - v.baselineStart) / unit;
91
+ const bx = x0 + (v.baselineStart - minTime) / unit;
92
+ const baselineCy = y + partHeight + ROW_GAP + partHeight / 2;
90
93
  const baseline = v.baselineStart && v.baselineEnd && baselineWidth > 0 ? (
91
- <rect
92
- x={x0 + (v.baselineStart - minTime) / unit}
93
- y={y + partHeight + ROW_GAP}
94
- width={baselineWidth}
95
- height={partHeight}
96
- rx={1.2}
97
- ry={1.2}
98
- style={styles.baseline}
99
- />
94
+ <g>
95
+ <text x={bx - 4} y={baselineCy} style={styles.text1}>{formatDay(v.baselineStart)}</text>
96
+ <text x={bx + baselineWidth + 4} y={baselineCy} style={styles.text2}>{formatDay(v.baselineEnd)}</text>
97
+ <rect
98
+ x={bx}
99
+ y={y + partHeight + ROW_GAP}
100
+ width={baselineWidth}
101
+ height={partHeight}
102
+ rx={1.2}
103
+ ry={1.2}
104
+ style={styles.baseline}
105
+ />
106
+ </g>
100
107
  ) : null;
101
108
  return (
102
109
  <g key={i} class="gantt-bar" style={{ cursor: 'pointer' }} onClick={handler}>
@@ -22,7 +22,7 @@ export default function getStyles({
22
22
  danger = '#f5222d',
23
23
  critical = '#ff4d4f',
24
24
  link = '#ffa011',
25
- baseline = '#EFA7BF',
25
+ baseline = '#b3a74e',
26
26
  textColor = '#222',
27
27
  lightTextColor = '#999',
28
28
  lineWidth = '1px',