@devexperts/dxcharts-lite 2.7.6 → 2.7.9
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/README.md +41 -43
- package/dist/chart/canvas/canvas-bounds-container.d.ts +1 -0
- package/dist/chart/canvas/canvas-bounds-container.js +8 -0
- package/dist/chart/chart.config.d.ts +5 -0
- package/dist/chart/chart.config.js +4 -0
- package/dist/chart/components/chart/candle.functions.js +1 -0
- package/dist/chart/components/highlights/highlights.drawer.js +4 -1
- package/dist/chart/components/pane/extent/y-extent-component.d.ts +1 -1
- package/dist/chart/components/pane/extent/y-extent-component.js +19 -3
- package/dist/chart/components/pane/pane.component.d.ts +2 -2
- package/dist/chart/components/pane/pane.component.js +5 -0
- package/dist/chart/drawers/chart-type-drawers/area.drawer.js +9 -2
- package/dist/chart/drawers/data-series-drawers/data-series-drawers.utils.d.ts +1 -0
- package/dist/chart/drawers/data-series-drawers/data-series-drawers.utils.js +12 -9
- package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.d.ts +5 -2
- package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.js +12 -11
- package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.d.ts +1 -1
- package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.js +14 -15
- package/dist/chart/drawers/data-series.drawer.js +3 -1
- package/dist/chart/drawers/ht-data-series.drawer.d.ts +1 -0
- package/dist/chart/drawers/ht-data-series.drawer.js +2 -1
- package/dist/chart/model/candle.model.d.ts +4 -0
- package/dist/chart/model/candle.model.js +2 -1
- package/dist/chart/model/data-series.config.d.ts +2 -1
- package/dist/chart/model/data-series.model.js +1 -1
- package/dist/chart/utils/math.utils.d.ts +2 -1
- package/dist/chart/utils/math.utils.js +37 -6
- package/dist/dxchart.min.js +4 -4
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ export declare class MathUtils {
|
|
|
8
8
|
static roundToNearest(value: number, precision: number): number;
|
|
9
9
|
static roundUpToNearest(value: number, precision: number): number;
|
|
10
10
|
static roundDecimal(x: number): number;
|
|
11
|
-
static makeDecimal(value: number, precision: number, decimal?: string): string;
|
|
11
|
+
static makeDecimal(value: number, precision: number, decimal?: string, thousandsSeparator?: string): string;
|
|
12
12
|
static compare(a: number, b: number, eps: number): number;
|
|
13
13
|
static isZero(a: number): boolean;
|
|
14
14
|
static cutNumber(value: number, amountToCut: NumberFormatLabels, zeros?: number): string;
|
|
@@ -38,3 +38,4 @@ export declare const floor: (value: number) => number;
|
|
|
38
38
|
export declare const ceil: (value: number) => number;
|
|
39
39
|
export declare const round: (value: number) => number;
|
|
40
40
|
export declare const shiftRight: (value: number, shift: number) => number;
|
|
41
|
+
export declare function countDecimalPlaces(number: number): number;
|
|
@@ -45,14 +45,33 @@ export class MathUtils {
|
|
|
45
45
|
// Mantissa >= 10^14 with fractions -- just round
|
|
46
46
|
return Math.round(x);
|
|
47
47
|
}
|
|
48
|
-
static makeDecimal(value, precision, decimal) {
|
|
49
|
-
if (isFinite(value)) {
|
|
50
|
-
const stringValue = value.toFixed(precision);
|
|
51
|
-
return decimal ? stringValue.replace('.', decimal) : stringValue;
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
48
|
+
static makeDecimal(value, precision, decimal, thousandsSeparator) {
|
|
49
|
+
if (!isFinite(value)) {
|
|
54
50
|
return '';
|
|
55
51
|
}
|
|
52
|
+
if (isFinite(value)) {
|
|
53
|
+
let stringValue = value.toFixed(precision);
|
|
54
|
+
if (!thousandsSeparator) {
|
|
55
|
+
return decimal ? stringValue.replace('.', decimal) : stringValue;
|
|
56
|
+
}
|
|
57
|
+
if (decimal === thousandsSeparator) {
|
|
58
|
+
throw new Error('Grouping symbol cannot be the same as decimal separator.');
|
|
59
|
+
}
|
|
60
|
+
const splittedValue = stringValue.split('.');
|
|
61
|
+
let integerPart = splittedValue[0];
|
|
62
|
+
const fractionPart = splittedValue[1];
|
|
63
|
+
if (Math.abs(value) >= 1000) {
|
|
64
|
+
integerPart = integerPart.replace(RegExp('\\d(?=(\\d{3})+$)', 'g'), `$&${thousandsSeparator}`);
|
|
65
|
+
}
|
|
66
|
+
if (fractionPart) {
|
|
67
|
+
stringValue = [integerPart, fractionPart].join(decimal);
|
|
68
|
+
return stringValue;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return integerPart;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return '';
|
|
56
75
|
}
|
|
57
76
|
static compare(a, b, eps) {
|
|
58
77
|
if (a > b + eps) {
|
|
@@ -121,3 +140,15 @@ export const ceil = (value) => ~~(value + 1);
|
|
|
121
140
|
export const round = (value) => ~~(value + 0.5);
|
|
122
141
|
// eslint-disable-next-line no-bitwise
|
|
123
142
|
export const shiftRight = (value, shift) => value >> shift;
|
|
143
|
+
export function countDecimalPlaces(number) {
|
|
144
|
+
if (!Number.isFinite(number)) {
|
|
145
|
+
throw new Error('Input must be a finite number.');
|
|
146
|
+
}
|
|
147
|
+
const numberString = number.toString();
|
|
148
|
+
if (numberString.includes('.')) {
|
|
149
|
+
return numberString.split('.')[1].length;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
return 0; // No decimal places
|
|
153
|
+
}
|
|
154
|
+
}
|