1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164 | 1×
1×
1×
1×
1×
74×
74×
74×
74×
74×
74×
74×
74×
74×
76×
75×
74×
69×
74×
1×
83×
83×
83×
83×
83×
83×
83×
83×
83×
83×
83×
83×
83×
83×
83×
82×
82×
73×
73×
73×
73×
9×
9×
9×
82×
82×
67×
67×
67×
67×
67×
67×
67×
67×
67×
67×
67×
67×
15×
15×
15×
52×
52×
52×
67×
67×
15×
15×
15×
15×
15×
15×
15×
15×
1×
1×
5×
5×
5×
5×
15×
1×
1×
1×
1×
5×
5×
82×
82×
82×
77×
1×
13×
11×
11×
11×
220×
209×
209×
11×
11×
11×
1×
386×
1×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "../utils/helper", "../utils/helper", "../model/constant"], function (require, exports, ej2_base_1, helper_1, helper_2, constant_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Annotations = (function () {
function Annotations() {
}
Annotations.prototype.renderAnnotationElements = function (gauge) {
var _this = this;
var secondaryID = gauge.element.id + '_Secondary_Element';
var annotationGroup = ej2_base_1.createElement('div', { id: gauge.element.id + '_AnnotationsGroup' });
annotationGroup.style.position = 'absolute';
annotationGroup.style.top = '0px';
annotationGroup.style.left = '0px';
annotationGroup.style.opacity = gauge.allowLoadingAnimation ? '0' : '1';
gauge.splitUpCount = gauge.allowLoadingAnimation && gauge.annotations.length > 0 ? gauge.splitUpCount + 1 : gauge.splitUpCount;
gauge.annotations.map(function (annotation, index) {
if (annotation.content !== null) {
_this.createAnnotationTemplate(annotationGroup, index, gauge);
}
});
if (annotationGroup.childElementCount > 0 && !(ej2_base_1.isNullOrUndefined(helper_1.getElement(secondaryID)))) {
helper_1.getElement(secondaryID).appendChild(annotationGroup);
}
gauge.renderReactTemplates();
};
Annotations.prototype.createAnnotationTemplate = function (element, annotationIndex, gauge) {
var left;
var top;
var templateFn;
var renderAnnotation = false;
var templateElement;
var axis;
var axisIndex;
var annotation = gauge.annotations[annotationIndex];
var childElement = ej2_base_1.createElement('div', {
id: gauge.element.id + '_Annotation_' + annotationIndex
});
childElement.style.cssText = 'position: absolute; z-index:' + annotation.zIndex + ';';
var style = {
size: annotation.font.size,
color: annotation.font.color,
fontFamily: annotation.font.fontFamily,
fontWeight: annotation.font.fontWeight,
fontStyle: annotation.font.fontStyle,
opacity: annotation.font.opacity
};
var argsData = {
cancel: false, name: constant_1.annotationRender, content: annotation.content,
annotation: annotation, textStyle: style
};
argsData.textStyle.color = style.color || gauge.themeStyle.labelColor;
gauge.trigger(constant_1.annotationRender, argsData, function () {
if (!argsData.cancel) {
templateFn = helper_1.getTemplateFunction(argsData.content, gauge);
if (templateFn && templateFn(gauge, gauge, argsData.content, gauge.element.id + '_ContentTemplate' + annotationIndex).length) {
templateElement = Array.prototype.slice.call(templateFn(gauge, gauge, argsData.content, gauge.element.id + '_ContentTemplate' + annotationIndex));
var length_1 = templateElement.length;
for (var i = 0; i < length_1; i++) {
childElement.appendChild(templateElement[i]);
}
}
else {
var annotationElement = ej2_base_1.createElement('div', {
innerHTML: !ej2_base_1.isNullOrUndefined(argsData.content) ? argsData.content.toString() : null
});
annotationElement.style.cssText = helper_2.getFontStyle(argsData.textStyle);
childElement.appendChild(annotationElement);
}
var offset = helper_1.getElementOffset(childElement.cloneNode(true), gauge.element);
if (!(ej2_base_1.isNullOrUndefined(annotation.axisValue))) {
axisIndex = ej2_base_1.isNullOrUndefined(annotation.axisIndex) ? 0 : annotation.axisIndex;
axis = gauge.axes[axisIndex];
var range = axis.visibleRange;
renderAnnotation = (annotation.axisValue >= range.min && annotation.axisValue <= range.max) ? true : false;
var line = axis.lineBounds;
var extraWidth = helper_1.getExtraWidth(gauge.element);
var axisCollection = helper_1.getElement(gauge.element.id + '_Axis_Collections');
Eif (!ej2_base_1.isNullOrUndefined(axisCollection)) {
var transformValue = axisCollection.getAttribute('transform').split('(')[1].split(')')[0];
var leftTransformValue = parseInt(transformValue.split(',')[0], 10);
var topTransformValue = parseInt(transformValue.split(',')[1], 10);
if (gauge.orientation === 'Vertical') {
left = line.x + parseFloat(annotation.x.toString()) + leftTransformValue - extraWidth;
top = ((helper_2.valueToCoefficient(parseFloat(annotation.axisValue.toString()), axis, gauge.orientation, range) * line.height) + line.y);
top += parseFloat(annotation.y.toString());
}
else {
left = ((helper_2.valueToCoefficient(parseFloat(annotation.axisValue.toString()), axis, gauge.orientation, range) * line.width) + line.x - extraWidth);
left += parseFloat(annotation.x.toString());
top = line.y + parseFloat(annotation.y.toString()) + topTransformValue;
}
left -= (offset.width / 2);
top -= (offset.height / 2);
}
}
else {
var elementRect = gauge.element.getBoundingClientRect();
var bounds = gauge.svgObject.getBoundingClientRect();
renderAnnotation = true;
left = Math.abs(bounds.left - elementRect.left);
top = Math.abs(bounds.top - elementRect.top);
left = (annotation.horizontalAlignment === 'None') ? (left + annotation.x) : left;
top = (annotation.verticalAlignment === 'None') ? top + annotation.y : top;
switch (annotation.verticalAlignment) {
case 'Near':
top = top + annotation.y;
break;
case 'Center':
top = top + annotation.y + ((bounds.height / 2) - (offset.height / 2));
break;
case 'Far':
top = (top + bounds.height) + annotation.y - offset.height;
break;
}
switch (annotation.horizontalAlignment) {
case 'Near':
left = left + annotation.x;
break;
case 'Center':
left = left + annotation.x + ((bounds.width / 2) - (offset.width / 2));
break;
case 'Far':
left = (left + bounds.width) + annotation.x - offset.width;
break;
}
}
childElement.style.left = left + 'px';
childElement.style.top = top + 'px';
if (renderAnnotation) {
element.appendChild(childElement);
}
}
});
};
Annotations.prototype.annotationAnimate = function (element, gauge) {
Eif (element.style.opacity === '0') {
var tempOpacity_1 = 0;
var opacity_1 = 1;
new ej2_base_1.Animation({}).animate(element, {
duration: (gauge.animationDuration === 0 && ej2_base_1.animationMode === 'Enable') ? 1000 :
(gauge.allowLoadingAnimation && gauge.animationDuration > 0 ? gauge.animationDuration / gauge.splitUpCount : 0),
progress: function (args) {
if (args.timeStamp > args.delay) {
tempOpacity_1 = ((args.timeStamp - args.delay) / args.duration);
element['style']['opacity'] = (opacity_1 * tempOpacity_1);
}
},
end: function () {
element['style']['opacity'] = opacity_1;
gauge.allowLoadingAnimation = false;
gauge.isOverAllAnimationComplete = true;
}
});
}
};
Annotations.prototype.getModuleName = function () {
return 'Annotations';
};
Annotations.prototype.destroy = function () { };
return Annotations;
}());
exports.Annotations = Annotations;
});
|