@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.
@@ -860,14 +860,26 @@ var Axis = (function (ChartElement) {
860
860
  };
861
861
  };
862
862
 
863
- Axis.prototype.lineInfo = function lineInfo () {
863
+ Axis.prototype.lineDir = function lineDir () {
864
+ /*
865
+ * Axis line direction:
866
+ * * Vertical: up.
867
+ * * Horizontal: right.
868
+ */
869
+
864
870
  var ref = this.options;
865
871
  var vertical = ref.vertical;
866
872
  var reverse = ref.reverse;
873
+ return (vertical ? -1 : 1) * (reverse ? -1 : 1);
874
+ };
875
+
876
+ Axis.prototype.lineInfo = function lineInfo () {
877
+ var ref = this.options;
878
+ var vertical = ref.vertical;
867
879
  var lineBox = this.lineBox();
868
880
  var lineSize = vertical ? lineBox.height() : lineBox.width();
869
881
  var axis = vertical ? Y : X;
870
- var axisDir = (vertical ? -1 : 1) * (reverse ? -1 : 1);
882
+ var axisDir = this.lineDir();
871
883
  var startEdge = axisDir === 1 ? 1 : 2;
872
884
  var axisOrigin = axis + startEdge.toString();
873
885
  var lineStart = lineBox[axisOrigin];
@@ -264,18 +264,53 @@ var CategoryAxis = (function (Axis) {
264
264
  return positions.slice(startIndex, endIndex + 1);
265
265
  };
266
266
 
267
+ CategoryAxis.prototype.lineInfo = function lineInfo () {
268
+ var ref = this.options;
269
+ var vertical = ref.vertical;
270
+ var reverse = ref.reverse;
271
+ var lineBox = this.lineBox();
272
+ var lineSize = vertical ? lineBox.height() : lineBox.width();
273
+ var axis = vertical ? Y : X;
274
+ var axisDir = reverse ? -1 : 1;
275
+ var startEdge = axisDir === 1 ? 1 : 2;
276
+ var axisOrigin = axis + startEdge.toString();
277
+ var lineStart = lineBox[axisOrigin];
278
+
279
+ return {
280
+ axis: axis,
281
+ axisOrigin: axisOrigin,
282
+ axisDir: axisDir,
283
+ lineBox: lineBox,
284
+ lineSize: lineSize,
285
+ lineStart: lineStart
286
+ };
287
+ };
288
+
289
+ CategoryAxis.prototype.lineDir = function lineDir () {
290
+ /*
291
+ * Category axis line direction:
292
+ * * Vertical: down.
293
+ * * Horizontal: right.
294
+ */
295
+
296
+ var ref = this.options;
297
+ var reverse = ref.reverse;
298
+ return reverse ? -1 : 1;
299
+ };
300
+
267
301
  // TODO: Rename to slotBox, valueSlot, slotByIndex?
268
302
  CategoryAxis.prototype.getSlot = function getSlot (from, to, limit) {
269
303
  var options = this.options;
270
304
  var reverse = options.reverse;
271
305
  var justified = options.justified;
272
- var vertical = options.vertical;
273
306
  var ref = this.scaleOptions();
274
307
  var scale = ref.scale;
275
308
  var box = ref.box;
276
309
  var min = ref.min;
277
- var valueAxis = vertical ? Y : X;
278
- var lineStart = box[valueAxis + (reverse ? 2 : 1)];
310
+ var ref$1 = this.lineInfo();
311
+ var valueAxis = ref$1.axis;
312
+ var lineStart = ref$1.lineStart;
313
+
279
314
  var slotBox = box.clone();
280
315
  var singleSlot = !defined(to);
281
316
 
@@ -420,6 +455,7 @@ var CategoryAxis = (function (Axis) {
420
455
  max = min + MIN_CATEGORY_RANGE;
421
456
  }
422
457
 
458
+
423
459
  return {
424
460
  min: min,
425
461
  max: max
@@ -3,7 +3,7 @@ import NumericAxis from './numeric-axis';
3
3
  import AxisLabel from './axis-label';
4
4
  import { DateLabelFormats } from './constants';
5
5
 
6
- import { BLACK, DATE, COORD_PRECISION, DEFAULT_PRECISION, X, Y } from '../common/constants';
6
+ import { BLACK, DATE, COORD_PRECISION, DEFAULT_PRECISION } from '../common/constants';
7
7
  import { setDefaultOptions, deepExtend, limitValue, round } from '../common';
8
8
 
9
9
  import autoMajorUnit from './utils/auto-major-unit';
@@ -63,14 +63,12 @@ var DateValueAxis = (function (Axis) {
63
63
 
64
64
  DateValueAxis.prototype.getTickPositions = function getTickPositions (step) {
65
65
  var options = this.options;
66
- var vertical = options.vertical;
67
- var lineBox = this.lineBox();
68
- var dir = (vertical ? -1 : 1) * (options.reverse ? -1 : 1);
69
- var startEdge = dir === 1 ? 1 : 2;
70
- var start = lineBox[(vertical ? Y : X) + startEdge];
66
+ var ref = this.lineInfo();
67
+ var dir = ref.axisDir;
68
+ var lineSize = ref.lineSize;
69
+ var start = ref.lineStart;
71
70
  var divisions = this.getDivisions(step);
72
71
  var timeRange = dateDiff(options.max, options.min);
73
- var lineSize = vertical ? lineBox.height() : lineBox.width();
74
72
  var scale = lineSize / timeRange;
75
73
  var weekStartDay = options.weekStartDay || 0;
76
74
 
@@ -7,8 +7,8 @@ import createAxisTick from './utils/create-axis-tick';
7
7
  import createAxisGridLine from './utils/create-axis-grid-line';
8
8
  import limitCoordinate from './utils/limit-coordinate';
9
9
 
10
- import { DEFAULT_PRECISION, BLACK, X, Y } from '../common/constants';
11
- import { deepExtend, defined, inArray, limitValue, round, setDefaultOptions } from '../common';
10
+ import { DEFAULT_PRECISION, BLACK } from '../common/constants';
11
+ import { deepExtend, defined, inArray, limitValue, round, setDefaultOptions, valueOrDefault } from '../common';
12
12
 
13
13
  var DEFAULT_MAJOR_UNIT = 10;
14
14
  var MIN_VALUE_RANGE = 1e-6;
@@ -60,51 +60,37 @@ var LogarithmicAxis = (function (Axis) {
60
60
  var options = ref.options;
61
61
  var logMin = ref.logMin;
62
62
  var logMax = ref.logMax;
63
- var reverse = options.reverse;
64
- var vertical = options.vertical;
65
63
  var base = options.majorUnit;
66
- var valueAxis = vertical ? Y : X;
67
- var lineBox = this.lineBox();
68
- var lineStart = lineBox[valueAxis + (reverse ? 2 : 1)];
69
- var lineSize = vertical ? lineBox.height() : lineBox.width();
70
- var dir = reverse ? -1 : 1;
71
- var step = dir * (lineSize / (logMax - logMin));
72
- var slotBox = new Box(lineBox.x1, lineBox.y1, lineBox.x1, lineBox.y1);
73
- var start = a;
74
- var end = b;
75
-
76
- if (!defined(start)) {
77
- start = end || 1;
78
- }
79
-
80
- if (!defined(end)) {
81
- end = start || 1;
82
- }
64
+ var min = options.min;
65
+ var max = options.max;
66
+ var ref$1 = this.lineInfo();
67
+ var axis = ref$1.axis;
68
+ var axisDir = ref$1.axisDir;
69
+ var lineBox = ref$1.lineBox;
70
+ var lineSize = ref$1.lineSize;
71
+ var lineStart = ref$1.lineStart;
72
+ var step = axisDir * (lineSize / (logMax - logMin));
73
+ var start = valueOrDefault(a, b || 1);
74
+ var end = valueOrDefault(b, a || 1);
83
75
 
84
76
  if (start <= 0 || end <= 0) {
85
77
  return null;
86
78
  }
87
79
 
88
80
  if (limit) {
89
- start = Math.max(Math.min(start, options.max), options.min);
90
- end = Math.max(Math.min(end, options.max), options.min);
81
+ start = limitValue(start, min, max);
82
+ end = limitValue(end, min, max);
91
83
  }
92
84
 
93
85
  start = log(start, base);
94
86
  end = log(end, base);
95
87
 
96
- var p1, p2;
97
-
98
- if (vertical) {
99
- p1 = logMax - Math.max(start, end);
100
- p2 = logMax - Math.min(start, end);
101
- } else {
102
- p1 = Math.min(start, end) - logMin;
103
- p2 = Math.max(start, end) - logMin;
104
- }
88
+ var p1 = Math.min(start, end) - logMin;
89
+ var p2 = Math.max(start, end) - logMin;
105
90
 
106
- slotBox[valueAxis + 1] = limitCoordinate(lineStart + step * (reverse ? p2 : p1));
107
- slotBox[valueAxis + 2] = limitCoordinate(lineStart + step * (reverse ? p1 : p2));
91
+ var slotBox = new Box(lineBox.x1, lineBox.y1, lineBox.x1, lineBox.y1);
92
+ slotBox[axis + 1] = limitCoordinate(lineStart + step * (axisDir > 0 ? p1 : p2));
93
+ slotBox[axis + 2] = limitCoordinate(lineStart + step * (axisDir > 0 ? p2 : p1));
108
94
 
109
95
  return slotBox;
110
96
  };
@@ -114,17 +100,14 @@ var LogarithmicAxis = (function (Axis) {
114
100
  var options = ref.options;
115
101
  var logMin = ref.logMin;
116
102
  var logMax = ref.logMax;
117
- var reverse = options.reverse;
118
- var vertical = options.vertical;
119
103
  var base = options.majorUnit;
120
- var lineBox = this.lineBox();
121
- var dir = vertical === reverse ? 1 : -1;
122
- var startEdge = dir === 1 ? 1 : 2;
123
- var lineSize = vertical ? lineBox.height() : lineBox.width();
104
+ var ref$1 = this.lineInfo();
105
+ var axis = ref$1.axis;
106
+ var axisDir = ref$1.axisDir;
107
+ var lineStart = ref$1.lineStart;
108
+ var lineSize = ref$1.lineSize;
124
109
  var step = ((logMax - logMin) / lineSize);
125
- var valueAxis = vertical ? Y : X;
126
- var lineStart = lineBox[valueAxis + startEdge];
127
- var offset = dir * (point[valueAxis] - lineStart);
110
+ var offset = axisDir * (point[axis] - lineStart);
128
111
  var valueOffset = offset * step;
129
112
 
130
113
  if (offset < 0 || offset > lineSize) {
@@ -250,7 +233,7 @@ var LogarithmicAxis = (function (Axis) {
250
233
  };
251
234
 
252
235
  LogarithmicAxis.prototype.traverseMajorTicksPositions = function traverseMajorTicksPositions (callback, tickOptions) {
253
- var ref = this._lineOptions();
236
+ var ref = this.lineInfo();
254
237
  var lineStart = ref.lineStart;
255
238
  var step = ref.step;
256
239
  var ref$1 = this;
@@ -271,7 +254,7 @@ var LogarithmicAxis = (function (Axis) {
271
254
  var max = ref.max;
272
255
  var minorUnit = ref.minorUnit;
273
256
  var base = ref.majorUnit;
274
- var ref$1 = this._lineOptions();
257
+ var ref$1 = this.lineInfo();
275
258
  var lineStart = ref$1.lineStart;
276
259
  var step = ref$1.step;
277
260
  var ref$2 = this;
@@ -371,23 +354,11 @@ var LogarithmicAxis = (function (Axis) {
371
354
  };
372
355
  };
373
356
 
374
- LogarithmicAxis.prototype._lineOptions = function _lineOptions () {
375
- var ref = this.options;
376
- var reverse = ref.reverse;
377
- var vertical = ref.vertical;
378
- var valueAxis = vertical ? Y : X;
379
- var lineBox = this.lineBox();
380
- var dir = vertical === reverse ? 1 : -1;
381
- var startEdge = dir === 1 ? 1 : 2;
382
- var lineSize = vertical ? lineBox.height() : lineBox.width();
383
- var step = dir * (lineSize / (this.logMax - this.logMin));
384
- var lineStart = lineBox[valueAxis + startEdge];
357
+ LogarithmicAxis.prototype.lineInfo = function lineInfo () {
358
+ var info = Axis.prototype.lineInfo.call(this);
359
+ info.step = info.axisDir * (info.lineSize / (this.logMax - this.logMin));
385
360
 
386
- return {
387
- step: step,
388
- lineStart: lineStart,
389
- lineBox: lineBox
390
- };
361
+ return info;
391
362
  };
392
363
 
393
364
  return LogarithmicAxis;
@@ -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';
@@ -73,18 +73,17 @@ var NumericAxis = (function (Axis) {
73
73
 
74
74
  NumericAxis.prototype.getTickPositions = function getTickPositions (unit, skipUnit) {
75
75
  var options = this.options;
76
- var vertical = options.vertical;
77
- var reverse = options.reverse;
78
- var lineBox = this.lineBox();
79
- var lineSize = vertical ? lineBox.height() : lineBox.width();
76
+ var ref = this.lineInfo();
77
+ var axisDir = ref.axisDir;
78
+ var axisOrigin = ref.axisOrigin;
79
+ var lineBox = ref.lineBox;
80
+ var lineSize = ref.lineSize;
80
81
  var range = options.max - options.min;
81
82
  var scale = lineSize / range;
82
83
  var step = unit * scale;
83
84
  var divisions = this.getDivisions(unit);
84
- var dir = (vertical ? -1 : 1) * (reverse ? -1 : 1);
85
- var startEdge = dir === 1 ? 1 : 2;
86
85
  var positions = [];
87
- var pos = lineBox[(vertical ? Y : X) + startEdge];
86
+ var pos = lineBox[axisOrigin];
88
87
  var skipStep = 0;
89
88
 
90
89
  if (skipUnit) {
@@ -96,7 +95,7 @@ var NumericAxis = (function (Axis) {
96
95
  positions.push(round(pos, COORD_PRECISION));
97
96
  }
98
97
 
99
- pos = pos + step * dir;
98
+ pos = pos + step * axisDir;
100
99
  }
101
100
 
102
101
  return positions;
@@ -114,71 +113,44 @@ var NumericAxis = (function (Axis) {
114
113
  if ( limit === void 0 ) limit = false;
115
114
 
116
115
  var options = this.options;
117
- var vertical = options.vertical;
118
- var reverse = options.reverse;
119
- var valueAxis = vertical ? Y : X;
120
- var lineBox = this.lineBox();
121
- var lineStart = lineBox[valueAxis + (reverse ? 2 : 1)];
122
- var lineSize = vertical ? lineBox.height() : lineBox.width();
123
- var dir = reverse ? -1 : 1;
124
- var step = dir * (lineSize / (options.max - options.min));
125
- var slotBox = new Box(lineBox.x1, lineBox.y1, lineBox.x1, lineBox.y1);
116
+ var ref = this.lineInfo();
117
+ var axis = ref.axis;
118
+ var axisDir = ref.axisDir;
119
+ var lineBox = ref.lineBox;
120
+ var lineSize = ref.lineSize;
121
+ var lineStart = ref.lineStart;
122
+ var step = axisDir * (lineSize / (options.max - options.min));
126
123
 
127
- var start = a;
128
- var end = b;
129
-
130
- if (!defined(start)) {
131
- start = end || 0;
132
- }
133
-
134
- if (!defined(end)) {
135
- end = start || 0;
136
- }
124
+ var start = valueOrDefault(a, b || 0);
125
+ var end = valueOrDefault(b, a || 0);
137
126
 
138
127
  if (limit) {
139
- start = Math.max(Math.min(start, options.max), options.min);
140
- end = Math.max(Math.min(end, options.max), options.min);
128
+ start = limitValue(start, options.min, options.max);
129
+ end = limitValue(end, options.min, options.max);
141
130
  }
142
131
 
143
- var p1, p2;
132
+ var p1 = Math.min(start, end) - options.min;
133
+ var p2 = Math.max(start, end) - options.min;
144
134
 
145
- if (vertical) {
146
- p1 = options.max - Math.max(start, end);
147
- p2 = options.max - Math.min(start, end);
148
- } else {
149
- p1 = Math.min(start, end) - options.min;
150
- p2 = Math.max(start, end) - options.min;
151
- }
152
-
153
- slotBox[valueAxis + 1] = limitCoordinate(lineStart + step * (reverse ? p2 : p1));
154
- slotBox[valueAxis + 2] = limitCoordinate(lineStart + step * (reverse ? p1 : p2));
135
+ var slotBox = new Box(lineBox.x1, lineBox.y1, lineBox.x1, lineBox.y1);
136
+ slotBox[axis + 1] = limitCoordinate(lineStart + step * (axisDir > 0 ? p1 : p2));
137
+ slotBox[axis + 2] = limitCoordinate(lineStart + step * (axisDir > 0 ? p2 : p1));
155
138
 
156
139
  return slotBox;
157
140
  };
158
141
 
159
142
  NumericAxis.prototype.getValue = function getValue (point) {
160
143
  var options = this.options;
161
- var vertical = options.vertical;
162
- var reverse = options.reverse;
163
144
  var max = Number(options.max);
164
145
  var min = Number(options.min);
165
- var valueAxis = vertical ? Y : X;
166
- var lineBox = this.lineBox();
167
- var lineStart = lineBox[valueAxis + (reverse ? 2 : 1)];
168
- var lineSize = vertical ? lineBox.height() : lineBox.width();
169
- var dir = reverse ? -1 : 1;
170
- var offset = dir * (point[valueAxis] - lineStart);
171
- var step = (max - min) / lineSize;
172
- var valueOffset = offset * step;
173
-
174
- if (offset < 0 || offset > lineSize) {
146
+ var offset = this.pointOffset(point);
147
+ var valueOffset = offset * (max - min);
148
+
149
+ if (offset < 0 || offset > 1) {
175
150
  return null;
176
151
  }
177
152
 
178
- var value = vertical ?
179
- max - valueOffset :
180
- min + valueOffset;
181
-
153
+ var value = min + valueOffset;
182
154
  return round(value, DEFAULT_PRECISION);
183
155
  };
184
156
 
@@ -188,10 +160,10 @@ var NumericAxis = (function (Axis) {
188
160
  var reverse = options.reverse;
189
161
  var max = options.max;
190
162
  var min = options.min;
191
- var lineBox = this.lineBox();
192
- var size = vertical ? lineBox.height() : lineBox.width();
163
+ var ref = this.lineInfo();
164
+ var lineSize = ref.lineSize;
193
165
  var range = max - min;
194
- var scale = size / range;
166
+ var scale = lineSize / range;
195
167
  var offset = round(delta / scale, DEFAULT_PRECISION);
196
168
 
197
169
  if ((vertical || reverse) && !(vertical && reverse )) {
@@ -818,12 +818,23 @@ class Axis extends ChartElement {
818
818
  };
819
819
  }
820
820
 
821
- lineInfo() {
821
+ lineDir() {
822
+ /*
823
+ * Axis line direction:
824
+ * * Vertical: up.
825
+ * * Horizontal: right.
826
+ */
827
+
822
828
  const { vertical, reverse } = this.options;
829
+ return (vertical ? -1 : 1) * (reverse ? -1 : 1);
830
+ }
831
+
832
+ lineInfo() {
833
+ const { vertical } = this.options;
823
834
  const lineBox = this.lineBox();
824
835
  const lineSize = vertical ? lineBox.height() : lineBox.width();
825
836
  const axis = vertical ? Y : X;
826
- const axisDir = (vertical ? -1 : 1) * (reverse ? -1 : 1);
837
+ const axisDir = this.lineDir();
827
838
  const startEdge = axisDir === 1 ? 1 : 2;
828
839
  const axisOrigin = axis + startEdge.toString();
829
840
  const lineStart = lineBox[axisOrigin];
@@ -245,13 +245,44 @@ class CategoryAxis extends Axis {
245
245
  return positions.slice(startIndex, endIndex + 1);
246
246
  }
247
247
 
248
+ lineInfo() {
249
+ const { vertical, reverse } = this.options;
250
+ const lineBox = this.lineBox();
251
+ const lineSize = vertical ? lineBox.height() : lineBox.width();
252
+ const axis = vertical ? Y : X;
253
+ const axisDir = reverse ? -1 : 1;
254
+ const startEdge = axisDir === 1 ? 1 : 2;
255
+ const axisOrigin = axis + startEdge.toString();
256
+ const lineStart = lineBox[axisOrigin];
257
+
258
+ return {
259
+ axis,
260
+ axisOrigin,
261
+ axisDir,
262
+ lineBox,
263
+ lineSize,
264
+ lineStart
265
+ };
266
+ }
267
+
268
+ lineDir() {
269
+ /*
270
+ * Category axis line direction:
271
+ * * Vertical: down.
272
+ * * Horizontal: right.
273
+ */
274
+
275
+ const { reverse } = this.options;
276
+ return reverse ? -1 : 1;
277
+ }
278
+
248
279
  // TODO: Rename to slotBox, valueSlot, slotByIndex?
249
280
  getSlot(from, to, limit) {
250
281
  const options = this.options;
251
- const { reverse, justified, vertical } = options;
282
+ const { reverse, justified } = options;
252
283
  const { scale, box, min } = this.scaleOptions();
253
- const valueAxis = vertical ? Y : X;
254
- const lineStart = box[valueAxis + (reverse ? 2 : 1)];
284
+ const { axis: valueAxis, lineStart } = this.lineInfo();
285
+
255
286
  const slotBox = box.clone();
256
287
  const singleSlot = !defined(to);
257
288
 
@@ -389,6 +420,7 @@ class CategoryAxis extends Axis {
389
420
  max = min + MIN_CATEGORY_RANGE;
390
421
  }
391
422
 
423
+
392
424
  return {
393
425
  min: min,
394
426
  max: max
@@ -3,7 +3,7 @@ import NumericAxis from './numeric-axis';
3
3
  import AxisLabel from './axis-label';
4
4
  import { DateLabelFormats } from './constants';
5
5
 
6
- import { BLACK, DATE, COORD_PRECISION, DEFAULT_PRECISION, X, Y } from '../common/constants';
6
+ import { BLACK, DATE, COORD_PRECISION, DEFAULT_PRECISION } from '../common/constants';
7
7
  import { setDefaultOptions, deepExtend, limitValue, round } from '../common';
8
8
 
9
9
  import autoMajorUnit from './utils/auto-major-unit';
@@ -59,14 +59,9 @@ class DateValueAxis extends Axis {
59
59
 
60
60
  getTickPositions(step) {
61
61
  const options = this.options;
62
- const vertical = options.vertical;
63
- const lineBox = this.lineBox();
64
- const dir = (vertical ? -1 : 1) * (options.reverse ? -1 : 1);
65
- const startEdge = dir === 1 ? 1 : 2;
66
- const start = lineBox[(vertical ? Y : X) + startEdge];
62
+ const { axisDir: dir, lineSize, lineStart: start } = this.lineInfo();
67
63
  const divisions = this.getDivisions(step);
68
64
  const timeRange = dateDiff(options.max, options.min);
69
- const lineSize = vertical ? lineBox.height() : lineBox.width();
70
65
  const scale = lineSize / timeRange;
71
66
  const weekStartDay = options.weekStartDay || 0;
72
67
 
@@ -7,8 +7,8 @@ import createAxisTick from './utils/create-axis-tick';
7
7
  import createAxisGridLine from './utils/create-axis-grid-line';
8
8
  import limitCoordinate from './utils/limit-coordinate';
9
9
 
10
- import { DEFAULT_PRECISION, BLACK, X, Y } from '../common/constants';
11
- import { deepExtend, defined, inArray, limitValue, round, setDefaultOptions } from '../common';
10
+ import { DEFAULT_PRECISION, BLACK } from '../common/constants';
11
+ import { deepExtend, defined, inArray, limitValue, round, setDefaultOptions, valueOrDefault } from '../common';
12
12
 
13
13
  const DEFAULT_MAJOR_UNIT = 10;
14
14
  const MIN_VALUE_RANGE = 1e-6;
@@ -53,64 +53,40 @@ class LogarithmicAxis extends Axis {
53
53
 
54
54
  getSlot(a, b, limit) {
55
55
  const { options, logMin, logMax } = this;
56
- const { reverse, vertical, majorUnit: base } = options;
57
- const valueAxis = vertical ? Y : X;
58
- const lineBox = this.lineBox();
59
- const lineStart = lineBox[valueAxis + (reverse ? 2 : 1)];
60
- const lineSize = vertical ? lineBox.height() : lineBox.width();
61
- const dir = reverse ? -1 : 1;
62
- const step = dir * (lineSize / (logMax - logMin));
63
- const slotBox = new Box(lineBox.x1, lineBox.y1, lineBox.x1, lineBox.y1);
64
- let start = a;
65
- let end = b;
66
-
67
- if (!defined(start)) {
68
- start = end || 1;
69
- }
70
-
71
- if (!defined(end)) {
72
- end = start || 1;
73
- }
56
+ const { majorUnit: base, min, max } = options;
57
+ const { axis, axisDir, lineBox, lineSize, lineStart } = this.lineInfo();
58
+ const step = axisDir * (lineSize / (logMax - logMin));
59
+ let start = valueOrDefault(a, b || 1);
60
+ let end = valueOrDefault(b, a || 1);
74
61
 
75
62
  if (start <= 0 || end <= 0) {
76
63
  return null;
77
64
  }
78
65
 
79
66
  if (limit) {
80
- start = Math.max(Math.min(start, options.max), options.min);
81
- end = Math.max(Math.min(end, options.max), options.min);
67
+ start = limitValue(start, min, max);
68
+ end = limitValue(end, min, max);
82
69
  }
83
70
 
84
71
  start = log(start, base);
85
72
  end = log(end, base);
86
73
 
87
- let p1, p2;
74
+ const p1 = Math.min(start, end) - logMin;
75
+ const p2 = Math.max(start, end) - logMin;
88
76
 
89
- if (vertical) {
90
- p1 = logMax - Math.max(start, end);
91
- p2 = logMax - Math.min(start, end);
92
- } else {
93
- p1 = Math.min(start, end) - logMin;
94
- p2 = Math.max(start, end) - logMin;
95
- }
96
-
97
- slotBox[valueAxis + 1] = limitCoordinate(lineStart + step * (reverse ? p2 : p1));
98
- slotBox[valueAxis + 2] = limitCoordinate(lineStart + step * (reverse ? p1 : p2));
77
+ const slotBox = new Box(lineBox.x1, lineBox.y1, lineBox.x1, lineBox.y1);
78
+ slotBox[axis + 1] = limitCoordinate(lineStart + step * (axisDir > 0 ? p1 : p2));
79
+ slotBox[axis + 2] = limitCoordinate(lineStart + step * (axisDir > 0 ? p2 : p1));
99
80
 
100
81
  return slotBox;
101
82
  }
102
83
 
103
84
  getValue(point) {
104
85
  const { options, logMin, logMax } = this;
105
- const { reverse, vertical, majorUnit: base } = options;
106
- const lineBox = this.lineBox();
107
- const dir = vertical === reverse ? 1 : -1;
108
- const startEdge = dir === 1 ? 1 : 2;
109
- const lineSize = vertical ? lineBox.height() : lineBox.width();
86
+ const { majorUnit: base } = options;
87
+ const { axis, axisDir, lineStart, lineSize } = this.lineInfo();
110
88
  const step = ((logMax - logMin) / lineSize);
111
- const valueAxis = vertical ? Y : X;
112
- const lineStart = lineBox[valueAxis + startEdge];
113
- const offset = dir * (point[valueAxis] - lineStart);
89
+ const offset = axisDir * (point[axis] - lineStart);
114
90
  const valueOffset = offset * step;
115
91
 
116
92
  if (offset < 0 || offset > lineSize) {
@@ -227,7 +203,7 @@ class LogarithmicAxis extends Axis {
227
203
  }
228
204
 
229
205
  traverseMajorTicksPositions(callback, tickOptions) {
230
- const { lineStart, step } = this._lineOptions();
206
+ const { lineStart, step } = this.lineInfo();
231
207
  const { logMin, logMax } = this;
232
208
 
233
209
  for (let power = Math.ceil(logMin) + tickOptions.skip; power <= logMax; power += tickOptions.step) {
@@ -238,7 +214,7 @@ class LogarithmicAxis extends Axis {
238
214
 
239
215
  traverseMinorTicksPositions(callback, tickOptions) {
240
216
  const { min, max, minorUnit, majorUnit: base } = this.options;
241
- const { lineStart, step } = this._lineOptions();
217
+ const { lineStart, step } = this.lineInfo();
242
218
  const { logMin, logMax } = this;
243
219
  const start = Math.floor(logMin);
244
220
 
@@ -329,21 +305,11 @@ class LogarithmicAxis extends Axis {
329
305
  };
330
306
  }
331
307
 
332
- _lineOptions() {
333
- const { reverse, vertical } = this.options;
334
- const valueAxis = vertical ? Y : X;
335
- const lineBox = this.lineBox();
336
- const dir = vertical === reverse ? 1 : -1;
337
- const startEdge = dir === 1 ? 1 : 2;
338
- const lineSize = vertical ? lineBox.height() : lineBox.width();
339
- const step = dir * (lineSize / (this.logMax - this.logMin));
340
- const lineStart = lineBox[valueAxis + startEdge];
308
+ lineInfo() {
309
+ const info = super.lineInfo();
310
+ info.step = info.axisDir * (info.lineSize / (this.logMax - this.logMin));
341
311
 
342
- return {
343
- step: step,
344
- lineStart: lineStart,
345
- lineBox: lineBox
346
- };
312
+ return info;
347
313
  }
348
314
  }
349
315