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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
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 | 1×
1×
1×
1×
117×
117×
117×
117×
117×
117×
117×
117×
117×
117×
117×
117×
1×
172×
122×
50×
1×
172×
122×
50×
1×
172×
122×
50×
1×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
684×
684×
122×
684×
684×
15×
684×
684×
684×
684×
684×
1×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
206×
206×
50×
206×
206×
206×
206×
206×
206×
206×
1×
890×
890×
1×
154×
50×
104×
1×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
562×
562×
2248×
2248×
112×
2248×
2248×
2248×
2248×
2248×
562×
1×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
158×
158×
632×
472×
160×
632×
632×
632×
632×
632×
632×
158×
1×
2880×
2880×
1×
104×
104×
104×
256×
256×
86×
18×
1×
50×
50×
50×
118×
118×
50×
1×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
122×
684×
684×
27×
684×
684×
684×
684×
684×
684×
122×
1×
890×
890×
1×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
50×
206×
206×
206×
206×
206×
206×
206×
206×
50×
1×
354×
54×
300×
1×
1334×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-svg-base"], function (require, exports, ej2_svg_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var BulletChartAxis = (function () {
function BulletChartAxis(bullet) {
this.bulletChart = bullet;
this.isVertical = (bullet.orientation === 'Vertical');
this.isLabelsInside = (bullet.labelPosition === 'Inside');
this.isHorizontal = (bullet.orientation === 'Horizontal');
this.isLeft = bullet.titlePosition === 'Left';
this.isRight = bullet.titlePosition === 'Right';
this.isTop = bullet.titlePosition === 'Top';
this.majorTickSize = bullet.majorTickLines.height;
this.location = 10;
this.labelOffset = 15;
this.labelSize = parseFloat(bullet.labelStyle.size);
this.isLabelBelow = !this.bulletChart.opposedPosition;
}
BulletChartAxis.prototype.renderMajorTickLines = function (intervalValue, scale) {
if (this.bulletChart.orientation === 'Horizontal') {
this.renderXMajorTickLines(intervalValue, scale);
}
else {
this.renderYMajorTickLines(intervalValue, scale);
}
};
BulletChartAxis.prototype.renderMinorTickLines = function (intervalValue, scale) {
if (this.bulletChart.orientation === 'Horizontal') {
this.renderXMinorTickLines(intervalValue, scale);
}
else {
this.renderYMinorTickLines(intervalValue, scale);
}
};
BulletChartAxis.prototype.renderAxisLabels = function (intervalValue, scale) {
if (this.bulletChart.orientation === 'Horizontal') {
this.renderXAxisLabels(intervalValue, scale);
}
else {
this.renderYAxisLabels(intervalValue, scale);
}
};
BulletChartAxis.prototype.renderXMajorTickLines = function (intervalValue, scale) {
var bullet = this.bulletChart;
var tickGroup = bullet.renderer.createGroup({ 'id': bullet.svgObject.id + '_majorTickGroup' });
var min = bullet.minimum;
var max = bullet.maximum;
var interval = bullet.interval;
var enableRtl = bullet.enableRtl;
var y1 = bullet.initialClipRect.y + ((bullet.opposedPosition) ? 0 : bullet.initialClipRect.height);
var y2 = y1 + ((!bullet.opposedPosition) ? ((bullet.tickPosition !== 'Inside' ?
this.majorTickSize : -this.majorTickSize)) : ((bullet.tickPosition !== 'Inside' ? -this.majorTickSize : this.majorTickSize)));
var majorTick = bullet.majorTickLines;
var strokeColor = majorTick.color || bullet.themeStyle.majorTickLineColor;
var options;
var condition;
var size = bullet.initialClipRect.x + ((bullet.enableRtl) ? bullet.initialClipRect.width : 0);
var majorPointX = bullet.initialClipRect.x + majorTick.width / 2 + ((enableRtl) ? bullet.initialClipRect.width : 0);
for (var i = min; i <= max; i += interval) {
condition = (!bullet.enableRtl) ? (i === max) : (i === min);
if (condition) {
majorPointX -= majorTick.width / 2;
}
condition = (!bullet.enableRtl) ? (i === max) : (i === min);
if (bullet.majorTickLines.useRangeColor) {
strokeColor = this.bindingRangeStrokes(majorPointX - ((condition) ? this.bulletChart.majorTickLines.width / 2 : 0), size, this.bulletChart.orientation, bullet.enableRtl);
}
options = this.majorTicks(majorPointX, majorPointX, y1, y2, strokeColor, i);
var majorTicks = bullet.renderer.drawLine(options);
majorPointX = majorPointX + ((enableRtl ? -intervalValue : intervalValue));
tickGroup.appendChild(majorTicks);
scale.appendChild(tickGroup);
}
};
BulletChartAxis.prototype.renderYMajorTickLines = function (intervalValue, scale) {
var bulletChart = this.bulletChart;
var tickGroup = bulletChart.renderer.createGroup({ 'id': bulletChart.svgObject.id + '_majorTickGroup' });
var min = bulletChart.minimum;
var max = bulletChart.maximum;
var interval = bulletChart.interval;
var enableRtl = bulletChart.enableRtl;
var rect = bulletChart.initialClipRect;
var x1 = rect.x + ((!bulletChart.opposedPosition) ? 0 : rect.width);
var x2 = x1 - ((!bulletChart.opposedPosition) ? ((bulletChart.tickPosition !== 'Inside' ?
this.majorTickSize : -this.majorTickSize)) : ((bulletChart.tickPosition !== 'Inside'
? -this.majorTickSize : this.majorTickSize)));
var majorTick = bulletChart.majorTickLines;
var strokeColor = majorTick.color || bulletChart.themeStyle.majorTickLineColor;
var condition;
var options;
var size = rect.y + ((!bulletChart.enableRtl) ? rect.height : 0);
var majorPointY = rect.y + majorTick.width / 2 + ((!enableRtl) ? rect.height : 0);
for (var i = min; i <= max; i += interval) {
condition = (bulletChart.enableRtl) ? (i === max) : (i === min);
if (condition) {
majorPointY -= majorTick.width / 2;
}
condition = (!bulletChart.enableRtl) ? (i === max) : (i === min);
Iif (bulletChart.majorTickLines.useRangeColor) {
strokeColor = this.bindingRangeStrokes(majorPointY - ((condition) ? this.bulletChart.majorTickLines.width / 2 : 0), size, this.bulletChart.orientation, bulletChart.enableRtl);
}
options = this.majorTicks(x1, x2, majorPointY, majorPointY, strokeColor, i);
var majorTicks = bulletChart.renderer.drawLine(options);
majorPointY = majorPointY + ((!enableRtl ? -intervalValue : intervalValue));
tickGroup.appendChild(majorTicks);
scale.appendChild(tickGroup);
}
};
BulletChartAxis.prototype.majorTicks = function (x1, x2, y1, y2, strokeColor, i) {
var options = {
'id': this.bulletChart.svgObject.id + '_MajorTickLine_' + i,
'x1': x1,
'y1': y1,
'x2': x2,
'y2': y2,
'stroke-width': this.bulletChart.majorTickLines.width,
'stroke': (this.bulletChart.majorTickLines.useRangeColor && strokeColor) ? strokeColor :
this.bulletChart.majorTickLines.color || strokeColor
};
return options;
};
BulletChartAxis.prototype.bindingRangeStrokes = function (majorPointX, size, orientation, rtl) {
if ((orientation === 'Vertical' && !rtl) || (rtl && orientation === 'Horizontal')) {
return this.backwardStrokeBinding(majorPointX, size);
}
else {
return this.forwardStrokeBinding(majorPointX, size);
}
};
BulletChartAxis.prototype.renderXMinorTickLines = function (intervalValue, scaleGroup) {
var minorTickGroup = this.bulletChart.renderer.createGroup({ 'id': this.bulletChart.svgObject.id + '_minorTickGroup' });
var bullet = this.bulletChart;
var max = bullet.maximum;
var min = bullet.minimum;
var interval = bullet.interval;
var minorTick = bullet.minorTickLines.height;
var minorTicksPerInterval = this.bulletChart.minorTicksPerInterval;
var minorPointX;
var x;
var majorPointX = bullet.initialClipRect.x;
var y1 = bullet.initialClipRect.y + ((bullet.opposedPosition) ? 0 : bullet.initialClipRect.height);
var y2 = y1 + ((!bullet.opposedPosition) ? ((bullet.tickPosition !== 'Inside' ? minorTick : -minorTick)) :
((bullet.tickPosition !== 'Inside' ? -minorTick : minorTick)));
var strokeColor = bullet.minorTickLines.color || bullet.themeStyle.minorTickLineColor;
var options;
var minorTicks;
var size = bullet.initialClipRect.x + ((bullet.enableRtl) ? bullet.initialClipRect.width : 0);
for (var i = min; i < max; i += interval) {
minorPointX = intervalValue / minorTicksPerInterval;
for (var j = 1; j <= minorTicksPerInterval; j++) {
x = majorPointX + minorPointX - (minorPointX / (minorTicksPerInterval + 1));
if (bullet.minorTickLines.useRangeColor) {
strokeColor = this.bindingRangeStrokes(x, size, this.bulletChart.orientation, bullet.enableRtl);
}
options = this.minorXTicks(x, x, y1, y2, strokeColor, i.toString() + j.toString());
minorTicks = this.bulletChart.renderer.drawLine(options);
minorTickGroup.appendChild(minorTicks);
scaleGroup.appendChild(minorTickGroup);
minorPointX = (intervalValue / minorTicksPerInterval) * (j + 1);
}
majorPointX += intervalValue;
}
};
BulletChartAxis.prototype.renderYMinorTickLines = function (intervalValue, scaleGroup) {
var minorTickGroup = this.bulletChart.renderer.createGroup({ 'id': this.bulletChart.svgObject.id + '_minorTickGroup' });
var bulletChart = this.bulletChart;
var max = bulletChart.maximum;
var min = bulletChart.minimum;
var interval = bulletChart.interval;
var minorTick = bulletChart.minorTickLines.height;
var minorTicksPerInterval = this.bulletChart.minorTicksPerInterval;
var minorPointY;
var y;
var majorPointY = bulletChart.initialClipRect.y + ((!bulletChart.enableRtl) ? bulletChart.initialClipRect.height : 0);
var x1 = bulletChart.initialClipRect.x + ((!bulletChart.opposedPosition) ? 0 : bulletChart.initialClipRect.width);
var x2 = x1 - ((!bulletChart.opposedPosition) ? ((bulletChart.tickPosition !== 'Inside' ? minorTick : -minorTick)) :
((bulletChart.tickPosition !== 'Inside' ? -minorTick : minorTick)));
var strokeColor = bulletChart.minorTickLines.color || bulletChart.themeStyle.minorTickLineColor;
var options;
var minorTicks;
var size = bulletChart.initialClipRect.y + ((!bulletChart.enableRtl) ? bulletChart.initialClipRect.height : 0);
for (var i = min; i < max; i += interval) {
minorPointY = intervalValue / minorTicksPerInterval;
for (var j = 1; j <= minorTicksPerInterval; j++) {
if (!this.bulletChart.enableRtl) {
y = majorPointY - minorPointY + (minorPointY / (minorTicksPerInterval + 1));
}
else {
y = majorPointY + minorPointY - (minorPointY / (minorTicksPerInterval + 1));
}
Iif (bulletChart.minorTickLines.useRangeColor) {
strokeColor = this.bindingRangeStrokes(y, size, this.bulletChart.orientation, bulletChart.enableRtl);
}
options = this.minorXTicks(x1, x2, y, y, strokeColor, i.toString() + j.toString());
minorTicks = this.bulletChart.renderer.drawLine(options);
minorTickGroup.appendChild(minorTicks);
scaleGroup.appendChild(minorTickGroup);
minorPointY = (intervalValue / minorTicksPerInterval) * (j + 1);
}
majorPointY -= (this.bulletChart.enableRtl) ? -intervalValue : intervalValue;
}
};
BulletChartAxis.prototype.minorXTicks = function (x1, x2, y1, y2, strokeColor, i) {
var options = {
'id': this.bulletChart.svgObject.id + '_MajorTickLine_' + i,
'x1': x1,
'x2': x2,
'y1': y1,
'y2': y2,
'stroke-width': this.bulletChart.minorTickLines.width,
'stroke': (this.bulletChart.minorTickLines.useRangeColor && strokeColor) ? strokeColor :
this.bulletChart.minorTickLines.color || strokeColor
};
return options;
};
BulletChartAxis.prototype.forwardStrokeBinding = function (position, size) {
var bullet = this.bulletChart;
var previous = size;
for (var k = 0; k <= bullet.rangeCollection.length - 1; k++) {
previous += (!k) ? 0 : bullet.rangeCollection[k - 1];
if (position >= previous && position < previous + bullet.rangeCollection[k]) {
return bullet.ranges[k].color;
}
}
return null;
};
BulletChartAxis.prototype.backwardStrokeBinding = function (position, size) {
var bullet = this.bulletChart;
var previous = size;
for (var k = 0; k <= bullet.rangeCollection.length - 1; k++) {
previous -= (!k) ? 0 : bullet.rangeCollection[k - 1];
if (Math.round(position) >= Math.round(previous - bullet.rangeCollection[k]) && position <= previous) {
return bullet.ranges[k].color;
}
}
return null;
};
BulletChartAxis.prototype.renderXAxisLabels = function (intervalValue, scaleGroup) {
var axisLabelGroup = this.bulletChart.renderer.createGroup({ 'id': this.bulletChart.svgObject.id + '_axisLabelGroup' });
var text;
var bullet = this.bulletChart;
var locale = this.bulletChart.locale;
var padding = 5;
var enableRtl = bullet.enableRtl;
var tick = (((bullet.tickPosition === bullet.labelPosition) ? bullet.majorTickLines.height : 0) + padding * 2);
var y = bullet.initialClipRect.y + ((bullet.opposedPosition) ? ((bullet.labelPosition === 'Inside') ? tick : -tick)
: bullet.initialClipRect.height + ((bullet.labelPosition === 'Inside') ? -tick : tick));
var x = bullet.initialClipRect.x + ((enableRtl) ? bullet.initialClipRect.width : 0);
var min = bullet.minimum;
var max = bullet.maximum;
var interval = bullet.interval;
var localizedText = locale && this.bulletChart.enableGroupSeparator;
var format = this.getFormat(this.bulletChart);
var strokeColor = bullet.labelStyle.color || bullet.themeStyle.axisLabelFont.color;
var condition;
var isCustomFormat = format.match('{value}') !== null;
this.format = this.bulletChart.intl.getNumberFormat({
format: isCustomFormat ? '' : format, useGrouping: this.bulletChart.enableGroupSeparator
});
var size = bullet.initialClipRect.x + ((bullet.enableRtl) ? bullet.initialClipRect.width : 0);
y += ej2_svg_base_1.measureText(this.formatValue(this, isCustomFormat, format, this.bulletChart.maximum), bullet.labelStyle, this.bulletChart.themeStyle.axisLabelFont).height / 3;
for (var i = min; i <= max; i += interval) {
condition = (!bullet.enableRtl) ? (i === max) : (i === min);
if (bullet.labelStyle.useRangeColor) {
strokeColor = this.bindingRangeStrokes(x - ((condition) ? this.bulletChart.majorTickLines.width / 2 : 0), size, this.bulletChart.orientation, bullet.enableRtl);
}
text = localizedText ? i.toLocaleString(locale) : this.formatValue(this, isCustomFormat, format, i);
var labelOptions = this.labelXOptions(x, y, text, i);
this.bulletChart.labelStyle.fontFamily = this.bulletChart.labelStyle.fontFamily ||
this.bulletChart.themeStyle.axisLabelFont.fontFamily;
var label = ej2_svg_base_1.textElement(labelOptions, this.bulletChart.labelStyle, strokeColor, scaleGroup, this.bulletChart.themeStyle.axisLabelFont);
axisLabelGroup.appendChild(label);
x += (enableRtl) ? -intervalValue : intervalValue;
}
scaleGroup.appendChild(axisLabelGroup);
};
BulletChartAxis.prototype.labelXOptions = function (labelX, pointY, displayText, i) {
var labelOptions = {
'id': this.bulletChart.svgObject.id + '_AxisLabel_' + i,
'anchor': 'middle',
'text': displayText,
'transform': '',
'x': labelX,
'y': pointY,
'baseLine': '',
'labelRotation': 0
};
return labelOptions;
};
BulletChartAxis.prototype.renderYAxisLabels = function (intervalValue, scaleGroup) {
var axisLabelGroup = this.bulletChart.renderer.createGroup({ 'id': this.bulletChart.svgObject.id + '_axisLabelGroup' });
var text;
var bulletChart = this.bulletChart;
var locale = bulletChart.locale;
var padding = 5;
var enableRtl = bulletChart.enableRtl;
var tick = (((bulletChart.tickPosition === bulletChart.labelPosition) ?
bulletChart.majorTickLines.height : 0) + padding * 2);
var y = bulletChart.initialClipRect.y + ((!enableRtl) ? bulletChart.initialClipRect.height : 0);
var x = bulletChart.initialClipRect.x + ((!bulletChart.opposedPosition) ?
((bulletChart.labelPosition === 'Inside') ? (tick + padding * 2) : -tick)
: bulletChart.initialClipRect.width + ((bulletChart.labelPosition === 'Inside') ? -(tick + padding * 2) : tick));
var min = bulletChart.minimum;
var max = bulletChart.maximum;
var interval = bulletChart.interval;
var localizedText = locale && this.bulletChart.enableGroupSeparator;
var strokeColor = bulletChart.labelStyle.color || bulletChart.themeStyle.axisLabelFont.color;
var format = this.getFormat(this.bulletChart);
var isCustomFormat = format.match('{value}') !== null;
var condition;
this.format = this.bulletChart.intl.getNumberFormat({
format: isCustomFormat ? '' : format, useGrouping: this.bulletChart.enableGroupSeparator
});
var size = bulletChart.initialClipRect.y + ((!bulletChart.enableRtl) ? bulletChart.initialClipRect.height : 0);
var labelWidth = ej2_svg_base_1.measureText(this.formatValue(this, isCustomFormat, format, this.bulletChart.maximum), bulletChart.labelStyle, this.bulletChart.themeStyle.axisLabelFont).width / 2;
var height = ej2_svg_base_1.measureText(this.formatValue(this, isCustomFormat, format, this.bulletChart.maximum), bulletChart.labelStyle, this.bulletChart.themeStyle.axisLabelFont).height / 3;
y += height;
for (var i = min; i <= max; i += interval) {
condition = (bulletChart.enableRtl) ? (i === max) : (i === min);
Iif (bulletChart.labelStyle.useRangeColor) {
strokeColor = this.bindingRangeStrokes(y - height - ((condition) ? this.bulletChart.majorTickLines.width / 2 : 0), size, this.bulletChart.orientation, bulletChart.enableRtl);
}
text = localizedText ? i.toLocaleString(locale) : this.formatValue(this, isCustomFormat, format, i);
var labelOptions = this.labelXOptions(x - (!this.bulletChart.opposedPosition ? labelWidth : -labelWidth), y, text, i);
this.bulletChart.labelStyle.fontFamily = this.bulletChart.labelStyle.fontFamily ||
this.bulletChart.themeStyle.axisLabelFont.fontFamily;
var label = ej2_svg_base_1.textElement(labelOptions, this.bulletChart.labelStyle, strokeColor, scaleGroup, bulletChart.themeStyle.axisLabelFont);
axisLabelGroup.appendChild(label);
y += (!enableRtl) ? -intervalValue : intervalValue;
}
scaleGroup.appendChild(axisLabelGroup);
};
BulletChartAxis.prototype.getFormat = function (axis) {
if (axis.labelFormat) {
return axis.labelFormat;
}
return '';
};
BulletChartAxis.prototype.formatValue = function (axis, isCustom, format, tempInterval) {
return isCustom ? format.replace('{value}', axis.format(tempInterval))
: axis.format(tempInterval);
};
return BulletChartAxis;
}());
exports.BulletChartAxis = BulletChartAxis;
});
|