1 | import { sanitizeUrl } from "@braintree/sanitize-url";
|
2 | import dayjs from "dayjs/esm/index.js";
|
3 | import dayjsIsoWeek from "dayjs/esm/plugin/isoWeek/index.js";
|
4 | import dayjsCustomParseFormat from "dayjs/esm/plugin/customParseFormat/index.js";
|
5 | import dayjsAdvancedFormat from "dayjs/esm/plugin/advancedFormat/index.js";
|
6 | import { c as getConfig, s as setAccTitle, g as getAccTitle, r as setDiagramTitle, t as getDiagramTitle, b as setAccDescription, a as getAccDescription, m as mermaidAPI, v as clear$1, u as utils, l as log, i as configureSvgSize, e as common } from "./mermaid-a953d906.js";
|
7 | import { select, scaleTime, min, max, scaleLinear, interpolateHcl, axisBottom, timeFormat, timeMonth, timeWeek, timeDay, timeHour, timeMinute, axisTop } from "d3";
|
8 | import "ts-dedent";
|
9 | import "dompurify";
|
10 | import "khroma";
|
11 | import "lodash-es/memoize.js";
|
12 | import "stylis";
|
13 | import "lodash-es/isEmpty.js";
|
14 | var parser = function() {
|
15 | var o = function(k, v, o2, l) {
|
16 | for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
|
17 | ;
|
18 | return o2;
|
19 | }, $V0 = [1, 3], $V1 = [1, 5], $V2 = [7, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 25, 26, 28, 35, 40], $V3 = [1, 15], $V4 = [1, 16], $V5 = [1, 17], $V6 = [1, 18], $V7 = [1, 19], $V8 = [1, 20], $V9 = [1, 21], $Va = [1, 22], $Vb = [1, 23], $Vc = [1, 24], $Vd = [1, 25], $Ve = [1, 26], $Vf = [1, 27], $Vg = [1, 29], $Vh = [1, 31], $Vi = [1, 34], $Vj = [5, 7, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 25, 26, 28, 35, 40];
|
20 | var parser2 = {
|
21 | trace: function trace() {
|
22 | },
|
23 | yy: {},
|
24 | symbols_: { "error": 2, "start": 3, "directive": 4, "gantt": 5, "document": 6, "EOF": 7, "line": 8, "SPACE": 9, "statement": 10, "NL": 11, "dateFormat": 12, "inclusiveEndDates": 13, "topAxis": 14, "axisFormat": 15, "tickInterval": 16, "excludes": 17, "includes": 18, "todayMarker": 19, "title": 20, "acc_title": 21, "acc_title_value": 22, "acc_descr": 23, "acc_descr_value": 24, "acc_descr_multiline_value": 25, "section": 26, "clickStatement": 27, "taskTxt": 28, "taskData": 29, "openDirective": 30, "typeDirective": 31, "closeDirective": 32, ":": 33, "argDirective": 34, "click": 35, "callbackname": 36, "callbackargs": 37, "href": 38, "clickStatementDebug": 39, "open_directive": 40, "type_directive": 41, "arg_directive": 42, "close_directive": 43, "$accept": 0, "$end": 1 },
|
25 | terminals_: { 2: "error", 5: "gantt", 7: "EOF", 9: "SPACE", 11: "NL", 12: "dateFormat", 13: "inclusiveEndDates", 14: "topAxis", 15: "axisFormat", 16: "tickInterval", 17: "excludes", 18: "includes", 19: "todayMarker", 20: "title", 21: "acc_title", 22: "acc_title_value", 23: "acc_descr", 24: "acc_descr_value", 25: "acc_descr_multiline_value", 26: "section", 28: "taskTxt", 29: "taskData", 33: ":", 35: "click", 36: "callbackname", 37: "callbackargs", 38: "href", 40: "open_directive", 41: "type_directive", 42: "arg_directive", 43: "close_directive" },
|
26 | productions_: [0, [3, 2], [3, 3], [6, 0], [6, 2], [8, 2], [8, 1], [8, 1], [8, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 2], [10, 2], [10, 1], [10, 1], [10, 1], [10, 2], [10, 1], [4, 4], [4, 6], [27, 2], [27, 3], [27, 3], [27, 4], [27, 3], [27, 4], [27, 2], [39, 2], [39, 3], [39, 3], [39, 4], [39, 3], [39, 4], [39, 2], [30, 1], [31, 1], [34, 1], [32, 1]],
|
27 | performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
|
28 | var $0 = $$.length - 1;
|
29 | switch (yystate) {
|
30 | case 2:
|
31 | return $$[$0 - 1];
|
32 | case 3:
|
33 | this.$ = [];
|
34 | break;
|
35 | case 4:
|
36 | $$[$0 - 1].push($$[$0]);
|
37 | this.$ = $$[$0 - 1];
|
38 | break;
|
39 | case 5:
|
40 | case 6:
|
41 | this.$ = $$[$0];
|
42 | break;
|
43 | case 7:
|
44 | case 8:
|
45 | this.$ = [];
|
46 | break;
|
47 | case 9:
|
48 | yy.setDateFormat($$[$0].substr(11));
|
49 | this.$ = $$[$0].substr(11);
|
50 | break;
|
51 | case 10:
|
52 | yy.enableInclusiveEndDates();
|
53 | this.$ = $$[$0].substr(18);
|
54 | break;
|
55 | case 11:
|
56 | yy.TopAxis();
|
57 | this.$ = $$[$0].substr(8);
|
58 | break;
|
59 | case 12:
|
60 | yy.setAxisFormat($$[$0].substr(11));
|
61 | this.$ = $$[$0].substr(11);
|
62 | break;
|
63 | case 13:
|
64 | yy.setTickInterval($$[$0].substr(13));
|
65 | this.$ = $$[$0].substr(13);
|
66 | break;
|
67 | case 14:
|
68 | yy.setExcludes($$[$0].substr(9));
|
69 | this.$ = $$[$0].substr(9);
|
70 | break;
|
71 | case 15:
|
72 | yy.setIncludes($$[$0].substr(9));
|
73 | this.$ = $$[$0].substr(9);
|
74 | break;
|
75 | case 16:
|
76 | yy.setTodayMarker($$[$0].substr(12));
|
77 | this.$ = $$[$0].substr(12);
|
78 | break;
|
79 | case 17:
|
80 | yy.setDiagramTitle($$[$0].substr(6));
|
81 | this.$ = $$[$0].substr(6);
|
82 | break;
|
83 | case 18:
|
84 | this.$ = $$[$0].trim();
|
85 | yy.setAccTitle(this.$);
|
86 | break;
|
87 | case 19:
|
88 | case 20:
|
89 | this.$ = $$[$0].trim();
|
90 | yy.setAccDescription(this.$);
|
91 | break;
|
92 | case 21:
|
93 | yy.addSection($$[$0].substr(8));
|
94 | this.$ = $$[$0].substr(8);
|
95 | break;
|
96 | case 23:
|
97 | yy.addTask($$[$0 - 1], $$[$0]);
|
98 | this.$ = "task";
|
99 | break;
|
100 | case 27:
|
101 | this.$ = $$[$0 - 1];
|
102 | yy.setClickEvent($$[$0 - 1], $$[$0], null);
|
103 | break;
|
104 | case 28:
|
105 | this.$ = $$[$0 - 2];
|
106 | yy.setClickEvent($$[$0 - 2], $$[$0 - 1], $$[$0]);
|
107 | break;
|
108 | case 29:
|
109 | this.$ = $$[$0 - 2];
|
110 | yy.setClickEvent($$[$0 - 2], $$[$0 - 1], null);
|
111 | yy.setLink($$[$0 - 2], $$[$0]);
|
112 | break;
|
113 | case 30:
|
114 | this.$ = $$[$0 - 3];
|
115 | yy.setClickEvent($$[$0 - 3], $$[$0 - 2], $$[$0 - 1]);
|
116 | yy.setLink($$[$0 - 3], $$[$0]);
|
117 | break;
|
118 | case 31:
|
119 | this.$ = $$[$0 - 2];
|
120 | yy.setClickEvent($$[$0 - 2], $$[$0], null);
|
121 | yy.setLink($$[$0 - 2], $$[$0 - 1]);
|
122 | break;
|
123 | case 32:
|
124 | this.$ = $$[$0 - 3];
|
125 | yy.setClickEvent($$[$0 - 3], $$[$0 - 1], $$[$0]);
|
126 | yy.setLink($$[$0 - 3], $$[$0 - 2]);
|
127 | break;
|
128 | case 33:
|
129 | this.$ = $$[$0 - 1];
|
130 | yy.setLink($$[$0 - 1], $$[$0]);
|
131 | break;
|
132 | case 34:
|
133 | case 40:
|
134 | this.$ = $$[$0 - 1] + " " + $$[$0];
|
135 | break;
|
136 | case 35:
|
137 | case 36:
|
138 | case 38:
|
139 | this.$ = $$[$0 - 2] + " " + $$[$0 - 1] + " " + $$[$0];
|
140 | break;
|
141 | case 37:
|
142 | case 39:
|
143 | this.$ = $$[$0 - 3] + " " + $$[$0 - 2] + " " + $$[$0 - 1] + " " + $$[$0];
|
144 | break;
|
145 | case 41:
|
146 | yy.parseDirective("%%{", "open_directive");
|
147 | break;
|
148 | case 42:
|
149 | yy.parseDirective($$[$0], "type_directive");
|
150 | break;
|
151 | case 43:
|
152 | $$[$0] = $$[$0].trim().replace(/'/g, '"');
|
153 | yy.parseDirective($$[$0], "arg_directive");
|
154 | break;
|
155 | case 44:
|
156 | yy.parseDirective("}%%", "close_directive", "gantt");
|
157 | break;
|
158 | }
|
159 | },
|
160 | table: [{ 3: 1, 4: 2, 5: $V0, 30: 4, 40: $V1 }, { 1: [3] }, { 3: 6, 4: 2, 5: $V0, 30: 4, 40: $V1 }, o($V2, [2, 3], { 6: 7 }), { 31: 8, 41: [1, 9] }, { 41: [2, 41] }, { 1: [2, 1] }, { 4: 30, 7: [1, 10], 8: 11, 9: [1, 12], 10: 13, 11: [1, 14], 12: $V3, 13: $V4, 14: $V5, 15: $V6, 16: $V7, 17: $V8, 18: $V9, 19: $Va, 20: $Vb, 21: $Vc, 23: $Vd, 25: $Ve, 26: $Vf, 27: 28, 28: $Vg, 30: 4, 35: $Vh, 40: $V1 }, { 32: 32, 33: [1, 33], 43: $Vi }, o([33, 43], [2, 42]), o($V2, [2, 8], { 1: [2, 2] }), o($V2, [2, 4]), { 4: 30, 10: 35, 12: $V3, 13: $V4, 14: $V5, 15: $V6, 16: $V7, 17: $V8, 18: $V9, 19: $Va, 20: $Vb, 21: $Vc, 23: $Vd, 25: $Ve, 26: $Vf, 27: 28, 28: $Vg, 30: 4, 35: $Vh, 40: $V1 }, o($V2, [2, 6]), o($V2, [2, 7]), o($V2, [2, 9]), o($V2, [2, 10]), o($V2, [2, 11]), o($V2, [2, 12]), o($V2, [2, 13]), o($V2, [2, 14]), o($V2, [2, 15]), o($V2, [2, 16]), o($V2, [2, 17]), { 22: [1, 36] }, { 24: [1, 37] }, o($V2, [2, 20]), o($V2, [2, 21]), o($V2, [2, 22]), { 29: [1, 38] }, o($V2, [2, 24]), { 36: [1, 39], 38: [1, 40] }, { 11: [1, 41] }, { 34: 42, 42: [1, 43] }, { 11: [2, 44] }, o($V2, [2, 5]), o($V2, [2, 18]), o($V2, [2, 19]), o($V2, [2, 23]), o($V2, [2, 27], { 37: [1, 44], 38: [1, 45] }), o($V2, [2, 33], { 36: [1, 46] }), o($Vj, [2, 25]), { 32: 47, 43: $Vi }, { 43: [2, 43] }, o($V2, [2, 28], { 38: [1, 48] }), o($V2, [2, 29]), o($V2, [2, 31], { 37: [1, 49] }), { 11: [1, 50] }, o($V2, [2, 30]), o($V2, [2, 32]), o($Vj, [2, 26])],
|
161 | defaultActions: { 5: [2, 41], 6: [2, 1], 34: [2, 44], 43: [2, 43] },
|
162 | parseError: function parseError(str, hash) {
|
163 | if (hash.recoverable) {
|
164 | this.trace(str);
|
165 | } else {
|
166 | var error = new Error(str);
|
167 | error.hash = hash;
|
168 | throw error;
|
169 | }
|
170 | },
|
171 | parse: function parse(input) {
|
172 | var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
|
173 | var args = lstack.slice.call(arguments, 1);
|
174 | var lexer2 = Object.create(this.lexer);
|
175 | var sharedState = { yy: {} };
|
176 | for (var k in this.yy) {
|
177 | if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
|
178 | sharedState.yy[k] = this.yy[k];
|
179 | }
|
180 | }
|
181 | lexer2.setInput(input, sharedState.yy);
|
182 | sharedState.yy.lexer = lexer2;
|
183 | sharedState.yy.parser = this;
|
184 | if (typeof lexer2.yylloc == "undefined") {
|
185 | lexer2.yylloc = {};
|
186 | }
|
187 | var yyloc = lexer2.yylloc;
|
188 | lstack.push(yyloc);
|
189 | var ranges = lexer2.options && lexer2.options.ranges;
|
190 | if (typeof sharedState.yy.parseError === "function") {
|
191 | this.parseError = sharedState.yy.parseError;
|
192 | } else {
|
193 | this.parseError = Object.getPrototypeOf(this).parseError;
|
194 | }
|
195 | function lex() {
|
196 | var token;
|
197 | token = tstack.pop() || lexer2.lex() || EOF;
|
198 | if (typeof token !== "number") {
|
199 | if (token instanceof Array) {
|
200 | tstack = token;
|
201 | token = tstack.pop();
|
202 | }
|
203 | token = self.symbols_[token] || token;
|
204 | }
|
205 | return token;
|
206 | }
|
207 | var symbol, state, action, r, yyval = {}, p, len, newState, expected;
|
208 | while (true) {
|
209 | state = stack[stack.length - 1];
|
210 | if (this.defaultActions[state]) {
|
211 | action = this.defaultActions[state];
|
212 | } else {
|
213 | if (symbol === null || typeof symbol == "undefined") {
|
214 | symbol = lex();
|
215 | }
|
216 | action = table[state] && table[state][symbol];
|
217 | }
|
218 | if (typeof action === "undefined" || !action.length || !action[0]) {
|
219 | var errStr = "";
|
220 | expected = [];
|
221 | for (p in table[state]) {
|
222 | if (this.terminals_[p] && p > TERROR) {
|
223 | expected.push("'" + this.terminals_[p] + "'");
|
224 | }
|
225 | }
|
226 | if (lexer2.showPosition) {
|
227 | errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
|
228 | } else {
|
229 | errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
|
230 | }
|
231 | this.parseError(errStr, {
|
232 | text: lexer2.match,
|
233 | token: this.terminals_[symbol] || symbol,
|
234 | line: lexer2.yylineno,
|
235 | loc: yyloc,
|
236 | expected
|
237 | });
|
238 | }
|
239 | if (action[0] instanceof Array && action.length > 1) {
|
240 | throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
|
241 | }
|
242 | switch (action[0]) {
|
243 | case 1:
|
244 | stack.push(symbol);
|
245 | vstack.push(lexer2.yytext);
|
246 | lstack.push(lexer2.yylloc);
|
247 | stack.push(action[1]);
|
248 | symbol = null;
|
249 | {
|
250 | yyleng = lexer2.yyleng;
|
251 | yytext = lexer2.yytext;
|
252 | yylineno = lexer2.yylineno;
|
253 | yyloc = lexer2.yylloc;
|
254 | }
|
255 | break;
|
256 | case 2:
|
257 | len = this.productions_[action[1]][1];
|
258 | yyval.$ = vstack[vstack.length - len];
|
259 | yyval._$ = {
|
260 | first_line: lstack[lstack.length - (len || 1)].first_line,
|
261 | last_line: lstack[lstack.length - 1].last_line,
|
262 | first_column: lstack[lstack.length - (len || 1)].first_column,
|
263 | last_column: lstack[lstack.length - 1].last_column
|
264 | };
|
265 | if (ranges) {
|
266 | yyval._$.range = [
|
267 | lstack[lstack.length - (len || 1)].range[0],
|
268 | lstack[lstack.length - 1].range[1]
|
269 | ];
|
270 | }
|
271 | r = this.performAction.apply(yyval, [
|
272 | yytext,
|
273 | yyleng,
|
274 | yylineno,
|
275 | sharedState.yy,
|
276 | action[1],
|
277 | vstack,
|
278 | lstack
|
279 | ].concat(args));
|
280 | if (typeof r !== "undefined") {
|
281 | return r;
|
282 | }
|
283 | if (len) {
|
284 | stack = stack.slice(0, -1 * len * 2);
|
285 | vstack = vstack.slice(0, -1 * len);
|
286 | lstack = lstack.slice(0, -1 * len);
|
287 | }
|
288 | stack.push(this.productions_[action[1]][0]);
|
289 | vstack.push(yyval.$);
|
290 | lstack.push(yyval._$);
|
291 | newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
292 | stack.push(newState);
|
293 | break;
|
294 | case 3:
|
295 | return true;
|
296 | }
|
297 | }
|
298 | return true;
|
299 | }
|
300 | };
|
301 | var lexer = function() {
|
302 | var lexer2 = {
|
303 | EOF: 1,
|
304 | parseError: function parseError(str, hash) {
|
305 | if (this.yy.parser) {
|
306 | this.yy.parser.parseError(str, hash);
|
307 | } else {
|
308 | throw new Error(str);
|
309 | }
|
310 | },
|
311 |
|
312 | setInput: function(input, yy) {
|
313 | this.yy = yy || this.yy || {};
|
314 | this._input = input;
|
315 | this._more = this._backtrack = this.done = false;
|
316 | this.yylineno = this.yyleng = 0;
|
317 | this.yytext = this.matched = this.match = "";
|
318 | this.conditionStack = ["INITIAL"];
|
319 | this.yylloc = {
|
320 | first_line: 1,
|
321 | first_column: 0,
|
322 | last_line: 1,
|
323 | last_column: 0
|
324 | };
|
325 | if (this.options.ranges) {
|
326 | this.yylloc.range = [0, 0];
|
327 | }
|
328 | this.offset = 0;
|
329 | return this;
|
330 | },
|
331 |
|
332 | input: function() {
|
333 | var ch = this._input[0];
|
334 | this.yytext += ch;
|
335 | this.yyleng++;
|
336 | this.offset++;
|
337 | this.match += ch;
|
338 | this.matched += ch;
|
339 | var lines = ch.match(/(?:\r\n?|\n).*/g);
|
340 | if (lines) {
|
341 | this.yylineno++;
|
342 | this.yylloc.last_line++;
|
343 | } else {
|
344 | this.yylloc.last_column++;
|
345 | }
|
346 | if (this.options.ranges) {
|
347 | this.yylloc.range[1]++;
|
348 | }
|
349 | this._input = this._input.slice(1);
|
350 | return ch;
|
351 | },
|
352 |
|
353 | unput: function(ch) {
|
354 | var len = ch.length;
|
355 | var lines = ch.split(/(?:\r\n?|\n)/g);
|
356 | this._input = ch + this._input;
|
357 | this.yytext = this.yytext.substr(0, this.yytext.length - len);
|
358 | this.offset -= len;
|
359 | var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
360 | this.match = this.match.substr(0, this.match.length - 1);
|
361 | this.matched = this.matched.substr(0, this.matched.length - 1);
|
362 | if (lines.length - 1) {
|
363 | this.yylineno -= lines.length - 1;
|
364 | }
|
365 | var r = this.yylloc.range;
|
366 | this.yylloc = {
|
367 | first_line: this.yylloc.first_line,
|
368 | last_line: this.yylineno + 1,
|
369 | first_column: this.yylloc.first_column,
|
370 | last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len
|
371 | };
|
372 | if (this.options.ranges) {
|
373 | this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
374 | }
|
375 | this.yyleng = this.yytext.length;
|
376 | return this;
|
377 | },
|
378 |
|
379 | more: function() {
|
380 | this._more = true;
|
381 | return this;
|
382 | },
|
383 |
|
384 | reject: function() {
|
385 | if (this.options.backtrack_lexer) {
|
386 | this._backtrack = true;
|
387 | } else {
|
388 | return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), {
|
389 | text: "",
|
390 | token: null,
|
391 | line: this.yylineno
|
392 | });
|
393 | }
|
394 | return this;
|
395 | },
|
396 |
|
397 | less: function(n) {
|
398 | this.unput(this.match.slice(n));
|
399 | },
|
400 |
|
401 | pastInput: function() {
|
402 | var past = this.matched.substr(0, this.matched.length - this.match.length);
|
403 | return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
|
404 | },
|
405 |
|
406 | upcomingInput: function() {
|
407 | var next = this.match;
|
408 | if (next.length < 20) {
|
409 | next += this._input.substr(0, 20 - next.length);
|
410 | }
|
411 | return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
|
412 | },
|
413 |
|
414 | showPosition: function() {
|
415 | var pre = this.pastInput();
|
416 | var c = new Array(pre.length + 1).join("-");
|
417 | return pre + this.upcomingInput() + "\n" + c + "^";
|
418 | },
|
419 |
|
420 | test_match: function(match, indexed_rule) {
|
421 | var token, lines, backup;
|
422 | if (this.options.backtrack_lexer) {
|
423 | backup = {
|
424 | yylineno: this.yylineno,
|
425 | yylloc: {
|
426 | first_line: this.yylloc.first_line,
|
427 | last_line: this.last_line,
|
428 | first_column: this.yylloc.first_column,
|
429 | last_column: this.yylloc.last_column
|
430 | },
|
431 | yytext: this.yytext,
|
432 | match: this.match,
|
433 | matches: this.matches,
|
434 | matched: this.matched,
|
435 | yyleng: this.yyleng,
|
436 | offset: this.offset,
|
437 | _more: this._more,
|
438 | _input: this._input,
|
439 | yy: this.yy,
|
440 | conditionStack: this.conditionStack.slice(0),
|
441 | done: this.done
|
442 | };
|
443 | if (this.options.ranges) {
|
444 | backup.yylloc.range = this.yylloc.range.slice(0);
|
445 | }
|
446 | }
|
447 | lines = match[0].match(/(?:\r\n?|\n).*/g);
|
448 | if (lines) {
|
449 | this.yylineno += lines.length;
|
450 | }
|
451 | this.yylloc = {
|
452 | first_line: this.yylloc.last_line,
|
453 | last_line: this.yylineno + 1,
|
454 | first_column: this.yylloc.last_column,
|
455 | last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
|
456 | };
|
457 | this.yytext += match[0];
|
458 | this.match += match[0];
|
459 | this.matches = match;
|
460 | this.yyleng = this.yytext.length;
|
461 | if (this.options.ranges) {
|
462 | this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
463 | }
|
464 | this._more = false;
|
465 | this._backtrack = false;
|
466 | this._input = this._input.slice(match[0].length);
|
467 | this.matched += match[0];
|
468 | token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
469 | if (this.done && this._input) {
|
470 | this.done = false;
|
471 | }
|
472 | if (token) {
|
473 | return token;
|
474 | } else if (this._backtrack) {
|
475 | for (var k in backup) {
|
476 | this[k] = backup[k];
|
477 | }
|
478 | return false;
|
479 | }
|
480 | return false;
|
481 | },
|
482 |
|
483 | next: function() {
|
484 | if (this.done) {
|
485 | return this.EOF;
|
486 | }
|
487 | if (!this._input) {
|
488 | this.done = true;
|
489 | }
|
490 | var token, match, tempMatch, index;
|
491 | if (!this._more) {
|
492 | this.yytext = "";
|
493 | this.match = "";
|
494 | }
|
495 | var rules = this._currentRules();
|
496 | for (var i = 0; i < rules.length; i++) {
|
497 | tempMatch = this._input.match(this.rules[rules[i]]);
|
498 | if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
499 | match = tempMatch;
|
500 | index = i;
|
501 | if (this.options.backtrack_lexer) {
|
502 | token = this.test_match(tempMatch, rules[i]);
|
503 | if (token !== false) {
|
504 | return token;
|
505 | } else if (this._backtrack) {
|
506 | match = false;
|
507 | continue;
|
508 | } else {
|
509 | return false;
|
510 | }
|
511 | } else if (!this.options.flex) {
|
512 | break;
|
513 | }
|
514 | }
|
515 | }
|
516 | if (match) {
|
517 | token = this.test_match(match, rules[index]);
|
518 | if (token !== false) {
|
519 | return token;
|
520 | }
|
521 | return false;
|
522 | }
|
523 | if (this._input === "") {
|
524 | return this.EOF;
|
525 | } else {
|
526 | return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
|
527 | text: "",
|
528 | token: null,
|
529 | line: this.yylineno
|
530 | });
|
531 | }
|
532 | },
|
533 |
|
534 | lex: function lex() {
|
535 | var r = this.next();
|
536 | if (r) {
|
537 | return r;
|
538 | } else {
|
539 | return this.lex();
|
540 | }
|
541 | },
|
542 |
|
543 | begin: function begin(condition) {
|
544 | this.conditionStack.push(condition);
|
545 | },
|
546 |
|
547 | popState: function popState() {
|
548 | var n = this.conditionStack.length - 1;
|
549 | if (n > 0) {
|
550 | return this.conditionStack.pop();
|
551 | } else {
|
552 | return this.conditionStack[0];
|
553 | }
|
554 | },
|
555 |
|
556 | _currentRules: function _currentRules() {
|
557 | if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
558 | return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
559 | } else {
|
560 | return this.conditions["INITIAL"].rules;
|
561 | }
|
562 | },
|
563 |
|
564 | topState: function topState(n) {
|
565 | n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
566 | if (n >= 0) {
|
567 | return this.conditionStack[n];
|
568 | } else {
|
569 | return "INITIAL";
|
570 | }
|
571 | },
|
572 |
|
573 | pushState: function pushState(condition) {
|
574 | this.begin(condition);
|
575 | },
|
576 |
|
577 | stateStackSize: function stateStackSize() {
|
578 | return this.conditionStack.length;
|
579 | },
|
580 | options: { "case-insensitive": true },
|
581 | performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
|
582 | switch ($avoiding_name_collisions) {
|
583 | case 0:
|
584 | this.begin("open_directive");
|
585 | return 40;
|
586 | case 1:
|
587 | this.begin("type_directive");
|
588 | return 41;
|
589 | case 2:
|
590 | this.popState();
|
591 | this.begin("arg_directive");
|
592 | return 33;
|
593 | case 3:
|
594 | this.popState();
|
595 | this.popState();
|
596 | return 43;
|
597 | case 4:
|
598 | return 42;
|
599 | case 5:
|
600 | this.begin("acc_title");
|
601 | return 21;
|
602 | case 6:
|
603 | this.popState();
|
604 | return "acc_title_value";
|
605 | case 7:
|
606 | this.begin("acc_descr");
|
607 | return 23;
|
608 | case 8:
|
609 | this.popState();
|
610 | return "acc_descr_value";
|
611 | case 9:
|
612 | this.begin("acc_descr_multiline");
|
613 | break;
|
614 | case 10:
|
615 | this.popState();
|
616 | break;
|
617 | case 11:
|
618 | return "acc_descr_multiline_value";
|
619 | case 12:
|
620 | break;
|
621 | case 13:
|
622 | break;
|
623 | case 14:
|
624 | break;
|
625 | case 15:
|
626 | return 11;
|
627 | case 16:
|
628 | break;
|
629 | case 17:
|
630 | break;
|
631 | case 18:
|
632 | break;
|
633 | case 19:
|
634 | this.begin("href");
|
635 | break;
|
636 | case 20:
|
637 | this.popState();
|
638 | break;
|
639 | case 21:
|
640 | return 38;
|
641 | case 22:
|
642 | this.begin("callbackname");
|
643 | break;
|
644 | case 23:
|
645 | this.popState();
|
646 | break;
|
647 | case 24:
|
648 | this.popState();
|
649 | this.begin("callbackargs");
|
650 | break;
|
651 | case 25:
|
652 | return 36;
|
653 | case 26:
|
654 | this.popState();
|
655 | break;
|
656 | case 27:
|
657 | return 37;
|
658 | case 28:
|
659 | this.begin("click");
|
660 | break;
|
661 | case 29:
|
662 | this.popState();
|
663 | break;
|
664 | case 30:
|
665 | return 35;
|
666 | case 31:
|
667 | return 5;
|
668 | case 32:
|
669 | return 12;
|
670 | case 33:
|
671 | return 13;
|
672 | case 34:
|
673 | return 14;
|
674 | case 35:
|
675 | return 15;
|
676 | case 36:
|
677 | return 16;
|
678 | case 37:
|
679 | return 18;
|
680 | case 38:
|
681 | return 17;
|
682 | case 39:
|
683 | return 19;
|
684 | case 40:
|
685 | return "date";
|
686 | case 41:
|
687 | return 20;
|
688 | case 42:
|
689 | return "accDescription";
|
690 | case 43:
|
691 | return 26;
|
692 | case 44:
|
693 | return 28;
|
694 | case 45:
|
695 | return 29;
|
696 | case 46:
|
697 | return 33;
|
698 | case 47:
|
699 | return 7;
|
700 | case 48:
|
701 | return "INVALID";
|
702 | }
|
703 | },
|
704 | rules: [/^(?:%%\{)/i, /^(?:((?:(?!\}%%)[^:.])*))/i, /^(?::)/i, /^(?:\}%%)/i, /^(?:((?:(?!\}%%).|\n)*))/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:%%(?!\{)*[^\n]*)/i, /^(?:[^\}]%%*[^\n]*)/i, /^(?:%%*[^\n]*[\n]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:href[\s]+["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:call[\s]+)/i, /^(?:\([\s]*\))/i, /^(?:\()/i, /^(?:[^(]*)/i, /^(?:\))/i, /^(?:[^)]*)/i, /^(?:click[\s]+)/i, /^(?:[\s\n])/i, /^(?:[^\s\n]*)/i, /^(?:gantt\b)/i, /^(?:dateFormat\s[^#\n;]+)/i, /^(?:inclusiveEndDates\b)/i, /^(?:topAxis\b)/i, /^(?:axisFormat\s[^#\n;]+)/i, /^(?:tickInterval\s[^#\n;]+)/i, /^(?:includes\s[^#\n;]+)/i, /^(?:excludes\s[^#\n;]+)/i, /^(?:todayMarker\s[^\n;]+)/i, /^(?:\d\d\d\d-\d\d-\d\d\b)/i, /^(?:title\s[^#\n;]+)/i, /^(?:accDescription\s[^#\n;]+)/i, /^(?:section\s[^#:\n;]+)/i, /^(?:[^#:\n;]+)/i, /^(?::[^#\n;]+)/i, /^(?::)/i, /^(?:$)/i, /^(?:.)/i],
|
705 | conditions: { "acc_descr_multiline": { "rules": [10, 11], "inclusive": false }, "acc_descr": { "rules": [8], "inclusive": false }, "acc_title": { "rules": [6], "inclusive": false }, "close_directive": { "rules": [], "inclusive": false }, "arg_directive": { "rules": [3, 4], "inclusive": false }, "type_directive": { "rules": [2, 3], "inclusive": false }, "open_directive": { "rules": [1], "inclusive": false }, "callbackargs": { "rules": [26, 27], "inclusive": false }, "callbackname": { "rules": [23, 24, 25], "inclusive": false }, "href": { "rules": [20, 21], "inclusive": false }, "click": { "rules": [29, 30], "inclusive": false }, "INITIAL": { "rules": [0, 5, 7, 9, 12, 13, 14, 15, 16, 17, 18, 19, 22, 28, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48], "inclusive": true } }
|
706 | };
|
707 | return lexer2;
|
708 | }();
|
709 | parser2.lexer = lexer;
|
710 | function Parser() {
|
711 | this.yy = {};
|
712 | }
|
713 | Parser.prototype = parser2;
|
714 | parser2.Parser = Parser;
|
715 | return new Parser();
|
716 | }();
|
717 | parser.parser = parser;
|
718 | const ganttParser = parser;
|
719 | dayjs.extend(dayjsIsoWeek);
|
720 | dayjs.extend(dayjsCustomParseFormat);
|
721 | dayjs.extend(dayjsAdvancedFormat);
|
722 | let dateFormat = "";
|
723 | let axisFormat = "";
|
724 | let tickInterval = void 0;
|
725 | let todayMarker = "";
|
726 | let includes = [];
|
727 | let excludes = [];
|
728 | let links = {};
|
729 | let sections = [];
|
730 | let tasks = [];
|
731 | let currentSection = "";
|
732 | let displayMode = "";
|
733 | const tags = ["active", "done", "crit", "milestone"];
|
734 | let funs = [];
|
735 | let inclusiveEndDates = false;
|
736 | let topAxis = false;
|
737 | let lastOrder = 0;
|
738 | const parseDirective = function(statement, context, type) {
|
739 | mermaidAPI.parseDirective(this, statement, context, type);
|
740 | };
|
741 | const clear = function() {
|
742 | sections = [];
|
743 | tasks = [];
|
744 | currentSection = "";
|
745 | funs = [];
|
746 | taskCnt = 0;
|
747 | lastTask = void 0;
|
748 | lastTaskID = void 0;
|
749 | rawTasks = [];
|
750 | dateFormat = "";
|
751 | axisFormat = "";
|
752 | displayMode = "";
|
753 | tickInterval = void 0;
|
754 | todayMarker = "";
|
755 | includes = [];
|
756 | excludes = [];
|
757 | inclusiveEndDates = false;
|
758 | topAxis = false;
|
759 | lastOrder = 0;
|
760 | links = {};
|
761 | clear$1();
|
762 | };
|
763 | const setAxisFormat = function(txt) {
|
764 | axisFormat = txt;
|
765 | };
|
766 | const getAxisFormat = function() {
|
767 | return axisFormat;
|
768 | };
|
769 | const setTickInterval = function(txt) {
|
770 | tickInterval = txt;
|
771 | };
|
772 | const getTickInterval = function() {
|
773 | return tickInterval;
|
774 | };
|
775 | const setTodayMarker = function(txt) {
|
776 | todayMarker = txt;
|
777 | };
|
778 | const getTodayMarker = function() {
|
779 | return todayMarker;
|
780 | };
|
781 | const setDateFormat = function(txt) {
|
782 | dateFormat = txt;
|
783 | };
|
784 | const enableInclusiveEndDates = function() {
|
785 | inclusiveEndDates = true;
|
786 | };
|
787 | const endDatesAreInclusive = function() {
|
788 | return inclusiveEndDates;
|
789 | };
|
790 | const enableTopAxis = function() {
|
791 | topAxis = true;
|
792 | };
|
793 | const topAxisEnabled = function() {
|
794 | return topAxis;
|
795 | };
|
796 | const setDisplayMode = function(txt) {
|
797 | displayMode = txt;
|
798 | };
|
799 | const getDisplayMode = function() {
|
800 | return displayMode;
|
801 | };
|
802 | const getDateFormat = function() {
|
803 | return dateFormat;
|
804 | };
|
805 | const setIncludes = function(txt) {
|
806 | includes = txt.toLowerCase().split(/[\s,]+/);
|
807 | };
|
808 | const getIncludes = function() {
|
809 | return includes;
|
810 | };
|
811 | const setExcludes = function(txt) {
|
812 | excludes = txt.toLowerCase().split(/[\s,]+/);
|
813 | };
|
814 | const getExcludes = function() {
|
815 | return excludes;
|
816 | };
|
817 | const getLinks = function() {
|
818 | return links;
|
819 | };
|
820 | const addSection = function(txt) {
|
821 | currentSection = txt;
|
822 | sections.push(txt);
|
823 | };
|
824 | const getSections = function() {
|
825 | return sections;
|
826 | };
|
827 | const getTasks = function() {
|
828 | let allItemsProcessed = compileTasks();
|
829 | const maxDepth = 10;
|
830 | let iterationCount = 0;
|
831 | while (!allItemsProcessed && iterationCount < maxDepth) {
|
832 | allItemsProcessed = compileTasks();
|
833 | iterationCount++;
|
834 | }
|
835 | tasks = rawTasks;
|
836 | return tasks;
|
837 | };
|
838 | const isInvalidDate = function(date, dateFormat2, excludes2, includes2) {
|
839 | if (includes2.includes(date.format(dateFormat2.trim()))) {
|
840 | return false;
|
841 | }
|
842 | if (date.isoWeekday() >= 6 && excludes2.includes("weekends")) {
|
843 | return true;
|
844 | }
|
845 | if (excludes2.includes(date.format("dddd").toLowerCase())) {
|
846 | return true;
|
847 | }
|
848 | return excludes2.includes(date.format(dateFormat2.trim()));
|
849 | };
|
850 | const checkTaskDates = function(task, dateFormat2, excludes2, includes2) {
|
851 | if (!excludes2.length || task.manualEndTime) {
|
852 | return;
|
853 | }
|
854 | let startTime;
|
855 | if (task.startTime instanceof Date) {
|
856 | startTime = dayjs(task.startTime);
|
857 | } else {
|
858 | startTime = dayjs(task.startTime, dateFormat2, true);
|
859 | }
|
860 | startTime = startTime.add(1, "d");
|
861 | let originalEndTime;
|
862 | if (task.endTime instanceof Date) {
|
863 | originalEndTime = dayjs(task.endTime);
|
864 | } else {
|
865 | originalEndTime = dayjs(task.endTime, dateFormat2, true);
|
866 | }
|
867 | const [fixedEndTime, renderEndTime] = fixTaskDates(
|
868 | startTime,
|
869 | originalEndTime,
|
870 | dateFormat2,
|
871 | excludes2,
|
872 | includes2
|
873 | );
|
874 | task.endTime = fixedEndTime.toDate();
|
875 | task.renderEndTime = renderEndTime;
|
876 | };
|
877 | const fixTaskDates = function(startTime, endTime, dateFormat2, excludes2, includes2) {
|
878 | let invalid = false;
|
879 | let renderEndTime = null;
|
880 | while (startTime <= endTime) {
|
881 | if (!invalid) {
|
882 | renderEndTime = endTime.toDate();
|
883 | }
|
884 | invalid = isInvalidDate(startTime, dateFormat2, excludes2, includes2);
|
885 | if (invalid) {
|
886 | endTime = endTime.add(1, "d");
|
887 | }
|
888 | startTime = startTime.add(1, "d");
|
889 | }
|
890 | return [endTime, renderEndTime];
|
891 | };
|
892 | const getStartDate = function(prevTime, dateFormat2, str) {
|
893 | str = str.trim();
|
894 | const re = /^after\s+([\d\w- ]+)/;
|
895 | const afterStatement = re.exec(str.trim());
|
896 | if (afterStatement !== null) {
|
897 | let latestEndingTask = null;
|
898 | afterStatement[1].split(" ").forEach(function(id) {
|
899 | let task = findTaskById(id);
|
900 | if (task !== void 0) {
|
901 | if (!latestEndingTask) {
|
902 | latestEndingTask = task;
|
903 | } else {
|
904 | if (task.endTime > latestEndingTask.endTime) {
|
905 | latestEndingTask = task;
|
906 | }
|
907 | }
|
908 | }
|
909 | });
|
910 | if (!latestEndingTask) {
|
911 | const dt = new Date();
|
912 | dt.setHours(0, 0, 0, 0);
|
913 | return dt;
|
914 | } else {
|
915 | return latestEndingTask.endTime;
|
916 | }
|
917 | }
|
918 | let mDate = dayjs(str, dateFormat2.trim(), true);
|
919 | if (mDate.isValid()) {
|
920 | return mDate.toDate();
|
921 | } else {
|
922 | log.debug("Invalid date:" + str);
|
923 | log.debug("With date format:" + dateFormat2.trim());
|
924 | const d = new Date(str);
|
925 | if (d === void 0 || isNaN(d.getTime()) ||
|
926 |
|
927 |
|
928 |
|
929 |
|
930 | d.getFullYear() < -1e4 || d.getFullYear() > 1e4) {
|
931 | throw new Error("Invalid date:" + str);
|
932 | }
|
933 | return d;
|
934 | }
|
935 | };
|
936 | const parseDuration = function(str) {
|
937 | const statement = /^(\d+(?:\.\d+)?)([Mdhmswy]|ms)$/.exec(str.trim());
|
938 | if (statement !== null) {
|
939 | return [Number.parseFloat(statement[1]), statement[2]];
|
940 | }
|
941 | return [NaN, "ms"];
|
942 | };
|
943 | const getEndDate = function(prevTime, dateFormat2, str, inclusive = false) {
|
944 | str = str.trim();
|
945 | let mDate = dayjs(str, dateFormat2.trim(), true);
|
946 | if (mDate.isValid()) {
|
947 | if (inclusive) {
|
948 | mDate = mDate.add(1, "d");
|
949 | }
|
950 | return mDate.toDate();
|
951 | }
|
952 | let endTime = dayjs(prevTime);
|
953 | const [durationValue, durationUnit] = parseDuration(str);
|
954 | if (!Number.isNaN(durationValue)) {
|
955 | const newEndTime = endTime.add(durationValue, durationUnit);
|
956 | if (newEndTime.isValid()) {
|
957 | endTime = newEndTime;
|
958 | }
|
959 | }
|
960 | return endTime.toDate();
|
961 | };
|
962 | let taskCnt = 0;
|
963 | const parseId = function(idStr) {
|
964 | if (idStr === void 0) {
|
965 | taskCnt = taskCnt + 1;
|
966 | return "task" + taskCnt;
|
967 | }
|
968 | return idStr;
|
969 | };
|
970 | const compileData = function(prevTask, dataStr) {
|
971 | let ds;
|
972 | if (dataStr.substr(0, 1) === ":") {
|
973 | ds = dataStr.substr(1, dataStr.length);
|
974 | } else {
|
975 | ds = dataStr;
|
976 | }
|
977 | const data = ds.split(",");
|
978 | const task = {};
|
979 | getTaskTags(data, task, tags);
|
980 | for (let i = 0; i < data.length; i++) {
|
981 | data[i] = data[i].trim();
|
982 | }
|
983 | let endTimeData = "";
|
984 | switch (data.length) {
|
985 | case 1:
|
986 | task.id = parseId();
|
987 | task.startTime = prevTask.endTime;
|
988 | endTimeData = data[0];
|
989 | break;
|
990 | case 2:
|
991 | task.id = parseId();
|
992 | task.startTime = getStartDate(void 0, dateFormat, data[0]);
|
993 | endTimeData = data[1];
|
994 | break;
|
995 | case 3:
|
996 | task.id = parseId(data[0]);
|
997 | task.startTime = getStartDate(void 0, dateFormat, data[1]);
|
998 | endTimeData = data[2];
|
999 | break;
|
1000 | }
|
1001 | if (endTimeData) {
|
1002 | task.endTime = getEndDate(task.startTime, dateFormat, endTimeData, inclusiveEndDates);
|
1003 | task.manualEndTime = dayjs(endTimeData, "YYYY-MM-DD", true).isValid();
|
1004 | checkTaskDates(task, dateFormat, excludes, includes);
|
1005 | }
|
1006 | return task;
|
1007 | };
|
1008 | const parseData = function(prevTaskId, dataStr) {
|
1009 | let ds;
|
1010 | if (dataStr.substr(0, 1) === ":") {
|
1011 | ds = dataStr.substr(1, dataStr.length);
|
1012 | } else {
|
1013 | ds = dataStr;
|
1014 | }
|
1015 | const data = ds.split(",");
|
1016 | const task = {};
|
1017 | getTaskTags(data, task, tags);
|
1018 | for (let i = 0; i < data.length; i++) {
|
1019 | data[i] = data[i].trim();
|
1020 | }
|
1021 | switch (data.length) {
|
1022 | case 1:
|
1023 | task.id = parseId();
|
1024 | task.startTime = {
|
1025 | type: "prevTaskEnd",
|
1026 | id: prevTaskId
|
1027 | };
|
1028 | task.endTime = {
|
1029 | data: data[0]
|
1030 | };
|
1031 | break;
|
1032 | case 2:
|
1033 | task.id = parseId();
|
1034 | task.startTime = {
|
1035 | type: "getStartDate",
|
1036 | startData: data[0]
|
1037 | };
|
1038 | task.endTime = {
|
1039 | data: data[1]
|
1040 | };
|
1041 | break;
|
1042 | case 3:
|
1043 | task.id = parseId(data[0]);
|
1044 | task.startTime = {
|
1045 | type: "getStartDate",
|
1046 | startData: data[1]
|
1047 | };
|
1048 | task.endTime = {
|
1049 | data: data[2]
|
1050 | };
|
1051 | break;
|
1052 | }
|
1053 | return task;
|
1054 | };
|
1055 | let lastTask;
|
1056 | let lastTaskID;
|
1057 | let rawTasks = [];
|
1058 | const taskDb = {};
|
1059 | const addTask = function(descr, data) {
|
1060 | const rawTask = {
|
1061 | section: currentSection,
|
1062 | type: currentSection,
|
1063 | processed: false,
|
1064 | manualEndTime: false,
|
1065 | renderEndTime: null,
|
1066 | raw: { data },
|
1067 | task: descr,
|
1068 | classes: []
|
1069 | };
|
1070 | const taskInfo = parseData(lastTaskID, data);
|
1071 | rawTask.raw.startTime = taskInfo.startTime;
|
1072 | rawTask.raw.endTime = taskInfo.endTime;
|
1073 | rawTask.id = taskInfo.id;
|
1074 | rawTask.prevTaskId = lastTaskID;
|
1075 | rawTask.active = taskInfo.active;
|
1076 | rawTask.done = taskInfo.done;
|
1077 | rawTask.crit = taskInfo.crit;
|
1078 | rawTask.milestone = taskInfo.milestone;
|
1079 | rawTask.order = lastOrder;
|
1080 | lastOrder++;
|
1081 | const pos = rawTasks.push(rawTask);
|
1082 | lastTaskID = rawTask.id;
|
1083 | taskDb[rawTask.id] = pos - 1;
|
1084 | };
|
1085 | const findTaskById = function(id) {
|
1086 | const pos = taskDb[id];
|
1087 | return rawTasks[pos];
|
1088 | };
|
1089 | const addTaskOrg = function(descr, data) {
|
1090 | const newTask = {
|
1091 | section: currentSection,
|
1092 | type: currentSection,
|
1093 | description: descr,
|
1094 | task: descr,
|
1095 | classes: []
|
1096 | };
|
1097 | const taskInfo = compileData(lastTask, data);
|
1098 | newTask.startTime = taskInfo.startTime;
|
1099 | newTask.endTime = taskInfo.endTime;
|
1100 | newTask.id = taskInfo.id;
|
1101 | newTask.active = taskInfo.active;
|
1102 | newTask.done = taskInfo.done;
|
1103 | newTask.crit = taskInfo.crit;
|
1104 | newTask.milestone = taskInfo.milestone;
|
1105 | lastTask = newTask;
|
1106 | tasks.push(newTask);
|
1107 | };
|
1108 | const compileTasks = function() {
|
1109 | const compileTask = function(pos) {
|
1110 | const task = rawTasks[pos];
|
1111 | let startTime = "";
|
1112 | switch (rawTasks[pos].raw.startTime.type) {
|
1113 | case "prevTaskEnd": {
|
1114 | const prevTask = findTaskById(task.prevTaskId);
|
1115 | task.startTime = prevTask.endTime;
|
1116 | break;
|
1117 | }
|
1118 | case "getStartDate":
|
1119 | startTime = getStartDate(void 0, dateFormat, rawTasks[pos].raw.startTime.startData);
|
1120 | if (startTime) {
|
1121 | rawTasks[pos].startTime = startTime;
|
1122 | }
|
1123 | break;
|
1124 | }
|
1125 | if (rawTasks[pos].startTime) {
|
1126 | rawTasks[pos].endTime = getEndDate(
|
1127 | rawTasks[pos].startTime,
|
1128 | dateFormat,
|
1129 | rawTasks[pos].raw.endTime.data,
|
1130 | inclusiveEndDates
|
1131 | );
|
1132 | if (rawTasks[pos].endTime) {
|
1133 | rawTasks[pos].processed = true;
|
1134 | rawTasks[pos].manualEndTime = dayjs(
|
1135 | rawTasks[pos].raw.endTime.data,
|
1136 | "YYYY-MM-DD",
|
1137 | true
|
1138 | ).isValid();
|
1139 | checkTaskDates(rawTasks[pos], dateFormat, excludes, includes);
|
1140 | }
|
1141 | }
|
1142 | return rawTasks[pos].processed;
|
1143 | };
|
1144 | let allProcessed = true;
|
1145 | for (const [i, rawTask] of rawTasks.entries()) {
|
1146 | compileTask(i);
|
1147 | allProcessed = allProcessed && rawTask.processed;
|
1148 | }
|
1149 | return allProcessed;
|
1150 | };
|
1151 | const setLink = function(ids, _linkStr) {
|
1152 | let linkStr = _linkStr;
|
1153 | if (getConfig().securityLevel !== "loose") {
|
1154 | linkStr = sanitizeUrl(_linkStr);
|
1155 | }
|
1156 | ids.split(",").forEach(function(id) {
|
1157 | let rawTask = findTaskById(id);
|
1158 | if (rawTask !== void 0) {
|
1159 | pushFun(id, () => {
|
1160 | window.open(linkStr, "_self");
|
1161 | });
|
1162 | links[id] = linkStr;
|
1163 | }
|
1164 | });
|
1165 | setClass(ids, "clickable");
|
1166 | };
|
1167 | const setClass = function(ids, className) {
|
1168 | ids.split(",").forEach(function(id) {
|
1169 | let rawTask = findTaskById(id);
|
1170 | if (rawTask !== void 0) {
|
1171 | rawTask.classes.push(className);
|
1172 | }
|
1173 | });
|
1174 | };
|
1175 | const setClickFun = function(id, functionName, functionArgs) {
|
1176 | if (getConfig().securityLevel !== "loose") {
|
1177 | return;
|
1178 | }
|
1179 | if (functionName === void 0) {
|
1180 | return;
|
1181 | }
|
1182 | let argList = [];
|
1183 | if (typeof functionArgs === "string") {
|
1184 | argList = functionArgs.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/);
|
1185 | for (let i = 0; i < argList.length; i++) {
|
1186 | let item = argList[i].trim();
|
1187 | if (item.charAt(0) === '"' && item.charAt(item.length - 1) === '"') {
|
1188 | item = item.substr(1, item.length - 2);
|
1189 | }
|
1190 | argList[i] = item;
|
1191 | }
|
1192 | }
|
1193 | if (argList.length === 0) {
|
1194 | argList.push(id);
|
1195 | }
|
1196 | let rawTask = findTaskById(id);
|
1197 | if (rawTask !== void 0) {
|
1198 | pushFun(id, () => {
|
1199 | utils.runFunc(functionName, ...argList);
|
1200 | });
|
1201 | }
|
1202 | };
|
1203 | const pushFun = function(id, callbackFunction) {
|
1204 | funs.push(
|
1205 | function() {
|
1206 | const elem = document.querySelector(`[id="${id}"]`);
|
1207 | if (elem !== null) {
|
1208 | elem.addEventListener("click", function() {
|
1209 | callbackFunction();
|
1210 | });
|
1211 | }
|
1212 | },
|
1213 | function() {
|
1214 | const elem = document.querySelector(`[id="${id}-text"]`);
|
1215 | if (elem !== null) {
|
1216 | elem.addEventListener("click", function() {
|
1217 | callbackFunction();
|
1218 | });
|
1219 | }
|
1220 | }
|
1221 | );
|
1222 | };
|
1223 | const setClickEvent = function(ids, functionName, functionArgs) {
|
1224 | ids.split(",").forEach(function(id) {
|
1225 | setClickFun(id, functionName, functionArgs);
|
1226 | });
|
1227 | setClass(ids, "clickable");
|
1228 | };
|
1229 | const bindFunctions = function(element) {
|
1230 | funs.forEach(function(fun) {
|
1231 | fun(element);
|
1232 | });
|
1233 | };
|
1234 | const ganttDb = {
|
1235 | parseDirective,
|
1236 | getConfig: () => getConfig().gantt,
|
1237 | clear,
|
1238 | setDateFormat,
|
1239 | getDateFormat,
|
1240 | enableInclusiveEndDates,
|
1241 | endDatesAreInclusive,
|
1242 | enableTopAxis,
|
1243 | topAxisEnabled,
|
1244 | setAxisFormat,
|
1245 | getAxisFormat,
|
1246 | setTickInterval,
|
1247 | getTickInterval,
|
1248 | setTodayMarker,
|
1249 | getTodayMarker,
|
1250 | setAccTitle,
|
1251 | getAccTitle,
|
1252 | setDiagramTitle,
|
1253 | getDiagramTitle,
|
1254 | setDisplayMode,
|
1255 | getDisplayMode,
|
1256 | setAccDescription,
|
1257 | getAccDescription,
|
1258 | addSection,
|
1259 | getSections,
|
1260 | getTasks,
|
1261 | addTask,
|
1262 | findTaskById,
|
1263 | addTaskOrg,
|
1264 | setIncludes,
|
1265 | getIncludes,
|
1266 | setExcludes,
|
1267 | getExcludes,
|
1268 | setClickEvent,
|
1269 | setLink,
|
1270 | getLinks,
|
1271 | bindFunctions,
|
1272 | parseDuration,
|
1273 | isInvalidDate
|
1274 | };
|
1275 | function getTaskTags(data, task, tags2) {
|
1276 | let matchFound = true;
|
1277 | while (matchFound) {
|
1278 | matchFound = false;
|
1279 | tags2.forEach(function(t) {
|
1280 | const pattern = "^\\s*" + t + "\\s*$";
|
1281 | const regex = new RegExp(pattern);
|
1282 | if (data[0].match(regex)) {
|
1283 | task[t] = true;
|
1284 | data.shift(1);
|
1285 | matchFound = true;
|
1286 | }
|
1287 | });
|
1288 | }
|
1289 | }
|
1290 | const setConf = function() {
|
1291 | log.debug("Something is calling, setConf, remove the call");
|
1292 | };
|
1293 | const getMaxIntersections = (tasks2, orderOffset) => {
|
1294 | let timeline = [...tasks2].map(() => -Infinity);
|
1295 | let sorted = [...tasks2].sort((a, b) => a.startTime - b.startTime || a.order - b.order);
|
1296 | let maxIntersections = 0;
|
1297 | for (const element of sorted) {
|
1298 | for (let j = 0; j < timeline.length; j++) {
|
1299 | if (element.startTime >= timeline[j]) {
|
1300 | timeline[j] = element.endTime;
|
1301 | element.order = j + orderOffset;
|
1302 | if (j > maxIntersections) {
|
1303 | maxIntersections = j;
|
1304 | }
|
1305 | break;
|
1306 | }
|
1307 | }
|
1308 | }
|
1309 | return maxIntersections;
|
1310 | };
|
1311 | let w;
|
1312 | const draw = function(text, id, version, diagObj) {
|
1313 | const conf = getConfig().gantt;
|
1314 | const securityLevel = getConfig().securityLevel;
|
1315 | let sandboxElement;
|
1316 | if (securityLevel === "sandbox") {
|
1317 | sandboxElement = select("#i" + id);
|
1318 | }
|
1319 | const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
|
1320 | const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document;
|
1321 | const elem = doc.getElementById(id);
|
1322 | w = elem.parentElement.offsetWidth;
|
1323 | if (w === void 0) {
|
1324 | w = 1200;
|
1325 | }
|
1326 | if (conf.useWidth !== void 0) {
|
1327 | w = conf.useWidth;
|
1328 | }
|
1329 | const taskArray = diagObj.db.getTasks();
|
1330 | let categories = [];
|
1331 | for (const element of taskArray) {
|
1332 | categories.push(element.type);
|
1333 | }
|
1334 | categories = checkUnique(categories);
|
1335 | const categoryHeights = {};
|
1336 | let h = 2 * conf.topPadding;
|
1337 | if (diagObj.db.getDisplayMode() === "compact" || conf.displayMode === "compact") {
|
1338 | const categoryElements = {};
|
1339 | for (const element of taskArray) {
|
1340 | if (categoryElements[element.section] === void 0) {
|
1341 | categoryElements[element.section] = [element];
|
1342 | } else {
|
1343 | categoryElements[element.section].push(element);
|
1344 | }
|
1345 | }
|
1346 | let intersections = 0;
|
1347 | for (const category of Object.keys(categoryElements)) {
|
1348 | const categoryHeight = getMaxIntersections(categoryElements[category], intersections) + 1;
|
1349 | intersections += categoryHeight;
|
1350 | h += categoryHeight * (conf.barHeight + conf.barGap);
|
1351 | categoryHeights[category] = categoryHeight;
|
1352 | }
|
1353 | } else {
|
1354 | h += taskArray.length * (conf.barHeight + conf.barGap);
|
1355 | for (const category of categories) {
|
1356 | categoryHeights[category] = taskArray.filter((task) => task.type === category).length;
|
1357 | }
|
1358 | }
|
1359 | elem.setAttribute("viewBox", "0 0 " + w + " " + h);
|
1360 | const svg = root.select(`[id="${id}"]`);
|
1361 | const timeScale = scaleTime().domain([
|
1362 | min(taskArray, function(d) {
|
1363 | return d.startTime;
|
1364 | }),
|
1365 | max(taskArray, function(d) {
|
1366 | return d.endTime;
|
1367 | })
|
1368 | ]).rangeRound([0, w - conf.leftPadding - conf.rightPadding]);
|
1369 | function taskCompare(a, b) {
|
1370 | const taskA = a.startTime;
|
1371 | const taskB = b.startTime;
|
1372 | let result = 0;
|
1373 | if (taskA > taskB) {
|
1374 | result = 1;
|
1375 | } else if (taskA < taskB) {
|
1376 | result = -1;
|
1377 | }
|
1378 | return result;
|
1379 | }
|
1380 | taskArray.sort(taskCompare);
|
1381 | makeGant(taskArray, w, h);
|
1382 | configureSvgSize(svg, h, w, conf.useMaxWidth);
|
1383 | svg.append("text").text(diagObj.db.getDiagramTitle()).attr("x", w / 2).attr("y", conf.titleTopMargin).attr("class", "titleText");
|
1384 | function makeGant(tasks2, pageWidth, pageHeight) {
|
1385 | const barHeight = conf.barHeight;
|
1386 | const gap = barHeight + conf.barGap;
|
1387 | const topPadding = conf.topPadding;
|
1388 | const leftPadding = conf.leftPadding;
|
1389 | const colorScale = scaleLinear().domain([0, categories.length]).range(["#00B9FA", "#F95002"]).interpolate(interpolateHcl);
|
1390 | drawExcludeDays(
|
1391 | gap,
|
1392 | topPadding,
|
1393 | leftPadding,
|
1394 | pageWidth,
|
1395 | pageHeight,
|
1396 | tasks2,
|
1397 | diagObj.db.getExcludes(),
|
1398 | diagObj.db.getIncludes()
|
1399 | );
|
1400 | makeGrid(leftPadding, topPadding, pageWidth, pageHeight);
|
1401 | drawRects(tasks2, gap, topPadding, leftPadding, barHeight, colorScale, pageWidth);
|
1402 | vertLabels(gap, topPadding);
|
1403 | drawToday(leftPadding, topPadding, pageWidth, pageHeight);
|
1404 | }
|
1405 | function drawRects(theArray, theGap, theTopPad, theSidePad, theBarHeight, theColorScale, w2) {
|
1406 | const uniqueTaskOrderIds = [...new Set(theArray.map((item) => item.order))];
|
1407 | const uniqueTasks = uniqueTaskOrderIds.map((id2) => theArray.find((item) => item.order === id2));
|
1408 | svg.append("g").selectAll("rect").data(uniqueTasks).enter().append("rect").attr("x", 0).attr("y", function(d, i) {
|
1409 | i = d.order;
|
1410 | return i * theGap + theTopPad - 2;
|
1411 | }).attr("width", function() {
|
1412 | return w2 - conf.rightPadding / 2;
|
1413 | }).attr("height", theGap).attr("class", function(d) {
|
1414 | for (const [i, category] of categories.entries()) {
|
1415 | if (d.type === category) {
|
1416 | return "section section" + i % conf.numberSectionStyles;
|
1417 | }
|
1418 | }
|
1419 | return "section section0";
|
1420 | });
|
1421 | const rectangles = svg.append("g").selectAll("rect").data(theArray).enter();
|
1422 | const links2 = diagObj.db.getLinks();
|
1423 | rectangles.append("rect").attr("id", function(d) {
|
1424 | return d.id;
|
1425 | }).attr("rx", 3).attr("ry", 3).attr("x", function(d) {
|
1426 | if (d.milestone) {
|
1427 | return timeScale(d.startTime) + theSidePad + 0.5 * (timeScale(d.endTime) - timeScale(d.startTime)) - 0.5 * theBarHeight;
|
1428 | }
|
1429 | return timeScale(d.startTime) + theSidePad;
|
1430 | }).attr("y", function(d, i) {
|
1431 | i = d.order;
|
1432 | return i * theGap + theTopPad;
|
1433 | }).attr("width", function(d) {
|
1434 | if (d.milestone) {
|
1435 | return theBarHeight;
|
1436 | }
|
1437 | return timeScale(d.renderEndTime || d.endTime) - timeScale(d.startTime);
|
1438 | }).attr("height", theBarHeight).attr("transform-origin", function(d, i) {
|
1439 | i = d.order;
|
1440 | return (timeScale(d.startTime) + theSidePad + 0.5 * (timeScale(d.endTime) - timeScale(d.startTime))).toString() + "px " + (i * theGap + theTopPad + 0.5 * theBarHeight).toString() + "px";
|
1441 | }).attr("class", function(d) {
|
1442 | const res = "task";
|
1443 | let classStr = "";
|
1444 | if (d.classes.length > 0) {
|
1445 | classStr = d.classes.join(" ");
|
1446 | }
|
1447 | let secNum = 0;
|
1448 | for (const [i, category] of categories.entries()) {
|
1449 | if (d.type === category) {
|
1450 | secNum = i % conf.numberSectionStyles;
|
1451 | }
|
1452 | }
|
1453 | let taskClass = "";
|
1454 | if (d.active) {
|
1455 | if (d.crit) {
|
1456 | taskClass += " activeCrit";
|
1457 | } else {
|
1458 | taskClass = " active";
|
1459 | }
|
1460 | } else if (d.done) {
|
1461 | if (d.crit) {
|
1462 | taskClass = " doneCrit";
|
1463 | } else {
|
1464 | taskClass = " done";
|
1465 | }
|
1466 | } else {
|
1467 | if (d.crit) {
|
1468 | taskClass += " crit";
|
1469 | }
|
1470 | }
|
1471 | if (taskClass.length === 0) {
|
1472 | taskClass = " task";
|
1473 | }
|
1474 | if (d.milestone) {
|
1475 | taskClass = " milestone " + taskClass;
|
1476 | }
|
1477 | taskClass += secNum;
|
1478 | taskClass += " " + classStr;
|
1479 | return res + taskClass;
|
1480 | });
|
1481 | rectangles.append("text").attr("id", function(d) {
|
1482 | return d.id + "-text";
|
1483 | }).text(function(d) {
|
1484 | return d.task;
|
1485 | }).attr("font-size", conf.fontSize).attr("x", function(d) {
|
1486 | let startX = timeScale(d.startTime);
|
1487 | let endX = timeScale(d.renderEndTime || d.endTime);
|
1488 | if (d.milestone) {
|
1489 | startX += 0.5 * (timeScale(d.endTime) - timeScale(d.startTime)) - 0.5 * theBarHeight;
|
1490 | }
|
1491 | if (d.milestone) {
|
1492 | endX = startX + theBarHeight;
|
1493 | }
|
1494 | const textWidth = this.getBBox().width;
|
1495 | if (textWidth > endX - startX) {
|
1496 | if (endX + textWidth + 1.5 * conf.leftPadding > w2) {
|
1497 | return startX + theSidePad - 5;
|
1498 | } else {
|
1499 | return endX + theSidePad + 5;
|
1500 | }
|
1501 | } else {
|
1502 | return (endX - startX) / 2 + startX + theSidePad;
|
1503 | }
|
1504 | }).attr("y", function(d, i) {
|
1505 | i = d.order;
|
1506 | return i * theGap + conf.barHeight / 2 + (conf.fontSize / 2 - 2) + theTopPad;
|
1507 | }).attr("text-height", theBarHeight).attr("class", function(d) {
|
1508 | const startX = timeScale(d.startTime);
|
1509 | let endX = timeScale(d.endTime);
|
1510 | if (d.milestone) {
|
1511 | endX = startX + theBarHeight;
|
1512 | }
|
1513 | const textWidth = this.getBBox().width;
|
1514 | let classStr = "";
|
1515 | if (d.classes.length > 0) {
|
1516 | classStr = d.classes.join(" ");
|
1517 | }
|
1518 | let secNum = 0;
|
1519 | for (const [i, category] of categories.entries()) {
|
1520 | if (d.type === category) {
|
1521 | secNum = i % conf.numberSectionStyles;
|
1522 | }
|
1523 | }
|
1524 | let taskType = "";
|
1525 | if (d.active) {
|
1526 | if (d.crit) {
|
1527 | taskType = "activeCritText" + secNum;
|
1528 | } else {
|
1529 | taskType = "activeText" + secNum;
|
1530 | }
|
1531 | }
|
1532 | if (d.done) {
|
1533 | if (d.crit) {
|
1534 | taskType = taskType + " doneCritText" + secNum;
|
1535 | } else {
|
1536 | taskType = taskType + " doneText" + secNum;
|
1537 | }
|
1538 | } else {
|
1539 | if (d.crit) {
|
1540 | taskType = taskType + " critText" + secNum;
|
1541 | }
|
1542 | }
|
1543 | if (d.milestone) {
|
1544 | taskType += " milestoneText";
|
1545 | }
|
1546 | if (textWidth > endX - startX) {
|
1547 | if (endX + textWidth + 1.5 * conf.leftPadding > w2) {
|
1548 | return classStr + " taskTextOutsideLeft taskTextOutside" + secNum + " " + taskType;
|
1549 | } else {
|
1550 | return classStr + " taskTextOutsideRight taskTextOutside" + secNum + " " + taskType + " width-" + textWidth;
|
1551 | }
|
1552 | } else {
|
1553 | return classStr + " taskText taskText" + secNum + " " + taskType + " width-" + textWidth;
|
1554 | }
|
1555 | });
|
1556 | const securityLevel2 = getConfig().securityLevel;
|
1557 | if (securityLevel2 === "sandbox") {
|
1558 | let sandboxElement2;
|
1559 | sandboxElement2 = select("#i" + id);
|
1560 | const doc2 = sandboxElement2.nodes()[0].contentDocument;
|
1561 | rectangles.filter(function(d) {
|
1562 | return links2[d.id] !== void 0;
|
1563 | }).each(function(o) {
|
1564 | var taskRect = doc2.querySelector("#" + o.id);
|
1565 | var taskText = doc2.querySelector("#" + o.id + "-text");
|
1566 | const oldParent = taskRect.parentNode;
|
1567 | var Link = doc2.createElement("a");
|
1568 | Link.setAttribute("xlink:href", links2[o.id]);
|
1569 | Link.setAttribute("target", "_top");
|
1570 | oldParent.appendChild(Link);
|
1571 | Link.appendChild(taskRect);
|
1572 | Link.appendChild(taskText);
|
1573 | });
|
1574 | }
|
1575 | }
|
1576 | function drawExcludeDays(theGap, theTopPad, theSidePad, w2, h2, tasks2, excludes2, includes2) {
|
1577 | const minTime = tasks2.reduce(
|
1578 | (min2, { startTime }) => min2 ? Math.min(min2, startTime) : startTime,
|
1579 | 0
|
1580 | );
|
1581 | const maxTime = tasks2.reduce((max2, { endTime }) => max2 ? Math.max(max2, endTime) : endTime, 0);
|
1582 | const dateFormat2 = diagObj.db.getDateFormat();
|
1583 | if (!minTime || !maxTime) {
|
1584 | return;
|
1585 | }
|
1586 | const excludeRanges = [];
|
1587 | let range = null;
|
1588 | let d = dayjs(minTime);
|
1589 | while (d.valueOf() <= maxTime) {
|
1590 | if (diagObj.db.isInvalidDate(d, dateFormat2, excludes2, includes2)) {
|
1591 | if (!range) {
|
1592 | range = {
|
1593 | start: d,
|
1594 | end: d
|
1595 | };
|
1596 | } else {
|
1597 | range.end = d;
|
1598 | }
|
1599 | } else {
|
1600 | if (range) {
|
1601 | excludeRanges.push(range);
|
1602 | range = null;
|
1603 | }
|
1604 | }
|
1605 | d = d.add(1, "d");
|
1606 | }
|
1607 | const rectangles = svg.append("g").selectAll("rect").data(excludeRanges).enter();
|
1608 | rectangles.append("rect").attr("id", function(d2) {
|
1609 | return "exclude-" + d2.start.format("YYYY-MM-DD");
|
1610 | }).attr("x", function(d2) {
|
1611 | return timeScale(d2.start) + theSidePad;
|
1612 | }).attr("y", conf.gridLineStartPadding).attr("width", function(d2) {
|
1613 | const renderEnd = d2.end.add(1, "day");
|
1614 | return timeScale(renderEnd) - timeScale(d2.start);
|
1615 | }).attr("height", h2 - theTopPad - conf.gridLineStartPadding).attr("transform-origin", function(d2, i) {
|
1616 | return (timeScale(d2.start) + theSidePad + 0.5 * (timeScale(d2.end) - timeScale(d2.start))).toString() + "px " + (i * theGap + 0.5 * h2).toString() + "px";
|
1617 | }).attr("class", "exclude-range");
|
1618 | }
|
1619 | function makeGrid(theSidePad, theTopPad, w2, h2) {
|
1620 | let bottomXAxis = axisBottom(timeScale).tickSize(-h2 + theTopPad + conf.gridLineStartPadding).tickFormat(timeFormat(diagObj.db.getAxisFormat() || conf.axisFormat || "%Y-%m-%d"));
|
1621 | const reTickInterval = /^([1-9]\d*)(minute|hour|day|week|month)$/;
|
1622 | const resultTickInterval = reTickInterval.exec(
|
1623 | diagObj.db.getTickInterval() || conf.tickInterval
|
1624 | );
|
1625 | if (resultTickInterval !== null) {
|
1626 | const every = resultTickInterval[1];
|
1627 | const interval = resultTickInterval[2];
|
1628 | switch (interval) {
|
1629 | case "minute":
|
1630 | bottomXAxis.ticks(timeMinute.every(every));
|
1631 | break;
|
1632 | case "hour":
|
1633 | bottomXAxis.ticks(timeHour.every(every));
|
1634 | break;
|
1635 | case "day":
|
1636 | bottomXAxis.ticks(timeDay.every(every));
|
1637 | break;
|
1638 | case "week":
|
1639 | bottomXAxis.ticks(timeWeek.every(every));
|
1640 | break;
|
1641 | case "month":
|
1642 | bottomXAxis.ticks(timeMonth.every(every));
|
1643 | break;
|
1644 | }
|
1645 | }
|
1646 | svg.append("g").attr("class", "grid").attr("transform", "translate(" + theSidePad + ", " + (h2 - 50) + ")").call(bottomXAxis).selectAll("text").style("text-anchor", "middle").attr("fill", "#000").attr("stroke", "none").attr("font-size", 10).attr("dy", "1em");
|
1647 | if (diagObj.db.topAxisEnabled() || conf.topAxis) {
|
1648 | let topXAxis = axisTop(timeScale).tickSize(-h2 + theTopPad + conf.gridLineStartPadding).tickFormat(timeFormat(diagObj.db.getAxisFormat() || conf.axisFormat || "%Y-%m-%d"));
|
1649 | if (resultTickInterval !== null) {
|
1650 | const every = resultTickInterval[1];
|
1651 | const interval = resultTickInterval[2];
|
1652 | switch (interval) {
|
1653 | case "minute":
|
1654 | topXAxis.ticks(timeMinute.every(every));
|
1655 | break;
|
1656 | case "hour":
|
1657 | topXAxis.ticks(timeHour.every(every));
|
1658 | break;
|
1659 | case "day":
|
1660 | topXAxis.ticks(timeDay.every(every));
|
1661 | break;
|
1662 | case "week":
|
1663 | topXAxis.ticks(timeWeek.every(every));
|
1664 | break;
|
1665 | case "month":
|
1666 | topXAxis.ticks(timeMonth.every(every));
|
1667 | break;
|
1668 | }
|
1669 | }
|
1670 | svg.append("g").attr("class", "grid").attr("transform", "translate(" + theSidePad + ", " + theTopPad + ")").call(topXAxis).selectAll("text").style("text-anchor", "middle").attr("fill", "#000").attr("stroke", "none").attr("font-size", 10);
|
1671 | }
|
1672 | }
|
1673 | function vertLabels(theGap, theTopPad) {
|
1674 | let prevGap = 0;
|
1675 | const numOccurances = Object.keys(categoryHeights).map((d) => [d, categoryHeights[d]]);
|
1676 | svg.append("g").selectAll("text").data(numOccurances).enter().append(function(d) {
|
1677 | const rows = d[0].split(common.lineBreakRegex);
|
1678 | const dy = -(rows.length - 1) / 2;
|
1679 | const svgLabel = doc.createElementNS("http://www.w3.org/2000/svg", "text");
|
1680 | svgLabel.setAttribute("dy", dy + "em");
|
1681 | for (const [j, row] of rows.entries()) {
|
1682 | const tspan = doc.createElementNS("http://www.w3.org/2000/svg", "tspan");
|
1683 | tspan.setAttribute("alignment-baseline", "central");
|
1684 | tspan.setAttribute("x", "10");
|
1685 | if (j > 0) {
|
1686 | tspan.setAttribute("dy", "1em");
|
1687 | }
|
1688 | tspan.textContent = row;
|
1689 | svgLabel.appendChild(tspan);
|
1690 | }
|
1691 | return svgLabel;
|
1692 | }).attr("x", 10).attr("y", function(d, i) {
|
1693 | if (i > 0) {
|
1694 | for (let j = 0; j < i; j++) {
|
1695 | prevGap += numOccurances[i - 1][1];
|
1696 | return d[1] * theGap / 2 + prevGap * theGap + theTopPad;
|
1697 | }
|
1698 | } else {
|
1699 | return d[1] * theGap / 2 + theTopPad;
|
1700 | }
|
1701 | }).attr("font-size", conf.sectionFontSize).attr("class", function(d) {
|
1702 | for (const [i, category] of categories.entries()) {
|
1703 | if (d[0] === category) {
|
1704 | return "sectionTitle sectionTitle" + i % conf.numberSectionStyles;
|
1705 | }
|
1706 | }
|
1707 | return "sectionTitle";
|
1708 | });
|
1709 | }
|
1710 | function drawToday(theSidePad, theTopPad, w2, h2) {
|
1711 | const todayMarker2 = diagObj.db.getTodayMarker();
|
1712 | if (todayMarker2 === "off") {
|
1713 | return;
|
1714 | }
|
1715 | const todayG = svg.append("g").attr("class", "today");
|
1716 | const today = new Date();
|
1717 | const todayLine = todayG.append("line");
|
1718 | todayLine.attr("x1", timeScale(today) + theSidePad).attr("x2", timeScale(today) + theSidePad).attr("y1", conf.titleTopMargin).attr("y2", h2 - conf.titleTopMargin).attr("class", "today");
|
1719 | if (todayMarker2 !== "") {
|
1720 | todayLine.attr("style", todayMarker2.replace(/,/g, ";"));
|
1721 | }
|
1722 | }
|
1723 | function checkUnique(arr) {
|
1724 | const hash = {};
|
1725 | const result = [];
|
1726 | for (let i = 0, l = arr.length; i < l; ++i) {
|
1727 | if (!Object.prototype.hasOwnProperty.call(hash, arr[i])) {
|
1728 | hash[arr[i]] = true;
|
1729 | result.push(arr[i]);
|
1730 | }
|
1731 | }
|
1732 | return result;
|
1733 | }
|
1734 | };
|
1735 | const ganttRenderer = {
|
1736 | setConf,
|
1737 | draw
|
1738 | };
|
1739 | const getStyles = (options) => `
|
1740 | .mermaid-main-font {
|
1741 | font-family: "trebuchet ms", verdana, arial, sans-serif;
|
1742 | font-family: var(--mermaid-font-family);
|
1743 | }
|
1744 | .exclude-range {
|
1745 | fill: ${options.excludeBkgColor};
|
1746 | }
|
1747 |
|
1748 | .section {
|
1749 | stroke: none;
|
1750 | opacity: 0.2;
|
1751 | }
|
1752 |
|
1753 | .section0 {
|
1754 | fill: ${options.sectionBkgColor};
|
1755 | }
|
1756 |
|
1757 | .section2 {
|
1758 | fill: ${options.sectionBkgColor2};
|
1759 | }
|
1760 |
|
1761 | .section1,
|
1762 | .section3 {
|
1763 | fill: ${options.altSectionBkgColor};
|
1764 | opacity: 0.2;
|
1765 | }
|
1766 |
|
1767 | .sectionTitle0 {
|
1768 | fill: ${options.titleColor};
|
1769 | }
|
1770 |
|
1771 | .sectionTitle1 {
|
1772 | fill: ${options.titleColor};
|
1773 | }
|
1774 |
|
1775 | .sectionTitle2 {
|
1776 | fill: ${options.titleColor};
|
1777 | }
|
1778 |
|
1779 | .sectionTitle3 {
|
1780 | fill: ${options.titleColor};
|
1781 | }
|
1782 |
|
1783 | .sectionTitle {
|
1784 | text-anchor: start;
|
1785 | // font-size: ${options.ganttFontSize};
|
1786 | // text-height: 14px;
|
1787 | font-family: 'trebuchet ms', verdana, arial, sans-serif;
|
1788 | font-family: var(--mermaid-font-family);
|
1789 |
|
1790 | }
|
1791 |
|
1792 |
|
1793 | /* Grid and axis */
|
1794 |
|
1795 | .grid .tick {
|
1796 | stroke: ${options.gridColor};
|
1797 | opacity: 0.8;
|
1798 | shape-rendering: crispEdges;
|
1799 | text {
|
1800 | font-family: ${options.fontFamily};
|
1801 | fill: ${options.textColor};
|
1802 | }
|
1803 | }
|
1804 |
|
1805 | .grid path {
|
1806 | stroke-width: 0;
|
1807 | }
|
1808 |
|
1809 |
|
1810 | /* Today line */
|
1811 |
|
1812 | .today {
|
1813 | fill: none;
|
1814 | stroke: ${options.todayLineColor};
|
1815 | stroke-width: 2px;
|
1816 | }
|
1817 |
|
1818 |
|
1819 | /* Task styling */
|
1820 |
|
1821 | /* Default task */
|
1822 |
|
1823 | .task {
|
1824 | stroke-width: 2;
|
1825 | }
|
1826 |
|
1827 | .taskText {
|
1828 | text-anchor: middle;
|
1829 | font-family: 'trebuchet ms', verdana, arial, sans-serif;
|
1830 | font-family: var(--mermaid-font-family);
|
1831 | }
|
1832 |
|
1833 | // .taskText:not([font-size]) {
|
1834 | // font-size: ${options.ganttFontSize};
|
1835 | // }
|
1836 |
|
1837 | .taskTextOutsideRight {
|
1838 | fill: ${options.taskTextDarkColor};
|
1839 | text-anchor: start;
|
1840 | // font-size: ${options.ganttFontSize};
|
1841 | font-family: 'trebuchet ms', verdana, arial, sans-serif;
|
1842 | font-family: var(--mermaid-font-family);
|
1843 |
|
1844 | }
|
1845 |
|
1846 | .taskTextOutsideLeft {
|
1847 | fill: ${options.taskTextDarkColor};
|
1848 | text-anchor: end;
|
1849 | // font-size: ${options.ganttFontSize};
|
1850 | }
|
1851 |
|
1852 | /* Special case clickable */
|
1853 | .task.clickable {
|
1854 | cursor: pointer;
|
1855 | }
|
1856 | .taskText.clickable {
|
1857 | cursor: pointer;
|
1858 | fill: ${options.taskTextClickableColor} !important;
|
1859 | font-weight: bold;
|
1860 | }
|
1861 |
|
1862 | .taskTextOutsideLeft.clickable {
|
1863 | cursor: pointer;
|
1864 | fill: ${options.taskTextClickableColor} !important;
|
1865 | font-weight: bold;
|
1866 | }
|
1867 |
|
1868 | .taskTextOutsideRight.clickable {
|
1869 | cursor: pointer;
|
1870 | fill: ${options.taskTextClickableColor} !important;
|
1871 | font-weight: bold;
|
1872 | }
|
1873 |
|
1874 | /* Specific task settings for the sections*/
|
1875 |
|
1876 | .taskText0,
|
1877 | .taskText1,
|
1878 | .taskText2,
|
1879 | .taskText3 {
|
1880 | fill: ${options.taskTextColor};
|
1881 | }
|
1882 |
|
1883 | .task0,
|
1884 | .task1,
|
1885 | .task2,
|
1886 | .task3 {
|
1887 | fill: ${options.taskBkgColor};
|
1888 | stroke: ${options.taskBorderColor};
|
1889 | }
|
1890 |
|
1891 | .taskTextOutside0,
|
1892 | .taskTextOutside2
|
1893 | {
|
1894 | fill: ${options.taskTextOutsideColor};
|
1895 | }
|
1896 |
|
1897 | .taskTextOutside1,
|
1898 | .taskTextOutside3 {
|
1899 | fill: ${options.taskTextOutsideColor};
|
1900 | }
|
1901 |
|
1902 |
|
1903 | /* Active task */
|
1904 |
|
1905 | .active0,
|
1906 | .active1,
|
1907 | .active2,
|
1908 | .active3 {
|
1909 | fill: ${options.activeTaskBkgColor};
|
1910 | stroke: ${options.activeTaskBorderColor};
|
1911 | }
|
1912 |
|
1913 | .activeText0,
|
1914 | .activeText1,
|
1915 | .activeText2,
|
1916 | .activeText3 {
|
1917 | fill: ${options.taskTextDarkColor} !important;
|
1918 | }
|
1919 |
|
1920 |
|
1921 | /* Completed task */
|
1922 |
|
1923 | .done0,
|
1924 | .done1,
|
1925 | .done2,
|
1926 | .done3 {
|
1927 | stroke: ${options.doneTaskBorderColor};
|
1928 | fill: ${options.doneTaskBkgColor};
|
1929 | stroke-width: 2;
|
1930 | }
|
1931 |
|
1932 | .doneText0,
|
1933 | .doneText1,
|
1934 | .doneText2,
|
1935 | .doneText3 {
|
1936 | fill: ${options.taskTextDarkColor} !important;
|
1937 | }
|
1938 |
|
1939 |
|
1940 | /* Tasks on the critical line */
|
1941 |
|
1942 | .crit0,
|
1943 | .crit1,
|
1944 | .crit2,
|
1945 | .crit3 {
|
1946 | stroke: ${options.critBorderColor};
|
1947 | fill: ${options.critBkgColor};
|
1948 | stroke-width: 2;
|
1949 | }
|
1950 |
|
1951 | .activeCrit0,
|
1952 | .activeCrit1,
|
1953 | .activeCrit2,
|
1954 | .activeCrit3 {
|
1955 | stroke: ${options.critBorderColor};
|
1956 | fill: ${options.activeTaskBkgColor};
|
1957 | stroke-width: 2;
|
1958 | }
|
1959 |
|
1960 | .doneCrit0,
|
1961 | .doneCrit1,
|
1962 | .doneCrit2,
|
1963 | .doneCrit3 {
|
1964 | stroke: ${options.critBorderColor};
|
1965 | fill: ${options.doneTaskBkgColor};
|
1966 | stroke-width: 2;
|
1967 | cursor: pointer;
|
1968 | shape-rendering: crispEdges;
|
1969 | }
|
1970 |
|
1971 | .milestone {
|
1972 | transform: rotate(45deg) scale(0.8,0.8);
|
1973 | }
|
1974 |
|
1975 | .milestoneText {
|
1976 | font-style: italic;
|
1977 | }
|
1978 | .doneCritText0,
|
1979 | .doneCritText1,
|
1980 | .doneCritText2,
|
1981 | .doneCritText3 {
|
1982 | fill: ${options.taskTextDarkColor} !important;
|
1983 | }
|
1984 |
|
1985 | .activeCritText0,
|
1986 | .activeCritText1,
|
1987 | .activeCritText2,
|
1988 | .activeCritText3 {
|
1989 | fill: ${options.taskTextDarkColor} !important;
|
1990 | }
|
1991 |
|
1992 | .titleText {
|
1993 | text-anchor: middle;
|
1994 | font-size: 18px;
|
1995 | fill: ${options.textColor} ;
|
1996 | font-family: 'trebuchet ms', verdana, arial, sans-serif;
|
1997 | font-family: var(--mermaid-font-family);
|
1998 | }
|
1999 | `;
|
2000 | const ganttStyles = getStyles;
|
2001 | const diagram = {
|
2002 | parser: ganttParser,
|
2003 | db: ganttDb,
|
2004 | renderer: ganttRenderer,
|
2005 | styles: ganttStyles
|
2006 | };
|
2007 | export {
|
2008 | diagram
|
2009 | };
|