@devexperts/dxcharts-lite 2.7.9 → 2.7.10

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.
Files changed (27) hide show
  1. package/dist/chart/canvas/canvas-bounds-container.js +0 -5
  2. package/dist/chart/chart.config.d.ts +7 -0
  3. package/dist/chart/chart.config.js +3 -0
  4. package/dist/chart/chart.d.ts +5 -1
  5. package/dist/chart/chart.js +11 -0
  6. package/dist/chart/components/chart/chart-area-pan.handler.js +0 -5
  7. package/dist/chart/components/chart/chart-base.model.d.ts +4 -1
  8. package/dist/chart/components/chart/chart-base.model.js +2 -2
  9. package/dist/chart/components/chart/chart.model.d.ts +4 -1
  10. package/dist/chart/components/chart/chart.model.js +6 -6
  11. package/dist/chart/components/chart/{price.formatter.d.ts → price-formatters/price.formatter.d.ts} +7 -6
  12. package/dist/chart/components/chart/{price.formatter.js → price-formatters/price.formatter.js} +10 -5
  13. package/dist/chart/components/chart/price-formatters/treasury-price.formatter.d.ts +16 -0
  14. package/dist/chart/components/chart/price-formatters/treasury-price.formatter.js +26 -0
  15. package/dist/chart/components/labels_generator/numeric-axis-labels.generator.d.ts +4 -1
  16. package/dist/chart/components/labels_generator/numeric-axis-labels.generator.js +12 -4
  17. package/dist/chart/components/navigation_map/navigation-map-move.handler.d.ts +8 -7
  18. package/dist/chart/components/pane/extent/y-extent-component.d.ts +2 -1
  19. package/dist/chart/components/pane/extent/y-extent-component.js +4 -8
  20. package/dist/chart/components/pane/pane.component.js +2 -7
  21. package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.d.ts +2 -1
  22. package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.js +2 -2
  23. package/dist/chart/components/y_axis/y-axis.model.js +1 -1
  24. package/dist/chart/utils/candles.utils.d.ts +5 -1
  25. package/dist/chart/utils/candles.utils.js +14 -4
  26. package/dist/dxchart.min.js +4 -4
  27. package/package.json +1 -1
@@ -1,8 +1,3 @@
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
1
  /*
7
2
  * Copyright (C) 2019 - 2025 Devexperts Solutions IE Limited
8
3
  * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
@@ -442,6 +442,10 @@ export interface YAxisConfig {
442
442
  };
443
443
  fontSize: number;
444
444
  fontFamily: string;
445
+ /**
446
+ * Treasury format for price values (1/32 tick format for bonds)
447
+ */
448
+ treasuryFormat?: YAxisConfigTreasuryFormat;
445
449
  }
446
450
  export interface ChartConfigComponentsOffsets {
447
451
  visible: boolean;
@@ -788,6 +792,9 @@ export interface YAxisLabels {
788
792
  */
789
793
  settings: Record<YAxisLabelType, YAxisLabelConfig>;
790
794
  }
795
+ export interface YAxisConfigTreasuryFormat {
796
+ enabled: boolean;
797
+ }
791
798
  export interface YAxisTypeConfigProps {
792
799
  rounded?: boolean;
793
800
  paddings?: {
@@ -134,6 +134,9 @@ export const getDefaultConfig = () => ({
134
134
  },
135
135
  },
136
136
  },
137
+ treasuryFormat: {
138
+ enabled: false,
139
+ },
137
140
  },
138
141
  xAxis: {
139
142
  visible: true,
@@ -4,7 +4,7 @@
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 ChartBootstrap from './bootstrap';
7
- import { BarType, PartialChartConfig } from './chart.config';
7
+ import { BarType, PartialChartConfig, YAxisConfigTreasuryFormat } from './chart.config';
8
8
  import { CandleSeries } from './components/chart/chart.component';
9
9
  import { PaneComponent, YExtentFormatters } from './components/pane/pane.component';
10
10
  /**
@@ -60,5 +60,9 @@ export declare class Chart extends ChartBootstrap {
60
60
  */
61
61
  setRtl(rtl: boolean): void;
62
62
  setChartType(type: BarType): void;
63
+ /**
64
+ * Sets if regular or logarithmic price types should apply treasury format
65
+ */
66
+ setTreasuryFormat(treasuryFormat: YAxisConfigTreasuryFormat): void;
63
67
  createPane(): PaneComponent;
64
68
  }
@@ -103,6 +103,17 @@ export class Chart extends ChartBootstrap {
103
103
  this.data.setChartType(type);
104
104
  this.yAxis.updateOrderedLabels();
105
105
  }
106
+ /**
107
+ * Sets if regular or logarithmic price types should apply treasury format
108
+ */
109
+ setTreasuryFormat(treasuryFormat) {
110
+ this.config.components.yAxis.treasuryFormat = treasuryFormat;
111
+ this.paneManager.yExtents.forEach(ext => {
112
+ ext.yAxis.updateOrderedLabels(true);
113
+ ext.yAxis.model.fancyLabelsModel.updateLabels(true);
114
+ ext.yAxis.model.baseLabelsModel.updateLabels();
115
+ });
116
+ }
106
117
  createPane() {
107
118
  return this.paneManager.createPane();
108
119
  }
@@ -3,11 +3,6 @@
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
- /*
7
- * Copyright (C) 2019 - 2024 Devexperts Solutions IE Limited
8
- * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
9
- * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
10
- */
11
6
  import { animationFrameScheduler } from 'rxjs';
12
7
  import { throttleTime, filter } from 'rxjs/operators';
13
8
  import { VIEWPORT_ANIMATION_ID } from '../../animation/canvas-animation';
@@ -40,7 +40,10 @@ export declare class ChartBaseModel<T extends BaseType = 'point'> {
40
40
  * For given timestamp finds the closest candle in dataset.
41
41
  * @param timestamp
42
42
  */
43
- dataFromTimestamp(timestamp: Timestamp, shouldExtrapolate?: boolean, selectedDataPoints?: DataPoint<T>[]): VisualPoint<T>;
43
+ dataFromTimestamp(timestamp: Timestamp, options?: {
44
+ extrapolate: boolean;
45
+ isDaysPeriod?: boolean;
46
+ }, selectedDataPoints?: DataPoint<T>[]): VisualPoint<T>;
44
47
  /**
45
48
  * Recalculates the period of the main candle series based on the data points.
46
49
  * If a period is detected, it is set as the new period.
@@ -34,8 +34,8 @@ export class ChartBaseModel {
34
34
  * @param timestamp
35
35
  */
36
36
  // TODO think how to make this function like candleFromX
37
- dataFromTimestamp(timestamp, shouldExtrapolate = true, selectedDataPoints = this.mainDataPoints) {
38
- const result = searchCandleIndex(timestamp, shouldExtrapolate, selectedDataPoints, this.period);
37
+ dataFromTimestamp(timestamp, options = { extrapolate: true }, selectedDataPoints = this.mainDataPoints) {
38
+ const result = searchCandleIndex(timestamp, options, selectedDataPoints, this.period);
39
39
  return this.dataFromIdx(result.index);
40
40
  }
41
41
  /**
@@ -227,7 +227,10 @@ export declare class ChartModel extends ChartBaseElement {
227
227
  * For given timestamp finds the closest candle in dataset.
228
228
  * @param timestamp
229
229
  */
230
- candleFromTimestamp(timestamp: Timestamp, extrapolate?: boolean, selectedCandleSeries?: CandleSeriesModel): VisualCandle;
230
+ candleFromTimestamp(timestamp: Timestamp, options?: {
231
+ extrapolate: boolean;
232
+ isDaysPeriod?: boolean;
233
+ }, selectedCandleSeries?: CandleSeriesModel): VisualCandle;
231
234
  /**
232
235
  * For given id finds the target candle
233
236
  * @param id
@@ -524,9 +524,9 @@ export class ChartModel extends ChartBaseElement {
524
524
  * For given timestamp finds the closest candle in dataset.
525
525
  * @param timestamp
526
526
  */
527
- candleFromTimestamp(timestamp, extrapolate = true, selectedCandleSeries = this.mainCandleSeries) {
527
+ candleFromTimestamp(timestamp, options = { extrapolate: true }, selectedCandleSeries = this.mainCandleSeries) {
528
528
  const dataPointsSource = selectedCandleSeries.dataPoints;
529
- return this.chartBaseModel.dataFromTimestamp(timestamp, extrapolate, dataPointsSource);
529
+ return this.chartBaseModel.dataFromTimestamp(timestamp, options, dataPointsSource);
530
530
  }
531
531
  /**
532
532
  * For given id finds the target candle
@@ -723,7 +723,7 @@ export class ChartModel extends ChartBaseElement {
723
723
  return series.reduce((candles, candle) => {
724
724
  const timestamp = candle.timestamp;
725
725
  // find index of candle in baseSeries
726
- const result = searchCandleIndex(timestamp, false, baseSeries, this.chartBaseModel.period);
726
+ const result = searchCandleIndex(timestamp, { extrapolate: false }, baseSeries, this.chartBaseModel.period);
727
727
  if (result.index >= 0 && result.index < baseSeries.length) {
728
728
  candle.idx = result.index;
729
729
  candles[result.index] = candle;
@@ -767,7 +767,7 @@ export class ChartModel extends ChartBaseElement {
767
767
  return;
768
768
  }
769
769
  // detect index of updating candle
770
- const result = searchCandleIndex(candle.timestamp, true, curCandles, this.getPeriod());
770
+ const result = searchCandleIndex(candle.timestamp, { extrapolate: true }, curCandles, this.getPeriod());
771
771
  const idx = Math.min(result.index, curCandles.length);
772
772
  isNewCandle = isNewCandle || idx === curCandles.length;
773
773
  // update the candle and index
@@ -873,7 +873,7 @@ export class ChartModel extends ChartBaseElement {
873
873
  const targetCopy = target.slice();
874
874
  const prepend = [];
875
875
  prependUpdate.forEach(c => {
876
- const result = searchCandleIndex(c.timestamp, false, target);
876
+ const result = searchCandleIndex(c.timestamp, { extrapolate: false }, target);
877
877
  const idx = result.index;
878
878
  if (idx < 0) {
879
879
  prepend.push(c);
@@ -1007,7 +1007,7 @@ const updateCandles = (target, update) => {
1007
1007
  const prepend = [];
1008
1008
  const append = [];
1009
1009
  update.forEach(c => {
1010
- const result = searchCandleIndex(c.timestamp, true, target);
1010
+ const result = searchCandleIndex(c.timestamp, { extrapolate: true }, target);
1011
1011
  const idx = result.index;
1012
1012
  if (idx < 0) {
1013
1013
  prepend.push(c);
@@ -3,10 +3,11 @@
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 { DataSeriesModel } from '../../model/data-series.model';
7
- import { Unit } from '../../model/scaling/viewport.model';
8
- import { YExtentComponent } from '../pane/extent/y-extent-component';
9
- import { YExtentFormatters } from '../pane/pane.component';
10
- export declare const createRegularPriceFormatter: (extent: YExtentComponent) => (value: unknown) => string;
6
+ import { YAxisConfig } from '../../../chart.config';
7
+ import { DataSeriesModel } from '../../../model/data-series.model';
8
+ import { Unit } from '../../../model/scaling/viewport.model';
9
+ import { YExtentComponent } from '../../pane/extent/y-extent-component';
10
+ import { YExtentFormatters } from '../../pane/pane.component';
11
+ export declare const createRegularPriceFormatter: (extent: YExtentComponent, config: YAxisConfig) => (value: unknown) => string;
11
12
  export declare const createPercentFormatter: (extent: YExtentComponent) => (value: Unit, dataSeries?: DataSeriesModel) => string;
12
- export declare const createYExtentFormatters: (extent: YExtentComponent) => YExtentFormatters;
13
+ export declare const createYExtentFormatters: (extent: YExtentComponent, config: YAxisConfig) => YExtentFormatters;
@@ -3,9 +3,10 @@
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 { unitToPercent } from '../../model/scaling/viewport.model';
7
- import { PriceIncrementsUtils } from '../../utils/price-increments.utils';
8
- export const createRegularPriceFormatter = (extent) => (value) => {
6
+ import { unitToPercent } from '../../../model/scaling/viewport.model';
7
+ import { PriceIncrementsUtils } from '../../../utils/price-increments.utils';
8
+ import { treasuryPriceFormatter } from './treasury-price.formatter';
9
+ export const createRegularPriceFormatter = (extent, config) => (value) => {
9
10
  let checkedValue;
10
11
  if (typeof value === 'number') {
11
12
  checkedValue = value;
@@ -16,6 +17,10 @@ export const createRegularPriceFormatter = (extent) => (value) => {
16
17
  else {
17
18
  return '—';
18
19
  }
20
+ const treasuryFormatConfig = config.treasuryFormat;
21
+ if (treasuryFormatConfig && treasuryFormatConfig.enabled) {
22
+ return treasuryPriceFormatter(checkedValue);
23
+ }
19
24
  const [mainDataSeries] = extent.dataSeries;
20
25
  if (mainDataSeries !== undefined) {
21
26
  const precision = PriceIncrementsUtils.getPricePrecision(checkedValue, mainDataSeries.pricePrecisions);
@@ -34,7 +39,7 @@ export const createPercentFormatter = (extent) => (value, dataSeries) => {
34
39
  const formatted = valueUnit.toFixed(PriceIncrementsUtils.DEFAULT_PRECISION).replace('-', '−') + ' %';
35
40
  return formatted === '−0.00 %' ? '0.00 %' : formatted;
36
41
  };
37
- export const createYExtentFormatters = (extent) => ({
42
+ export const createYExtentFormatters = (extent, config) => ({
38
43
  percent: createPercentFormatter(extent),
39
- regular: createRegularPriceFormatter(extent),
44
+ regular: createRegularPriceFormatter(extent, config),
40
45
  });
@@ -0,0 +1,16 @@
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
+ /**
7
+ * Formats price values for US Treasury contracts in 32nds format
8
+ *
9
+ * Examples:
10
+ *
11
+ * 132.015625 => 132'00 (0.015625 = 0.5/32)
12
+ * 132.0625 => 132'02 (0.0625 = 2/32)
13
+ *
14
+ */
15
+ export declare const TREASURY_32ND: number;
16
+ export declare const treasuryPriceFormatter: (value: number) => string;
@@ -0,0 +1,26 @@
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
+ /**
7
+ * Formats price values for US Treasury contracts in 32nds format
8
+ *
9
+ * Examples:
10
+ *
11
+ * 132.015625 => 132'00 (0.015625 = 0.5/32)
12
+ * 132.0625 => 132'02 (0.0625 = 2/32)
13
+ *
14
+ */
15
+ export const TREASURY_32ND = 1 / 32; // 0.03125
16
+ export const treasuryPriceFormatter = (value) => {
17
+ const integerValue = Math.floor(value);
18
+ // Get the decimal part and convert to 64ths
19
+ const decimalPart = value - integerValue;
20
+ const sixtyFourths = Math.round(decimalPart * 64);
21
+ // Calculate 32nds and half
22
+ const thirtySeconds = Math.floor(sixtyFourths / 2);
23
+ // Format the 32nds part to always show 2 digits (00-31)
24
+ const thirtySecondsFormatted = thirtySeconds.toString().padStart(2, '0');
25
+ return `${integerValue}'${thirtySecondsFormatted}`;
26
+ };
@@ -6,6 +6,7 @@
6
6
  import { Observable, Subject } from 'rxjs';
7
7
  import { Unit } from '../../model/scaling/viewport.model';
8
8
  import { AnimationFrameCache } from '../../utils/performance/animation-frame-cache.utils';
9
+ import { YAxisConfig } from '../../chart.config';
9
10
  export type PriceAxisType = 'regular' | 'percent' | 'logarithmic';
10
11
  export interface LabelsGenerator {
11
12
  readonly observeLabelsChanged: () => Observable<NumericAxisLabel[]>;
@@ -23,6 +24,7 @@ export declare class NumericAxisLabelsGenerator implements LabelsGenerator {
23
24
  private baseLineProvider;
24
25
  private labelFilter;
25
26
  private singleLabelHeightPixels;
27
+ private yAxisConfig?;
26
28
  /**
27
29
  * Multipliers which are using for price increments to
28
30
  * calculate horizontal grid and price lines step.
@@ -34,7 +36,8 @@ export declare class NumericAxisLabelsGenerator implements LabelsGenerator {
34
36
  newGeneratedLabelsSubject: Subject<NumericAxisLabel[]>;
35
37
  private lastStart;
36
38
  private lastEnd;
37
- constructor(increment: number | null, startEndProvider: () => [Unit, Unit], lengthProvider: () => Unit, valueFormatter: (value: number) => string, withZero: boolean, axisTypeProvider: () => PriceAxisType, baseLineProvider: () => number, labelFilter?: (labels: NumericAxisLabel[]) => NumericAxisLabel[], singleLabelHeightPixels?: number);
39
+ private treasuryFormat;
40
+ constructor(increment: number | null, startEndProvider: () => [Unit, Unit], lengthProvider: () => Unit, valueFormatter: (value: number) => string, withZero: boolean, axisTypeProvider: () => PriceAxisType, baseLineProvider: () => number, labelFilter?: (labels: NumericAxisLabel[]) => NumericAxisLabel[], singleLabelHeightPixels?: number, yAxisConfig?: YAxisConfig | undefined);
38
41
  private generateRegularLabels;
39
42
  private generatePercentLabels;
40
43
  private generateLogarithmLabels;
@@ -9,13 +9,14 @@ import { AnimationFrameCache } from '../../utils/performance/animation-frame-cac
9
9
  import { identity } from '../../utils/function.utils';
10
10
  import { MathUtils } from '../../utils/math.utils';
11
11
  import { PriceIncrementsUtils } from '../../utils/price-increments.utils';
12
+ import { TREASURY_32ND } from '../chart/price-formatters/treasury-price.formatter';
12
13
  const PIXEL_OFFSET = 0;
13
14
  const DEFAULT_REGULAR_INCREMENT = 0.01;
14
15
  /**
15
16
  * Generator of axes labels.
16
17
  */
17
18
  export class NumericAxisLabelsGenerator {
18
- constructor(increment, startEndProvider, lengthProvider, valueFormatter, withZero = false, axisTypeProvider, baseLineProvider, labelFilter = identity, singleLabelHeightPixels = 23) {
19
+ constructor(increment, startEndProvider, lengthProvider, valueFormatter, withZero = false, axisTypeProvider, baseLineProvider, labelFilter = identity, singleLabelHeightPixels = 23, yAxisConfig) {
19
20
  this.increment = increment;
20
21
  this.startEndProvider = startEndProvider;
21
22
  this.lengthProvider = lengthProvider;
@@ -25,6 +26,7 @@ export class NumericAxisLabelsGenerator {
25
26
  this.baseLineProvider = baseLineProvider;
26
27
  this.labelFilter = labelFilter;
27
28
  this.singleLabelHeightPixels = singleLabelHeightPixels;
29
+ this.yAxisConfig = yAxisConfig;
28
30
  /**
29
31
  * Multipliers which are using for price increments to
30
32
  * calculate horizontal grid and price lines step.
@@ -38,6 +40,7 @@ export class NumericAxisLabelsGenerator {
38
40
  this.lastStart = 0;
39
41
  this.lastEnd = 0;
40
42
  this.labelsCache = new AnimationFrameCache(() => this.labelFilter(this.doGenerateLabels()));
43
+ this.treasuryFormat = this.yAxisConfig && this.yAxisConfig.treasuryFormat;
41
44
  }
42
45
  generateRegularLabels(min, max, singleLabelHeightValue) {
43
46
  const newLabels = [];
@@ -136,29 +139,34 @@ export class NumericAxisLabelsGenerator {
136
139
  return this.newGeneratedLabelsSubject.asObservable();
137
140
  }
138
141
  calculateIncrement(valueLength) {
142
+ var _a;
139
143
  // provided increment
140
144
  if (this.increment) {
141
145
  return this.increment;
142
146
  }
143
147
  // auto-generated increment
144
148
  if (!isNaN(valueLength)) {
145
- const calculatedIncrement = PriceIncrementsUtils.autoDetectIncrementOfValueRange(valueLength);
149
+ const calculatedIncrement = ((_a = this.treasuryFormat) === null || _a === void 0 ? void 0 : _a.enabled)
150
+ ? TREASURY_32ND
151
+ : PriceIncrementsUtils.autoDetectIncrementOfValueRange(valueLength);
146
152
  return this.adjustIncrementOnAxisType(calculatedIncrement);
147
153
  }
148
154
  return this.adjustIncrementOnAxisType(DEFAULT_REGULAR_INCREMENT);
149
155
  }
150
156
  adjustIncrementOnAxisType(increment) {
157
+ var _a;
158
+ const calculatedIncrement = ((_a = this.treasuryFormat) === null || _a === void 0 ? void 0 : _a.enabled) ? TREASURY_32ND : increment;
151
159
  switch (this.axisTypeProvider()) {
152
160
  case 'percent':
153
161
  return increment;
154
162
  case 'logarithmic':
155
163
  const [logMin] = this.calculateMinMax();
156
164
  const regularMin = logValueToUnit(logMin);
157
- const regularIncrementedValue = regularMin + increment;
165
+ const regularIncrementedValue = regularMin + calculatedIncrement;
158
166
  const incrementedLogValue = calcLogValue(regularIncrementedValue);
159
167
  return incrementedLogValue - logMin;
160
168
  case 'regular':
161
- return increment;
169
+ return calculatedIncrement;
162
170
  }
163
171
  }
164
172
  // TODO rework, generator should act as model and update itself on scaleChanged
@@ -6,9 +6,10 @@
6
6
  import { CanvasBoundsContainer } from '../../canvas/canvas-bounds-container';
7
7
  import EventBus from '../../events/event-bus';
8
8
  import { ChartBaseElement } from '../../model/chart-base-element';
9
- import { CanvasInputListenerComponent } from '../../inputlisteners/canvas-input-listener.component';
9
+ import { CanvasInputListenerComponent, Point } from '../../inputlisteners/canvas-input-listener.component';
10
10
  import { ScaleModel } from '../../model/scale.model';
11
11
  import { ChartModel } from '../chart/chart.model';
12
+ import { DragInfo } from '../dran-n-drop_helper/drag-n-drop.component';
12
13
  import { ChartPanComponent } from '../pan/chart-pan.component';
13
14
  export declare class NavigationMapMoveHandler extends ChartBaseElement {
14
15
  private bus;
@@ -17,8 +18,8 @@ export declare class NavigationMapMoveHandler extends ChartBaseElement {
17
18
  private canvasInputListeners;
18
19
  private canvasBoundsContainer;
19
20
  private chartPanComponent;
20
- private leftKnotDragStartXRelative;
21
- private rightKnotDragStartXRelative;
21
+ leftKnotDragStartXRelative: number;
22
+ rightKnotDragStartXRelative: number;
22
23
  private lastMousePosition;
23
24
  constructor(bus: EventBus, chartModel: ChartModel, scale: ScaleModel, canvasInputListeners: CanvasInputListenerComponent, canvasBoundsContainer: CanvasBoundsContainer, chartPanComponent: ChartPanComponent);
24
25
  /**
@@ -27,10 +28,10 @@ export declare class NavigationMapMoveHandler extends ChartBaseElement {
27
28
  * @returns {void}
28
29
  */
29
30
  protected doActivate(): void;
30
- private leftKnotDragStart;
31
- private leftKnotDragTick;
32
- private rightKnotDragStart;
33
- private rightKnotDragTick;
31
+ leftKnotDragStart: (point: Point) => void;
32
+ leftKnotDragTick: (dragInfo: DragInfo) => void;
33
+ rightKnotDragStart: (point: Point) => void;
34
+ rightKnotDragTick: (dragInfo: DragInfo) => void;
34
35
  private sliderDragStart;
35
36
  private sliderDragTick;
36
37
  }
@@ -29,6 +29,7 @@ export interface YExtentCreationOptions {
29
29
  lockToPriceRatio: boolean;
30
30
  }
31
31
  export declare class YExtentComponent extends ChartBaseElement {
32
+ config: YAxisConfig;
32
33
  paneUUID: string;
33
34
  idx: number;
34
35
  paneComponent: PaneComponent;
@@ -42,7 +43,7 @@ export declare class YExtentComponent extends ChartBaseElement {
42
43
  formatters: YExtentFormatters;
43
44
  yAxis: YAxisComponent;
44
45
  mainDataSeries?: DataSeriesModel;
45
- constructor(paneUUID: string, idx: number, paneComponent: PaneComponent, chartBaseModel: ChartBaseModel<'candle'>, canvasBoundsContainer: CanvasBoundsContainer, hitTestController: PaneHitTestController, dynamicObjectsCanvasModel: CanvasModel, scale: ScaleModel, createYAxisComponent: (formatter: (value: number) => string, dataSeriesProvider: () => DataSeriesModel | undefined) => YAxisComponent, dragNDrop: DragNDropYComponent, dataSeries?: Set<DataSeriesModel>, formatters?: YExtentFormatters);
46
+ constructor(config: YAxisConfig, paneUUID: string, idx: number, paneComponent: PaneComponent, chartBaseModel: ChartBaseModel<'candle'>, canvasBoundsContainer: CanvasBoundsContainer, hitTestController: PaneHitTestController, dynamicObjectsCanvasModel: CanvasModel, scale: ScaleModel, createYAxisComponent: (formatter: (value: number) => string, dataSeriesProvider: () => DataSeriesModel | undefined) => YAxisComponent, dragNDrop: DragNDropYComponent, dataSeries?: Set<DataSeriesModel>, formatters?: YExtentFormatters);
46
47
  protected doDeactivate(): void;
47
48
  getYAxisBounds: () => Bounds;
48
49
  yAxisHT: import("../../../canvas/canvas-bounds-container").HitBoundsTest;
@@ -1,8 +1,3 @@
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
1
  /*
7
2
  * Copyright (C) 2019 - 2025 Devexperts Solutions IE Limited
8
3
  * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
@@ -13,12 +8,13 @@ import { ChartBaseElement } from '../../../model/chart-base-element';
13
8
  import { DataSeriesModel, VisualSeriesPoint, defaultValueFormatter, } from '../../../model/data-series.model';
14
9
  import { mergeHighLow } from '../../../model/scaling/auto-scale.model';
15
10
  import { uuid } from '../../../utils/uuid.utils';
16
- import { createYExtentFormatters } from '../../chart/price.formatter';
11
+ import { createYExtentFormatters } from '../../chart/price-formatters/price.formatter';
17
12
  export class YExtentComponent extends ChartBaseElement {
18
- constructor(paneUUID, idx, paneComponent, chartBaseModel, canvasBoundsContainer, hitTestController, dynamicObjectsCanvasModel, scale, createYAxisComponent, dragNDrop, dataSeries = new Set(), formatters = {
13
+ constructor(config, paneUUID, idx, paneComponent, chartBaseModel, canvasBoundsContainer, hitTestController, dynamicObjectsCanvasModel, scale, createYAxisComponent, dragNDrop, dataSeries = new Set(), formatters = {
19
14
  regular: defaultValueFormatter,
20
15
  }) {
21
16
  super();
17
+ this.config = config;
22
18
  this.paneUUID = paneUUID;
23
19
  this.idx = idx;
24
20
  this.paneComponent = paneComponent;
@@ -56,7 +52,7 @@ export class YExtentComponent extends ChartBaseElement {
56
52
  }
57
53
  };
58
54
  this.addChildEntity(scale);
59
- this.setValueFormatters(createYExtentFormatters(this));
55
+ this.setValueFormatters(createYExtentFormatters(this, config));
60
56
  this.yAxis = createYAxisComponent(this.valueFormatter.bind(this), () => this.mainDataSeries);
61
57
  this.addChildEntity(this.yAxis);
62
58
  }
@@ -1,8 +1,3 @@
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
1
  /*
7
2
  * Copyright (C) 2019 - 2025 Devexperts Solutions IE Limited
8
3
  * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
@@ -66,7 +61,7 @@ export class PaneComponent extends ChartBaseElement {
66
61
  this.mainExtent = yExtentComponent;
67
62
  this.ht = this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.PANE_UUID(uuid), {
68
63
  // this is needed to reduce cross event fire zone, so cross event won't be fired when hover resizer
69
- // maybe we need to rework it, this isn't perfect - top and bottom panes will have small no-hover area
64
+ // maybe we need to rework it, this isn't perfect: top and bottom panes will have small no-hover area
70
65
  extensionY: -this.config.components.paneResizer.dragZone,
71
66
  });
72
67
  }
@@ -138,7 +133,7 @@ export class PaneComponent extends ChartBaseElement {
138
133
  // creating partially resolved constructor except formatter & dataSeriesProvider - bcs it's not possible to provide formatter
139
134
  // before y-extent is created
140
135
  const createYAxisComponent = (formatter, dataSeriesProvider) => new YAxisComponent(this.eventBus, this.config, this.yAxisLabelsCanvasModel, scaleModel, this.canvasInputListener, this.canvasBoundsContainer, this.chartPanComponent, this.cursorHandler, formatter, dataSeriesProvider, this.uuid, extentIdx, this.hitTestCanvasModel, this.chartResizeHandler, initialYAxisState);
141
- const yExtentComponent = new YExtentComponent(this.uuid, extentIdx, this, this.chartBaseModel, this.canvasBoundsContainer, this.hitTestController, this.dynamicObjectsCanvasModel, scaleModel, createYAxisComponent, dragNDrop);
136
+ const yExtentComponent = new YExtentComponent(this.config.components.yAxis, this.uuid, extentIdx, this, this.chartBaseModel, this.canvasBoundsContainer, this.hitTestController, this.dynamicObjectsCanvasModel, scaleModel, createYAxisComponent, dragNDrop);
142
137
  yExtentComponent.addSubscription(unsub);
143
138
  yExtentComponent.addSubscription(this.addCursors(extentIdx, yExtentComponent.yAxis));
144
139
  (options === null || options === void 0 ? void 0 : options.paneFormatters) && yExtentComponent.setValueFormatters(options.paneFormatters);
@@ -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 { YAxisConfig } from '../../chart.config';
6
7
  import { DataSeriesModel } from '../../model/data-series.model';
7
8
  import { ViewportModel } from '../../model/scaling/viewport.model';
8
9
  import { NumericAxisLabelsGenerator, PriceAxisType } from '../labels_generator/numeric-axis-labels.generator';
@@ -11,7 +12,7 @@ import { NumericAxisLabelsGenerator, PriceAxisType } from '../labels_generator/n
11
12
  */
12
13
  export declare class NumericYAxisLabelsGenerator extends NumericAxisLabelsGenerator {
13
14
  private dataSeriesProvider;
14
- constructor(increment: number | null, dataSeriesProvider: () => DataSeriesModel | undefined, viewportModel: ViewportModel, valueFormatter: (value: number) => string, axisTypeProvider?: () => PriceAxisType, singleLabelHeightPixels?: number);
15
+ constructor(increment: number | null, dataSeriesProvider: () => DataSeriesModel | undefined, viewportModel: ViewportModel, valueFormatter: (value: number) => string, axisTypeProvider: (() => PriceAxisType) | undefined, singleLabelHeightPixels: number | undefined, config: YAxisConfig);
15
16
  getLargestLabel(): string;
16
17
  /**
17
18
  * Calculates the increment to be used on the chart axis based on the length of the value and the instrument's price increments.
@@ -10,8 +10,8 @@ import { NumericAxisLabelsGenerator } from '../labels_generator/numeric-axis-lab
10
10
  * Y axis labels generator for prices. Respects price increment from instrument.
11
11
  */
12
12
  export class NumericYAxisLabelsGenerator extends NumericAxisLabelsGenerator {
13
- constructor(increment, dataSeriesProvider, viewportModel, valueFormatter, axisTypeProvider = () => 'regular', singleLabelHeightPixels = 23) {
14
- super(increment, () => [viewportModel.yStart, viewportModel.yEnd], () => viewportModel.getBounds().height, valueFormatter, false, axisTypeProvider, () => { var _a, _b; return (_b = (_a = dataSeriesProvider()) === null || _a === void 0 ? void 0 : _a.getBaseline()) !== null && _b !== void 0 ? _b : 1; }, undefined, singleLabelHeightPixels);
13
+ constructor(increment, dataSeriesProvider, viewportModel, valueFormatter, axisTypeProvider = () => 'regular', singleLabelHeightPixels = 23, config) {
14
+ super(increment, () => [viewportModel.yStart, viewportModel.yEnd], () => viewportModel.getBounds().height, valueFormatter, false, axisTypeProvider, () => { var _a, _b; return (_b = (_a = dataSeriesProvider()) === null || _a === void 0 ? void 0 : _a.getBaseline()) !== null && _b !== void 0 ? _b : 1; }, undefined, singleLabelHeightPixels, config);
15
15
  this.dataSeriesProvider = dataSeriesProvider;
16
16
  }
17
17
  getLargestLabel() {
@@ -14,7 +14,7 @@ export class YAxisModel extends ChartBaseElement {
14
14
  this.state = state;
15
15
  this.canvasBoundsContainer = canvasBoundsContainer;
16
16
  this.extentIdx = extentIdx;
17
- this.labelsGenerator = new NumericYAxisLabelsGenerator(null, dataSeriesProvider, scale, valueFormatter, () => this.state.type, state.labelHeight);
17
+ this.labelsGenerator = new NumericYAxisLabelsGenerator(null, dataSeriesProvider, scale, valueFormatter, () => this.state.type, state.labelHeight, state);
18
18
  this.baseLabelsModel = new YAxisBaseLabelsModel(scale, this.labelsGenerator, this.canvasBoundsContainer, paneUUID, extentIdx);
19
19
  this.addChildEntity(this.baseLabelsModel);
20
20
  this.fancyLabelsModel = new FancyYAxisLabelsModel(eventBus, scale, canvasBoundsContainer, state, canvasModel, paneUUID, () => this.canvasBoundsContainer.updateYAxisWidths(), chartResizeHandler);
@@ -5,4 +5,8 @@
5
5
  */
6
6
  import { DataSeriesPoint } from '../model/data-series.model';
7
7
  import { BinarySearchResult } from './array.utils';
8
- export declare const searchCandleIndex: (timestamp: number, shouldExtrapolate: boolean, candles: DataSeriesPoint[], periodMs?: number) => BinarySearchResult;
8
+ export declare const getDaysOnlyTimestampFn: (isDaysPeriod: boolean) => (timestamp: number) => number;
9
+ export declare const searchCandleIndex: (rawTimestamp: number, options: {
10
+ extrapolate?: boolean | undefined;
11
+ isDaysPeriod?: boolean | undefined;
12
+ } | undefined, candles: DataSeriesPoint[], periodMs?: number) => BinarySearchResult;
@@ -5,10 +5,20 @@
5
5
  */
6
6
  import { binarySearch, firstOf, lastOf } from './array.utils';
7
7
  import { floor } from './math.utils';
8
- export const searchCandleIndex = (timestamp, shouldExtrapolate, candles, periodMs = 1000) => {
8
+ export const getDaysOnlyTimestampFn = (isDaysPeriod) => (timestamp) => {
9
+ if (isDaysPeriod) {
10
+ return new Date(timestamp).setHours(0, 0, 0, 0);
11
+ }
12
+ return timestamp;
13
+ };
14
+ export const searchCandleIndex = (rawTimestamp, options = {}, candles, periodMs = 1000) => {
9
15
  var _a, _b, _c, _d;
10
- const firstTimestamp = (_b = (_a = firstOf(candles)) === null || _a === void 0 ? void 0 : _a.timestamp) !== null && _b !== void 0 ? _b : 0;
11
- const lastTimestamp = (_d = (_c = lastOf(candles)) === null || _c === void 0 ? void 0 : _c.timestamp) !== null && _d !== void 0 ? _d : 0;
16
+ const { extrapolate, isDaysPeriod } = options;
17
+ const shouldExtrapolate = Boolean(extrapolate);
18
+ const getDaysOnlyTimestamp = getDaysOnlyTimestampFn(Boolean(isDaysPeriod));
19
+ const timestamp = getDaysOnlyTimestamp(rawTimestamp);
20
+ const firstTimestamp = getDaysOnlyTimestamp((_b = (_a = firstOf(candles)) === null || _a === void 0 ? void 0 : _a.timestamp) !== null && _b !== void 0 ? _b : 0);
21
+ const lastTimestamp = getDaysOnlyTimestamp((_d = (_c = lastOf(candles)) === null || _c === void 0 ? void 0 : _c.timestamp) !== null && _d !== void 0 ? _d : 0);
12
22
  if (timestamp > lastTimestamp) {
13
23
  // TODO rework the code below, it looks very very sus ( ≖.≖)
14
24
  if (shouldExtrapolate) {
@@ -42,6 +52,6 @@ export const searchCandleIndex = (timestamp, shouldExtrapolate, candles, periodM
42
52
  }
43
53
  }
44
54
  else {
45
- return binarySearch(candles, timestamp, candle => candle.timestamp);
55
+ return binarySearch(candles, timestamp, candle => getDaysOnlyTimestamp(candle.timestamp));
46
56
  }
47
57
  };