@progress/kendo-charts 2.12.0 → 2.12.1-develop.2
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/core/date-value-axis.js +3 -3
- package/dist/es/core/numeric-axis.js +17 -23
- package/dist/es/core/utils/auto-major-unit.js +5 -5
- package/dist/es/core/utils/ceil-to-step.js +5 -0
- package/dist/es/core/utils/floor-to-step.js +5 -0
- package/dist/es/core/utils/round-to-precision.js +21 -0
- package/dist/es/stock/stock-chart.js +3 -0
- package/dist/es2015/core/date-value-axis.js +3 -3
- package/dist/es2015/core/numeric-axis.js +17 -23
- package/dist/es2015/core/utils/auto-major-unit.js +5 -5
- package/dist/es2015/core/utils/ceil-to-step.js +5 -0
- package/dist/es2015/core/utils/floor-to-step.js +5 -0
- package/dist/es2015/core/utils/round-to-precision.js +21 -0
- package/dist/es2015/stock/stock-chart.js +3 -0
- package/dist/npm/main.js +74 -56
- package/dist/systemjs/kendo-charts.js +1 -1
- package/package.json +1 -1
- package/dist/es/core/utils/ceil.js +0 -6
- package/dist/es/core/utils/floor.js +0 -6
- package/dist/es2015/core/utils/ceil.js +0 -6
- package/dist/es2015/core/utils/floor.js +0 -6
|
@@ -7,7 +7,7 @@ import { BLACK, DATE, COORD_PRECISION, DEFAULT_PRECISION } from '../common/const
|
|
|
7
7
|
import { setDefaultOptions, deepExtend, limitValue, round } from '../common';
|
|
8
8
|
|
|
9
9
|
import autoMajorUnit from './utils/auto-major-unit';
|
|
10
|
-
import
|
|
10
|
+
import ceilToStep from './utils/ceil-to-step';
|
|
11
11
|
|
|
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';
|
|
@@ -226,12 +226,12 @@ function applyDefaults(seriesMin, seriesMax, options) {
|
|
|
226
226
|
const autoMin = floorDate(toTime(min) - 1, baseUnit, weekStartDay) || toDate(max);
|
|
227
227
|
const autoMax = ceilDate(toTime(max) + 1, baseUnit, weekStartDay);
|
|
228
228
|
const userMajorUnit = options.majorUnit ? options.majorUnit : undefined;
|
|
229
|
-
const majorUnit = userMajorUnit ||
|
|
229
|
+
const majorUnit = userMajorUnit || ceilToStep(
|
|
230
230
|
autoMajorUnit(autoMin.getTime(), autoMax.getTime()),
|
|
231
231
|
baseUnitTime
|
|
232
232
|
) / baseUnitTime;
|
|
233
233
|
const actualUnits = duration(autoMin, autoMax, baseUnit);
|
|
234
|
-
const totalUnits =
|
|
234
|
+
const totalUnits = ceilToStep(actualUnits, majorUnit);
|
|
235
235
|
const unitsToAdd = totalUnits - actualUnits;
|
|
236
236
|
const head = Math.floor(unitsToAdd / 2);
|
|
237
237
|
const tail = unitsToAdd - head;
|
|
@@ -9,11 +9,12 @@ import { deepExtend, defined, limitValue, round, setDefaultOptions, valueOrDefau
|
|
|
9
9
|
import autoMajorUnit from './utils/auto-major-unit';
|
|
10
10
|
import autoAxisMin from './utils/auto-axis-min';
|
|
11
11
|
import autoAxisMax from './utils/auto-axis-max';
|
|
12
|
-
import
|
|
13
|
-
import
|
|
12
|
+
import floorToStep from './utils/floor-to-step';
|
|
13
|
+
import ceilToStep from './utils/ceil-to-step';
|
|
14
14
|
import limitCoordinate from './utils/limit-coordinate';
|
|
15
|
+
import roundToPrecision from './utils/round-to-precision';
|
|
15
16
|
|
|
16
|
-
const
|
|
17
|
+
const MIN_POINTS_RANGE = Math.pow(10, 1 - DEFAULT_PRECISION);
|
|
17
18
|
|
|
18
19
|
class NumericAxis extends Axis {
|
|
19
20
|
|
|
@@ -137,7 +138,7 @@ class NumericAxis extends Axis {
|
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
const value = min + valueOffset;
|
|
140
|
-
return
|
|
141
|
+
return roundToPrecision(value);
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
translateRange(delta) {
|
|
@@ -146,15 +147,15 @@ class NumericAxis extends Axis {
|
|
|
146
147
|
const { lineSize } = this.lineInfo();
|
|
147
148
|
const range = max - min;
|
|
148
149
|
const scale = lineSize / range;
|
|
149
|
-
let offset =
|
|
150
|
+
let offset = delta / scale;
|
|
150
151
|
|
|
151
152
|
if ((vertical || reverse) && !(vertical && reverse )) {
|
|
152
153
|
offset = -offset;
|
|
153
154
|
}
|
|
154
155
|
|
|
155
156
|
return {
|
|
156
|
-
min: min + offset,
|
|
157
|
-
max: max + offset,
|
|
157
|
+
min: roundToPrecision(min + offset),
|
|
158
|
+
max: roundToPrecision(max + offset),
|
|
158
159
|
offset: offset
|
|
159
160
|
};
|
|
160
161
|
}
|
|
@@ -165,7 +166,7 @@ class NumericAxis extends Axis {
|
|
|
165
166
|
|
|
166
167
|
createAxisLabel(index, labelOptions, labelContext) {
|
|
167
168
|
const options = this.options;
|
|
168
|
-
const value =
|
|
169
|
+
const value = roundToPrecision(options.min + (index * options.majorUnit));
|
|
169
170
|
const text = this.axisLabelText(value, labelOptions, labelContext);
|
|
170
171
|
|
|
171
172
|
return new AxisLabel(value, text, index, null, labelOptions);
|
|
@@ -186,8 +187,9 @@ class NumericAxis extends Axis {
|
|
|
186
187
|
const endValue = this.getValue(end);
|
|
187
188
|
const min = Math.min(startValue, endValue);
|
|
188
189
|
const max = Math.max(startValue, endValue);
|
|
190
|
+
const range = max - min;
|
|
189
191
|
|
|
190
|
-
if (
|
|
192
|
+
if (range > MIN_POINTS_RANGE) {
|
|
191
193
|
return {
|
|
192
194
|
min: min,
|
|
193
195
|
max: max
|
|
@@ -201,12 +203,8 @@ class NumericAxis extends Axis {
|
|
|
201
203
|
const delta = this.scaleToDelta(scale, range);
|
|
202
204
|
const minDelta = position * delta;
|
|
203
205
|
const maxDelta = (1 - position) * delta;
|
|
204
|
-
const min =
|
|
205
|
-
let max =
|
|
206
|
-
|
|
207
|
-
if (max - min < MIN_VALUE_RANGE) {
|
|
208
|
-
max = min + MIN_VALUE_RANGE;
|
|
209
|
-
}
|
|
206
|
+
const min = roundToPrecision(this.options.min + minDelta);
|
|
207
|
+
let max = roundToPrecision(this.options.max - maxDelta);
|
|
210
208
|
|
|
211
209
|
return {
|
|
212
210
|
min: min,
|
|
@@ -224,10 +222,6 @@ class NumericAxis extends Axis {
|
|
|
224
222
|
narrowRange: false
|
|
225
223
|
};
|
|
226
224
|
}
|
|
227
|
-
|
|
228
|
-
isValidRange(min, max) {
|
|
229
|
-
return max - min > MIN_VALUE_RANGE;
|
|
230
|
-
}
|
|
231
225
|
}
|
|
232
226
|
|
|
233
227
|
function autoAxisOptions(seriesMin, seriesMax, options) {
|
|
@@ -251,8 +245,8 @@ function autoAxisOptions(seriesMin, seriesMax, options) {
|
|
|
251
245
|
}
|
|
252
246
|
}
|
|
253
247
|
|
|
254
|
-
autoOptions.min =
|
|
255
|
-
autoOptions.max =
|
|
248
|
+
autoOptions.min = floorToStep(autoMin, majorUnit);
|
|
249
|
+
autoOptions.max = ceilToStep(autoMax, majorUnit);
|
|
256
250
|
|
|
257
251
|
return autoOptions;
|
|
258
252
|
}
|
|
@@ -297,8 +291,8 @@ function axisOptions(autoOptions, userOptions) {
|
|
|
297
291
|
}
|
|
298
292
|
|
|
299
293
|
if (userOptions.majorUnit) {
|
|
300
|
-
autoOptions.min =
|
|
301
|
-
autoOptions.max =
|
|
294
|
+
autoOptions.min = floorToStep(autoOptions.min, userOptions.majorUnit);
|
|
295
|
+
autoOptions.max = ceilToStep(autoOptions.max, userOptions.majorUnit);
|
|
302
296
|
} else if (userSetLimits) {
|
|
303
297
|
options = deepExtend(autoOptions, userOptions);
|
|
304
298
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DEFAULT_PRECISION } from '../../common/constants';
|
|
2
|
-
import
|
|
2
|
+
import roundToPrecision from './round-to-precision';
|
|
3
3
|
|
|
4
4
|
export default function autoMajorUnit(min, max) {
|
|
5
|
-
let diff =
|
|
5
|
+
let diff = roundToPrecision(max - min, DEFAULT_PRECISION - 1);
|
|
6
6
|
|
|
7
7
|
if (diff === 0) {
|
|
8
8
|
if (max === 0) {
|
|
@@ -13,7 +13,7 @@ export default function autoMajorUnit(min, max) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const scale = Math.pow(10, Math.floor(Math.log(diff) / Math.log(10)));
|
|
16
|
-
const relativeValue =
|
|
16
|
+
const relativeValue = roundToPrecision((diff / scale), DEFAULT_PRECISION);
|
|
17
17
|
let scaleMultiplier = 1;
|
|
18
18
|
|
|
19
19
|
if (relativeValue < 1.904762) {
|
|
@@ -26,5 +26,5 @@ export default function autoMajorUnit(min, max) {
|
|
|
26
26
|
scaleMultiplier = 2;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
return
|
|
30
|
-
}
|
|
29
|
+
return roundToPrecision((scale * scaleMultiplier), DEFAULT_PRECISION);
|
|
30
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DEFAULT_PRECISION } from '../../common/constants';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Rounds the given value to the specified number of significant digits and returns it as a number.
|
|
5
|
+
*
|
|
6
|
+
* This maintains the order of magnitude of the original value while rounding it to a specified number of significant digits,
|
|
7
|
+
* which is particularly useful for handling very small or very large numbers without losing their scale.
|
|
8
|
+
*
|
|
9
|
+
* For example, `roundToPrecision(0.000123456, 3)` will return `0.000123`, and `roundToPrecision(123456, 2)` will return `120000`.
|
|
10
|
+
*
|
|
11
|
+
* @param {*} value The value to round.
|
|
12
|
+
* @param {*} precision The number of significant digits to round to. Defaults to DEFAULT_PRECISION.
|
|
13
|
+
* @returns The rounded value as a number.
|
|
14
|
+
*/
|
|
15
|
+
export default function roundToPrecision(value, precision = DEFAULT_PRECISION) {
|
|
16
|
+
if (!Number.isFinite(value) || value === 0) {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return parseFloat((value).toPrecision(precision));
|
|
21
|
+
}
|
|
@@ -7,7 +7,7 @@ import { BLACK, DATE, COORD_PRECISION, DEFAULT_PRECISION } from '../common/const
|
|
|
7
7
|
import { setDefaultOptions, deepExtend, limitValue, round } from '../common';
|
|
8
8
|
|
|
9
9
|
import autoMajorUnit from './utils/auto-major-unit';
|
|
10
|
-
import
|
|
10
|
+
import ceilToStep from './utils/ceil-to-step';
|
|
11
11
|
|
|
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';
|
|
@@ -226,12 +226,12 @@ function applyDefaults(seriesMin, seriesMax, options) {
|
|
|
226
226
|
const autoMin = floorDate(toTime(min) - 1, baseUnit, weekStartDay) || toDate(max);
|
|
227
227
|
const autoMax = ceilDate(toTime(max) + 1, baseUnit, weekStartDay);
|
|
228
228
|
const userMajorUnit = options.majorUnit ? options.majorUnit : undefined;
|
|
229
|
-
const majorUnit = userMajorUnit ||
|
|
229
|
+
const majorUnit = userMajorUnit || ceilToStep(
|
|
230
230
|
autoMajorUnit(autoMin.getTime(), autoMax.getTime()),
|
|
231
231
|
baseUnitTime
|
|
232
232
|
) / baseUnitTime;
|
|
233
233
|
const actualUnits = duration(autoMin, autoMax, baseUnit);
|
|
234
|
-
const totalUnits =
|
|
234
|
+
const totalUnits = ceilToStep(actualUnits, majorUnit);
|
|
235
235
|
const unitsToAdd = totalUnits - actualUnits;
|
|
236
236
|
const head = Math.floor(unitsToAdd / 2);
|
|
237
237
|
const tail = unitsToAdd - head;
|
|
@@ -9,11 +9,12 @@ import { deepExtend, defined, limitValue, round, setDefaultOptions, valueOrDefau
|
|
|
9
9
|
import autoMajorUnit from './utils/auto-major-unit';
|
|
10
10
|
import autoAxisMin from './utils/auto-axis-min';
|
|
11
11
|
import autoAxisMax from './utils/auto-axis-max';
|
|
12
|
-
import
|
|
13
|
-
import
|
|
12
|
+
import floorToStep from './utils/floor-to-step';
|
|
13
|
+
import ceilToStep from './utils/ceil-to-step';
|
|
14
14
|
import limitCoordinate from './utils/limit-coordinate';
|
|
15
|
+
import roundToPrecision from './utils/round-to-precision';
|
|
15
16
|
|
|
16
|
-
const
|
|
17
|
+
const MIN_POINTS_RANGE = Math.pow(10, 1 - DEFAULT_PRECISION);
|
|
17
18
|
|
|
18
19
|
class NumericAxis extends Axis {
|
|
19
20
|
|
|
@@ -137,7 +138,7 @@ class NumericAxis extends Axis {
|
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
const value = min + valueOffset;
|
|
140
|
-
return
|
|
141
|
+
return roundToPrecision(value);
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
translateRange(delta) {
|
|
@@ -146,15 +147,15 @@ class NumericAxis extends Axis {
|
|
|
146
147
|
const { lineSize } = this.lineInfo();
|
|
147
148
|
const range = max - min;
|
|
148
149
|
const scale = lineSize / range;
|
|
149
|
-
let offset =
|
|
150
|
+
let offset = delta / scale;
|
|
150
151
|
|
|
151
152
|
if ((vertical || reverse) && !(vertical && reverse )) {
|
|
152
153
|
offset = -offset;
|
|
153
154
|
}
|
|
154
155
|
|
|
155
156
|
return {
|
|
156
|
-
min: min + offset,
|
|
157
|
-
max: max + offset,
|
|
157
|
+
min: roundToPrecision(min + offset),
|
|
158
|
+
max: roundToPrecision(max + offset),
|
|
158
159
|
offset: offset
|
|
159
160
|
};
|
|
160
161
|
}
|
|
@@ -165,7 +166,7 @@ class NumericAxis extends Axis {
|
|
|
165
166
|
|
|
166
167
|
createAxisLabel(index, labelOptions, labelContext) {
|
|
167
168
|
const options = this.options;
|
|
168
|
-
const value =
|
|
169
|
+
const value = roundToPrecision(options.min + (index * options.majorUnit));
|
|
169
170
|
const text = this.axisLabelText(value, labelOptions, labelContext);
|
|
170
171
|
|
|
171
172
|
return new AxisLabel(value, text, index, null, labelOptions);
|
|
@@ -186,8 +187,9 @@ class NumericAxis extends Axis {
|
|
|
186
187
|
const endValue = this.getValue(end);
|
|
187
188
|
const min = Math.min(startValue, endValue);
|
|
188
189
|
const max = Math.max(startValue, endValue);
|
|
190
|
+
const range = max - min;
|
|
189
191
|
|
|
190
|
-
if (
|
|
192
|
+
if (range > MIN_POINTS_RANGE) {
|
|
191
193
|
return {
|
|
192
194
|
min: min,
|
|
193
195
|
max: max
|
|
@@ -201,12 +203,8 @@ class NumericAxis extends Axis {
|
|
|
201
203
|
const delta = this.scaleToDelta(scale, range);
|
|
202
204
|
const minDelta = position * delta;
|
|
203
205
|
const maxDelta = (1 - position) * delta;
|
|
204
|
-
const min =
|
|
205
|
-
let max =
|
|
206
|
-
|
|
207
|
-
if (max - min < MIN_VALUE_RANGE) {
|
|
208
|
-
max = min + MIN_VALUE_RANGE;
|
|
209
|
-
}
|
|
206
|
+
const min = roundToPrecision(this.options.min + minDelta);
|
|
207
|
+
let max = roundToPrecision(this.options.max - maxDelta);
|
|
210
208
|
|
|
211
209
|
return {
|
|
212
210
|
min: min,
|
|
@@ -224,10 +222,6 @@ class NumericAxis extends Axis {
|
|
|
224
222
|
narrowRange: false
|
|
225
223
|
};
|
|
226
224
|
}
|
|
227
|
-
|
|
228
|
-
isValidRange(min, max) {
|
|
229
|
-
return max - min > MIN_VALUE_RANGE;
|
|
230
|
-
}
|
|
231
225
|
}
|
|
232
226
|
|
|
233
227
|
function autoAxisOptions(seriesMin, seriesMax, options) {
|
|
@@ -251,8 +245,8 @@ function autoAxisOptions(seriesMin, seriesMax, options) {
|
|
|
251
245
|
}
|
|
252
246
|
}
|
|
253
247
|
|
|
254
|
-
autoOptions.min =
|
|
255
|
-
autoOptions.max =
|
|
248
|
+
autoOptions.min = floorToStep(autoMin, majorUnit);
|
|
249
|
+
autoOptions.max = ceilToStep(autoMax, majorUnit);
|
|
256
250
|
|
|
257
251
|
return autoOptions;
|
|
258
252
|
}
|
|
@@ -297,8 +291,8 @@ function axisOptions(autoOptions, userOptions) {
|
|
|
297
291
|
}
|
|
298
292
|
|
|
299
293
|
if (userOptions.majorUnit) {
|
|
300
|
-
autoOptions.min =
|
|
301
|
-
autoOptions.max =
|
|
294
|
+
autoOptions.min = floorToStep(autoOptions.min, userOptions.majorUnit);
|
|
295
|
+
autoOptions.max = ceilToStep(autoOptions.max, userOptions.majorUnit);
|
|
302
296
|
} else if (userSetLimits) {
|
|
303
297
|
options = deepExtend(autoOptions, userOptions);
|
|
304
298
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DEFAULT_PRECISION } from '../../common/constants';
|
|
2
|
-
import
|
|
2
|
+
import roundToPrecision from './round-to-precision';
|
|
3
3
|
|
|
4
4
|
export default function autoMajorUnit(min, max) {
|
|
5
|
-
let diff =
|
|
5
|
+
let diff = roundToPrecision(max - min, DEFAULT_PRECISION - 1);
|
|
6
6
|
|
|
7
7
|
if (diff === 0) {
|
|
8
8
|
if (max === 0) {
|
|
@@ -13,7 +13,7 @@ export default function autoMajorUnit(min, max) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const scale = Math.pow(10, Math.floor(Math.log(diff) / Math.log(10)));
|
|
16
|
-
const relativeValue =
|
|
16
|
+
const relativeValue = roundToPrecision((diff / scale), DEFAULT_PRECISION);
|
|
17
17
|
let scaleMultiplier = 1;
|
|
18
18
|
|
|
19
19
|
if (relativeValue < 1.904762) {
|
|
@@ -26,5 +26,5 @@ export default function autoMajorUnit(min, max) {
|
|
|
26
26
|
scaleMultiplier = 2;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
return
|
|
30
|
-
}
|
|
29
|
+
return roundToPrecision((scale * scaleMultiplier), DEFAULT_PRECISION);
|
|
30
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DEFAULT_PRECISION } from '../../common/constants';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Rounds the given value to the specified number of significant digits and returns it as a number.
|
|
5
|
+
*
|
|
6
|
+
* This maintains the order of magnitude of the original value while rounding it to a specified number of significant digits,
|
|
7
|
+
* which is particularly useful for handling very small or very large numbers without losing their scale.
|
|
8
|
+
*
|
|
9
|
+
* For example, `roundToPrecision(0.000123456, 3)` will return `0.000123`, and `roundToPrecision(123456, 2)` will return `120000`.
|
|
10
|
+
*
|
|
11
|
+
* @param {*} value The value to round.
|
|
12
|
+
* @param {*} precision The number of significant digits to round to. Defaults to DEFAULT_PRECISION.
|
|
13
|
+
* @returns The rounded value as a number.
|
|
14
|
+
*/
|
|
15
|
+
export default function roundToPrecision(value, precision = DEFAULT_PRECISION) {
|
|
16
|
+
if (!Number.isFinite(value) || value === 0) {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return parseFloat((value).toPrecision(precision));
|
|
21
|
+
}
|