@syncfusion/ej2-maps 31.1.17 → 31.2.12

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.
Files changed (67) hide show
  1. package/README.md +11 -2
  2. package/dist/ej2-maps.min.js +3 -3
  3. package/dist/ej2-maps.umd.min.js +3 -3
  4. package/dist/ej2-maps.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-maps.es2015.js +84 -53
  6. package/dist/es6/ej2-maps.es2015.js.map +1 -1
  7. package/dist/es6/ej2-maps.es5.js +87 -56
  8. package/dist/es6/ej2-maps.es5.js.map +1 -1
  9. package/dist/global/ej2-maps.min.js +3 -3
  10. package/dist/global/ej2-maps.min.js.map +1 -1
  11. package/dist/global/index.d.ts +2 -2
  12. package/package.json +18 -53
  13. package/src/maps/layers/layer-panel.js +86 -55
  14. package/dist/ts/index.d.ts +0 -4
  15. package/dist/ts/index.ts +0 -4
  16. package/dist/ts/maps/index.d.ts +0 -28
  17. package/dist/ts/maps/index.ts +0 -28
  18. package/dist/ts/maps/layers/bing-map.d.ts +0 -21
  19. package/dist/ts/maps/layers/bing-map.ts +0 -51
  20. package/dist/ts/maps/layers/bubble.d.ts +0 -77
  21. package/dist/ts/maps/layers/bubble.ts +0 -304
  22. package/dist/ts/maps/layers/color-mapping.d.ts +0 -36
  23. package/dist/ts/maps/layers/color-mapping.ts +0 -230
  24. package/dist/ts/maps/layers/data-label.d.ts +0 -45
  25. package/dist/ts/maps/layers/data-label.ts +0 -457
  26. package/dist/ts/maps/layers/layer-panel.d.ts +0 -144
  27. package/dist/ts/maps/layers/layer-panel.ts +0 -1455
  28. package/dist/ts/maps/layers/legend.d.ts +0 -173
  29. package/dist/ts/maps/layers/legend.ts +0 -2465
  30. package/dist/ts/maps/layers/marker.d.ts +0 -105
  31. package/dist/ts/maps/layers/marker.ts +0 -632
  32. package/dist/ts/maps/layers/navigation-selected-line.d.ts +0 -33
  33. package/dist/ts/maps/layers/navigation-selected-line.ts +0 -171
  34. package/dist/ts/maps/layers/polygon.d.ts +0 -30
  35. package/dist/ts/maps/layers/polygon.ts +0 -68
  36. package/dist/ts/maps/maps-model.d.ts +0 -409
  37. package/dist/ts/maps/maps.d.ts +0 -1247
  38. package/dist/ts/maps/maps.ts +0 -3416
  39. package/dist/ts/maps/model/base-model.d.ts +0 -2107
  40. package/dist/ts/maps/model/base.d.ts +0 -1840
  41. package/dist/ts/maps/model/base.ts +0 -2257
  42. package/dist/ts/maps/model/constants.d.ts +0 -225
  43. package/dist/ts/maps/model/constants.ts +0 -226
  44. package/dist/ts/maps/model/export-image.d.ts +0 -39
  45. package/dist/ts/maps/model/export-image.ts +0 -194
  46. package/dist/ts/maps/model/export-pdf.d.ts +0 -40
  47. package/dist/ts/maps/model/export-pdf.ts +0 -183
  48. package/dist/ts/maps/model/interface.d.ts +0 -892
  49. package/dist/ts/maps/model/interface.ts +0 -929
  50. package/dist/ts/maps/model/print.d.ts +0 -45
  51. package/dist/ts/maps/model/print.ts +0 -125
  52. package/dist/ts/maps/model/theme.d.ts +0 -98
  53. package/dist/ts/maps/model/theme.ts +0 -919
  54. package/dist/ts/maps/user-interaction/annotation.d.ts +0 -27
  55. package/dist/ts/maps/user-interaction/annotation.ts +0 -133
  56. package/dist/ts/maps/user-interaction/highlight.d.ts +0 -63
  57. package/dist/ts/maps/user-interaction/highlight.ts +0 -272
  58. package/dist/ts/maps/user-interaction/selection.d.ts +0 -85
  59. package/dist/ts/maps/user-interaction/selection.ts +0 -342
  60. package/dist/ts/maps/user-interaction/tooltip.d.ts +0 -78
  61. package/dist/ts/maps/user-interaction/tooltip.ts +0 -500
  62. package/dist/ts/maps/user-interaction/zoom.d.ts +0 -334
  63. package/dist/ts/maps/user-interaction/zoom.ts +0 -2523
  64. package/dist/ts/maps/utils/enum.d.ts +0 -328
  65. package/dist/ts/maps/utils/enum.ts +0 -343
  66. package/dist/ts/maps/utils/helper.d.ts +0 -1318
  67. package/dist/ts/maps/utils/helper.ts +0 -3811
@@ -1,304 +0,0 @@
1
- import { Maps } from '../../index';
2
- import { BubbleSettingsModel, ColorMapping, IBubbleRenderingEventArgs, bubbleRendering } from '../index';
3
- import { IBubbleClickEventArgs, bubbleClick, LayerSettings, IBubbleMoveEventArgs, bubbleMouseMove } from '../index';
4
- import { isNullOrUndefined, animationMode } from '@syncfusion/ej2-base';
5
- import { CircleOption, MapLocation, findMidPointOfPolygon, Point, drawCircle, elementAnimate, getTranslate } from '../utils/helper';
6
- import { RectOption, Rect, drawRectangle, checkPropertyPath, getZoomTranslate, getRatioOfBubble, maintainSelection,
7
- getValueFromObject } from '../utils/helper';
8
- import { BorderModel } from '../model/base-model';
9
-
10
- /**
11
- * Bubble module class
12
- */
13
- export class Bubble {
14
- private maps: Maps;
15
- /** @private */
16
- public bubbleCollection: object[];
17
- /**
18
- * Bubble Id for current layer
19
- *
20
- * @private
21
- */
22
- public id: string = '';
23
- constructor(maps: Maps) {
24
- this.maps = maps;
25
- this.bubbleCollection = [];
26
- }
27
- /**
28
- * To render bubble
29
- *
30
- * @param {BubbleSettingsModel} bubbleSettings - Specifies the bubble data to be rendered
31
- * @param {object} shapeData - Specifies the data about the shape
32
- * @param {string} color - Specifies the color of the bubble
33
- * @param {number} range - Specifies the range of the bubble
34
- * @param {number} range.min - Specifies the minimum range of the bubble
35
- * @param {number} range.max - Specifies the maximum range of the bubble
36
- * @param {number} bubbleIndex - Specifies the index of the bubble
37
- * @param {number} dataIndex - Specifies the index of the data
38
- * @param {number} layerIndex - Specifies the index of the layer
39
- * @param {LayerSettings} layer - Specifies the layer data
40
- * @param {Element} group - Specifies the element group
41
- * @param {string} bubbleID - Specifies the ID of the bubble
42
- * @returns {void}
43
- * @private
44
- */
45
- public renderBubble(
46
- bubbleSettings: BubbleSettingsModel, shapeData: object, color: string, range: { min: number, max: number },
47
- bubbleIndex: number, dataIndex: number, layerIndex: number, layer: LayerSettings, group: Element, bubbleID? : string
48
- ): void {
49
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
- const layerData: any[] = layer.layerData; const colorValuePath: string = bubbleSettings.colorValuePath;
51
- const equalValue: string = (!isNullOrUndefined(colorValuePath)) ? ((colorValuePath.indexOf('.') > -1) ?
52
- (getValueFromObject(shapeData, bubbleSettings.colorValuePath)) : shapeData[colorValuePath as string]) :
53
- shapeData[colorValuePath as string];
54
- const colorValue: number = (!isNullOrUndefined(colorValuePath)) ? ((colorValuePath.indexOf('.') > -1) ?
55
- Number(getValueFromObject(shapeData, bubbleSettings.colorValuePath)) : Number(shapeData[colorValuePath as string])) :
56
- Number(shapeData[colorValuePath as string]);
57
- const bubbleValue: number = (!isNullOrUndefined(bubbleSettings.valuePath)) ? ((bubbleSettings.valuePath.indexOf('.') > -1) ?
58
- Number(getValueFromObject(shapeData, bubbleSettings.valuePath)) : Number(shapeData[bubbleSettings.valuePath])) :
59
- Number(shapeData[bubbleSettings.valuePath]);
60
- let opacity: number; let bubbleColor: string;
61
- if (isNaN(bubbleValue) && isNaN(colorValue) && isNullOrUndefined(equalValue)) {
62
- return null;
63
- }
64
- let radius: number = getRatioOfBubble(bubbleSettings.minRadius, bubbleSettings.maxRadius, bubbleValue, range.min, range.max);
65
- const colorMapping: ColorMapping = new ColorMapping(this.maps);
66
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
- const shapeColor: any = colorMapping.getColorByValue(bubbleSettings.colorMapping, colorValue, equalValue);
68
- // eslint-disable-next-line prefer-const
69
- bubbleColor = (Object.prototype.toString.call(shapeColor) === '[object Object]' &&
70
- !isNullOrUndefined(shapeColor['fill'])) ? shapeColor['fill'] : color;
71
- // eslint-disable-next-line prefer-const
72
- opacity = (Object.prototype.toString.call(shapeColor) === '[object Object]' &&
73
- !isNullOrUndefined(shapeColor['opacity'])) ? shapeColor['opacity'] : bubbleSettings.opacity;
74
- const shapePoints: [MapLocation[]] = [[]]; this.maps.translateType = 'bubble';
75
- let midIndex: number = 0; let pointsLength: number = 0; let currentLength: number = 0;
76
- for (let i: number = 0, len: number = layerData.length; i < len; i++) {
77
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
- let shape: any = layerData[i as number];
79
- shape = shape['property'];
80
- const shapePath: string = checkPropertyPath(shapeData[layer.shapeDataPath], layer.shapePropertyPath, shape);
81
- const shapeDataLayerPathValue: string = !isNullOrUndefined(shapeData[layer.shapeDataPath]) &&
82
- isNaN(shapeData[layer.shapeDataPath]) ? shapeData[layer.shapeDataPath].toLowerCase() : shapeData[layer.shapeDataPath];
83
- const shapePathValue: string = !isNullOrUndefined(shape[shapePath as string]) && isNaN(shape[shapePath as string])
84
- ? shape[shapePath as string].toLowerCase() : shape[shapePath as string];
85
- if (shapeDataLayerPathValue === shapePathValue && (layerData[i as number].type !== 'LineString' && layerData[i as number].type !== 'MultiLineString' && layerData[i as number]['type'] !== 'Point' && layerData[i as number]['type'] !== 'MultiPoint')) {
86
- if (!layerData[i as number]['_isMultiPolygon']) {
87
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
- shapePoints.push(this.getPoints(layerData[i as number] as any[], []));
89
- currentLength = shapePoints[shapePoints.length - 1].length;
90
- if (pointsLength < currentLength) {
91
- pointsLength = currentLength;
92
- midIndex = shapePoints.length - 1;
93
- }
94
-
95
- } else {
96
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
97
- const layer: any[] = <any[]>layerData[i as number];
98
- for (let j: number = 0; j < layer.length; j++) {
99
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
- shapePoints.push(this.getPoints(layer[j as number] as any[], []));
101
- currentLength = shapePoints[shapePoints.length - 1].length;
102
- if (pointsLength < currentLength) {
103
- pointsLength = currentLength;
104
- midIndex = shapePoints.length - 1;
105
- }
106
- }
107
- }
108
- }
109
- }
110
- const projectionType: string = this.maps.projectionType;
111
- let centerY: number; let eventArgs: IBubbleRenderingEventArgs;
112
- const bubbleBorder: BorderModel = {
113
- color: bubbleSettings.border.color, opacity: bubbleSettings.border.opacity,
114
- width: bubbleSettings.border.width
115
- };
116
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
117
- const center: any = findMidPointOfPolygon(shapePoints[midIndex as number], projectionType, layer.geometryType);
118
- if (bubbleSettings.visible) {
119
- if (!isNullOrUndefined(center)) {
120
- centerY = this.maps.projectionType === 'Mercator' ? center['y'] : (-center['y']);
121
- eventArgs = {
122
- cancel: false, name: bubbleRendering, border: bubbleBorder,
123
- cx: center['x'], cy: centerY, data: shapeData, fill: bubbleColor,
124
- maps: this.maps, radius: radius
125
- };
126
- } else {
127
- const shapePointsLength: number = shapePoints.length - 1;
128
- if (shapePoints[shapePointsLength as number]['x'] && shapePoints[shapePointsLength as number]['y']) {
129
- eventArgs = {
130
- cancel: false, name: bubbleRendering, border: bubbleBorder,
131
- cx: shapePoints[shapePointsLength as number]['x'], cy: shapePoints[shapePointsLength as number]['y'],
132
- data: shapeData, fill: bubbleColor, maps: this.maps,
133
- radius: radius
134
- };
135
- } else {
136
- return;
137
- }
138
- }
139
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
140
- this.maps.trigger('bubbleRendering', eventArgs, (bubbleArgs: IBubbleRenderingEventArgs) => {
141
- if (eventArgs.cancel) {
142
- return;
143
- }
144
- let bubbleElement: Element;
145
- eventArgs.border.opacity = isNullOrUndefined(eventArgs.border.opacity) ? opacity : eventArgs.border.opacity;
146
- if (bubbleSettings.bubbleType === 'Circle') {
147
- const circle: CircleOption = new CircleOption(
148
- bubbleID, eventArgs.fill, eventArgs.border, opacity,
149
- 0, 0, eventArgs.radius, null
150
- );
151
- bubbleElement = drawCircle(this.maps, circle, group);
152
- } else {
153
- const y: number = this.maps.projectionType === 'Mercator' ? (eventArgs.cy - radius) : (eventArgs.cy + radius);
154
- const rectangle: RectOption = new RectOption(
155
- bubbleID, eventArgs.fill, eventArgs.border, opacity,
156
- new Rect(0, 0, radius * 2, radius * 2), 2, 2
157
- );
158
- eventArgs.cx -= radius; eventArgs.cy = y;
159
- bubbleElement = drawRectangle(this.maps, rectangle, group);
160
- }
161
- maintainSelection(this.maps.selectedBubbleElementId, this.maps.bubbleSelectionClass, bubbleElement,
162
- 'BubbleselectionMapStyle');
163
- this.bubbleCollection.push({
164
- LayerIndex: layerIndex,
165
- BubbleIndex: bubbleIndex,
166
- DataIndex: dataIndex,
167
- element: bubbleElement,
168
- center: { x: eventArgs.cx, y: eventArgs.cy }
169
- });
170
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
171
- let translate: any;
172
- const animate: boolean = (layer.animationDuration !== 0 || animationMode === 'Enable') || isNullOrUndefined(this.maps.zoomModule);
173
- if (this.maps.zoomSettings.zoomFactor > 1 && !isNullOrUndefined(this.maps.zoomModule) && !this.maps.isTileMap) {
174
- translate = getZoomTranslate(this.maps, layer, animate);
175
- } else {
176
- translate = getTranslate(this.maps, layer, animate);
177
- }
178
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
179
- const bubbleDataSource: any[] = bubbleSettings.dataSource as any[];
180
- const scale: number = translate['scale']; const transPoint: Point = translate['location'] as Point;
181
- const position: MapLocation = new MapLocation(
182
- (this.maps.isTileMap ? ((eventArgs.cx + this.maps.translatePoint.x) * this.maps.tileZoomLevel)
183
- : ((eventArgs.cx + transPoint.x) * scale)),
184
- (this.maps.isTileMap ? ((eventArgs.cy + this.maps.translatePoint.y) * this.maps.tileZoomLevel)
185
- : ((eventArgs.cy + transPoint.y) * scale)));
186
- bubbleElement.setAttribute('transform', 'translate( ' + (position.x) + ' ' + (position.y) + ' )');
187
- const bubble: string = (bubbleDataSource.length - 1) === dataIndex ? 'bubble' : null;
188
- if (bubbleSettings.bubbleType === 'Square') {
189
- position.x += radius;
190
- position.y += radius * (this.maps.projectionType === 'Mercator' ? 1 : -1);
191
- } else {
192
- radius = 0;
193
- }
194
- if (bubbleSettings.animationDuration > 0 || animationMode === 'Enable') {
195
- elementAnimate(
196
- bubbleElement, bubbleSettings.animationDelay, bubbleSettings.animationDuration, position, this.maps, bubble, radius
197
- );
198
- }
199
- });
200
- }
201
- }
202
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
203
- private getPoints(shape: any[], points: MapLocation[]): MapLocation[] {
204
- if (isNullOrUndefined(shape.map)) {
205
- points = shape['point'];
206
- } else {
207
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
208
- shape.map((current: any) => {
209
- points.push(new Point(current['point']['x'], current['point']['y']));
210
- });
211
- }
212
- return points;
213
- }
214
-
215
- /**
216
- * To check and trigger bubble click event.
217
- *
218
- * @param {PointerEvent} e - Specifies the pointer event argument.
219
- * @returns {void}
220
- * @private
221
- */
222
- public bubbleClick(e: PointerEvent): void {
223
- const target: string = (e.target as Element).id;
224
- if (target.indexOf('_LayerIndex_') === -1) {
225
- return;
226
- }
227
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
228
- const data: any = this.getbubble(target);
229
- if (isNullOrUndefined(data)) {
230
- return;
231
- }
232
- const eventArgs: IBubbleClickEventArgs = {
233
- cancel: false, name: bubbleClick, data: data, maps: this.maps,
234
- target: target, x: e.clientX, y: e.clientY
235
- };
236
- this.maps.trigger(bubbleClick, eventArgs);
237
- }
238
- /**
239
- * To get bubble from target id.
240
- *
241
- * @param {string} target - Specifies the target
242
- * @returns {object} - Returns the object
243
- */
244
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
245
- private getbubble(target: string): any {
246
- const id: string[] = target.split('_LayerIndex_');
247
- const index: number = parseInt(id[1].split('_')[0], 10);
248
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
249
- let data: any;
250
- if (target.indexOf('_BubbleIndex_') > -1) {
251
- const layer: LayerSettings = <LayerSettings>this.maps.layers[index as number];
252
- const bubbleIndex: number = parseInt(id[1].split('_BubbleIndex_')[1], 10);
253
- const dataIndex: number = parseInt(id[1].split('_BubbleIndex_')[1].split('_dataIndex_')[1], 10);
254
- if (!isNaN(bubbleIndex as number)) {
255
- data = layer.bubbleSettings[bubbleIndex as number].dataSource[dataIndex as number];
256
- return data;
257
- }
258
- }
259
- return null;
260
- }
261
- // eslint-disable-next-line valid-jsdoc
262
- /**
263
- * To check and trigger bubble move event.
264
- *
265
- * @param {PointerEvent} e - Specifies the pointer event argument.
266
- * @retruns {void}
267
- * @private
268
- */
269
- public bubbleMove(e: PointerEvent): void {
270
- const target: string = (e.target as Element).id;
271
- if (target.indexOf('_LayerIndex_') === -1) {
272
- return;
273
- }
274
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
275
- const data: any = this.getbubble(target);
276
- if (isNullOrUndefined(data)) {
277
- return;
278
- }
279
- const eventArgs: IBubbleMoveEventArgs = {
280
- cancel: false, name: bubbleMouseMove, data: data, maps: this.maps,
281
- target: target, x: e.clientX, y: e.clientY
282
- };
283
- this.maps.trigger(bubbleMouseMove, eventArgs);
284
- }
285
- /**
286
- * Get module name.
287
- *
288
- * @returns {string} - Returns the module name.
289
- */
290
- protected getModuleName(): string {
291
- return 'Bubble';
292
- }
293
-
294
- /**
295
- * To destroy the bubble.
296
- *
297
- * @returns {void}
298
- * @private
299
- */
300
- public destroy(): void {
301
- this.bubbleCollection = [];
302
- this.maps = null;
303
- }
304
- }
@@ -1,36 +0,0 @@
1
- import { Maps } from '../../index';
2
- import { ShapeSettingsModel, ColorMappingSettingsModel, ColorValue } from '../index';
3
- /**
4
- * ColorMapping class
5
- */
6
- export declare class ColorMapping {
7
- constructor(maps: Maps);
8
- /**
9
- * To get color based on shape settings.
10
- *
11
- * @param { ShapeSettingsModel } shapeSettings - Specifies the shape settings.
12
- * @param { object } layerData - Specifies the layer data.
13
- * @param { string } color - Specifies the color.
14
- * @returns {object} - Returns the object.
15
- * @private
16
- */
17
- getShapeColorMapping(shapeSettings: ShapeSettingsModel, layerData: object, color: string): any;
18
- /**
19
- * To color by value and color mapping.
20
- *
21
- * @param {ColorMappingSettingsModel[]} colorMapping - Specifies the color mapping instance.
22
- * @param {number} colorValue - Specifies the color value
23
- * @param {string} equalValue - Specifies the equal value.
24
- * @returns {any} - Returns the color mapping values.
25
- * @private
26
- */
27
- getColorByValue(colorMapping: ColorMappingSettingsModel[], colorValue: number, equalValue: string): any;
28
- deSaturationColor(colorMapping: ColorMappingSettingsModel, color: string, rangeValue: number, equalValue: string): number;
29
- rgbToHex(r: number, g: number, b: number): string;
30
- componentToHex(value: number): string;
31
- getColor(colorMap: ColorMappingSettingsModel, value: number): string;
32
- getGradientColor(value: number, colorMap: ColorMappingSettingsModel): ColorValue;
33
- getPercentageColor(percent: number, previous: string, next: string): ColorValue;
34
- getPercentage(percent: number, previous: number, next: number): number;
35
- _colorNameToHex(color: string): string;
36
- }
@@ -1,230 +0,0 @@
1
- import { Maps } from '../../index';
2
- import { ShapeSettingsModel, ColorMappingSettingsModel, ColorValue } from '../index';
3
- import { isNullOrUndefined } from '@syncfusion/ej2-base';
4
- import { getValueFromObject } from '../utils/helper';
5
-
6
- /**
7
- * ColorMapping class
8
- */
9
- export class ColorMapping {
10
- /* eslint-disable @typescript-eslint/no-unused-vars */
11
- /* eslint-disable @typescript-eslint/no-empty-function */
12
- constructor(maps: Maps) {
13
- }
14
- /* eslint-enable @typescript-eslint/no-unused-vars */
15
- /* eslint-enable @typescript-eslint/no-empty-function */
16
- /**
17
- * To get color based on shape settings.
18
- *
19
- * @param { ShapeSettingsModel } shapeSettings - Specifies the shape settings.
20
- * @param { object } layerData - Specifies the layer data.
21
- * @param { string } color - Specifies the color.
22
- * @returns {object} - Returns the object.
23
- * @private
24
- */
25
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
- public getShapeColorMapping(shapeSettings: ShapeSettingsModel, layerData: object, color: string): any {
27
- const colorValuePath: string = shapeSettings.colorValuePath ? shapeSettings.colorValuePath : shapeSettings.valuePath;
28
- const equalValue: string = (!isNullOrUndefined(colorValuePath)) ? ((colorValuePath.indexOf('.') > -1) ?
29
- getValueFromObject(layerData, colorValuePath) : layerData[colorValuePath as string]) : layerData[colorValuePath as string];
30
- const colorValue: number = Number(equalValue);
31
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
- const shapeColor: any = this.getColorByValue(shapeSettings.colorMapping, colorValue, equalValue);
33
- return !isNullOrUndefined(shapeColor) ? shapeColor : color;
34
- }
35
- /**
36
- * To color by value and color mapping.
37
- *
38
- * @param {ColorMappingSettingsModel[]} colorMapping - Specifies the color mapping instance.
39
- * @param {number} colorValue - Specifies the color value
40
- * @param {string} equalValue - Specifies the equal value.
41
- * @returns {any} - Returns the color mapping values.
42
- * @private
43
- */
44
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
- public getColorByValue(colorMapping: ColorMappingSettingsModel[], colorValue: number, equalValue: string): any {
46
- if (isNaN(colorValue) && isNullOrUndefined(equalValue)) {
47
- return null;
48
- }
49
- let fill: string = ''; let opacity: number; let gradientFill: string;
50
- for (const colorMap of colorMapping) {
51
-
52
- if ((!isNullOrUndefined(colorMap.from) && !isNullOrUndefined(colorMap.to)
53
- && (colorValue >= colorMap.from && colorValue <= colorMap.to)) ||
54
- (colorMap.value === equalValue)) {
55
- if (Object.prototype.toString.call(colorMap.color) === '[object Array]') {
56
- if (!isNullOrUndefined(colorMap.value)) {
57
- fill = colorMap.color[0];
58
- } else {
59
- gradientFill = this.getColor(colorMap, colorValue);
60
- fill = gradientFill;
61
- }
62
- } else {
63
- fill = <string>colorMap.color;
64
- }
65
- }
66
- if (((colorValue >= colorMap.from && colorValue <= colorMap.to) || (colorMap.value === equalValue))
67
- && (!isNullOrUndefined(colorMap.minOpacity) && !isNullOrUndefined(colorMap.maxOpacity) && fill)) {
68
- opacity = this.deSaturationColor(colorMap, fill, colorValue, equalValue);
69
- }
70
- if ((fill === '' || isNullOrUndefined(fill)) && isNullOrUndefined(colorMap.from) && isNullOrUndefined(colorMap.to)
71
- && isNullOrUndefined(colorMap.minOpacity) && isNullOrUndefined(colorMap.maxOpacity) && isNullOrUndefined(colorMap.value)) {
72
- fill = Object.prototype.toString.call(colorMap.color) === '[object Array]' ? colorMap.color[0] : <string>colorMap.color;
73
- }
74
- }
75
- return { fill: fill || ((!colorMapping.length) ? equalValue : null), opacity: opacity };
76
- }
77
-
78
- public deSaturationColor(
79
- colorMapping: ColorMappingSettingsModel, color: string,
80
- rangeValue: number, equalValue: string): number {
81
- let opacity: number = 1;
82
- if (((rangeValue >= colorMapping.from && rangeValue <= colorMapping.to) || colorMapping.value === equalValue)) {
83
- const ratio: number = !isNaN(rangeValue) ? (rangeValue - colorMapping.from) / (colorMapping.to - colorMapping.from) :
84
- colorMapping.from / (colorMapping.to - colorMapping.from);
85
- opacity = (ratio * (colorMapping.maxOpacity - colorMapping.minOpacity)) + colorMapping.minOpacity;
86
- }
87
- return opacity;
88
- }
89
-
90
- public rgbToHex(r: number, g: number, b: number): string {
91
- return '#' + this.componentToHex(r) + this.componentToHex(g) + this.componentToHex(b);
92
- }
93
-
94
- public componentToHex(value: number): string {
95
- const hex: string = value.toString(16);
96
- return hex.length === 1 ? '0' + hex : hex;
97
- }
98
-
99
- public getColor(colorMap: ColorMappingSettingsModel, value: number): string {
100
- let color: string = '';
101
- let rbg: ColorValue;
102
- if (Number(value) === colorMap.from) {
103
- color = colorMap.color[0];
104
- } else if (Number(value) === colorMap.to) {
105
- color = colorMap.color[colorMap.color.length - 1];
106
- } else {
107
- rbg = this.getGradientColor(Number(value), colorMap);
108
- color = this.rgbToHex(rbg.r, rbg.g, rbg.b);
109
- }
110
- return color;
111
- }
112
-
113
- public getGradientColor(value: number, colorMap: ColorMappingSettingsModel): ColorValue {
114
- const previousOffset: number = colorMap.from;
115
- const nextOffset: number = colorMap.to;
116
- let percent: number = 0;
117
- const full: number = nextOffset - previousOffset; let midColor: string;
118
- percent = (value - previousOffset) / full; let previousColor: string; let nextColor: string;
119
- if (colorMap.color.length <= 2) {
120
- previousColor = colorMap.color[0].charAt(0) === '#' ? colorMap.color[0] : this._colorNameToHex(colorMap.color[0]);
121
- nextColor = colorMap.color[colorMap.color.length - 1].charAt(0) === '#' ?
122
- colorMap.color[colorMap.color.length - 1] : this._colorNameToHex(colorMap.color[colorMap.color.length - 1]);
123
- } else {
124
- previousColor = colorMap.color[0].charAt(0) === '#' ? colorMap.color[0] : this._colorNameToHex(colorMap.color[0]);
125
- nextColor = colorMap.color[colorMap.color.length - 1].charAt(0) === '#' ?
126
- colorMap.color[colorMap.color.length - 1] : this._colorNameToHex(colorMap.color[colorMap.color.length - 1]);
127
- const a: number = full / (colorMap.color.length - 1); let b: number; let c: number;
128
-
129
- const length: number = colorMap.color.length - 1;
130
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
131
- const splitColorValueOffset: any[] = []; let splitColor: any = {};
132
- for (let j: number = 1; j < length; j++) {
133
- c = j * a;
134
- b = previousOffset + c;
135
- splitColor = { b: b, color: colorMap.color[j as number] };
136
- splitColorValueOffset.push(splitColor);
137
- }
138
- for (let i: number = 0; i < splitColorValueOffset.length; i++) {
139
- if (previousOffset <= value && value <= splitColorValueOffset[i as number]['b'] && i === 0) {
140
- midColor = splitColorValueOffset[i as number]['color'].charAt(0) === '#' ?
141
- splitColorValueOffset[i as number]['color'] : this._colorNameToHex(splitColorValueOffset[i as number]['color']);
142
- nextColor = midColor;
143
- percent = value < splitColorValueOffset[i as number]['b'] ? 1 - Math.abs((value - splitColorValueOffset[i as number]['b']) / a)
144
- : (value - splitColorValueOffset[i as number]['b']) / a;
145
- } else if (splitColorValueOffset[i as number]['b'] <= value && value <= nextOffset && i === (splitColorValueOffset.length - 1)) {
146
- midColor = splitColorValueOffset[i as number]['color'].charAt(0) === '#' ?
147
- splitColorValueOffset[i as number]['color'] : this._colorNameToHex(splitColorValueOffset[i as number]['color']);
148
- previousColor = midColor;
149
- percent = value < splitColorValueOffset[i as number]['b'] ?
150
- 1 - Math.abs((value - splitColorValueOffset[i as number]['b']) / a) : (value - splitColorValueOffset[i as number]['b']) / a;
151
- }
152
- if (i !== splitColorValueOffset.length - 1 && i < splitColorValueOffset.length) {
153
- if (splitColorValueOffset[i as number]['b'] <= value && value <= splitColorValueOffset[i + 1]['b']) {
154
- midColor = splitColorValueOffset[i as number]['color'].charAt(0) === '#' ?
155
- splitColorValueOffset[i as number]['color'] : this._colorNameToHex(splitColorValueOffset[i as number]['color']);
156
- previousColor = midColor;
157
- nextColor = splitColorValueOffset[i + 1]['color'].charAt(0) === '#' ?
158
- splitColorValueOffset[i + 1]['color'] : this._colorNameToHex(splitColorValueOffset[i + 1]['color']);
159
- percent = Math.abs((value - splitColorValueOffset[i + 1]['b'])) / a;
160
- }
161
- }
162
- }
163
- }
164
- return this.getPercentageColor(percent, previousColor, nextColor);
165
- }
166
-
167
- public getPercentageColor(percent: number, previous: string, next: string): ColorValue {
168
- const nextColor: string = next.split('#')[1];
169
- const prevColor: string = previous.split('#')[1];
170
- const r: number = this.getPercentage(percent, parseInt(prevColor.substr(0, 2), 16), parseInt(nextColor.substr(0, 2), 16));
171
- const g: number = this.getPercentage(percent, parseInt(prevColor.substr(2, 2), 16), parseInt(nextColor.substr(2, 2), 16));
172
- const b: number = this.getPercentage(percent, parseInt(prevColor.substr(4, 2), 16), parseInt(nextColor.substr(4, 2), 16));
173
- return new ColorValue(r, g, b);
174
- }
175
-
176
- public getPercentage(percent: number, previous: number, next: number): number {
177
- const full: number = next - previous;
178
- return Math.round((previous + (full * percent)));
179
- }
180
-
181
- public _colorNameToHex(color: string): string {
182
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
183
- const colors: any = {
184
- 'aliceblue': '#f0f8ff', 'antiquewhite': '#faebd7', 'aqua': '#00ffff', 'aquamarine': '#7fffd4', 'azure': '#f0ffff',
185
- 'beige': '#f5f5dc', 'bisque': '#ffe4c4', 'black': '#000000', 'blanchedalmond': '#ffebcd', 'blue': '#0000ff',
186
- 'blueviolet': '#8a2be2', 'brown': '#a52a2a', 'burlywood': '#deb887',
187
- 'cadetblue': '#5f9ea0', 'chartreuse': '#7fff00', 'chocolate': '#d2691e', 'coral': '#ff7f50',
188
- 'cornflowerblue': '#6495ed', 'cornsilk': '#fff8dc', 'crimson': '#dc143c', 'cyan': '#00ffff',
189
- 'darkblue': '#00008b', 'darkcyan': '#008b8b', 'darkgoldenrod': '#b8860b', 'darkgray': '#a9a9a9', 'darkgreen': '#006400',
190
- 'darkkhaki': '#bdb76b', 'darkmagenta': '#8b008b', 'darkolivegreen': '#556b2f',
191
- 'darkorange': '#ff8c00', 'darkorchid': '#9932cc', 'darkred': '#8b0000', 'darksalmon': '#e9967a', 'darkseagreen': '#8fbc8f',
192
- 'darkslateblue': '#483d8b', 'darkslategray': '#2f4f4f', 'darkturquoise': '#00ced1',
193
- 'darkviolet': '#9400d3', 'deeppink': '#ff1493', 'deepskyblue': '#00bfff', 'dimgray': '#696969', 'dodgerblue': '#1e90ff',
194
- 'firebrick': '#b22222', 'floralwhite': '#fffaf0', 'forestgreen': '#228b22', 'fuchsia': '#ff00ff',
195
- 'gainsboro': '#dcdcdc', 'ghostwhite': '#f8f8ff', 'gold': '#ffd700', 'goldenrod': '#daa520', 'gray': '#808080',
196
- 'green': '#008000', 'greenyellow': '#adff2f',
197
- 'honeydew': '#f0fff0', 'hotpink': '#ff69b4',
198
- 'indianred ': '#cd5c5c', 'indigo ': '#4b0082', 'ivory': '#fffff0', 'khaki': '#f0e68c',
199
- 'lavender': '#e6e6fa', 'lavenderblush': '#fff0f5', 'lawngreen': '#7cfc00', 'lemonchiffon': '#fffacd', 'lightblue': '#add8e6',
200
- 'lightcoral': '#f08080', 'lightcyan': '#e0ffff', 'lightgoldenrodyellow': '#fafad2',
201
- 'lightgrey': '#d3d3d3', 'lightgreen': '#90ee90', 'lightpink': '#ffb6c1', 'lightsalmon': '#ffa07a', 'lightseagreen': '#20b2aa',
202
- 'lightskyblue': '#87cefa', 'lightslategray': '#778899', 'lightsteelblue': '#b0c4de',
203
- 'lightyellow': '#ffffe0', 'lime': '#00ff00', 'limegreen': '#32cd32', 'linen': '#faf0e6',
204
- 'magenta': '#ff00ff', 'maroon': '#800000', 'mediumaquamarine': '#66cdaa', 'mediumblue': '#0000cd', 'mediumorchid': '#ba55d3',
205
- 'mediumpurple': '#9370d8', 'mediumseagreen': '#3cb371', 'mediumslateblue': '#7b68ee',
206
- 'mediumspringgreen': '#00fa9a', 'mediumturquoise': '#48d1cc', 'mediumvioletred': '#c71585', 'midnightblue': '#191970',
207
- 'mintcream': '#f5fffa', 'mistyrose': '#ffe4e1', 'moccasin': '#ffe4b5',
208
- 'navajowhite': '#ffdead', 'navy': '#000080', 'orchid': '#da70d6', 'papayawhip': '#ffefd5',
209
- 'oldlace': '#fdf5e6', 'olive': '#808000', 'olivedrab': '#6b8e23', 'orange': '#ffa500', 'orangered': '#ff4500',
210
- 'palegoldenrod': '#eee8aa', 'palegreen': '#98fb98', 'paleturquoise': '#afeeee', 'palevioletred': '#d87093',
211
- 'peachpuff': '#ffdab9', 'peru': '#cd853f', 'pink': '#ffc0cb', 'plum': '#dda0dd', 'powderblue': '#b0e0e6', 'purple': '#800080',
212
- 'red': '#ff0000', 'rosybrown': '#bc8f8f', 'royalblue': '#4169e1',
213
- 'saddlebrown': '#8b4513', 'salmon': '#fa8072', 'sandybrown': '#f4a460', 'seagreen': '#2e8b57', 'seashell': '#fff5ee',
214
- 'sienna': '#a0522d', 'silver': '#c0c0c0', 'skyblue': '#87ceeb', 'slateblue': '#6a5acd',
215
- 'slategray': '#708090', 'snow': '#fffafa', 'springgreen': '#00ff7f', 'steelblue': '#4682b4',
216
- 'tan': '#d2b48c', 'teal': '#008080', 'thistle': '#d8bfd8', 'tomato': '#ff6347', 'turquoise': '#40e0d0',
217
- 'violet': '#ee82ee',
218
- 'wheat': '#f5deb3', 'white': '#ffffff', 'whitesmoke': '#f5f5f5',
219
- 'yellow': '#ffff00', 'yellowgreen': '#9acd32'
220
- };
221
- if (Object.prototype.toString.call(color) === '[object Array]') {
222
- return color;
223
- }
224
- if (typeof colors[color.toLowerCase()] !== 'undefined') {
225
- return colors[color.toLowerCase()];
226
- }
227
-
228
- return color;
229
- }
230
- }
@@ -1,45 +0,0 @@
1
- import { Maps } from '../../index';
2
- import { LayerSettings } from '../index';
3
- /**
4
- * DataLabel Module used to render the maps datalabel
5
- */
6
- export declare class DataLabel {
7
- private maps;
8
- /**
9
- * Datalabel collections
10
- *
11
- * @private
12
- */
13
- dataLabelCollections: any[];
14
- private value;
15
- constructor(maps: Maps);
16
- private getDataLabel;
17
- /**
18
- * To render label for maps.
19
- *
20
- * @param {LayerSettings} layer - Specifies the layer settings
21
- * @param {number} layerIndex - Specifies the layer index.
22
- * @param {object} shape - Specifies the shape.
23
- * @param {any[]} layerData - Specifies the layer data.
24
- * @param {Element} group Specifies the element.
25
- * @param {HTMLElement} labelTemplateElement - Specifies the template element.
26
- * @param {number} index - Specifies the index number.
27
- * @param {any[]} intersect - Specifies the intersect.
28
- * @returns {void}
29
- * @private
30
- */
31
- renderLabel(layer: LayerSettings, layerIndex: number, shape: object, layerData: any[], group: Element, labelTemplateElement: HTMLElement, index: number, intersect: any[]): void;
32
- private datalabelAnimate;
33
- private getPoint;
34
- /**
35
- * Get module name.
36
- *
37
- * @returns {string} - Returns the module name.
38
- */
39
- protected getModuleName(): string;
40
- /**
41
- * @returns {void}
42
- * @private
43
- */
44
- destroy(): void;
45
- }