@devexperts/dxcharts-lite 2.7.18 → 2.7.20

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.
@@ -512,6 +512,7 @@ export interface ChartConfigComponentsHighLow {
512
512
  high: string;
513
513
  low: string;
514
514
  };
515
+ lineDash: Array<number>;
515
516
  }
516
517
  export interface ChartConfigComponentsCrossTool {
517
518
  /**
@@ -763,6 +764,7 @@ export interface YAxisLabelColorConfig {
763
764
  boxColor: string;
764
765
  textColor?: string;
765
766
  descriptionText?: string;
767
+ descriptionTextColor?: string;
766
768
  }
767
769
  export interface YAxisLastPriceLabelColorConfig {
768
770
  boxSelected: string;
@@ -204,7 +204,7 @@ export const getDefaultConfig = () => ({
204
204
  logoWidth: 20,
205
205
  logoHeight: 20,
206
206
  },
207
- highLow: { visible: false, font: '12px sans-serif', prefix: { high: 'H: ', low: 'L: ' } },
207
+ highLow: { visible: false, font: '12px sans-serif', prefix: { high: 'H: ', low: 'L: ' }, lineDash: [2, 4] },
208
208
  highlights: {
209
209
  visible: false,
210
210
  fontFamily: 'Open Sans',
@@ -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).replace('-', '−') + ' %';
40
- return formatted === '−0.00 %' ? '0.00 %' : 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;
@@ -65,8 +65,9 @@ export function drawLabel(ctx, yAxisDescriptionsCtx, backgroundCtx, bounds, pane
65
65
  lineXEnd = chartBounds.x + chartBounds.width;
66
66
  }
67
67
  const lineY = (_e = visualLabel.lineY) !== null && _e !== void 0 ? _e : visualLabel.y;
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);
68
+ const _drawLine = () => showLine &&
69
+ avoidAntialiasing(ctx, () => drawLine(ctx, lineXStart, lineY, lineXEnd, lineY, 1, visualLabel.lineDash));
70
+ const _drawLabel = () => drawLabel(ctx, bounds, replaceMinusSign(text), centralY, visualLabel, config, colors.yAxis, false);
70
71
  const drawLineLabel = () => {
71
72
  _drawLine();
72
73
  _drawDescription();
@@ -25,6 +25,7 @@ export interface YAxisLabelDrawConfig {
25
25
  paddingEnd?: number;
26
26
  paddingStart?: number;
27
27
  rounded?: boolean;
28
+ lineDash?: Array<number>;
28
29
  }
29
30
  export declare const DEFAULT_PRICE_LABEL_PADDING = 4;
30
31
  /**
@@ -4,11 +4,12 @@
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 { MouseButton, leftMouseButtonListener, subscribeListener } from '../utils/dom.utils';
7
- import { merge, Subject } from 'rxjs';
7
+ import { asyncScheduler, fromEvent, merge, Subject } from 'rxjs';
8
8
  import { ChartBaseElement } from '../model/chart-base-element';
9
- import { distinctUntilChanged, filter, map, tap } from 'rxjs/operators';
9
+ import { distinctUntilChanged, filter, map, tap, throttleTime } from 'rxjs/operators';
10
10
  import { EVENT_RESIZED } from '../events/events';
11
11
  import { deviceDetector } from '../utils/device/device-detector.utils';
12
+ import { ONE_FRAME_MS } from '../utils/numeric-constants.utils';
12
13
  /**
13
14
  * Gathers user input on canvas element:
14
15
  * Chart update order should be following:
@@ -373,6 +374,9 @@ export class CanvasInputListenerComponent extends ChartBaseElement {
373
374
  this.canvasBounds.width = bcr.width;
374
375
  this.canvasBounds.height = bcr.height;
375
376
  }));
377
+ this.addRxSubscription(fromEvent(document, 'scroll', { capture: true, passive: true })
378
+ .pipe(throttleTime(ONE_FRAME_MS, asyncScheduler, { trailing: true }))
379
+ .subscribe(() => this.invalidateRectCache()));
376
380
  const mouseLeaveListener = () => {
377
381
  this.mouseLeavesCanvasSubject.next(true);
378
382
  };
@@ -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 (isSafari) {
288
- startViewportModelAnimationSafari(this.canvasAnimation, this, constrainedState, this.state.auto ? this.autoScaleModel : undefined);
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).
@@ -46,7 +46,7 @@ export declare function drawPriceLabel(ctx: CanvasRenderingContext2D, x0: number
46
46
  *
47
47
  * @returns {void}
48
48
  */
49
- export declare function drawLine(ctx: CanvasRenderingContext2D, x0: number, y0: number, x1: number, y1: number, thickness?: number): void;
49
+ export declare function drawLine(ctx: CanvasRenderingContext2D, x0: number, y0: number, x1: number, y1: number, thickness?: number, lineDash?: Array<number>): void;
50
50
  /**
51
51
  * Try to avoid anti-aliasing
52
52
  */
@@ -109,8 +109,9 @@ export function drawPriceLabel(ctx, x0, y0, x1, y1, x2, y2, _width, rounded, ali
109
109
  *
110
110
  * @returns {void}
111
111
  */
112
- export function drawLine(ctx, x0, y0, x1, y1, thickness = 1) {
112
+ export function drawLine(ctx, x0, y0, x1, y1, thickness = 1, lineDash = []) {
113
113
  ctx.save();
114
+ ctx.setLineDash(lineDash);
114
115
  ctx.lineWidth = thickness;
115
116
  ctx.beginPath();
116
117
  ctx.moveTo(x0, y0);
@@ -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 = undefined;
6
+ let isMobileCache;
7
+ let userAgentCache;
7
8
  /**
8
9
  * @doc-tags utility,mobile
9
10
  */
10
11
  export const isMobile = () => {
11
- if (!isMobileCache) {
12
- isMobileCache = !!navigator.userAgent.match(/Android|iPhone|Opera Mini/) || false;
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 = '-';