@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,167 @@
1
+ import {
2
+ geometry as g,
3
+ drawing as d
4
+ } from '@progress/kendo-drawing';
5
+
6
+ import {
7
+ Class,
8
+ defined,
9
+ isFunction,
10
+ getter,
11
+ setDefaultOptions
12
+ } from '../../common';
13
+
14
+ import {
15
+ ShapeLayer
16
+ } from './shape';
17
+
18
+ import {
19
+ Location
20
+ } from '../location';
21
+
22
+ export class BubbleLayer extends ShapeLayer {
23
+ _readData() {
24
+ const data = this.options.data || [];
25
+ return data;
26
+ }
27
+
28
+ _load(data) {
29
+ this._data = data;
30
+ this.surface.clear();
31
+
32
+ if (data.length === 0) {
33
+ return;
34
+ }
35
+
36
+ let options = this.options;
37
+ let getValue = getter(options.valueField);
38
+
39
+ let newData = data.slice(0);
40
+ newData.sort(function(a, b) {
41
+ return getValue(b) - getValue(a);
42
+ });
43
+
44
+ let scaleType = this._scaleType();
45
+ let scale;
46
+ let getLocation = getter(this.options.locationField);
47
+
48
+ for (let i = 0; i < newData.length; i++) {
49
+ let dataItem = newData[i];
50
+ let location = getLocation(dataItem);
51
+ let value = getValue(dataItem);
52
+
53
+ if (defined(location) && defined(value)) {
54
+ if (!scale) {
55
+ scale = new scaleType([
56
+ 0,
57
+ value
58
+ ], [
59
+ options.minSize,
60
+ options.maxSize
61
+ ]);
62
+ }
63
+
64
+ location = Location.create(location);
65
+
66
+ let center = this.map.locationToView(location);
67
+ let size = scale.map(value);
68
+ let symbol = this._createSymbol({
69
+ center: center,
70
+ size: size,
71
+ style: options.style,
72
+ dataItem: dataItem,
73
+ location: location
74
+ });
75
+
76
+ symbol.dataItem = dataItem;
77
+ symbol.location = location;
78
+ symbol.value = value;
79
+
80
+ this._drawSymbol(symbol);
81
+ }
82
+ }
83
+ }
84
+
85
+ _scaleType() {
86
+ let scale = this.options.scale;
87
+
88
+ if (isFunction(scale)) {
89
+ return scale;
90
+ }
91
+
92
+ return Scales[scale];
93
+ }
94
+
95
+ _createSymbol(args) {
96
+ let symbol = this.options.symbol;
97
+
98
+ if (!isFunction(symbol)) {
99
+ symbol = Symbols[symbol];
100
+ }
101
+
102
+ return symbol(args);
103
+ }
104
+
105
+ _drawSymbol(shape) {
106
+ let args = {
107
+ layer: this,
108
+ shape: shape
109
+ };
110
+
111
+ let cancelled = this.map.trigger('shapeCreated', args);
112
+
113
+ if (!cancelled) {
114
+ this.surface.draw(shape);
115
+ }
116
+ }
117
+ }
118
+
119
+ setDefaultOptions(BubbleLayer, {
120
+ // autoBind: true,
121
+ locationField: 'location',
122
+ valueField: 'value',
123
+ minSize: 0,
124
+ maxSize: 100,
125
+ scale: 'sqrt',
126
+ symbol: 'circle',
127
+ // ensure bubble layers are displayed over tile and shape layers
128
+ zIndex: 200
129
+ });
130
+
131
+ class SqrtScale extends Class {
132
+ constructor(domain, range) {
133
+ super();
134
+
135
+ this._domain = domain;
136
+ this._range = range;
137
+
138
+ let domainRange = Math.sqrt(domain[1]) - Math.sqrt(domain[0]);
139
+ let outputRange = range[1] - range[0];
140
+
141
+ this._ratio = outputRange / domainRange;
142
+ }
143
+
144
+ map(value) {
145
+ let rel = (Math.sqrt(value) - Math.sqrt(this._domain[0])) * this._ratio;
146
+ return this._range[0] + rel;
147
+ }
148
+ }
149
+
150
+ let Scales = {
151
+ sqrt: SqrtScale
152
+ };
153
+
154
+ let Symbols = {
155
+ circle: function(args) {
156
+ let geo = new g.Circle(args.center, args.size / 2);
157
+ return new d.Circle(geo, args.style);
158
+ },
159
+
160
+ square: function(args) {
161
+ let path = new d.Path(args.style);
162
+ let halfSize = args.size / 2;
163
+ let center = args.center;
164
+ path.moveTo(center.x - halfSize, center.y - halfSize).lineTo(center.x + halfSize, center.y - halfSize).lineTo(center.x + halfSize, center.y + halfSize).lineTo(center.x - halfSize, center.y + halfSize).close();
165
+ return path;
166
+ }
167
+ };
@@ -0,0 +1,134 @@
1
+ import {
2
+ Class,
3
+ addClass,
4
+ deepExtend,
5
+ defined
6
+ } from '../../common';
7
+
8
+ import {
9
+ Extent
10
+ } from './../extent';
11
+
12
+ import {
13
+ getSupportedFeatures
14
+ } from '../utils';
15
+
16
+ export class Layer extends Class {
17
+ constructor(map, options) {
18
+ super();
19
+
20
+ this.support = getSupportedFeatures();
21
+
22
+ this._initOptions(options);
23
+ this.map = map;
24
+
25
+ let element = document.createElement("div");
26
+ addClass(element, "k-layer");
27
+ element.style.zIndex = this.options.zIndex;
28
+ element.style.opacity = this.options.opacity;
29
+
30
+ this.element = element;
31
+
32
+ map.scrollElement.appendChild(this.element);
33
+
34
+ this._beforeReset = this._beforeReset.bind(this);
35
+ this._reset = this._reset.bind(this);
36
+ this._resize = this._resize.bind(this);
37
+ this._panEnd = this._panEnd.bind(this);
38
+
39
+ this._activate();
40
+ this._updateAttribution();
41
+ }
42
+
43
+ destroy() {
44
+ this._deactivate();
45
+ }
46
+
47
+ _initOptions(options) {
48
+ this.options = deepExtend({}, this.options, options);
49
+ }
50
+
51
+ show() {
52
+ this.reset();
53
+ this._activate();
54
+ this._applyExtent(true);
55
+ }
56
+
57
+ hide() {
58
+ this._deactivate();
59
+ this._setVisibility(false);
60
+ }
61
+
62
+ reset() {
63
+ this._beforeReset();
64
+ this._reset();
65
+ }
66
+
67
+ _reset() {
68
+ this._applyExtent();
69
+ }
70
+
71
+ _beforeReset() {
72
+
73
+ }
74
+
75
+ _resize() {
76
+
77
+ }
78
+
79
+ _panEnd() {
80
+ this._applyExtent();
81
+ }
82
+
83
+ _applyExtent() {
84
+ let options = this.options;
85
+ let zoom = this.map.zoom();
86
+ let matchMinZoom = !defined(options.minZoom) || zoom >= options.minZoom;
87
+ let matchMaxZoom = !defined(options.maxZoom) || zoom <= options.maxZoom;
88
+ let extent = Extent.create(options.extent);
89
+ let inside = !extent || extent.overlaps(this.map.extent());
90
+
91
+ this._setVisibility(matchMinZoom && matchMaxZoom && inside);
92
+ }
93
+
94
+ _setVisibility(visible) {
95
+ this.element.style.display = visible ? '' : 'none';
96
+ }
97
+
98
+ _activate() {
99
+ let map = this.map;
100
+
101
+ this._deactivate();
102
+
103
+ map.bind('beforeReset', this._beforeReset);
104
+ map.bind('reset', this._reset);
105
+ map.bind('resize', this._resize);
106
+ map.bind('panEnd', this._panEnd);
107
+ }
108
+
109
+ _deactivate() {
110
+ let map = this.map;
111
+
112
+ map.unbind('beforeReset', this._beforeReset);
113
+ map.unbind('reset', this._reset);
114
+ map.unbind('resize', this._resize);
115
+ map.unbind('panEnd', this._panEnd);
116
+ }
117
+
118
+ _updateAttribution() {
119
+ const attribution = this.map.attribution;
120
+
121
+ if (attribution) {
122
+ attribution.add(this.options.attribution);
123
+ }
124
+ }
125
+
126
+ _readData() {
127
+ const data = this.options.data || [];
128
+ return data;
129
+ }
130
+
131
+ _hasData() {
132
+ return this._data && this._data.length > 0;
133
+ }
134
+ }
@@ -0,0 +1,328 @@
1
+ import {
2
+ Class,
3
+ addClass,
4
+ isArray,
5
+ getter,
6
+ deepExtend,
7
+ setDefaultOptions
8
+ } from '../../common';
9
+
10
+ import { Layer } from './layer';
11
+ import { Location } from '../location';
12
+
13
+ import {
14
+ proxy,
15
+ on,
16
+ off,
17
+ toHyphens,
18
+ toPixels
19
+ } from '../utils';
20
+
21
+ const CLICK = "click";
22
+ const MOUSE_ENTER = "mouseenter";
23
+ const MOUSE_LEAVE = "mouseleave";
24
+
25
+ const extend = Object.assign;
26
+ const MARKER_CLASS = ".k-marker";
27
+
28
+ const doc = document;
29
+ const math = Math;
30
+
31
+ export class MarkerLayer extends Layer {
32
+ constructor(map, options) {
33
+ super(map, options);
34
+
35
+ this._markerClickHandler = proxy(this._markerClick, this);
36
+ on(this.element, CLICK, MARKER_CLASS, this._markerClickHandler);
37
+
38
+ this.items = [];
39
+
40
+ this._load(this._readData());
41
+ }
42
+
43
+ destroy() {
44
+ super.destroy();
45
+ off(this.element, CLICK, this._markerClickHandler);
46
+ this.clear();
47
+ }
48
+
49
+ add(args) {
50
+ if (isArray(args)) {
51
+ for (let i = 0; i < args.length; i++) {
52
+ this._addOne(args[i]);
53
+ }
54
+ } else {
55
+ return this._addOne(args);
56
+ }
57
+ }
58
+
59
+ remove(marker) {
60
+ marker.destroy();
61
+ let index = (this.items || []).indexOf(marker);
62
+
63
+ if (index > -1) {
64
+ this.items.splice(index, 1);
65
+ }
66
+ }
67
+
68
+ clear() {
69
+ for (let i = 0; i < this.items.length; i++) {
70
+ this.items[i].destroy();
71
+ }
72
+
73
+ this.items = [];
74
+ }
75
+
76
+ update(marker) {
77
+ let location = marker.location();
78
+
79
+ if (location) {
80
+ marker.showAt(this.map.locationToView(location));
81
+
82
+ let args = {
83
+ marker: marker,
84
+ layer: this
85
+ };
86
+
87
+ this.map.trigger('markerActivate', args);
88
+ }
89
+ }
90
+
91
+ _reset() {
92
+ super._reset();
93
+
94
+ let items = this.items;
95
+
96
+ for (let i = 0; i < items.length; i++) {
97
+ this.update(items[i]);
98
+ }
99
+ }
100
+
101
+ bind(options, dataItem) {
102
+ let marker = Marker.create(options, this.options);
103
+ marker.dataItem = dataItem;
104
+
105
+ let args = {
106
+ marker: marker,
107
+ layer: this
108
+ };
109
+
110
+ let cancelled = this.map.trigger('markerCreated', args);
111
+
112
+ if (!cancelled) {
113
+ this.add(marker);
114
+ return marker;
115
+ }
116
+ }
117
+
118
+ _addOne(arg) {
119
+ let marker = Marker.create(arg, this.options);
120
+ marker.addTo(this);
121
+ return marker;
122
+ }
123
+
124
+ _readData() {
125
+ const data = this.options.data || [];
126
+ return data;
127
+ }
128
+
129
+ _load(data) {
130
+ this._data = data;
131
+ this.clear();
132
+
133
+ let getLocation = getter(this.options.locationField);
134
+ let getTitle = getter(this.options.titleField);
135
+
136
+ for (let i = 0; i < data.length; i++) {
137
+ let dataItem = data[i];
138
+
139
+ this.bind({
140
+ location: getLocation(dataItem),
141
+ title: getTitle(dataItem)
142
+ }, dataItem);
143
+ }
144
+ }
145
+
146
+ _markerClick(e) {
147
+ const layers = this.map.layers || [];
148
+ const marker = e.target._kendoNode;
149
+
150
+ let args = {
151
+ // marker: $(e.target).data('kendoMarker'),
152
+ // marker: e.target.getAttribute("data-kendoMarker"),
153
+ layer: this,
154
+ layerIndex: layers.indexOf(this),
155
+ marker: marker,
156
+ markerIndex: (this.items || []).indexOf(marker),
157
+ originalEvent: e
158
+ };
159
+
160
+ this.map.trigger('markerClick', args);
161
+ }
162
+
163
+ _markerMouseEnter(e) {
164
+ const args = this._createMarkerEventArgs(e);
165
+ this.map.trigger("markerMouseEnter", args);
166
+ }
167
+
168
+ _markerMouseLeave(e) {
169
+ const args = this._createMarkerEventArgs(e);
170
+ this.map.trigger("markerMouseLeave", args);
171
+ }
172
+
173
+ _createMarkerEventArgs(e) {
174
+ const marker = e.marker;
175
+
176
+ let args = extend({}, {
177
+ layer: this,
178
+ layerIndex: this.map.layers.indexOf(this),
179
+ marker: marker,
180
+ markerIndex: (this.items || []).indexOf(marker)
181
+ }, e);
182
+
183
+ return args;
184
+ }
185
+ }
186
+
187
+ setDefaultOptions(MarkerLayer, {
188
+ zIndex: 1000,
189
+ autoBind: true,
190
+ dataSource: {},
191
+ locationField: 'location',
192
+ titleField: 'title'
193
+ });
194
+
195
+ export class Marker extends Class {
196
+ constructor(options) {
197
+ super();
198
+ this.options = options || {};
199
+ }
200
+
201
+ destroy() {
202
+ this.layer = null;
203
+ this.unbindEvents();
204
+ this.hide();
205
+ }
206
+
207
+ addTo(parent) {
208
+ this.layer = parent.markers || parent;
209
+ this.layer.items.push(this);
210
+ this.layer.update(this);
211
+ }
212
+
213
+ location(value) {
214
+ if (value) {
215
+ this.options.location = Location.create(value).toArray();
216
+
217
+ if (this.layer) {
218
+ this.layer.update(this);
219
+ }
220
+
221
+ return this;
222
+ }
223
+
224
+ return Location.create(this.options.location);
225
+ }
226
+
227
+ showAt(point) {
228
+ this.render();
229
+
230
+ this.element.style.left = toPixels(math.round(point.x));
231
+ this.element.style.top = toPixels(math.round(point.y));
232
+
233
+ if (this.tooltip && this.tooltip.popup) {
234
+ this.tooltip.popup._position();
235
+ }
236
+ }
237
+
238
+ hide() {
239
+ if (this.element) {
240
+ this.element.remove();
241
+ this.element = null;
242
+ }
243
+ if (this.tooltip) {
244
+ this.tooltip.destroy();
245
+ this.tooltip = null;
246
+ }
247
+ }
248
+
249
+ bindEvents() {
250
+ if (!this.element) {
251
+ return;
252
+ }
253
+
254
+ this._mouseEnterHandler = proxy(this._mouseEnter, this);
255
+ on(this.element, MOUSE_ENTER, MARKER_CLASS, this._mouseEnterHandler);
256
+ this._mouseLeaveHandler = proxy(this._mouseLeave, this);
257
+ on(this.element, MOUSE_LEAVE, MARKER_CLASS, this._mouseLeaveHandler);
258
+ }
259
+
260
+ unbindEvents() {
261
+ if (!this.element) {
262
+ return;
263
+ }
264
+
265
+ off(this.element, MOUSE_ENTER, this._mouseEnterHandler);
266
+ off(this.element, MOUSE_LEAVE, this._mouseLeaveHandler);
267
+ }
268
+
269
+ render() {
270
+ if (!this.element) {
271
+ let options = this.options;
272
+ let layer = this.layer;
273
+
274
+ const element = doc.createElement('span');
275
+ addClass(element, 'k-marker k-icon k-i-marker-' + toHyphens(options.shape || 'pin'));
276
+
277
+ element.setAttribute("title", options.title);
278
+
279
+ const attributes = options.attributes || {};
280
+ Object.keys(attributes).forEach(function(key) {
281
+ element.setAttributett(key, attributes[key]);
282
+ });
283
+
284
+ element._kendoNode = this;
285
+ element.style.zIndex = options.zIndex;
286
+
287
+ this.element = element;
288
+
289
+ if (layer) {
290
+ layer.element.appendChild(this.element);
291
+ }
292
+
293
+ this.bindEvents();
294
+
295
+ this.renderTooltip();
296
+ }
297
+ }
298
+
299
+ _mouseEnter(e) {
300
+ const args = this._createEventArgs(e);
301
+ this.layer._markerMouseEnter(args);
302
+ }
303
+
304
+ _mouseLeave(e) {
305
+ const args = this._createEventArgs(e);
306
+ this.layer._markerMouseLeave(args);
307
+ }
308
+
309
+ _createEventArgs(e) {
310
+ let args = {
311
+ marker: this,
312
+ originalEvent: e
313
+ };
314
+
315
+ return args;
316
+ }
317
+
318
+ renderTooltip() {
319
+ }
320
+
321
+ static create(arg, defaults) {
322
+ if (arg instanceof Marker) {
323
+ return arg;
324
+ }
325
+
326
+ return new Marker(deepExtend({}, defaults, arg));
327
+ }
328
+ }