@progress/kendo-charts 1.19.1 → 1.20.0-dev.202111121622
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.
- package/dist/cdn/js/kendo-charts.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/chart/chart.js +15 -6
- package/dist/es/chart/constants.js +3 -1
- package/dist/es/chart/pan-and-zoom/mousewheel-zoom.js +8 -4
- package/dist/es/chart/selection.js +41 -1
- package/dist/es/common/mousewheel-delta.js +4 -7
- package/dist/es/core/axis.js +47 -0
- package/dist/es/core/category-axis.js +62 -20
- package/dist/es/core/date-category-axis.js +26 -38
- package/dist/es/core/date-value-axis.js +37 -40
- package/dist/es/core/logarithmic-axis.js +62 -88
- package/dist/es/core/numeric-axis.js +57 -81
- package/dist/es/main.js +1 -0
- package/dist/es/qrcode/encodings/data-modes/alpha-numeric-data-mode.js +103 -0
- package/dist/es/qrcode/encodings/data-modes/byte-data-mode.js +51 -0
- package/dist/es/qrcode/encodings/data-modes/data-mode-instances.js +12 -0
- package/dist/es/qrcode/encodings/data-modes/numeric-data-mode.js +49 -0
- package/dist/es/qrcode/encodings/data-modes/qr-data-mode.js +50 -0
- package/dist/es/qrcode/encodings/encoders/iso-encoder.js +29 -0
- package/dist/es/qrcode/encodings/encoders/utf8-encoder.js +91 -0
- package/dist/es/qrcode/encodings/encoding-result.js +16 -0
- package/dist/es/qrcode/encodings/encoding.js +701 -0
- package/dist/es/qrcode/encodings/free-cell-visitor.js +57 -0
- package/dist/es/qrcode/encodings/version-codewords.js +1289 -0
- package/dist/es/qrcode/qrcode.js +403 -0
- package/dist/es/qrcode/utils.js +28 -0
- package/dist/es/qrcode.js +1 -0
- package/dist/es/stock/navigator.js +3 -2
- package/dist/es2015/chart/chart.js +15 -6
- package/dist/es2015/chart/constants.js +3 -1
- package/dist/es2015/chart/pan-and-zoom/mousewheel-zoom.js +6 -4
- package/dist/es2015/chart/selection.js +40 -1
- package/dist/es2015/common/mousewheel-delta.js +4 -7
- package/dist/es2015/core/axis.js +39 -0
- package/dist/es2015/core/category-axis.js +56 -18
- package/dist/es2015/core/date-category-axis.js +27 -36
- package/dist/es2015/core/date-value-axis.js +35 -40
- package/dist/es2015/core/logarithmic-axis.js +52 -83
- package/dist/es2015/core/numeric-axis.js +47 -78
- package/dist/es2015/main.js +1 -0
- package/dist/es2015/qrcode/encodings/data-modes/alpha-numeric-data-mode.js +91 -0
- package/dist/es2015/qrcode/encodings/data-modes/byte-data-mode.js +41 -0
- package/dist/es2015/qrcode/encodings/data-modes/data-mode-instances.js +13 -0
- package/dist/es2015/qrcode/encodings/data-modes/numeric-data-mode.js +39 -0
- package/dist/es2015/qrcode/encodings/data-modes/qr-data-mode.js +44 -0
- package/dist/es2015/qrcode/encodings/encoders/iso-encoder.js +19 -0
- package/dist/es2015/qrcode/encodings/encoders/utf8-encoder.js +83 -0
- package/dist/es2015/qrcode/encodings/encoding-result.js +10 -0
- package/dist/es2015/qrcode/encodings/encoding.js +701 -0
- package/dist/es2015/qrcode/encodings/free-cell-visitor.js +49 -0
- package/dist/es2015/qrcode/encodings/version-codewords.js +1289 -0
- package/dist/es2015/qrcode/qrcode.js +395 -0
- package/dist/es2015/qrcode/utils.js +28 -0
- package/dist/es2015/qrcode.js +1 -0
- package/dist/es2015/stock/navigator.js +3 -2
- package/dist/npm/main.d.ts +1 -0
- package/dist/npm/main.js +3172 -283
- package/dist/npm/qrcode.d.ts +5 -0
- package/dist/systemjs/kendo-charts.js +1 -1
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ import { defined, isNumber, last, limitValue, round, setDefaultOptions, valueOrD
|
|
|
6
6
|
import { dateEquals } from '../date-utils';
|
|
7
7
|
|
|
8
8
|
const MIN_CATEGORY_POINTS_RANGE = 0.01;
|
|
9
|
+
const MIN_CATEGORY_RANGE = 0.1;
|
|
9
10
|
|
|
10
11
|
function indexOf(value, arr) {
|
|
11
12
|
if (value instanceof Date) {
|
|
@@ -244,13 +245,44 @@ class CategoryAxis extends Axis {
|
|
|
244
245
|
return positions.slice(startIndex, endIndex + 1);
|
|
245
246
|
}
|
|
246
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
|
+
|
|
247
279
|
// TODO: Rename to slotBox, valueSlot, slotByIndex?
|
|
248
280
|
getSlot(from, to, limit) {
|
|
249
281
|
const options = this.options;
|
|
250
|
-
const { reverse, justified
|
|
282
|
+
const { reverse, justified } = options;
|
|
251
283
|
const { scale, box, min } = this.scaleOptions();
|
|
252
|
-
const
|
|
253
|
-
|
|
284
|
+
const { axis: valueAxis, lineStart } = this.lineInfo();
|
|
285
|
+
|
|
254
286
|
const slotBox = box.clone();
|
|
255
287
|
const singleSlot = !defined(to);
|
|
256
288
|
|
|
@@ -375,27 +407,33 @@ class CategoryAxis extends Axis {
|
|
|
375
407
|
};
|
|
376
408
|
}
|
|
377
409
|
|
|
378
|
-
|
|
410
|
+
scaleRange(scale, cursor) {
|
|
411
|
+
const position = Math.abs(this.pointOffset(cursor));
|
|
379
412
|
const rangeIndices = this.totalRangeIndices();
|
|
380
|
-
const
|
|
381
|
-
const
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
};
|
|
413
|
+
const delta = (rangeIndices.max - rangeIndices.min) * Math.min(1, scale);
|
|
414
|
+
const minDelta = position * delta;
|
|
415
|
+
const maxDelta = (1 - position) * delta;
|
|
416
|
+
const min = rangeIndices.min + minDelta;
|
|
417
|
+
let max = rangeIndices.max - maxDelta;
|
|
418
|
+
|
|
419
|
+
if (max - min < MIN_CATEGORY_RANGE) {
|
|
420
|
+
max = min + MIN_CATEGORY_RANGE;
|
|
389
421
|
}
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
return {
|
|
425
|
+
min: min,
|
|
426
|
+
max: max
|
|
427
|
+
};
|
|
390
428
|
}
|
|
391
429
|
|
|
392
|
-
|
|
393
|
-
const
|
|
394
|
-
const
|
|
430
|
+
zoomRange(scale, cursor) {
|
|
431
|
+
const { min: totalMin, max: totalMax } = this.totalRange();
|
|
432
|
+
const range = this.scaleRange(scale, cursor);
|
|
395
433
|
|
|
396
434
|
return {
|
|
397
|
-
min:
|
|
398
|
-
max: range
|
|
435
|
+
min: limitValue(range.min, totalMin, totalMax),
|
|
436
|
+
max: limitValue(range.max, totalMin, totalMax)
|
|
399
437
|
};
|
|
400
438
|
}
|
|
401
439
|
|
|
@@ -459,30 +459,6 @@ class DateCategoryAxis extends CategoryAxis {
|
|
|
459
459
|
return range;
|
|
460
460
|
}
|
|
461
461
|
|
|
462
|
-
scaleRange(delta) {
|
|
463
|
-
let rounds = Math.abs(delta);
|
|
464
|
-
let result = this.range();
|
|
465
|
-
let { min: from, max: to } = result;
|
|
466
|
-
|
|
467
|
-
if (from && to) {
|
|
468
|
-
while (rounds--) {
|
|
469
|
-
const range = dateDiff(from, to);
|
|
470
|
-
const step = Math.round(range * 0.1);
|
|
471
|
-
if (delta < 0) {
|
|
472
|
-
from = addTicks(from, step);
|
|
473
|
-
to = addTicks(to, -step);
|
|
474
|
-
} else {
|
|
475
|
-
from = addTicks(from, -step);
|
|
476
|
-
to = addTicks(to, step);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
result = { min: from, max: to };
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
return result;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
462
|
labelsRange() {
|
|
487
463
|
return {
|
|
488
464
|
min: this.options.labels.skip,
|
|
@@ -541,18 +517,24 @@ class DateCategoryAxis extends CategoryAxis {
|
|
|
541
517
|
};
|
|
542
518
|
}
|
|
543
519
|
|
|
544
|
-
|
|
520
|
+
scaleRange(scale, cursor) {
|
|
545
521
|
if (this.isEmpty()) {
|
|
546
|
-
return
|
|
522
|
+
return {};
|
|
547
523
|
}
|
|
548
524
|
|
|
549
525
|
const options = this.options;
|
|
550
526
|
const fit = options.userSetBaseUnit === FIT;
|
|
551
527
|
const totalLimits = this.dataRange.total();
|
|
552
528
|
const { min: rangeMin, max: rangeMax } = this.dataRange.displayRange();
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
529
|
+
|
|
530
|
+
const position = Math.abs(this.pointOffset(cursor));
|
|
531
|
+
const delta = (rangeMax - rangeMin) * scale;
|
|
532
|
+
const minDelta = Math.round(position * delta);
|
|
533
|
+
const maxDelta = Math.round((1 - position) * delta);
|
|
534
|
+
|
|
535
|
+
let { baseUnit } = this.dataRange.options;
|
|
536
|
+
let min = new Date(rangeMin.getTime() + minDelta);
|
|
537
|
+
let max = new Date(rangeMax.getTime() - maxDelta);
|
|
556
538
|
|
|
557
539
|
if (fit) {
|
|
558
540
|
const { autoBaseUnitSteps, maxDateGroups } = options;
|
|
@@ -594,13 +576,6 @@ class DateCategoryAxis extends CategoryAxis {
|
|
|
594
576
|
}
|
|
595
577
|
}
|
|
596
578
|
|
|
597
|
-
if (min < totalLimits.min) {
|
|
598
|
-
min = totalLimits.min;
|
|
599
|
-
}
|
|
600
|
-
if (max > totalLimits.max) {
|
|
601
|
-
max = totalLimits.max;
|
|
602
|
-
}
|
|
603
|
-
|
|
604
579
|
if (min && max && dateDiff(max, min) > 0) {
|
|
605
580
|
return {
|
|
606
581
|
min: min,
|
|
@@ -611,6 +586,22 @@ class DateCategoryAxis extends CategoryAxis {
|
|
|
611
586
|
}
|
|
612
587
|
}
|
|
613
588
|
|
|
589
|
+
zoomRange(scale, cursor) {
|
|
590
|
+
const totalLimits = this.dataRange.total();
|
|
591
|
+
const range = this.scaleRange(scale, cursor);
|
|
592
|
+
|
|
593
|
+
if (range) {
|
|
594
|
+
if (range.min < totalLimits.min) {
|
|
595
|
+
range.min = totalLimits.min;
|
|
596
|
+
}
|
|
597
|
+
if (range.max > totalLimits.max) {
|
|
598
|
+
range.max = totalLimits.max;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
return range;
|
|
603
|
+
}
|
|
604
|
+
|
|
614
605
|
range() {
|
|
615
606
|
return this.dataRange.displayRange();
|
|
616
607
|
}
|
|
@@ -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
|
|
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';
|
|
@@ -12,6 +12,8 @@ import ceil from './utils/ceil';
|
|
|
12
12
|
import { toDate, toTime, floorDate, ceilDate, duration, addDuration, addTicks, dateDiff, absoluteDateDiff, dateComparer, parseDate, parseDates, firstDay } from '../date-utils';
|
|
13
13
|
import { HOURS, DAYS, WEEKS, MONTHS, YEARS, TIME_PER_DAY, TIME_PER_WEEK, TIME_PER_MONTH, TIME_PER_YEAR, TIME_PER_UNIT } from '../date-utils/constants';
|
|
14
14
|
|
|
15
|
+
const MIN_VALUE_RANGE = 1000;
|
|
16
|
+
|
|
15
17
|
class DateValueAxis extends Axis {
|
|
16
18
|
constructor(seriesMin, seriesMax, axisOptions, chartService) {
|
|
17
19
|
const min = toDate(seriesMin);
|
|
@@ -57,14 +59,9 @@ class DateValueAxis extends Axis {
|
|
|
57
59
|
|
|
58
60
|
getTickPositions(step) {
|
|
59
61
|
const options = this.options;
|
|
60
|
-
const
|
|
61
|
-
const lineBox = this.lineBox();
|
|
62
|
-
const dir = (vertical ? -1 : 1) * (options.reverse ? -1 : 1);
|
|
63
|
-
const startEdge = dir === 1 ? 1 : 2;
|
|
64
|
-
const start = lineBox[(vertical ? Y : X) + startEdge];
|
|
62
|
+
const { axisDir: dir, lineSize, lineStart: start } = this.lineInfo();
|
|
65
63
|
const divisions = this.getDivisions(step);
|
|
66
64
|
const timeRange = dateDiff(options.max, options.min);
|
|
67
|
-
const lineSize = vertical ? lineBox.height() : lineBox.width();
|
|
68
65
|
const scale = lineSize / timeRange;
|
|
69
66
|
const weekStartDay = options.weekStartDay || 0;
|
|
70
67
|
|
|
@@ -120,23 +117,22 @@ class DateValueAxis extends Axis {
|
|
|
120
117
|
return new AxisLabel(date, text, index, null, labelOptions);
|
|
121
118
|
}
|
|
122
119
|
|
|
123
|
-
translateRange(delta
|
|
120
|
+
translateRange(delta) {
|
|
124
121
|
const options = this.options;
|
|
125
|
-
const baseUnit = options.baseUnit;
|
|
126
|
-
const weekStartDay = options.weekStartDay || 0;
|
|
127
122
|
const lineBox = this.lineBox();
|
|
128
|
-
const
|
|
123
|
+
const { vertical, reverse } = options;
|
|
124
|
+
const size = vertical ? lineBox.height() : lineBox.width();
|
|
129
125
|
const range = this.range();
|
|
130
126
|
const scale = size / dateDiff(range.max, range.min);
|
|
131
|
-
const offset = round(delta / scale, DEFAULT_PRECISION) * (options.reverse ? -1 : 1);
|
|
132
|
-
let from = addTicks(options.min, offset);
|
|
133
|
-
let to = addTicks(options.max, offset);
|
|
134
127
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
128
|
+
let offset = round(delta / scale, DEFAULT_PRECISION);
|
|
129
|
+
if ((vertical || reverse) && !(vertical && reverse )) {
|
|
130
|
+
offset = -offset;
|
|
138
131
|
}
|
|
139
132
|
|
|
133
|
+
let from = addTicks(options.min, offset);
|
|
134
|
+
let to = addTicks(options.max, offset);
|
|
135
|
+
|
|
140
136
|
return {
|
|
141
137
|
min: from,
|
|
142
138
|
max: to,
|
|
@@ -144,25 +140,6 @@ class DateValueAxis extends Axis {
|
|
|
144
140
|
};
|
|
145
141
|
}
|
|
146
142
|
|
|
147
|
-
scaleRange(delta) {
|
|
148
|
-
let { min: from, max: to } = this.options;
|
|
149
|
-
let rounds = Math.abs(delta);
|
|
150
|
-
|
|
151
|
-
while (rounds--) {
|
|
152
|
-
const range = dateDiff(from, to);
|
|
153
|
-
const step = Math.round(range * 0.1);
|
|
154
|
-
if (delta < 0) {
|
|
155
|
-
from = addTicks(from, step);
|
|
156
|
-
to = addTicks(to, -step);
|
|
157
|
-
} else {
|
|
158
|
-
from = addTicks(from, -step);
|
|
159
|
-
to = addTicks(to, step);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return { min: from, max: to };
|
|
164
|
-
}
|
|
165
|
-
|
|
166
143
|
shouldRenderNote(value) {
|
|
167
144
|
const range = this.range();
|
|
168
145
|
|
|
@@ -193,16 +170,34 @@ class DateValueAxis extends Axis {
|
|
|
193
170
|
};
|
|
194
171
|
}
|
|
195
172
|
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
const
|
|
199
|
-
const
|
|
173
|
+
scaleRange(scale, cursor) {
|
|
174
|
+
const position = Math.abs(this.pointOffset(cursor));
|
|
175
|
+
const delta = (this.options.max - this.options.min) * Math.min(1, scale);
|
|
176
|
+
const minDelta = position * delta;
|
|
177
|
+
const maxDelta = (1 - position) * delta;
|
|
178
|
+
const min = toDate(toTime(this.options.min) + minDelta);
|
|
179
|
+
let max = toDate(toTime(this.options.max) - maxDelta);
|
|
180
|
+
|
|
181
|
+
if (max - min < MIN_VALUE_RANGE) {
|
|
182
|
+
max = toDate(toTime(min) + MIN_VALUE_RANGE);
|
|
183
|
+
}
|
|
200
184
|
|
|
201
185
|
return {
|
|
202
186
|
min: min,
|
|
203
187
|
max: max
|
|
204
188
|
};
|
|
205
189
|
}
|
|
190
|
+
|
|
191
|
+
zoomRange(scale, cursor) {
|
|
192
|
+
const range = this.scaleRange(scale, cursor);
|
|
193
|
+
const min = toDate(limitValue(toTime(range.min), this.totalMin, this.totalMax));
|
|
194
|
+
const max = toDate(limitValue(toTime(range.max), this.totalMin, this.totalMax));
|
|
195
|
+
|
|
196
|
+
return {
|
|
197
|
+
min,
|
|
198
|
+
max
|
|
199
|
+
};
|
|
200
|
+
}
|
|
206
201
|
}
|
|
207
202
|
|
|
208
203
|
function timeUnits(delta) {
|
|
@@ -7,10 +7,11 @@ 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
|
|
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
|
+
const MIN_VALUE_RANGE = 1e-6;
|
|
14
15
|
|
|
15
16
|
class LogarithmicAxis extends Axis {
|
|
16
17
|
constructor(seriesMin, seriesMax, options, chartService) {
|
|
@@ -52,64 +53,40 @@ class LogarithmicAxis extends Axis {
|
|
|
52
53
|
|
|
53
54
|
getSlot(a, b, limit) {
|
|
54
55
|
const { options, logMin, logMax } = this;
|
|
55
|
-
const {
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const dir = reverse ? -1 : 1;
|
|
61
|
-
const step = dir * (lineSize / (logMax - logMin));
|
|
62
|
-
const slotBox = new Box(lineBox.x1, lineBox.y1, lineBox.x1, lineBox.y1);
|
|
63
|
-
let start = a;
|
|
64
|
-
let end = b;
|
|
65
|
-
|
|
66
|
-
if (!defined(start)) {
|
|
67
|
-
start = end || 1;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (!defined(end)) {
|
|
71
|
-
end = start || 1;
|
|
72
|
-
}
|
|
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);
|
|
73
61
|
|
|
74
62
|
if (start <= 0 || end <= 0) {
|
|
75
63
|
return null;
|
|
76
64
|
}
|
|
77
65
|
|
|
78
66
|
if (limit) {
|
|
79
|
-
start =
|
|
80
|
-
end =
|
|
67
|
+
start = limitValue(start, min, max);
|
|
68
|
+
end = limitValue(end, min, max);
|
|
81
69
|
}
|
|
82
70
|
|
|
83
71
|
start = log(start, base);
|
|
84
72
|
end = log(end, base);
|
|
85
73
|
|
|
86
|
-
|
|
74
|
+
const p1 = Math.min(start, end) - logMin;
|
|
75
|
+
const p2 = Math.max(start, end) - logMin;
|
|
87
76
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
} else {
|
|
92
|
-
p1 = Math.min(start, end) - logMin;
|
|
93
|
-
p2 = Math.max(start, end) - logMin;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
slotBox[valueAxis + 1] = limitCoordinate(lineStart + step * (reverse ? p2 : p1));
|
|
97
|
-
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));
|
|
98
80
|
|
|
99
81
|
return slotBox;
|
|
100
82
|
}
|
|
101
83
|
|
|
102
84
|
getValue(point) {
|
|
103
85
|
const { options, logMin, logMax } = this;
|
|
104
|
-
const {
|
|
105
|
-
const
|
|
106
|
-
const dir = vertical === reverse ? 1 : -1;
|
|
107
|
-
const startEdge = dir === 1 ? 1 : 2;
|
|
108
|
-
const lineSize = vertical ? lineBox.height() : lineBox.width();
|
|
86
|
+
const { majorUnit: base } = options;
|
|
87
|
+
const { axis, axisDir, lineStart, lineSize } = this.lineInfo();
|
|
109
88
|
const step = ((logMax - logMin) / lineSize);
|
|
110
|
-
const
|
|
111
|
-
const lineStart = lineBox[valueAxis + startEdge];
|
|
112
|
-
const offset = dir * (point[valueAxis] - lineStart);
|
|
89
|
+
const offset = axisDir * (point[axis] - lineStart);
|
|
113
90
|
const valueOffset = offset * step;
|
|
114
91
|
|
|
115
92
|
if (offset < 0 || offset > lineSize) {
|
|
@@ -126,16 +103,6 @@ class LogarithmicAxis extends Axis {
|
|
|
126
103
|
return { min: options.min, max: options.max };
|
|
127
104
|
}
|
|
128
105
|
|
|
129
|
-
scaleRange(delta) {
|
|
130
|
-
const base = this.options.majorUnit;
|
|
131
|
-
const offset = -delta;
|
|
132
|
-
|
|
133
|
-
return {
|
|
134
|
-
min: Math.pow(base, this.logMin - offset),
|
|
135
|
-
max: Math.pow(base, this.logMax + offset)
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
106
|
translateRange(delta) {
|
|
140
107
|
const { options, logMin, logMax } = this;
|
|
141
108
|
const { reverse, vertical, majorUnit: base } = options;
|
|
@@ -236,7 +203,7 @@ class LogarithmicAxis extends Axis {
|
|
|
236
203
|
}
|
|
237
204
|
|
|
238
205
|
traverseMajorTicksPositions(callback, tickOptions) {
|
|
239
|
-
const { lineStart, step } = this.
|
|
206
|
+
const { lineStart, step } = this.lineInfo();
|
|
240
207
|
const { logMin, logMax } = this;
|
|
241
208
|
|
|
242
209
|
for (let power = Math.ceil(logMin) + tickOptions.skip; power <= logMax; power += tickOptions.step) {
|
|
@@ -247,7 +214,7 @@ class LogarithmicAxis extends Axis {
|
|
|
247
214
|
|
|
248
215
|
traverseMinorTicksPositions(callback, tickOptions) {
|
|
249
216
|
const { min, max, minorUnit, majorUnit: base } = this.options;
|
|
250
|
-
const { lineStart, step } = this.
|
|
217
|
+
const { lineStart, step } = this.lineInfo();
|
|
251
218
|
const { logMin, logMax } = this;
|
|
252
219
|
const start = Math.floor(logMin);
|
|
253
220
|
|
|
@@ -296,21 +263,33 @@ class LogarithmicAxis extends Axis {
|
|
|
296
263
|
};
|
|
297
264
|
}
|
|
298
265
|
|
|
299
|
-
|
|
300
|
-
const {
|
|
301
|
-
const
|
|
302
|
-
const
|
|
303
|
-
const
|
|
304
|
-
const
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
if (
|
|
309
|
-
|
|
310
|
-
min: min,
|
|
311
|
-
max: max
|
|
312
|
-
};
|
|
266
|
+
scaleRange(scale, cursor) {
|
|
267
|
+
const { majorUnit: base } = this.options;
|
|
268
|
+
const logMin = log(this.options.min, base);
|
|
269
|
+
const logMax = log(this.options.max, base);
|
|
270
|
+
const position = Math.abs(this.pointOffset(cursor));
|
|
271
|
+
const delta = (logMax - logMin) * Math.min(1, scale);
|
|
272
|
+
const min = Math.pow(base, logMin + position * delta);
|
|
273
|
+
let max = Math.pow(base, logMax - (1 - position) * delta);
|
|
274
|
+
|
|
275
|
+
if (max - min < MIN_VALUE_RANGE) {
|
|
276
|
+
max = min + MIN_VALUE_RANGE;
|
|
313
277
|
}
|
|
278
|
+
|
|
279
|
+
return {
|
|
280
|
+
min: min,
|
|
281
|
+
max: max
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
zoomRange(scale, cursor) {
|
|
286
|
+
const range = this.scaleRange(scale, cursor);
|
|
287
|
+
const { totalMin, totalMax } = this;
|
|
288
|
+
|
|
289
|
+
return {
|
|
290
|
+
min: limitValue(range.min, totalMin, totalMax),
|
|
291
|
+
max: limitValue(range.max, totalMin, totalMax)
|
|
292
|
+
};
|
|
314
293
|
}
|
|
315
294
|
|
|
316
295
|
_minorIntervalOptions(power) {
|
|
@@ -326,21 +305,11 @@ class LogarithmicAxis extends Axis {
|
|
|
326
305
|
};
|
|
327
306
|
}
|
|
328
307
|
|
|
329
|
-
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
const lineBox = this.lineBox();
|
|
333
|
-
const dir = vertical === reverse ? 1 : -1;
|
|
334
|
-
const startEdge = dir === 1 ? 1 : 2;
|
|
335
|
-
const lineSize = vertical ? lineBox.height() : lineBox.width();
|
|
336
|
-
const step = dir * (lineSize / (this.logMax - this.logMin));
|
|
337
|
-
const lineStart = lineBox[valueAxis + startEdge];
|
|
308
|
+
lineInfo() {
|
|
309
|
+
const info = super.lineInfo();
|
|
310
|
+
info.step = info.axisDir * (info.lineSize / (this.logMax - this.logMin));
|
|
338
311
|
|
|
339
|
-
return
|
|
340
|
-
step: step,
|
|
341
|
-
lineStart: lineStart,
|
|
342
|
-
lineBox: lineBox
|
|
343
|
-
};
|
|
312
|
+
return info;
|
|
344
313
|
}
|
|
345
314
|
}
|
|
346
315
|
|
|
@@ -398,8 +367,8 @@ function throwNegativeValuesError() {
|
|
|
398
367
|
throw new Error("Non positive values cannot be used for a logarithmic axis");
|
|
399
368
|
}
|
|
400
369
|
|
|
401
|
-
function log(
|
|
402
|
-
return Math.log(
|
|
370
|
+
function log(x, base) {
|
|
371
|
+
return Math.log(x) / Math.log(base);
|
|
403
372
|
}
|
|
404
373
|
|
|
405
374
|
setDefaultOptions(LogarithmicAxis, {
|