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

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.
@@ -3,8 +3,8 @@ import Axis from './axis';
3
3
  import AxisLabel from './axis-label';
4
4
  import Box from './box';
5
5
 
6
- import { BLACK, DEFAULT_PRECISION, COORD_PRECISION, X, Y } from '../common/constants';
7
- import { deepExtend, defined, limitValue, round, setDefaultOptions } from '../common';
6
+ import { BLACK, DEFAULT_PRECISION, COORD_PRECISION } from '../common/constants';
7
+ import { deepExtend, defined, limitValue, round, setDefaultOptions, valueOrDefault } from '../common';
8
8
 
9
9
  import autoMajorUnit from './utils/auto-major-unit';
10
10
  import autoAxisMin from './utils/auto-axis-min';
@@ -70,17 +70,13 @@ class NumericAxis extends Axis {
70
70
 
71
71
  getTickPositions(unit, skipUnit) {
72
72
  const options = this.options;
73
- const { vertical, reverse } = options;
74
- const lineBox = this.lineBox();
75
- const lineSize = vertical ? lineBox.height() : lineBox.width();
73
+ const { axisDir, axisOrigin, lineBox, lineSize } = this.lineInfo();
76
74
  const range = options.max - options.min;
77
75
  const scale = lineSize / range;
78
76
  const step = unit * scale;
79
77
  const divisions = this.getDivisions(unit);
80
- const dir = (vertical ? -1 : 1) * (reverse ? -1 : 1);
81
- const startEdge = dir === 1 ? 1 : 2;
82
78
  const positions = [];
83
- let pos = lineBox[(vertical ? Y : X) + startEdge];
79
+ let pos = lineBox[axisOrigin];
84
80
  let skipStep = 0;
85
81
 
86
82
  if (skipUnit) {
@@ -92,7 +88,7 @@ class NumericAxis extends Axis {
92
88
  positions.push(round(pos, COORD_PRECISION));
93
89
  }
94
90
 
95
- pos = pos + step * dir;
91
+ pos = pos + step * axisDir;
96
92
  }
97
93
 
98
94
  return positions;
@@ -108,79 +104,48 @@ class NumericAxis extends Axis {
108
104
 
109
105
  getSlot(a, b, limit = false) {
110
106
  const options = this.options;
111
- const { vertical, reverse } = options;
112
- const valueAxis = vertical ? Y : X;
113
- const lineBox = this.lineBox();
114
- const lineStart = lineBox[valueAxis + (reverse ? 2 : 1)];
115
- const lineSize = vertical ? lineBox.height() : lineBox.width();
116
- const dir = reverse ? -1 : 1;
117
- const step = dir * (lineSize / (options.max - options.min));
118
- const slotBox = new Box(lineBox.x1, lineBox.y1, lineBox.x1, lineBox.y1);
119
-
120
- let start = a;
121
- let end = b;
122
-
123
- if (!defined(start)) {
124
- start = end || 0;
125
- }
107
+ const { axis, axisDir, lineBox, lineSize, lineStart } = this.lineInfo();
108
+ const step = axisDir * (lineSize / (options.max - options.min));
126
109
 
127
- if (!defined(end)) {
128
- end = start || 0;
129
- }
110
+ let start = valueOrDefault(a, b || 0);
111
+ let end = valueOrDefault(b, a || 0);
130
112
 
131
113
  if (limit) {
132
- start = Math.max(Math.min(start, options.max), options.min);
133
- end = Math.max(Math.min(end, options.max), options.min);
114
+ start = limitValue(start, options.min, options.max);
115
+ end = limitValue(end, options.min, options.max);
134
116
  }
135
117
 
136
- let p1, p2;
118
+ const p1 = Math.min(start, end) - options.min;
119
+ const p2 = Math.max(start, end) - options.min;
137
120
 
138
- if (vertical) {
139
- p1 = options.max - Math.max(start, end);
140
- p2 = options.max - Math.min(start, end);
141
- } else {
142
- p1 = Math.min(start, end) - options.min;
143
- p2 = Math.max(start, end) - options.min;
144
- }
145
-
146
- slotBox[valueAxis + 1] = limitCoordinate(lineStart + step * (reverse ? p2 : p1));
147
- slotBox[valueAxis + 2] = limitCoordinate(lineStart + step * (reverse ? p1 : p2));
121
+ const slotBox = new Box(lineBox.x1, lineBox.y1, lineBox.x1, lineBox.y1);
122
+ slotBox[axis + 1] = limitCoordinate(lineStart + step * (axisDir > 0 ? p1 : p2));
123
+ slotBox[axis + 2] = limitCoordinate(lineStart + step * (axisDir > 0 ? p2 : p1));
148
124
 
149
125
  return slotBox;
150
126
  }
151
127
 
152
128
  getValue(point) {
153
129
  const options = this.options;
154
- const { vertical, reverse } = options;
155
130
  const max = Number(options.max);
156
131
  const min = Number(options.min);
157
- const valueAxis = vertical ? Y : X;
158
- const lineBox = this.lineBox();
159
- const lineStart = lineBox[valueAxis + (reverse ? 2 : 1)];
160
- const lineSize = vertical ? lineBox.height() : lineBox.width();
161
- const dir = reverse ? -1 : 1;
162
- const offset = dir * (point[valueAxis] - lineStart);
163
- const step = (max - min) / lineSize;
164
- const valueOffset = offset * step;
165
-
166
- if (offset < 0 || offset > lineSize) {
132
+ const offset = this.pointOffset(point);
133
+ const valueOffset = offset * (max - min);
134
+
135
+ if (offset < 0 || offset > 1) {
167
136
  return null;
168
137
  }
169
138
 
170
- const value = vertical ?
171
- max - valueOffset :
172
- min + valueOffset;
173
-
139
+ const value = min + valueOffset;
174
140
  return round(value, DEFAULT_PRECISION);
175
141
  }
176
142
 
177
143
  translateRange(delta) {
178
144
  const options = this.options;
179
145
  const { vertical, reverse, max, min } = options;
180
- const lineBox = this.lineBox();
181
- const size = vertical ? lineBox.height() : lineBox.width();
146
+ const { lineSize } = this.lineInfo();
182
147
  const range = max - min;
183
- const scale = size / range;
148
+ const scale = lineSize / range;
184
149
  let offset = round(delta / scale, DEFAULT_PRECISION);
185
150
 
186
151
  if ((vertical || reverse) && !(vertical && reverse )) {