@progress/kendo-charts 1.19.0 → 1.20.0-dev.202111081615

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 (63) hide show
  1. package/dist/cdn/js/kendo-charts.js +1 -1
  2. package/dist/cdn/main.js +1 -1
  3. package/dist/es/chart/chart.js +13 -5
  4. package/dist/es/chart/constants.js +3 -1
  5. package/dist/es/chart/pan-and-zoom/mousewheel-zoom.js +8 -4
  6. package/dist/es/chart/selection.js +41 -1
  7. package/dist/es/common/create-hash-set.js +11 -1
  8. package/dist/es/common/mousewheel-delta.js +4 -7
  9. package/dist/es/core/axis.js +35 -0
  10. package/dist/es/core/category-axis.js +23 -17
  11. package/dist/es/core/date-category-axis.js +26 -38
  12. package/dist/es/core/date-value-axis.js +32 -33
  13. package/dist/es/core/logarithmic-axis.js +30 -27
  14. package/dist/es/core/numeric-axis.js +24 -20
  15. package/dist/es/main.js +1 -0
  16. package/dist/es/qrcode/encodings/data-modes/alpha-numeric-data-mode.js +103 -0
  17. package/dist/es/qrcode/encodings/data-modes/byte-data-mode.js +51 -0
  18. package/dist/es/qrcode/encodings/data-modes/data-mode-instances.js +12 -0
  19. package/dist/es/qrcode/encodings/data-modes/numeric-data-mode.js +49 -0
  20. package/dist/es/qrcode/encodings/data-modes/qr-data-mode.js +50 -0
  21. package/dist/es/qrcode/encodings/encoders/iso-encoder.js +29 -0
  22. package/dist/es/qrcode/encodings/encoders/utf8-encoder.js +91 -0
  23. package/dist/es/qrcode/encodings/encoding-result.js +16 -0
  24. package/dist/es/qrcode/encodings/encoding.js +701 -0
  25. package/dist/es/qrcode/encodings/free-cell-visitor.js +57 -0
  26. package/dist/es/qrcode/encodings/version-codewords.js +1289 -0
  27. package/dist/es/qrcode/qrcode.js +403 -0
  28. package/dist/es/qrcode/utils.js +28 -0
  29. package/dist/es/qrcode.js +1 -0
  30. package/dist/es/stock/navigator.js +3 -2
  31. package/dist/es2015/chart/chart.js +13 -5
  32. package/dist/es2015/chart/constants.js +3 -1
  33. package/dist/es2015/chart/pan-and-zoom/mousewheel-zoom.js +6 -4
  34. package/dist/es2015/chart/selection.js +40 -1
  35. package/dist/es2015/common/create-hash-set.js +11 -1
  36. package/dist/es2015/common/mousewheel-delta.js +4 -7
  37. package/dist/es2015/core/axis.js +28 -0
  38. package/dist/es2015/core/category-axis.js +21 -15
  39. package/dist/es2015/core/date-category-axis.js +27 -36
  40. package/dist/es2015/core/date-value-axis.js +33 -33
  41. package/dist/es2015/core/logarithmic-axis.js +29 -26
  42. package/dist/es2015/core/numeric-axis.js +24 -20
  43. package/dist/es2015/main.js +1 -0
  44. package/dist/es2015/qrcode/encodings/data-modes/alpha-numeric-data-mode.js +91 -0
  45. package/dist/es2015/qrcode/encodings/data-modes/byte-data-mode.js +41 -0
  46. package/dist/es2015/qrcode/encodings/data-modes/data-mode-instances.js +13 -0
  47. package/dist/es2015/qrcode/encodings/data-modes/numeric-data-mode.js +39 -0
  48. package/dist/es2015/qrcode/encodings/data-modes/qr-data-mode.js +44 -0
  49. package/dist/es2015/qrcode/encodings/encoders/iso-encoder.js +19 -0
  50. package/dist/es2015/qrcode/encodings/encoders/utf8-encoder.js +83 -0
  51. package/dist/es2015/qrcode/encodings/encoding-result.js +10 -0
  52. package/dist/es2015/qrcode/encodings/encoding.js +701 -0
  53. package/dist/es2015/qrcode/encodings/free-cell-visitor.js +49 -0
  54. package/dist/es2015/qrcode/encodings/version-codewords.js +1289 -0
  55. package/dist/es2015/qrcode/qrcode.js +395 -0
  56. package/dist/es2015/qrcode/utils.js +28 -0
  57. package/dist/es2015/qrcode.js +1 -0
  58. package/dist/es2015/stock/navigator.js +3 -2
  59. package/dist/npm/main.d.ts +1 -0
  60. package/dist/npm/main.js +3058 -149
  61. package/dist/npm/qrcode.d.ts +5 -0
  62. package/dist/systemjs/kendo-charts.js +1 -1
  63. package/package.json +1 -1
@@ -0,0 +1,395 @@
1
+ import {
2
+ geometry as geom,
3
+ drawing as draw
4
+ } from '@progress/kendo-drawing';
5
+
6
+ import {
7
+ Class,
8
+ addClass,
9
+ setDefaultOptions,
10
+ deepExtend
11
+ } from '../common';
12
+
13
+ import { Box } from '../core';
14
+ import { encodeData } from './encodings/encoding';
15
+ import { extend } from './utils';
16
+
17
+ const round = Math.round;
18
+ const crossPattern = [[0, 1], [1, 1], [1, 2], [2, 2], [2, 1], [3, 1], [3, 0], [2, 0], [2, -1], [1, -1], [1, 0]];
19
+ const squarePattern = [[0, 1], [1, 1], [1, 0]];
20
+
21
+ const QRCodeDefaults = {
22
+ DEFAULT_SIZE: 200,
23
+ QUIET_ZONE_LENGTH: 4,
24
+ DEFAULT_ERROR_CORRECTION_LEVEL: "L",
25
+ DEFAULT_BACKGROUND: "#fff",
26
+ DEFAULT_DARK_MODULE_COLOR: "#000",
27
+ MIN_BASE_UNIT_SIZE: 1,
28
+ DEFAULT_LOGO_SIZE: 7
29
+ };
30
+
31
+ class QRCode extends Class {
32
+ constructor(element, options) {
33
+ super();
34
+
35
+ this.options = deepExtend({}, this.options, options);
36
+ this.element = element;
37
+ this.wrapper = this.element;
38
+
39
+ this._initElement();
40
+ this._initSurface();
41
+
42
+ this.setOptions(options);
43
+ }
44
+
45
+ destroy() {
46
+ this._destroySurface();
47
+ }
48
+
49
+ _initElement() {
50
+ addClass(this.element, "k-qrcode");
51
+ this.element.style.display = "block";
52
+ }
53
+
54
+ _initSurface() {
55
+ const { options, surface } = this;
56
+
57
+ if (!surface || surface.options.type !== options.renderAs) {
58
+ this._destroySurface();
59
+ this._initSurfaceElement();
60
+ this.surface = this._createSurface();
61
+ }
62
+ }
63
+
64
+ _createSurface() {
65
+ return draw.Surface.create(this.surfaceElement, {
66
+ type: this.options.renderAs
67
+ });
68
+ }
69
+
70
+ _destroySurface() {
71
+ if (this.surface) {
72
+ this.surface.destroy();
73
+ this.surface = null;
74
+ this._destroySurfaceElement();
75
+ }
76
+ }
77
+
78
+ _initSurfaceElement() {
79
+ if (!this.surfaceElement) {
80
+ this.surfaceElement = document.createElement('div');
81
+ this.surfaceElement.style.position = "relative";
82
+ this.element.appendChild(this.surfaceElement);
83
+ }
84
+ }
85
+
86
+ _destroySurfaceElement() {
87
+ if (this.surfaceElement && this.surfaceElement.parentNode) {
88
+ this.surfaceElement.parentNode.removeChild(this.surfaceElement);
89
+ this.surfaceElement = null;
90
+ }
91
+ }
92
+
93
+ redraw() {
94
+ let size = this._getSize();
95
+
96
+ this.surface.clear();
97
+
98
+ this.surface.setSize({
99
+ width: size,
100
+ height: size
101
+ });
102
+
103
+ this.createVisual();
104
+
105
+ this.surface.draw(this.visual);
106
+ }
107
+
108
+ getSize() {
109
+ const element = this.element;
110
+ const elementWidth = element.clientWidth;
111
+ const elementHeight = element.clientHeight;
112
+ const size = { width: 0, height: 0 };
113
+
114
+ if (elementWidth > 0) {
115
+ size.width = elementWidth;
116
+ }
117
+
118
+ if (elementHeight) {
119
+ size.height = elementHeight;
120
+ }
121
+
122
+ return size;
123
+ }
124
+
125
+ _resize() {
126
+ this.redraw();
127
+ }
128
+
129
+ createVisual() {
130
+ this.visual = this._render();
131
+ }
132
+
133
+ exportVisual() {
134
+ return this._render();
135
+ }
136
+
137
+ _render() {
138
+ let value = this._value,
139
+ baseUnit,
140
+ border = this.options.border || {},
141
+ padding = this.options.padding || 0,
142
+ borderWidth = border.width || 0,
143
+ quietZoneSize,
144
+ matrix,
145
+ size,
146
+ dataSize,
147
+ contentSize;
148
+
149
+ border.width = borderWidth;
150
+
151
+ let visual = new draw.Group();
152
+
153
+ if (value) {
154
+ matrix = encodeData(value, this.options.errorCorrection, this.options.encoding);
155
+ size = this._getSize();
156
+ contentSize = size - 2 * (borderWidth + padding);
157
+ baseUnit = this._calculateBaseUnit(contentSize, matrix.length);
158
+ dataSize = matrix.length * baseUnit;
159
+ quietZoneSize = borderWidth + padding + (contentSize - dataSize) / 2;
160
+
161
+ visual.append(this._renderBackground(size, border));
162
+ visual.append(this._renderMatrix(matrix, baseUnit, quietZoneSize));
163
+
164
+ if (this._hasCustomLogo()) {
165
+ visual.append(this._renderLogo(size, baseUnit));
166
+ } else if (this._isSwiss()) {
167
+ visual.append(this._renderSwissCode(size, baseUnit));
168
+ }
169
+ }
170
+
171
+ return visual;
172
+ }
173
+
174
+ _renderLogo(qrSize, baseUnit) {
175
+ let image;
176
+ let imageRect;
177
+ let center = round(qrSize / 2);
178
+ let logoSize = this._getLogoSize(baseUnit * QRCodeDefaults.DEFAULT_LOGO_SIZE);
179
+ let logoUrl = this.options.overlay.imageUrl;
180
+ let position = {
181
+ x: center - logoSize.width / 2,
182
+ y: center - logoSize.height / 2
183
+ };
184
+
185
+ imageRect = new geom.Rect(
186
+ new geom.Point(position.x, position.y),
187
+ new geom.Size(logoSize.width, logoSize.height)
188
+ );
189
+
190
+ image = new draw.Image(logoUrl, imageRect);
191
+
192
+ return image;
193
+ }
194
+
195
+ _renderSwissCode(qrSize, baseUnit) {
196
+ let logoSize = this._getLogoSize(baseUnit * QRCodeDefaults.DEFAULT_LOGO_SIZE);
197
+ logoSize = Math.max(logoSize.width, logoSize.height);
198
+ let crossSize = logoSize / 4;
199
+ let crossOffset = crossSize / 2;
200
+ let center = qrSize / 2;
201
+ let start = {};
202
+ let visual = new draw.Group();
203
+
204
+ start.x = start.y = Math.ceil(center - baseUnit - logoSize / 2);
205
+ visual.append(this._renderShape(start, Math.ceil(logoSize + baseUnit * 2), squarePattern, "#fff"));
206
+
207
+ start.x = start.y = center - logoSize / 2;
208
+ visual.append(this._renderShape(start, logoSize, squarePattern, this.options.color));
209
+
210
+ start.x = center + crossOffset - logoSize / 2;
211
+ start.y = center + crossOffset + crossSize - logoSize / 2;
212
+ visual.append(this._renderShape(start, crossSize, crossPattern, "#fff"));
213
+
214
+ return visual;
215
+ }
216
+
217
+ _renderShape(start, step, pattern, color) {
218
+ let path = new draw.MultiPath({
219
+ fill: {
220
+ color: color
221
+ },
222
+ stroke: null
223
+ });
224
+
225
+ path.moveTo(start.x, start.y);
226
+
227
+ for (let i = 0; i < pattern.length; i++) {
228
+ path.lineTo(start.x + step * pattern[i][0], start.y + step * pattern[i][1]);
229
+ }
230
+
231
+ path.close();
232
+
233
+ return path;
234
+ }
235
+
236
+ _getSize() {
237
+ let size;
238
+
239
+ if (this.options.size) {
240
+ size = parseInt(this.options.size, 10);
241
+ } else {
242
+ const element = this.element;
243
+ const min = Math.min(element.clientWidth, element.clientHeight);
244
+
245
+ if (min > 0) {
246
+ size = min;
247
+ } else {
248
+ size = QRCodeDefaults.DEFAULT_SIZE;
249
+ }
250
+ }
251
+
252
+ return size;
253
+ }
254
+
255
+ _calculateBaseUnit(size, matrixSize) {
256
+ let baseUnit = Math.floor(size / matrixSize);
257
+
258
+ if (baseUnit < QRCodeDefaults.MIN_BASE_UNIT_SIZE) {
259
+ throw new Error("Insufficient size.");
260
+ }
261
+
262
+ if (baseUnit * matrixSize >= size &&
263
+ baseUnit - 1 >= QRCodeDefaults.MIN_BASE_UNIT_SIZE) {
264
+ baseUnit--;
265
+ }
266
+
267
+ return baseUnit;
268
+ }
269
+
270
+ _renderMatrix(matrix, baseUnit, quietZoneSize) {
271
+ let path = new draw.MultiPath({
272
+ fill: {
273
+ color: this.options.color
274
+ },
275
+ stroke: null
276
+ });
277
+
278
+ for (let row = 0; row < matrix.length; row++) {
279
+ let y = quietZoneSize + row * baseUnit;
280
+ let column = 0;
281
+
282
+ while (column < matrix.length) {
283
+ while (matrix[row][column] === 0 && column < matrix.length) {
284
+ column++;
285
+ }
286
+
287
+ if (column < matrix.length) {
288
+ let x = column;
289
+ while (matrix[row][column] === 1) {
290
+ column++;
291
+ }
292
+
293
+ let x1 = round(quietZoneSize + x * baseUnit);
294
+ let y1 = round(y);
295
+ let x2 = round(quietZoneSize + column * baseUnit);
296
+ let y2 = round(y + baseUnit);
297
+
298
+ path.moveTo(x1, y1)
299
+ .lineTo(x1, y2)
300
+ .lineTo(x2, y2)
301
+ .lineTo(x2, y1)
302
+ .close();
303
+ }
304
+ }
305
+ }
306
+
307
+ return path;
308
+ }
309
+
310
+ _renderBackground(size, border) {
311
+ const box = new Box(0, 0, size, size).unpad(border.width / 2);
312
+ const background = draw.Path.fromRect(box.toRect(), {
313
+ fill: {
314
+ color: this.options.background
315
+ },
316
+ stroke: {
317
+ color: border.color,
318
+ width: border.width
319
+ }
320
+ });
321
+
322
+ return background;
323
+ }
324
+
325
+ setOptions(options) {
326
+ let newOptions = options || {};
327
+ this.options = extend(this.options, newOptions);
328
+
329
+ if (options.value !== undefined) {
330
+ this._value = String(this.options.value);
331
+ }
332
+
333
+ this.redraw();
334
+ }
335
+
336
+ value(value) {
337
+ if (value === undefined) {
338
+ return this._value;
339
+ }
340
+
341
+ this._value = String(value);
342
+
343
+ this.redraw();
344
+ }
345
+
346
+ _hasCustomLogo() {
347
+ return Boolean(this.options.overlay.imageUrl);
348
+ }
349
+
350
+ _isSwiss() {
351
+ return this.options.overlay.type === "swiss";
352
+ }
353
+
354
+ _getLogoSize(defautLogoSize) {
355
+ let width = this.options.overlay.width;
356
+ let height = this.options.overlay.height;
357
+
358
+ if (!width && !height) {
359
+ width = height = defautLogoSize;
360
+ } else if (width && !height) {
361
+ height = width;
362
+ } else if (!width && height) {
363
+ width = height;
364
+ }
365
+
366
+ return {
367
+ width: width,
368
+ height: height
369
+ };
370
+ }
371
+ }
372
+
373
+ setDefaultOptions(QRCode, {
374
+ name: "QRCode",
375
+ renderAs: "svg",
376
+ encoding: "ISO_8859_1",
377
+ value: "",
378
+ errorCorrection: QRCodeDefaults.DEFAULT_ERROR_CORRECTION_LEVEL,
379
+ background: QRCodeDefaults.DEFAULT_BACKGROUND,
380
+ color: QRCodeDefaults.DEFAULT_DARK_MODULE_COLOR,
381
+ size: "",
382
+ padding: 0,
383
+ border: {
384
+ color: "",
385
+ width: 0
386
+ },
387
+ overlay: {
388
+ type: "image",
389
+ imageUrl: "",
390
+ width: 0,
391
+ height: 0
392
+ }
393
+ });
394
+
395
+ export default QRCode;
@@ -0,0 +1,28 @@
1
+ export const extend = Object.assign;
2
+
3
+ export function splitInto(str, chunkLength) {
4
+ let result = [];
5
+ let idx = 0;
6
+
7
+ while (idx < str.length) {
8
+ result.push(str.substring(idx, idx + chunkLength));
9
+ idx += chunkLength;
10
+ }
11
+
12
+ return result;
13
+ }
14
+
15
+ export function toBitsString(value, length) {
16
+ let bitString = Number(value).toString(2);
17
+
18
+ if (bitString.length < length) {
19
+ bitString = new Array(length - bitString.length + 1).join(0) + bitString;
20
+ }
21
+
22
+ return bitString;
23
+ }
24
+
25
+ export function toDecimal(value) {
26
+ return parseInt(value, 2);
27
+ }
28
+
@@ -0,0 +1 @@
1
+ export { default as QRCode } from './qrcode/qrcode';
@@ -260,6 +260,7 @@ class Navigator extends Class {
260
260
 
261
261
  const fromIx = mainAxis.categoryIndex(selection.options.from);
262
262
  const toIx = mainAxis.categoryIndex(selection.options.to);
263
+ const coords = this.chart._eventCoordinates(e.originalEvent);
263
264
 
264
265
  e.originalEvent.preventDefault();
265
266
 
@@ -268,11 +269,11 @@ class Navigator extends Class {
268
269
  }
269
270
 
270
271
  if (toIx - fromIx > 1) {
271
- selection.expand(delta);
272
+ selection.zoom(delta, coords);
272
273
  this.readSelection();
273
274
  } else {
274
275
  axis.options.min = select.from;
275
- select.from = axis.scaleRange(-e.delta).min;
276
+ select.from = axis.scaleRange(-e.delta * this.chart._mousewheelZoomRate(), coords).min;
276
277
  }
277
278
 
278
279
  if (liveDrag) {
@@ -5,6 +5,7 @@ export * from './sparkline';
5
5
  export * from './stock';
6
6
  export * from './gauges';
7
7
  export * from './barcode';
8
+ export * from './qrcode';
8
9
  export * from './common';
9
10
 
10
11
  export function chartBaseTheme(): any;