@devexperts/dxcharts-lite 2.7.17 → 2.7.19
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/chart/components/chart/price-formatters/price.formatter.js +4 -2
- package/dist/chart/components/labels_generator/numeric-axis-labels.generator.js +3 -3
- package/dist/chart/components/y_axis/price_labels/price-label.drawer.js +2 -2
- package/dist/chart/model/scale.model.js +4 -9
- package/dist/chart/utils/device/browser.utils.js +9 -3
- package/dist/chart/utils/math.utils.d.ts +1 -0
- package/dist/chart/utils/math.utils.js +4 -0
- package/dist/chart/utils/symbol-constants.d.ts +7 -0
- package/dist/chart/utils/symbol-constants.js +7 -0
- package/dist/dxchart.min.js +4 -4
- package/package.json +7 -7
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
6
|
import { unitToPercent } from '../../../model/scaling/viewport.model';
|
|
7
|
+
import { replaceMinusSign } from '../../../utils/math.utils';
|
|
7
8
|
import { PriceIncrementsUtils } from '../../../utils/price-increments.utils';
|
|
9
|
+
import { MINUS_SIGN } from '../../../utils/symbol-constants';
|
|
8
10
|
import { treasuryPriceFormatter } from './treasury-price.formatter';
|
|
9
11
|
export const createRegularPriceFormatter = (extent, config) => (value) => {
|
|
10
12
|
let checkedValue;
|
|
@@ -36,8 +38,8 @@ export const createPercentFormatter = (extent) => (value, dataSeries) => {
|
|
|
36
38
|
valueUnit = unitToPercent(value, series.getBaseline());
|
|
37
39
|
}
|
|
38
40
|
// always apply default precision for percent
|
|
39
|
-
const formatted = valueUnit.toFixed(PriceIncrementsUtils.DEFAULT_PRECISION)
|
|
40
|
-
return formatted ===
|
|
41
|
+
const formatted = replaceMinusSign(valueUnit.toFixed(PriceIncrementsUtils.DEFAULT_PRECISION)) + ' %';
|
|
42
|
+
return formatted === `${MINUS_SIGN}0.00 %` ? '0.00 %' : formatted;
|
|
41
43
|
};
|
|
42
44
|
export const createYExtentFormatters = (extent, config) => ({
|
|
43
45
|
percent: createPercentFormatter(extent),
|
|
@@ -7,7 +7,7 @@ import { Subject } from 'rxjs';
|
|
|
7
7
|
import { logValueToUnit, percentToUnit, calcLogValue } from '../../model/scaling/viewport.model';
|
|
8
8
|
import { AnimationFrameCache } from '../../utils/performance/animation-frame-cache.utils';
|
|
9
9
|
import { identity } from '../../utils/function.utils';
|
|
10
|
-
import { MathUtils } from '../../utils/math.utils';
|
|
10
|
+
import { replaceMinusSign, MathUtils } from '../../utils/math.utils';
|
|
11
11
|
import { PriceIncrementsUtils } from '../../utils/price-increments.utils';
|
|
12
12
|
import { TREASURY_32ND } from '../chart/price-formatters/treasury-price.formatter';
|
|
13
13
|
const PIXEL_OFFSET = 0;
|
|
@@ -49,7 +49,7 @@ export class NumericAxisLabelsGenerator {
|
|
|
49
49
|
while (value < max) {
|
|
50
50
|
// Adjust value to increment
|
|
51
51
|
const adjustedValue = MathUtils.roundToNearest(value, singleLabelHeightValue);
|
|
52
|
-
const labelText = this.valueFormatter(adjustedValue);
|
|
52
|
+
const labelText = replaceMinusSign(this.valueFormatter(adjustedValue));
|
|
53
53
|
newLabels.push({
|
|
54
54
|
value: adjustedValue,
|
|
55
55
|
text: labelText,
|
|
@@ -66,7 +66,7 @@ export class NumericAxisLabelsGenerator {
|
|
|
66
66
|
// Adjust value to increment
|
|
67
67
|
const adjustedValue = MathUtils.roundToNearest(value, singleLabelHeightValue);
|
|
68
68
|
const valueUnit = percentToUnit(adjustedValue, baseLine);
|
|
69
|
-
const labelText = this.valueFormatter(valueUnit);
|
|
69
|
+
const labelText = replaceMinusSign(this.valueFormatter(valueUnit));
|
|
70
70
|
newLabels.push({
|
|
71
71
|
value: adjustedValue,
|
|
72
72
|
text: labelText,
|
|
@@ -8,7 +8,7 @@ import { getFontFromConfig, } from '../../../chart.config';
|
|
|
8
8
|
import { redrawBackgroundArea } from '../../../drawers/chart-background.drawer';
|
|
9
9
|
import { avoidAntialiasing, drawLine } from '../../../utils/canvas/canvas-drawing-functions.utils';
|
|
10
10
|
import { calculateSymbolHeight, calculateTextWidth } from '../../../utils/canvas/canvas-font-measure-tool.utils';
|
|
11
|
-
import { floor } from '../../../utils/math.utils';
|
|
11
|
+
import { floor, replaceMinusSign } from '../../../utils/math.utils';
|
|
12
12
|
import { drawBadgeLabel, drawPlainLabel, drawRectLabel, checkLabelInBoundaries } from '../y-axis-labels.drawer';
|
|
13
13
|
export const DEFAULT_LABEL_APPEARANCE_TYPE = 'badge';
|
|
14
14
|
const DEFAULT_PADDING = 4;
|
|
@@ -66,7 +66,7 @@ export function drawLabel(ctx, yAxisDescriptionsCtx, backgroundCtx, bounds, pane
|
|
|
66
66
|
}
|
|
67
67
|
const lineY = (_e = visualLabel.lineY) !== null && _e !== void 0 ? _e : visualLabel.y;
|
|
68
68
|
const _drawLine = () => showLine && avoidAntialiasing(ctx, () => drawLine(ctx, lineXStart, lineY, lineXEnd, lineY, 1));
|
|
69
|
-
const _drawLabel = () => drawLabel(ctx, bounds, text, centralY, visualLabel, config, colors.yAxis, false);
|
|
69
|
+
const _drawLabel = () => drawLabel(ctx, bounds, replaceMinusSign(text), centralY, visualLabel, config, colors.yAxis, false);
|
|
70
70
|
const drawLineLabel = () => {
|
|
71
71
|
_drawLine();
|
|
72
72
|
_drawDescription();
|
|
@@ -246,7 +246,7 @@ export class ScaleModel extends ViewportModel {
|
|
|
246
246
|
if (initialState.yStart === yStart && initialState.yEnd === yEnd && initialState.zoomY > 0) {
|
|
247
247
|
return;
|
|
248
248
|
}
|
|
249
|
-
if (this.state.lockPriceToBarRatio) {
|
|
249
|
+
if (this.state.lockPriceToBarRatio && this.initialViewportValidSubject.getValue()) {
|
|
250
250
|
this.setLockedYScale(yStart, yEnd, fire, initialState);
|
|
251
251
|
return;
|
|
252
252
|
}
|
|
@@ -284,15 +284,10 @@ export class ScaleModel extends ViewportModel {
|
|
|
284
284
|
moveXStart(state, xStart);
|
|
285
285
|
// there we need only candles constraint
|
|
286
286
|
const constrainedState = this.scalePostProcessor(initialStateCopy, state);
|
|
287
|
-
if (
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
else {
|
|
291
|
-
if (this.state.auto) {
|
|
292
|
-
this.autoScaleModel.doAutoYScale(constrainedState);
|
|
293
|
-
}
|
|
294
|
-
this.apply(constrainedState);
|
|
287
|
+
if (this.state.auto) {
|
|
288
|
+
this.autoScaleModel.doAutoYScale(constrainedState);
|
|
295
289
|
}
|
|
290
|
+
this.apply(constrainedState);
|
|
296
291
|
}
|
|
297
292
|
/**
|
|
298
293
|
* Moves both yStart and yEnd without changing the viewport height (zoom).
|
|
@@ -3,13 +3,19 @@
|
|
|
3
3
|
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
|
-
let isMobileCache
|
|
6
|
+
let isMobileCache;
|
|
7
|
+
let userAgentCache;
|
|
7
8
|
/**
|
|
8
9
|
* @doc-tags utility,mobile
|
|
9
10
|
*/
|
|
10
11
|
export const isMobile = () => {
|
|
11
|
-
if (
|
|
12
|
-
|
|
12
|
+
if (typeof navigator === 'undefined') {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const currentUserAgent = navigator.userAgent;
|
|
16
|
+
if (userAgentCache !== currentUserAgent || isMobileCache === undefined) {
|
|
17
|
+
userAgentCache = currentUserAgent;
|
|
18
|
+
isMobileCache = !!currentUserAgent.match(/Android|iPhone|Opera Mini/);
|
|
13
19
|
}
|
|
14
20
|
return isMobileCache;
|
|
15
21
|
};
|
|
@@ -39,3 +39,4 @@ 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
41
|
export declare function countDecimalPlaces(number: number): number;
|
|
42
|
+
export declare const replaceMinusSign: (stringValue: string) => string;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
|
+
import { MINUS_SIGN, TRUE_MINUS_SIGN } from './symbol-constants';
|
|
6
7
|
const MAX_DECIMAL_DIGITS = 14;
|
|
7
8
|
// Array of powers of 10. Used in roundDecimal to walk through mantissa.
|
|
8
9
|
const POW10 = [];
|
|
@@ -152,3 +153,6 @@ export function countDecimalPlaces(number) {
|
|
|
152
153
|
return 0; // No decimal places
|
|
153
154
|
}
|
|
154
155
|
}
|
|
156
|
+
export const replaceMinusSign = (stringValue) => {
|
|
157
|
+
return stringValue.replace(TRUE_MINUS_SIGN, MINUS_SIGN);
|
|
158
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2019 - 2025 Devexperts Solutions IE Limited
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
|
+
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
|
+
*/
|
|
6
|
+
export declare const MINUS_SIGN = "\u2212";
|
|
7
|
+
export declare const TRUE_MINUS_SIGN = "-";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2019 - 2025 Devexperts Solutions IE Limited
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
|
+
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
|
+
*/
|
|
6
|
+
export const MINUS_SIGN = '−';
|
|
7
|
+
export const TRUE_MINUS_SIGN = '-';
|