fhdp-charts 4.10.401 → 4.10.901
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/Module.d.ts +6 -6
- package/dist/Module.js +39 -36
- package/dist/Module.js.map +1 -1
- package/dist/package.json +45 -36
- package/dist/source/charts/ChartTime24.d.ts +85 -85
- package/dist/source/charts/ChartTime24.js +377 -374
- package/dist/source/charts/ChartTime24.js.map +1 -1
- package/package.json +22 -13
|
@@ -1,375 +1,378 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
d
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
_this
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
_this.
|
|
28
|
-
|
|
29
|
-
_this.
|
|
30
|
-
_this.
|
|
31
|
-
_this.
|
|
32
|
-
_this.
|
|
33
|
-
_this.
|
|
34
|
-
_this.
|
|
35
|
-
_this.
|
|
36
|
-
_this.
|
|
37
|
-
_this.
|
|
38
|
-
_this.
|
|
39
|
-
|
|
40
|
-
_this.
|
|
41
|
-
_this.
|
|
42
|
-
//?
|
|
43
|
-
_this.
|
|
44
|
-
_this.
|
|
45
|
-
|
|
46
|
-
_this.
|
|
47
|
-
|
|
48
|
-
_this.
|
|
49
|
-
_this.
|
|
50
|
-
|
|
51
|
-
_this.
|
|
52
|
-
|
|
53
|
-
_this.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
_this.
|
|
57
|
-
|
|
58
|
-
_this.
|
|
59
|
-
|
|
60
|
-
_this.
|
|
61
|
-
_this.
|
|
62
|
-
|
|
63
|
-
_this.
|
|
64
|
-
_this.
|
|
65
|
-
_this.
|
|
66
|
-
_this.
|
|
67
|
-
|
|
68
|
-
_this.
|
|
69
|
-
_this.
|
|
70
|
-
|
|
71
|
-
_this.
|
|
72
|
-
_this.
|
|
73
|
-
_this.
|
|
74
|
-
|
|
75
|
-
_this.
|
|
76
|
-
_this.
|
|
77
|
-
|
|
78
|
-
_this.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.
|
|
87
|
-
|
|
88
|
-
this.
|
|
89
|
-
this.
|
|
90
|
-
this.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
};
|
|
95
|
-
ChartTime24.prototype.
|
|
96
|
-
this.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
_super.prototype.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
var
|
|
117
|
-
var
|
|
118
|
-
var
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
var
|
|
133
|
-
var
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
scrollContainer
|
|
137
|
-
scrollContainer.
|
|
138
|
-
scrollContainer.style.
|
|
139
|
-
scrollContainer.style.
|
|
140
|
-
scrollContainer.style.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
var
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
var
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
var
|
|
168
|
-
var
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
var
|
|
177
|
-
var
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
var
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
var
|
|
259
|
-
var
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
tooltip
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
var
|
|
286
|
-
var
|
|
287
|
-
var
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.ChartTime24 = void 0;
|
|
19
|
+
var fh_forms_handler_1 = require("fh-forms-handler");
|
|
20
|
+
var konva_1 = require("konva");
|
|
21
|
+
var ChartTime24 = /** @class */ (function (_super) {
|
|
22
|
+
__extends(ChartTime24, _super);
|
|
23
|
+
function ChartTime24(componentObj, parent) {
|
|
24
|
+
var _this = _super.call(this, componentObj, parent) || this;
|
|
25
|
+
_this.barElements = [];
|
|
26
|
+
//? resize event
|
|
27
|
+
_this.resizeWindowBind = _this.resizeWindow.bind(_this);
|
|
28
|
+
//? base parameters
|
|
29
|
+
_this.hAxisName = componentObj.haxisName || '';
|
|
30
|
+
_this.vAxisName = componentObj.vaxisName || '';
|
|
31
|
+
_this.bgColor = componentObj.bgColor || '#f3f2ec';
|
|
32
|
+
_this.tooltipBgColor = componentObj.tooltipBgColor || 'black';
|
|
33
|
+
_this.axisLabelColor = componentObj.axisLabelColor || 'black';
|
|
34
|
+
_this.lineColor = componentObj.lineColor || 'LightSlateGrey';
|
|
35
|
+
_this.tooltipColor = componentObj.tooltipColor || 'white';
|
|
36
|
+
_this.fontFamily = componentObj.fontFamily || 'Calibri';
|
|
37
|
+
_this.barElements = componentObj.bars;
|
|
38
|
+
_this.highlightedValue = Number(componentObj.highlightedValue) || 22;
|
|
39
|
+
_this.highlightedStroke = Number(componentObj.highlightedStroke) || 3;
|
|
40
|
+
_this.gradation = Number(componentObj.gradation) || 2;
|
|
41
|
+
_this.maxValueX = Number(componentObj.maxValueX) || 26;
|
|
42
|
+
//? containers ids
|
|
43
|
+
_this.mainElementId = componentObj.mainElementId || 'chartContainer';
|
|
44
|
+
_this.scrollContainerId = componentObj.scrollContainerId || 'scrollContainer';
|
|
45
|
+
//? bar
|
|
46
|
+
_this.barBreakWidth = Number(componentObj.barBreakWidth) || 60;
|
|
47
|
+
_this.barHeight = Number(componentObj.barHeight) || 100;
|
|
48
|
+
_this.barBreakHeight = Number(componentObj.barBreakHeight) || 30;
|
|
49
|
+
_this.percentDarkColorOnMove = Number(componentObj.percentDarkColorOnMove) || 20;
|
|
50
|
+
//? base margin
|
|
51
|
+
_this.leftMarginChart = Number(componentObj.leftMarginChart) || 100;
|
|
52
|
+
_this.rightMarginChart = Number(componentObj.rightMarginChart) || 110;
|
|
53
|
+
_this.topMarginChart = Number(componentObj.topMarginChart) || 50;
|
|
54
|
+
_this.bottomMarginChart = Number(componentObj.bottomMarginChart) || 50;
|
|
55
|
+
//? scroll container
|
|
56
|
+
_this.scrollSizeChart = Number(componentObj.scrollSizeChart) || 23;
|
|
57
|
+
//? lines, value lines
|
|
58
|
+
_this.protrudingLinesHeight = Number(componentObj.protrudingLinesHeight) || 10;
|
|
59
|
+
_this.labelTextHeight = Number(componentObj.labelTextHeight) || 3;
|
|
60
|
+
_this.labelTextFontSize = Number(componentObj.labelTextFontSize) || 22;
|
|
61
|
+
_this.lineStrokeWidth = Number(componentObj.lineStrokeWidth) || 1;
|
|
62
|
+
//? legend
|
|
63
|
+
_this.topMarginLegend = Number(componentObj.topMarginLegend) || 20;
|
|
64
|
+
_this.legendColorWidth = Number(componentObj.legendColorWidth) || 40;
|
|
65
|
+
_this.legendColorHeight = Number(componentObj.legendColorHeight) || 20;
|
|
66
|
+
_this.legendFontSize = Number(componentObj.legendFontSize) || 18;
|
|
67
|
+
_this.legendBreakColorText = Number(componentObj.legendBreakColorText) || 5;
|
|
68
|
+
_this.legendElementBreakWidth = Number(componentObj.legendElementBreakWidth) || 25;
|
|
69
|
+
_this.legendElementBreakHeight = Number(componentObj.legendElementBreakHeight) || 3;
|
|
70
|
+
//? tooltip
|
|
71
|
+
_this.tooltipOpacity = Number(componentObj.tooltipOpacity) || 0.8;
|
|
72
|
+
_this.tooltipPointerWidth = Number(componentObj.tooltipPointerWidth) || 10;
|
|
73
|
+
_this.tooltipPointerHeight = Number(componentObj.tooltipPointerHeight) || 20;
|
|
74
|
+
_this.tooltipCornerRadius = Number(componentObj.tooltipCornerRadius) || 5;
|
|
75
|
+
_this.tooltipFontSize = Number(componentObj.tooltipFontSize) || 18;
|
|
76
|
+
_this.tooltipPadding = Number(componentObj.tooltipPadding) || 10;
|
|
77
|
+
//? label name prop
|
|
78
|
+
_this.labelNameFontSize = Number(componentObj.labelNameFontSize) || 22;
|
|
79
|
+
_this.labelNameBreak = Number(componentObj.labelNameBreak) || 13;
|
|
80
|
+
_this.resizeWindowBind = _this.resizeWindow.bind(_this);
|
|
81
|
+
_this.initResizeWindow();
|
|
82
|
+
return _this;
|
|
83
|
+
}
|
|
84
|
+
ChartTime24.prototype.create = function () {
|
|
85
|
+
var mainElement = document.createElement('div');
|
|
86
|
+
mainElement.id = this.mainElementId;
|
|
87
|
+
mainElement.style.display = 'flex';
|
|
88
|
+
this.component = mainElement;
|
|
89
|
+
this.wrap(false, false);
|
|
90
|
+
this.addStyles();
|
|
91
|
+
this.display();
|
|
92
|
+
this.buildChart(mainElement.id);
|
|
93
|
+
this.display();
|
|
94
|
+
};
|
|
95
|
+
ChartTime24.prototype.initResizeWindow = function () {
|
|
96
|
+
$(window).on('resize', this.resizeWindowBind);
|
|
97
|
+
};
|
|
98
|
+
ChartTime24.prototype.resizeWindow = function () {
|
|
99
|
+
this.destroy(true);
|
|
100
|
+
this.create();
|
|
101
|
+
this.initResizeWindow();
|
|
102
|
+
};
|
|
103
|
+
ChartTime24.prototype.destroy = function (removeFromParent) {
|
|
104
|
+
$(window).off('resize', this.resizeWindowBind);
|
|
105
|
+
_super.prototype.destroy.call(this, removeFromParent);
|
|
106
|
+
};
|
|
107
|
+
ChartTime24.prototype.update = function (change) {
|
|
108
|
+
_super.prototype.update.call(this, change);
|
|
109
|
+
this.destroy(true);
|
|
110
|
+
this.create();
|
|
111
|
+
this.resizeWindowBind = this.resizeWindow.bind(this);
|
|
112
|
+
this.initResizeWindow();
|
|
113
|
+
};
|
|
114
|
+
ChartTime24.prototype.buildChart = function (id) {
|
|
115
|
+
//? create hAxisLabels numbers
|
|
116
|
+
var _a = this.getHAxisLables(), hAxisLabels = _a.hAxisLabels, maxX = _a.maxX;
|
|
117
|
+
var maxXFullWidth = maxX + this.leftMarginChart + this.rightMarginChart;
|
|
118
|
+
var stageWidth = maxXFullWidth < this.htmlElement.offsetWidth ? maxXFullWidth : this.htmlElement.offsetWidth;
|
|
119
|
+
var chartLinesHeight = (this.barElements.length + 1) * this.barBreakHeight + this.barElements.length * this.barHeight;
|
|
120
|
+
var chartHeight = chartLinesHeight + this.protrudingLinesHeight + this.labelTextFontSize + this.labelTextHeight;
|
|
121
|
+
var stage = new konva_1.default.Stage({
|
|
122
|
+
container: id,
|
|
123
|
+
width: stageWidth,
|
|
124
|
+
});
|
|
125
|
+
var _b = this.createStaticLayer(stageWidth, chartLinesHeight), staticLayer = _b.staticLayer, background = _b.background;
|
|
126
|
+
var legendLayer = new konva_1.default.Layer({
|
|
127
|
+
x: this.leftMarginChart,
|
|
128
|
+
});
|
|
129
|
+
stage.add(staticLayer, legendLayer);
|
|
130
|
+
stage.draw();
|
|
131
|
+
//? create div for scroll stage
|
|
132
|
+
var baseContainer = document.getElementById(id);
|
|
133
|
+
var baseConvasContainer = baseContainer.childNodes[0];
|
|
134
|
+
var scrollLayer = this.createScrollLayer(hAxisLabels, maxX, chartLinesHeight);
|
|
135
|
+
var _c = this.createBarsLayer(legendLayer, stageWidth), barsLayer = _c.barsLayer, tooltipLayer = _c.tooltipLayer, maxLegendY = _c.maxLegendY;
|
|
136
|
+
var scrollContainer = document.createElement('div');
|
|
137
|
+
scrollContainer.id = this.scrollContainerId;
|
|
138
|
+
scrollContainer.style.overflow = 'auto';
|
|
139
|
+
scrollContainer.style.marginLeft = "".concat(this.leftMarginChart, "px");
|
|
140
|
+
scrollContainer.style.height = "".concat(chartHeight + this.scrollSizeChart, "px");
|
|
141
|
+
scrollContainer.style.position = 'relative';
|
|
142
|
+
scrollContainer.style.marginTop = "".concat(this.topMarginChart, "px");
|
|
143
|
+
scrollContainer.style.marginRight = "".concat(this.rightMarginChart, "px");
|
|
144
|
+
baseConvasContainer.appendChild(scrollContainer);
|
|
145
|
+
//? Resizze Legend
|
|
146
|
+
var legendY = chartHeight + this.scrollSizeChart + this.topMarginChart + this.topMarginLegend;
|
|
147
|
+
legendLayer.y(legendY);
|
|
148
|
+
var legendWidth = maxLegendY + this.legendColorHeight;
|
|
149
|
+
var allHeight = legendY + legendWidth + this.bottomMarginChart;
|
|
150
|
+
stage.height(allHeight);
|
|
151
|
+
background.height(allHeight);
|
|
152
|
+
//? scroll stage
|
|
153
|
+
var scrollStage = new konva_1.default.Stage({
|
|
154
|
+
container: scrollContainer.id,
|
|
155
|
+
width: maxX,
|
|
156
|
+
height: chartHeight,
|
|
157
|
+
x: this.lineStrokeWidth,
|
|
158
|
+
});
|
|
159
|
+
scrollStage.add(scrollLayer, barsLayer, tooltipLayer);
|
|
160
|
+
scrollStage.draw();
|
|
161
|
+
};
|
|
162
|
+
ChartTime24.prototype.getHAxisLables = function () {
|
|
163
|
+
var _this = this;
|
|
164
|
+
var maxTo = this.barElements.reduce(function (prev, curr) {
|
|
165
|
+
return (Number(prev.to) > Number(curr.to)) ? prev : curr;
|
|
166
|
+
});
|
|
167
|
+
var yearStart = 1;
|
|
168
|
+
var yearEnd = Number(maxTo.to) > this.maxValueX ? Math.ceil(Number(maxTo.to) / this.gradation) + 2 : Math.ceil(this.maxValueX / 2);
|
|
169
|
+
var hAxisLabels = Array(yearEnd - yearStart + 1).fill(0).map(function () { return _this.gradation * yearStart++; });
|
|
170
|
+
var baseMaxX = hAxisLabels.length * this.barBreakWidth + this.barBreakWidth;
|
|
171
|
+
var tooltipTextBox = new konva_1.default.Text({
|
|
172
|
+
text: maxTo.tooltipText.replace(/\\n/g, "\n"),
|
|
173
|
+
fontFamily: this.fontFamily,
|
|
174
|
+
fontSize: this.tooltipFontSize,
|
|
175
|
+
});
|
|
176
|
+
var valueOneGradation = this.barBreakWidth / this.gradation;
|
|
177
|
+
var widthBar = (Number(maxTo.to) * valueOneGradation + this.leftMarginChart) - (Number(maxTo.from) * valueOneGradation + this.leftMarginChart);
|
|
178
|
+
var barXMax = Number(maxTo.from) * valueOneGradation + widthBar;
|
|
179
|
+
var maxXTooltip = barXMax + Math.ceil(tooltipTextBox.textWidth) + 2 * this.tooltipPadding + this.tooltipPointerWidth;
|
|
180
|
+
var maxX = baseMaxX > maxXTooltip ? baseMaxX : maxXTooltip;
|
|
181
|
+
return { hAxisLabels: hAxisLabels, maxX: maxX };
|
|
182
|
+
};
|
|
183
|
+
ChartTime24.prototype.createScrollLayer = function (hAxisLabels, maxX, chartHeight) {
|
|
184
|
+
var _this = this;
|
|
185
|
+
var scrollLayer = new konva_1.default.Layer();
|
|
186
|
+
//? Create grid
|
|
187
|
+
var baseGridLine = new konva_1.default.Line({
|
|
188
|
+
points: [0, 0, 0, chartHeight, maxX, chartHeight],
|
|
189
|
+
stroke: this.lineColor,
|
|
190
|
+
strokeWidth: this.lineStrokeWidth,
|
|
191
|
+
lineCap: 'round',
|
|
192
|
+
lineJoin: 'round',
|
|
193
|
+
});
|
|
194
|
+
scrollLayer.add(baseGridLine);
|
|
195
|
+
//? labels and line OX
|
|
196
|
+
hAxisLabels.forEach(function (el, i) {
|
|
197
|
+
var configLabel = {
|
|
198
|
+
points: [(i + 1) * _this.barBreakWidth, 0, (i + 1) * _this.barBreakWidth, chartHeight + _this.protrudingLinesHeight],
|
|
199
|
+
stroke: _this.lineColor,
|
|
200
|
+
strokeWidth: _this.lineStrokeWidth,
|
|
201
|
+
lineCap: 'round',
|
|
202
|
+
lineJoin: 'round',
|
|
203
|
+
};
|
|
204
|
+
if (el === _this.highlightedValue) {
|
|
205
|
+
configLabel.strokeWidth = _this.highlightedStroke;
|
|
206
|
+
}
|
|
207
|
+
var labelText = new konva_1.default.Text({
|
|
208
|
+
x: (i + 1) * _this.barBreakWidth,
|
|
209
|
+
y: chartHeight + _this.protrudingLinesHeight + _this.labelTextHeight,
|
|
210
|
+
text: String(el),
|
|
211
|
+
fontSize: _this.labelTextFontSize,
|
|
212
|
+
fontFamily: _this.fontFamily,
|
|
213
|
+
fill: _this.axisLabelColor,
|
|
214
|
+
});
|
|
215
|
+
labelText.attrs.x -= (labelText.textWidth / 2);
|
|
216
|
+
var lineLabel = new konva_1.default.Line(configLabel);
|
|
217
|
+
scrollLayer.add(lineLabel);
|
|
218
|
+
scrollLayer.add(labelText);
|
|
219
|
+
});
|
|
220
|
+
return scrollLayer;
|
|
221
|
+
};
|
|
222
|
+
ChartTime24.prototype.createStaticLayer = function (width, chartHeight) {
|
|
223
|
+
var staticLayer = new konva_1.default.Layer();
|
|
224
|
+
//? Create background
|
|
225
|
+
var background = new konva_1.default.Rect({
|
|
226
|
+
width: width,
|
|
227
|
+
fill: this.bgColor,
|
|
228
|
+
});
|
|
229
|
+
staticLayer.add(background);
|
|
230
|
+
this.createAxisLabel(staticLayer, width, chartHeight);
|
|
231
|
+
return { staticLayer: staticLayer, background: background };
|
|
232
|
+
};
|
|
233
|
+
ChartTime24.prototype.createAxisLabel = function (staticLayer, width, chartHeight) {
|
|
234
|
+
//? Label X NAME
|
|
235
|
+
var labelXName = new konva_1.default.Text({
|
|
236
|
+
x: width - this.rightMarginChart + this.labelNameBreak,
|
|
237
|
+
y: chartHeight + this.protrudingLinesHeight + this.labelTextHeight + this.topMarginChart,
|
|
238
|
+
text: this.hAxisName,
|
|
239
|
+
fontSize: this.labelNameFontSize,
|
|
240
|
+
fontFamily: this.fontFamily,
|
|
241
|
+
fill: this.axisLabelColor,
|
|
242
|
+
});
|
|
243
|
+
staticLayer.add(labelXName);
|
|
244
|
+
//? Label Y NAME
|
|
245
|
+
var labelYName = new konva_1.default.Text({
|
|
246
|
+
x: this.leftMarginChart - this.labelNameBreak,
|
|
247
|
+
y: this.topMarginChart,
|
|
248
|
+
text: this.vAxisName,
|
|
249
|
+
fontSize: this.labelNameFontSize,
|
|
250
|
+
fontFamily: this.fontFamily,
|
|
251
|
+
fill: this.axisLabelColor,
|
|
252
|
+
});
|
|
253
|
+
labelYName.attrs.y -= labelYName.textHeight;
|
|
254
|
+
labelYName.attrs.x -= labelYName.textWidth;
|
|
255
|
+
staticLayer.add(labelYName);
|
|
256
|
+
};
|
|
257
|
+
ChartTime24.prototype.createBarsLayer = function (legendLayer, stageWidth) {
|
|
258
|
+
var _this = this;
|
|
259
|
+
var legendX = 0;
|
|
260
|
+
var legendY = 0;
|
|
261
|
+
var barsLayer = new konva_1.default.Layer();
|
|
262
|
+
var tooltip = new konva_1.default.Label({
|
|
263
|
+
opacity: this.tooltipOpacity,
|
|
264
|
+
});
|
|
265
|
+
tooltip.add(new konva_1.default.Tag({
|
|
266
|
+
fill: this.tooltipBgColor,
|
|
267
|
+
pointerDirection: 'left',
|
|
268
|
+
pointerWidth: this.tooltipPointerWidth,
|
|
269
|
+
pointerHeight: this.tooltipPointerHeight,
|
|
270
|
+
lineJoin: 'round',
|
|
271
|
+
cornerRadius: this.tooltipCornerRadius,
|
|
272
|
+
}));
|
|
273
|
+
var tooltipTextBox = new konva_1.default.Text({
|
|
274
|
+
text: '',
|
|
275
|
+
fontFamily: this.fontFamily,
|
|
276
|
+
fontSize: this.tooltipFontSize,
|
|
277
|
+
padding: this.tooltipPadding,
|
|
278
|
+
fill: this.tooltipColor,
|
|
279
|
+
});
|
|
280
|
+
tooltip.add(tooltipTextBox);
|
|
281
|
+
tooltip.hide();
|
|
282
|
+
this.barElements
|
|
283
|
+
.sort(function (a, b) { return (Number(a.position) > Number(b.position) ? 1 : -1); })
|
|
284
|
+
.forEach(function (el, i) {
|
|
285
|
+
var fromValue = Number(el.from);
|
|
286
|
+
var toValue = Number(el.to);
|
|
287
|
+
var valueOneGradation = _this.barBreakWidth / _this.gradation;
|
|
288
|
+
var barHeight = _this.barHeight;
|
|
289
|
+
var barBreakHeight = _this.barBreakHeight;
|
|
290
|
+
var bar = new konva_1.default.Rect({
|
|
291
|
+
width: (toValue * valueOneGradation + _this.leftMarginChart) - (fromValue * valueOneGradation + _this.leftMarginChart),
|
|
292
|
+
height: barHeight,
|
|
293
|
+
fill: el.color,
|
|
294
|
+
x: fromValue * valueOneGradation,
|
|
295
|
+
y: barHeight * i + barBreakHeight * (i + 1),
|
|
296
|
+
});
|
|
297
|
+
var darkColor = _this.darkenColor(el.color, _this.percentDarkColorOnMove);
|
|
298
|
+
bar.on('mousemove', function (e) {
|
|
299
|
+
this.fill(darkColor);
|
|
300
|
+
//? positioning tooltip
|
|
301
|
+
tooltip.position({
|
|
302
|
+
x: (fromValue * valueOneGradation) + (toValue * valueOneGradation) - (fromValue * valueOneGradation),
|
|
303
|
+
y: barHeight * i + barBreakHeight * (i + 1) + barHeight / 2,
|
|
304
|
+
});
|
|
305
|
+
tooltipTextBox.text(el.tooltipText.replace(/\\n/g, "\n"));
|
|
306
|
+
tooltip.show();
|
|
307
|
+
});
|
|
308
|
+
bar.on('mouseout', function () {
|
|
309
|
+
this.fill(el.color);
|
|
310
|
+
tooltip.hide();
|
|
311
|
+
});
|
|
312
|
+
barsLayer.add(bar);
|
|
313
|
+
var legendParam = _this.createLegendByBar(legendX, legendY, el, legendLayer, darkColor, bar, tooltip, tooltipTextBox, i, fromValue, toValue, valueOneGradation, barHeight, barBreakHeight, stageWidth);
|
|
314
|
+
legendX = legendParam.legendX;
|
|
315
|
+
legendY = legendParam.legendY;
|
|
316
|
+
});
|
|
317
|
+
var tooltipLayer = new konva_1.default.Layer();
|
|
318
|
+
tooltipLayer.add(tooltip);
|
|
319
|
+
return { barsLayer: barsLayer, tooltipLayer: tooltipLayer, maxLegendY: legendY };
|
|
320
|
+
};
|
|
321
|
+
ChartTime24.prototype.createLegendByBar = function (legendX, legendY, el, legendLayer, darkColor, bar, tooltip, tooltipTextBox, iter, fromValue, toValue, valueOneGradation, barHeight, barBreakHeight, stageWidth) {
|
|
322
|
+
var legend = new konva_1.default.Rect({
|
|
323
|
+
width: this.legendColorWidth,
|
|
324
|
+
height: this.legendColorHeight,
|
|
325
|
+
fill: el.color,
|
|
326
|
+
x: legendX,
|
|
327
|
+
y: legendY,
|
|
328
|
+
});
|
|
329
|
+
var legendText = new konva_1.default.Text({
|
|
330
|
+
x: legendX + legend.attrs.width + this.legendBreakColorText,
|
|
331
|
+
y: legendY,
|
|
332
|
+
height: legend.attrs.height,
|
|
333
|
+
text: el.legendText,
|
|
334
|
+
fontSize: this.legendFontSize,
|
|
335
|
+
fontFamily: this.fontFamily,
|
|
336
|
+
fill: 'black',
|
|
337
|
+
verticalAlign: 'middle'
|
|
338
|
+
});
|
|
339
|
+
var sumWidthLegend = legend.attrs.width + this.legendElementBreakWidth + legendText.textWidth + this.legendBreakColorText;
|
|
340
|
+
var widthLegend = legendX + sumWidthLegend;
|
|
341
|
+
var scrollWidth = stageWidth - this.leftMarginChart - this.rightMarginChart;
|
|
342
|
+
if (widthLegend > scrollWidth) {
|
|
343
|
+
legendY += this.legendColorHeight + this.legendElementBreakHeight;
|
|
344
|
+
legendX = 0;
|
|
345
|
+
legend.y(legendY);
|
|
346
|
+
legend.x(legendX);
|
|
347
|
+
legendText.y(legendY);
|
|
348
|
+
legendText.x(legendX + legend.attrs.width + this.legendBreakColorText);
|
|
349
|
+
}
|
|
350
|
+
legendX += sumWidthLegend;
|
|
351
|
+
legendLayer.add(legend);
|
|
352
|
+
legendLayer.add(legendText);
|
|
353
|
+
legend.on('mousemove', function (e) {
|
|
354
|
+
this.fill(darkColor);
|
|
355
|
+
bar.fill(darkColor);
|
|
356
|
+
tooltip.position({
|
|
357
|
+
x: (fromValue * valueOneGradation) + (toValue * valueOneGradation) - (fromValue * valueOneGradation),
|
|
358
|
+
y: barHeight * iter + barBreakHeight * (iter + 1) + barHeight / 2,
|
|
359
|
+
});
|
|
360
|
+
tooltipTextBox.text(el.tooltipText.replace(/\\n/g, "\n"));
|
|
361
|
+
tooltip.show();
|
|
362
|
+
});
|
|
363
|
+
legend.on('mouseout', function () {
|
|
364
|
+
this.fill(el.color);
|
|
365
|
+
bar.fill(el.color);
|
|
366
|
+
tooltip.hide();
|
|
367
|
+
});
|
|
368
|
+
return { legendX: legendX, legendY: legendY };
|
|
369
|
+
};
|
|
370
|
+
ChartTime24.prototype.darkenColor = function (color, percent) {
|
|
371
|
+
var num = parseInt(color.replace("#", ""), 16), amt = Math.round(2.55 * percent), R = (num >> 16) - amt, B = (num >> 8 & 0x00FF) - amt, G = (num & 0x0000FF) - amt;
|
|
372
|
+
return "#" + (0x1000000 + (R < 255 ? R < 1 ? 0 : R : 255) * 0x10000 + (B < 255 ? B < 1 ? 0 : B : 255) * 0x100 + (G < 255 ? G < 1 ? 0 : G : 255)).toString(16).slice(1);
|
|
373
|
+
};
|
|
374
|
+
;
|
|
375
|
+
return ChartTime24;
|
|
376
|
+
}(fh_forms_handler_1.HTMLFormComponent));
|
|
377
|
+
exports.ChartTime24 = ChartTime24;
|
|
375
378
|
//# sourceMappingURL=ChartTime24.js.map
|