@progress/kendo-charts 1.23.0-dev.202202081459 → 1.23.0

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.
@@ -20,6 +20,7 @@ import {
20
20
  } from '../core';
21
21
 
22
22
  import { Encodings } from './encodings/main';
23
+ import { surfaceSize } from './surface-size';
23
24
 
24
25
  var DEFAULT_BARCODE_WIDTH = 300;
25
26
  var DEFAULT_BARCODE_HEIGHT = 100;
@@ -84,7 +85,7 @@ var Barcode = (function (Class) {
84
85
  Barcode.prototype._initSurfaceElement = function _initSurfaceElement () {
85
86
  if (!this.surfaceElement) {
86
87
  this.surfaceElement = document.createElement('div');
87
- this.surfaceElement.style.position = "relative";
88
+ this.surfaceElement.style.position = 'relative';
88
89
  this.element.appendChild(this.surfaceElement);
89
90
  }
90
91
  };
@@ -98,6 +99,7 @@ var Barcode = (function (Class) {
98
99
 
99
100
  Barcode.prototype.setOptions = function setOptions (options) {
100
101
  this._setOptions(options);
102
+ this._initSurface();
101
103
  this.redraw();
102
104
  };
103
105
 
@@ -184,16 +186,15 @@ var Barcode = (function (Class) {
184
186
 
185
187
  Barcode.prototype._getSize = function _getSize () {
186
188
  var element = this.element;
187
- var elementWidth = element.clientWidth;
188
- var elementHeight = element.clientHeight;
189
+ var elementSize = surfaceSize(element, this.options.renderAs);
189
190
  var size = new geom.Size(DEFAULT_BARCODE_WIDTH, DEFAULT_BARCODE_HEIGHT);
190
191
 
191
- if (elementWidth > 0) {
192
- size.width = elementWidth;
192
+ if (elementSize.width > 0) {
193
+ size.width = elementSize.width;
193
194
  }
194
195
 
195
- if (elementHeight) {
196
- size.height = elementHeight;
196
+ if (elementSize.height > 0) {
197
+ size.height = elementSize.height;
197
198
  }
198
199
 
199
200
  if (this.options.width) {
@@ -0,0 +1,19 @@
1
+ export function surfaceSize(element, surfaceType) {
2
+ var display = element.style.display;
3
+ if (surfaceType === 'canvas') {
4
+ // The Canvas default size is different from SVG for
5
+ // inline-block containers such as the Barcode and QR Code.
6
+ //
7
+ // Switch to display: block to get same dimensions.
8
+ element.style.display = 'block';
9
+ }
10
+
11
+ var size = {
12
+ width: element.clientWidth,
13
+ height: element.clientHeight
14
+ };
15
+
16
+ element.style.display = display;
17
+
18
+ return size;
19
+ }
@@ -8,7 +8,7 @@ var colorScale = function (color, minLightnessOffset) {
8
8
  var offset = 1 - minLightnessOffset;
9
9
 
10
10
  return function (value) {
11
- var hsl = baseColor .toHSL();
11
+ var hsl = baseColor.toHSL();
12
12
  var range = 100 - hsl.l;
13
13
  var point = offset - value;
14
14
  hsl.l += Math.min(point * range, range);
@@ -121,7 +121,7 @@ var HeatmapChart = (function (ChartElement) {
121
121
 
122
122
  if (isFunction(series.color)) {
123
123
  color = pointOptions.color;
124
- } else {
124
+ } else if (this.valueRange.max !== 0) {
125
125
  var scale = colorScale(color);
126
126
  color = scale(value.value / this.valueRange.max);
127
127
  }
@@ -28,16 +28,18 @@ var terminator = "0000",
28
28
  paddingCodewords = ["11101100", "00010001"],
29
29
  finderPatternValue = 93,
30
30
  /* eslint-disable arrow-body-style */
31
+ /* eslint-disable no-unused-vars */
31
32
  maskPatternConditions = [
32
33
  function (row, column) { return (row + column) % 2 === 0; },
33
- function (row) { return row % 2 === 0; },
34
- function (column) { return column % 3 === 0; },
34
+ function (row, column) { return row % 2 === 0; },
35
+ function (row, column) { return column % 3 === 0; },
35
36
  function (row, column) { return (row + column) % 3 === 0; },
36
37
  function (row, column) { return (Math.floor(row / 2) + Math.floor(column / 3)) % 2 === 0; },
37
38
  function (row, column) { return ((row * column) % 2) + ((row * column) % 3) === 0; },
38
39
  function (row, column) { return (((row * column) % 2) + ((row * column) % 3)) % 2 === 0; },
39
40
  function (row, column) { return (((row + column) % 2) + ((row * column) % 3)) % 2 === 0; }
40
41
  ],
42
+ /* eslint-enable no-unused-vars */
41
43
  /* eslint-enable arrow-body-style */
42
44
  numberRegex = /^\d+/,
43
45
  alphaPattern = "A-Z0-9 $%*+./:-",
@@ -15,6 +15,8 @@ import { Box } from '../core';
15
15
  import { encodeData } from './encodings/encoding';
16
16
  import { extend } from './utils';
17
17
 
18
+ import { surfaceSize } from '../barcode/surface-size';
19
+
18
20
  var round = Math.round;
19
21
  var crossPattern = [[0, 1], [1, 1], [1, 2], [2, 2], [2, 1], [3, 1], [3, 0], [2, 0], [2, -1], [1, -1], [1, 0]];
20
22
  var squarePattern = [[0, 1], [1, 1], [1, 0]];
@@ -253,7 +255,8 @@ var QRCode = (function (Class) {
253
255
  size = parseInt(this.options.size, 10);
254
256
  } else {
255
257
  var element = this.element;
256
- var min = Math.min(element.clientWidth, element.clientHeight);
258
+ var elementSize = surfaceSize(element, this.options.renderAs);
259
+ var min = Math.min(elementSize.width, elementSize.height);
257
260
 
258
261
  if (min > 0) {
259
262
  size = min;
@@ -344,6 +347,7 @@ var QRCode = (function (Class) {
344
347
  this._value = String(this.options.value);
345
348
  }
346
349
 
350
+ this._initSurface();
347
351
  this.redraw();
348
352
  };
349
353
 
@@ -20,6 +20,7 @@ import {
20
20
  } from '../core';
21
21
 
22
22
  import { Encodings } from './encodings/main';
23
+ import { surfaceSize } from './surface-size';
23
24
 
24
25
  const DEFAULT_BARCODE_WIDTH = 300;
25
26
  const DEFAULT_BARCODE_HEIGHT = 100;
@@ -76,7 +77,7 @@ class Barcode extends Class {
76
77
  _initSurfaceElement() {
77
78
  if (!this.surfaceElement) {
78
79
  this.surfaceElement = document.createElement('div');
79
- this.surfaceElement.style.position = "relative";
80
+ this.surfaceElement.style.position = 'relative';
80
81
  this.element.appendChild(this.surfaceElement);
81
82
  }
82
83
  }
@@ -90,6 +91,7 @@ class Barcode extends Class {
90
91
 
91
92
  setOptions(options) {
92
93
  this._setOptions(options);
94
+ this._initSurface();
93
95
  this.redraw();
94
96
  }
95
97
 
@@ -176,16 +178,15 @@ class Barcode extends Class {
176
178
 
177
179
  _getSize() {
178
180
  const element = this.element;
179
- const elementWidth = element.clientWidth;
180
- const elementHeight = element.clientHeight;
181
+ const elementSize = surfaceSize(element, this.options.renderAs);
181
182
  const size = new geom.Size(DEFAULT_BARCODE_WIDTH, DEFAULT_BARCODE_HEIGHT);
182
183
 
183
- if (elementWidth > 0) {
184
- size.width = elementWidth;
184
+ if (elementSize.width > 0) {
185
+ size.width = elementSize.width;
185
186
  }
186
187
 
187
- if (elementHeight) {
188
- size.height = elementHeight;
188
+ if (elementSize.height > 0) {
189
+ size.height = elementSize.height;
189
190
  }
190
191
 
191
192
  if (this.options.width) {
@@ -0,0 +1,19 @@
1
+ export function surfaceSize(element, surfaceType) {
2
+ const display = element.style.display;
3
+ if (surfaceType === 'canvas') {
4
+ // The Canvas default size is different from SVG for
5
+ // inline-block containers such as the Barcode and QR Code.
6
+ //
7
+ // Switch to display: block to get same dimensions.
8
+ element.style.display = 'block';
9
+ }
10
+
11
+ const size = {
12
+ width: element.clientWidth,
13
+ height: element.clientHeight
14
+ };
15
+
16
+ element.style.display = display;
17
+
18
+ return size;
19
+ }
@@ -6,7 +6,7 @@ const colorScale = (color, minLightnessOffset = 0.05) => {
6
6
  const offset = 1 - minLightnessOffset;
7
7
 
8
8
  return (value) => {
9
- const hsl = baseColor .toHSL();
9
+ const hsl = baseColor.toHSL();
10
10
  const range = 100 - hsl.l;
11
11
  const point = offset - value;
12
12
  hsl.l += Math.min(point * range, range);
@@ -112,7 +112,7 @@ class HeatmapChart extends ChartElement {
112
112
 
113
113
  if (isFunction(series.color)) {
114
114
  color = pointOptions.color;
115
- } else {
115
+ } else if (this.valueRange.max !== 0) {
116
116
  const scale = colorScale(color);
117
117
  color = scale(value.value / this.valueRange.max);
118
118
  }
@@ -28,16 +28,18 @@ let terminator = "0000",
28
28
  paddingCodewords = ["11101100", "00010001"],
29
29
  finderPatternValue = 93,
30
30
  /* eslint-disable arrow-body-style */
31
+ /* eslint-disable no-unused-vars */
31
32
  maskPatternConditions = [
32
33
  (row, column) => { return (row + column) % 2 === 0; },
33
- (row) => { return row % 2 === 0; },
34
- (column) => { return column % 3 === 0; },
34
+ (row, column) => { return row % 2 === 0; },
35
+ (row, column) => { return column % 3 === 0; },
35
36
  (row, column) => { return (row + column) % 3 === 0; },
36
37
  (row, column) => { return (Math.floor(row / 2) + Math.floor(column / 3)) % 2 === 0; },
37
38
  (row, column) => { return ((row * column) % 2) + ((row * column) % 3) === 0; },
38
39
  (row, column) => { return (((row * column) % 2) + ((row * column) % 3)) % 2 === 0; },
39
40
  (row, column) => { return (((row + column) % 2) + ((row * column) % 3)) % 2 === 0; }
40
41
  ],
42
+ /* eslint-enable no-unused-vars */
41
43
  /* eslint-enable arrow-body-style */
42
44
  numberRegex = /^\d+/,
43
45
  alphaPattern = "A-Z0-9 $%*+./:-",
@@ -15,6 +15,8 @@ import { Box } from '../core';
15
15
  import { encodeData } from './encodings/encoding';
16
16
  import { extend } from './utils';
17
17
 
18
+ import { surfaceSize } from '../barcode/surface-size';
19
+
18
20
  const round = Math.round;
19
21
  const crossPattern = [[0, 1], [1, 1], [1, 2], [2, 2], [2, 1], [3, 1], [3, 0], [2, 0], [2, -1], [1, -1], [1, 0]];
20
22
  const squarePattern = [[0, 1], [1, 1], [1, 0]];
@@ -245,7 +247,8 @@ class QRCode extends Class {
245
247
  size = parseInt(this.options.size, 10);
246
248
  } else {
247
249
  const element = this.element;
248
- const min = Math.min(element.clientWidth, element.clientHeight);
250
+ const elementSize = surfaceSize(element, this.options.renderAs);
251
+ const min = Math.min(elementSize.width, elementSize.height);
249
252
 
250
253
  if (min > 0) {
251
254
  size = min;
@@ -336,6 +339,7 @@ class QRCode extends Class {
336
339
  this._value = String(this.options.value);
337
340
  }
338
341
 
342
+ this._initSurface();
339
343
  this.redraw();
340
344
  }
341
345