@progress/kendo-charts 1.22.0 → 1.23.0-dev.202201170838

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