@progress/kendo-charts 1.21.0 → 1.23.0-dev.202201120958

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 (68) hide show
  1. package/dist/cdn/js/kendo-charts.js +1 -1
  2. package/dist/cdn/main.js +1 -1
  3. package/dist/es/barcode/barcode-validator.js +50 -0
  4. package/dist/es/barcode.js +1 -0
  5. package/dist/es/common/keys.js +25 -0
  6. package/dist/es/common.js +1 -0
  7. package/dist/es/drawing-utils.js +27 -3
  8. package/dist/es/main.js +1 -0
  9. package/dist/es/map/attribution.js +157 -0
  10. package/dist/es/map/crs.js +277 -0
  11. package/dist/es/map/datums.js +16 -0
  12. package/dist/es/map/extent.js +129 -0
  13. package/dist/es/map/layers/bubble.js +185 -0
  14. package/dist/es/map/layers/layer.js +140 -0
  15. package/dist/es/map/layers/marker.js +348 -0
  16. package/dist/es/map/layers/shape.js +390 -0
  17. package/dist/es/map/layers/tile.js +481 -0
  18. package/dist/es/map/location.js +201 -0
  19. package/dist/es/map/map.js +929 -0
  20. package/dist/es/map/navigator.js +174 -0
  21. package/dist/es/map/scroller/draggable.js +454 -0
  22. package/dist/es/map/scroller/fx.js +119 -0
  23. package/dist/es/map/scroller/observable.js +151 -0
  24. package/dist/es/map/scroller/scroller.js +746 -0
  25. package/dist/es/map/scroller/user-events.js +712 -0
  26. package/dist/es/map/utils.js +450 -0
  27. package/dist/es/map/zoom.js +139 -0
  28. package/dist/es/map.js +1 -0
  29. package/dist/es/qrcode/qrcode-validator.js +24 -0
  30. package/dist/es/qrcode.js +1 -0
  31. package/dist/es/services/map-service.js +15 -0
  32. package/dist/es2015/barcode/barcode-validator.js +48 -0
  33. package/dist/es2015/barcode.js +1 -0
  34. package/dist/es2015/common/keys.js +25 -0
  35. package/dist/es2015/common.js +1 -0
  36. package/dist/es2015/drawing-utils.js +43 -3
  37. package/dist/es2015/main.js +1 -0
  38. package/dist/es2015/map/attribution.js +147 -0
  39. package/dist/es2015/map/crs.js +233 -0
  40. package/dist/es2015/map/datums.js +16 -0
  41. package/dist/es2015/map/extent.js +115 -0
  42. package/dist/es2015/map/layers/bubble.js +167 -0
  43. package/dist/es2015/map/layers/layer.js +134 -0
  44. package/dist/es2015/map/layers/marker.js +328 -0
  45. package/dist/es2015/map/layers/shape.js +370 -0
  46. package/dist/es2015/map/layers/tile.js +455 -0
  47. package/dist/es2015/map/location.js +193 -0
  48. package/dist/es2015/map/map.js +905 -0
  49. package/dist/es2015/map/navigator.js +169 -0
  50. package/dist/es2015/map/scroller/draggable.js +418 -0
  51. package/dist/es2015/map/scroller/fx.js +112 -0
  52. package/dist/es2015/map/scroller/observable.js +143 -0
  53. package/dist/es2015/map/scroller/scroller.js +716 -0
  54. package/dist/es2015/map/scroller/user-events.js +694 -0
  55. package/dist/es2015/map/utils.js +450 -0
  56. package/dist/es2015/map/zoom.js +134 -0
  57. package/dist/es2015/map.js +1 -0
  58. package/dist/es2015/qrcode/qrcode-validator.js +22 -0
  59. package/dist/es2015/qrcode.js +1 -0
  60. package/dist/es2015/services/map-service.js +15 -0
  61. package/dist/npm/barcode.d.ts +4 -1
  62. package/dist/npm/main.d.ts +2 -0
  63. package/dist/npm/main.js +6227 -329
  64. package/dist/npm/map.d.ts +4 -0
  65. package/dist/npm/qrcode.d.ts +3 -0
  66. package/dist/npm/validation.d.ts +9 -0
  67. package/dist/systemjs/kendo-charts.js +1 -1
  68. package/package.json +3 -3
@@ -0,0 +1,370 @@
1
+ import {
2
+ geometry as g,
3
+ drawing as d
4
+ } from '@progress/kendo-drawing';
5
+
6
+ import {
7
+ Class,
8
+ defined,
9
+ last,
10
+ setDefaultOptions
11
+ } from '../../common';
12
+
13
+ import {
14
+ proxy
15
+ } from '../utils';
16
+
17
+ import {
18
+ Layer
19
+ } from './layer';
20
+
21
+ import {
22
+ Movable
23
+ } from '../scroller/draggable';
24
+
25
+ import {
26
+ Location
27
+ } from '../location';
28
+
29
+ const Group = d.Group;
30
+
31
+ export class ShapeLayer extends Layer {
32
+ constructor(map, options) {
33
+ super(map, options);
34
+
35
+ this._pan = proxy(this._pan, this);
36
+
37
+ this.surface = d.Surface.create(this.element, {
38
+ width: map.scrollElement.clientWidth,
39
+ height: map.scrollElement.clientHeight
40
+ });
41
+
42
+ this._initRoot();
43
+ this.movable = new Movable(this.surface.element);
44
+ this._markers = [];
45
+
46
+ this._click = this._handler('shapeClick');
47
+ this.surface.bind('click', this._click);
48
+ this._mouseenter = this._handler('shapeMouseEnter');
49
+ this.surface.bind('mouseenter', this._mouseenter);
50
+ this._mouseleave = this._handler('shapeMouseLeave');
51
+ this.surface.bind('mouseleave', this._mouseleave);
52
+ }
53
+
54
+ destroy() {
55
+ super.destroy();
56
+
57
+ this.surface.destroy();
58
+ this.dataSource.unbind('change', this._dataChange);
59
+ }
60
+
61
+ _reset() {
62
+ super._reset();
63
+
64
+ this._translateSurface();
65
+
66
+ this._data = this._readData();
67
+
68
+ if (this._hasData()) {
69
+ this._load(this._data);
70
+ }
71
+ }
72
+
73
+ _initRoot() {
74
+ this._root = new Group();
75
+ this.surface.draw(this._root);
76
+ }
77
+
78
+ _beforeReset() {
79
+ this.surface.clear();
80
+ this._initRoot();
81
+ }
82
+
83
+ _resize() {
84
+ this.surface.size(this.map.size());
85
+ }
86
+
87
+ _readData() {
88
+ const data = super._readData();
89
+
90
+ if (data.type === "FeatureCollection") {
91
+ return data.features;
92
+ }
93
+
94
+ if (data.type === "GeometryCollection") {
95
+ return data.geometries;
96
+ }
97
+
98
+ return data;
99
+ }
100
+
101
+ _load(data) {
102
+ this._data = data;
103
+ this._clearMarkers();
104
+
105
+ if (!this._loader) {
106
+ this._loader = new GeoJsonLoader(this.map, this.options.style, this);
107
+ }
108
+
109
+ let container = new Group();
110
+
111
+ for (let i = 0; i < data.length; i++) {
112
+ let shape = this._loader.parse(data[i]);
113
+
114
+ if (shape) {
115
+ container.append(shape);
116
+ }
117
+ }
118
+
119
+ this._root.clear();
120
+ this._root.append(container);
121
+ }
122
+
123
+ shapeCreated(shape) {
124
+ let cancelled = false;
125
+
126
+ // the GeoJSON loader builds "Point" type as a circle
127
+ // use the circle shape type as and indicator for rendering a marker
128
+ // keep the behavior under a setting as this is supported by kendo jQuery Map
129
+ // but we opted out of this in blazor
130
+ if (shape instanceof d.Circle && this.map.options.renderPointsAsMarkers) {
131
+ cancelled = defined(this._createMarker(shape));
132
+ }
133
+
134
+ if (!cancelled) {
135
+ let args = {
136
+ layer: this,
137
+ shape: shape
138
+ };
139
+
140
+ cancelled = this.map.trigger('shapeCreated', args);
141
+ }
142
+
143
+ return cancelled;
144
+ }
145
+
146
+ featureCreated(e) {
147
+ e.layer = this;
148
+ this.map.trigger('shapeFeatureCreated', e);
149
+ }
150
+
151
+ _createMarker(shape) {
152
+ let marker = this.map.markers.bind({
153
+ location: shape.location
154
+ }, shape.dataItem);
155
+
156
+ if (marker) {
157
+ this._markers.push(marker);
158
+ }
159
+
160
+ return marker;
161
+ }
162
+
163
+ _clearMarkers() {
164
+ for (let i = 0; i < this._markers.length; i++) {
165
+ this.map.markers.remove(this._markers[i]);
166
+ }
167
+
168
+ this._markers = [];
169
+ }
170
+
171
+ _pan() {
172
+ if (!this._panning) {
173
+ this._panning = true;
174
+ this.surface.suspendTracking();
175
+ }
176
+ }
177
+
178
+ _panEnd(e) {
179
+ super._panEnd(e);
180
+ this._translateSurface();
181
+ this.surface.resumeTracking();
182
+ this._panning = false;
183
+ }
184
+
185
+ _translateSurface() {
186
+ let map = this.map;
187
+ let nw = map.locationToView(map.extent().nw);
188
+
189
+ if (this.surface.translate) {
190
+ this.surface.translate(nw);
191
+ this.movable.moveTo({
192
+ x: nw.x,
193
+ y: nw.y
194
+ });
195
+ }
196
+ }
197
+
198
+ _handler(event) {
199
+ let layer = this;
200
+
201
+ return function(e) {
202
+ if (e.element) {
203
+ let args = {
204
+ layer: layer,
205
+ layerIndex: (layer.map.layers || []).indexOf(layer),
206
+ shape: e.element,
207
+ shapeIndex: (layer._data || []).indexOf(e.element.dataItem),
208
+ originalEvent: e.originalEvent
209
+ };
210
+
211
+ layer.map.trigger(event, args);
212
+ }
213
+ };
214
+ }
215
+
216
+ _activate() {
217
+ super._activate();
218
+ this._panHandler = proxy(this._pan, this);
219
+ this.map.bind('pan', this.panHandler);
220
+ }
221
+
222
+ _deactivate() {
223
+ super._deactivate();
224
+ this.map.unbind('pan', this._panHandler);
225
+ }
226
+ }
227
+
228
+ setDefaultOptions(ShapeLayer, {
229
+ autoBind: true,
230
+ zIndex: 100
231
+ });
232
+
233
+ class GeoJsonLoader extends Class {
234
+ constructor(locator, defaultStyle, observer) {
235
+ super();
236
+ this.observer = observer;
237
+ this.locator = locator;
238
+ this.style = defaultStyle;
239
+ }
240
+
241
+ parse(item) {
242
+ let root = new Group();
243
+ let unwrap = true;
244
+
245
+ if (item.type === 'Feature') {
246
+ unwrap = false;
247
+ this._loadGeometryTo(root, item.geometry, item);
248
+ this._featureCreated(root, item);
249
+ } else {
250
+ this._loadGeometryTo(root, item, item);
251
+ }
252
+
253
+ if (unwrap && root.children.length < 2) {
254
+ root = root.children[0];
255
+ }
256
+
257
+ return root;
258
+ }
259
+
260
+ _shapeCreated(shape) {
261
+ let cancelled = false;
262
+
263
+ if (this.observer && this.observer.shapeCreated) {
264
+ cancelled = this.observer.shapeCreated(shape);
265
+ }
266
+
267
+ return cancelled;
268
+ }
269
+
270
+ _featureCreated(group, dataItem) {
271
+ if (this.observer && this.observer.featureCreated) {
272
+ this.observer.featureCreated({
273
+ group: group,
274
+ dataItem: dataItem,
275
+ properties: dataItem.properties
276
+ });
277
+ }
278
+ }
279
+
280
+ /* eslint-disable indent */
281
+ _loadGeometryTo(container, geometry, dataItem) {
282
+ let coords = geometry.coordinates;
283
+ let i;
284
+ let path;
285
+
286
+ switch (geometry.type) {
287
+ case 'LineString':
288
+ path = this._loadPolygon(container, [coords], dataItem);
289
+ this._setLineFill(path);
290
+ break;
291
+ case 'MultiLineString':
292
+ for (i = 0; i < coords.length; i++) {
293
+ path = this._loadPolygon(container, [coords[i]], dataItem);
294
+ this._setLineFill(path);
295
+ }
296
+ break;
297
+ case 'Polygon':
298
+ this._loadPolygon(container, coords, dataItem);
299
+ break;
300
+ case 'MultiPolygon':
301
+ for (i = 0; i < coords.length; i++) {
302
+ this._loadPolygon(container, coords[i], dataItem);
303
+ }
304
+ break;
305
+ case 'Point':
306
+ this._loadPoint(container, coords, dataItem);
307
+ break;
308
+ case 'MultiPoint':
309
+ for (i = 0; i < coords.length; i++) {
310
+ this._loadPoint(container, coords[i], dataItem);
311
+ }
312
+ break;
313
+ default:
314
+ break;
315
+ }
316
+ }
317
+ /* eslint-disable indent */
318
+
319
+ _setLineFill(path) {
320
+ let segments = path.segments;
321
+
322
+ if (segments.length < 4 || !segments[0].anchor().equals(last(segments).anchor())) {
323
+ path.options.fill = null;
324
+ }
325
+ }
326
+
327
+ _loadShape(container, shape) {
328
+ if (!this._shapeCreated(shape)) {
329
+ container.append(shape);
330
+ }
331
+
332
+ return shape;
333
+ }
334
+
335
+ _loadPolygon(container, rings, dataItem) {
336
+ let shape = this._buildPolygon(rings);
337
+ shape.dataItem = dataItem;
338
+ return this._loadShape(container, shape);
339
+ }
340
+
341
+ _buildPolygon(rings) {
342
+ let type = rings.length > 1 ? d.MultiPath : d.Path;
343
+ let path = new type(this.style);
344
+
345
+ for (let i = 0; i < rings.length; i++) {
346
+ for (let j = 0; j < rings[i].length; j++) {
347
+ let point = this.locator.locationToView(Location.fromLngLat(rings[i][j]));
348
+ if (j === 0) {
349
+ path.moveTo(point.x, point.y);
350
+ } else {
351
+ path.lineTo(point.x, point.y);
352
+ }
353
+ }
354
+ }
355
+
356
+ return path;
357
+ }
358
+
359
+ _loadPoint(container, coords, dataItem) {
360
+ let location = Location.fromLngLat(coords);
361
+ let point = this.locator.locationToView(location);
362
+ let circle = new g.Circle(point, 10);
363
+ let shape = new d.Circle(circle, this.style);
364
+
365
+ shape.dataItem = dataItem;
366
+ shape.location = location;
367
+
368
+ return this._loadShape(container, shape);
369
+ }
370
+ }