@devexperts/dxcharts-lite 2.7.10 → 2.7.11

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.
@@ -109,7 +109,8 @@ export class Chart extends ChartBootstrap {
109
109
  setTreasuryFormat(treasuryFormat) {
110
110
  this.config.components.yAxis.treasuryFormat = treasuryFormat;
111
111
  this.paneManager.yExtents.forEach(ext => {
112
- ext.yAxis.updateOrderedLabels(true);
112
+ ext.yAxis.model.labelsGenerator.updateTreasuryFormat(treasuryFormat);
113
+ ext.yAxis.model.labelsGenerator.doGenerateLabels();
113
114
  ext.yAxis.model.fancyLabelsModel.updateLabels(true);
114
115
  ext.yAxis.model.baseLabelsModel.updateLabels();
115
116
  });
@@ -14,3 +14,4 @@
14
14
  */
15
15
  export declare const TREASURY_32ND: number;
16
16
  export declare const treasuryPriceFormatter: (value: number) => string;
17
+ export declare const isTreasuryPriceFormat: (value: string) => boolean;
@@ -24,3 +24,4 @@ export const treasuryPriceFormatter = (value) => {
24
24
  const thirtySecondsFormatted = thirtySeconds.toString().padStart(2, '0');
25
25
  return `${integerValue}'${thirtySecondsFormatted}`;
26
26
  };
27
+ export const isTreasuryPriceFormat = (value) => Boolean(value.match(/^\-?0*(\d+)'(\d{2})$/));
@@ -6,7 +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
+ import { YAxisConfig, YAxisConfigTreasuryFormat } from '../../chart.config';
10
10
  export type PriceAxisType = 'regular' | 'percent' | 'logarithmic';
11
11
  export interface LabelsGenerator {
12
12
  readonly observeLabelsChanged: () => Observable<NumericAxisLabel[]>;
@@ -36,7 +36,7 @@ export declare class NumericAxisLabelsGenerator implements LabelsGenerator {
36
36
  newGeneratedLabelsSubject: Subject<NumericAxisLabel[]>;
37
37
  private lastStart;
38
38
  private lastEnd;
39
- private treasuryFormat;
39
+ protected treasuryFormat: YAxisConfigTreasuryFormat | undefined;
40
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);
41
41
  private generateRegularLabels;
42
42
  private generatePercentLabels;
@@ -154,19 +154,17 @@ export class NumericAxisLabelsGenerator {
154
154
  return this.adjustIncrementOnAxisType(DEFAULT_REGULAR_INCREMENT);
155
155
  }
156
156
  adjustIncrementOnAxisType(increment) {
157
- var _a;
158
- const calculatedIncrement = ((_a = this.treasuryFormat) === null || _a === void 0 ? void 0 : _a.enabled) ? TREASURY_32ND : increment;
159
157
  switch (this.axisTypeProvider()) {
160
158
  case 'percent':
161
159
  return increment;
162
160
  case 'logarithmic':
163
161
  const [logMin] = this.calculateMinMax();
164
162
  const regularMin = logValueToUnit(logMin);
165
- const regularIncrementedValue = regularMin + calculatedIncrement;
163
+ const regularIncrementedValue = regularMin + increment;
166
164
  const incrementedLogValue = calcLogValue(regularIncrementedValue);
167
165
  return incrementedLogValue - logMin;
168
166
  case 'regular':
169
- return calculatedIncrement;
167
+ return increment;
170
168
  }
171
169
  }
172
170
  // TODO rework, generator should act as model and update itself on scaleChanged
@@ -54,7 +54,7 @@ export declare class PaneComponent extends ChartBaseElement {
54
54
  yExtentComponentsChangedSubject: Subject<void>;
55
55
  get scale(): ScaleModel;
56
56
  get yAxis(): YAxisComponent;
57
- get dataSeries(): DataSeriesModel<import("../../model/data-series.model").DataSeriesPoint, import("../../model/data-series.model").VisualSeriesPoint>[];
57
+ get dataSeries(): DataSeriesModel<import("../../model/data-series.model").DataSeriesPoint, import("../../model/data-series.model").VisualSeriesPoint, import("../../model/data-series.config").DataSeriesConfig>[];
58
58
  get visible(): boolean;
59
59
  mainExtent: YExtentComponent;
60
60
  constructor(chartBaseModel: ChartBaseModel<'candle'>, mainCanvasModel: CanvasModel, yAxisLabelsCanvasModel: CanvasModel, dynamicObjectsCanvasModel: CanvasModel, hitTestController: PaneHitTestController, config: FullChartConfig, mainScale: ScaleModel, drawingManager: DrawingManager, chartPanComponent: ChartPanComponent, canvasInputListener: CanvasInputListenerComponent, canvasAnimation: CanvasAnimation, cursorHandler: CursorHandler, eventBus: EventBus, canvasBoundsContainer: CanvasBoundsContainer, uuid: string, seriesAddedSubject: Subject<DataSeriesModel>, seriesRemovedSubject: Subject<DataSeriesModel>, hitTestCanvasModel: HitTestCanvasModel, chartResizeHandler: ChartResizeHandler, options?: AtLeastOne<YExtentCreationOptions>);
@@ -3,7 +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
+ import { YAxisConfig, YAxisConfigTreasuryFormat } from '../../chart.config';
7
7
  import { DataSeriesModel } from '../../model/data-series.model';
8
8
  import { ViewportModel } from '../../model/scaling/viewport.model';
9
9
  import { NumericAxisLabelsGenerator, PriceAxisType } from '../labels_generator/numeric-axis-labels.generator';
@@ -14,6 +14,7 @@ export declare class NumericYAxisLabelsGenerator extends NumericAxisLabelsGenera
14
14
  private dataSeriesProvider;
15
15
  constructor(increment: number | null, dataSeriesProvider: () => DataSeriesModel | undefined, viewportModel: ViewportModel, valueFormatter: (value: number) => string, axisTypeProvider: (() => PriceAxisType) | undefined, singleLabelHeightPixels: number | undefined, config: YAxisConfig);
16
16
  getLargestLabel(): string;
17
+ updateTreasuryFormat(treasuryFormat: YAxisConfigTreasuryFormat): void;
17
18
  /**
18
19
  * Calculates the increment to be used on the chart axis based on the length of the value and the instrument's price increments.
19
20
  * @param {number} valueLength - The length of the value.
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { lastOf } from '../../utils/array.utils';
7
7
  import { precisionsToIncrement } from '../../utils/price-increments.utils';
8
+ import { TREASURY_32ND } from '../chart/price-formatters/treasury-price.formatter';
8
9
  import { NumericAxisLabelsGenerator } from '../labels_generator/numeric-axis-labels.generator';
9
10
  /**
10
11
  * Y axis labels generator for prices. Respects price increment from instrument.
@@ -18,19 +19,23 @@ export class NumericYAxisLabelsGenerator extends NumericAxisLabelsGenerator {
18
19
  var _a;
19
20
  return ((_a = this.labelsCache.getLastCachedValue()) !== null && _a !== void 0 ? _a : []).reduce((maxLengthText, label) => (label.text.length > maxLengthText.length ? label.text : maxLengthText), '');
20
21
  }
22
+ updateTreasuryFormat(treasuryFormat) {
23
+ this.treasuryFormat = treasuryFormat;
24
+ }
21
25
  /**
22
26
  * Calculates the increment to be used on the chart axis based on the length of the value and the instrument's price increments.
23
27
  * @param {number} valueLength - The length of the value.
24
28
  * @returns {number} - The calculated increment.
25
29
  */
26
30
  calculateIncrement(valueLength) {
27
- var _a;
31
+ var _a, _b;
28
32
  const dataSeries = this.dataSeriesProvider();
29
33
  if (dataSeries) {
30
34
  const lastCandle = lastOf(dataSeries.dataPoints);
31
35
  const priceIncrementBasis = (_a = lastCandle === null || lastCandle === void 0 ? void 0 : lastCandle.close) !== null && _a !== void 0 ? _a : 0;
32
36
  const increment = precisionsToIncrement(priceIncrementBasis, dataSeries.pricePrecisions);
33
- return this.adjustIncrementOnAxisType(increment);
37
+ const calculatedIncrement = ((_b = this.treasuryFormat) === null || _b === void 0 ? void 0 : _b.enabled) ? TREASURY_32ND : increment;
38
+ return this.adjustIncrementOnAxisType(calculatedIncrement);
34
39
  }
35
40
  // auto-generated increment
36
41
  return super.calculateIncrement(valueLength);
@@ -43,7 +43,7 @@ export interface DataSeriesViewportIndexes {
43
43
  * If the data is presented as two-dim array when every data array will be drawn as a separate time-series
44
44
  * For example, linear chart type will be drawn with gaps on the chart
45
45
  */
46
- export declare class DataSeriesModel<D extends DataSeriesPoint = DataSeriesPoint, V extends VisualSeriesPoint = VisualSeriesPoint> extends ChartBaseElement {
46
+ export declare class DataSeriesModel<D extends DataSeriesPoint = DataSeriesPoint, V extends VisualSeriesPoint = VisualSeriesPoint, C extends DataSeriesConfig = DataSeriesConfig> extends ChartBaseElement {
47
47
  extentComponent: YExtentComponent;
48
48
  id: string;
49
49
  htId: number;
@@ -51,7 +51,7 @@ export declare class DataSeriesModel<D extends DataSeriesPoint = DataSeriesPoint
51
51
  name: string;
52
52
  highlighted: boolean;
53
53
  yAxisLabelProvider: DataSeriesYAxisLabelsProvider;
54
- readonly config: DataSeriesConfig;
54
+ readonly config: C;
55
55
  scale: ScaleModel;
56
56
  view: DataSeriesView;
57
57
  protected _dataPoints: D[][];
@@ -59,7 +59,7 @@ export declare class DataSeriesModel<D extends DataSeriesPoint = DataSeriesPoint
59
59
  /**
60
60
  * Should be used for paint tools like rectangular drawing or diff cloud
61
61
  */
62
- linkedDataSeriesModels: DataSeriesModel<D, V>[];
62
+ linkedDataSeriesModels: DataSeriesModel<D, V, C>[];
63
63
  highLowProvider: HighLowProvider;
64
64
  get dataPoints2D(): D[][];
65
65
  get dataPoints(): D[];
@@ -72,7 +72,7 @@ export declare class DataSeriesModel<D extends DataSeriesPoint = DataSeriesPoint
72
72
  get visualPoints(): V[];
73
73
  get visualPoints2D(): V[][];
74
74
  set visualPoints(points: V[][] | V[]);
75
- constructor(extentComponent: YExtentComponent, id: string, htId: number, parentId?: string | number | undefined, _config?: AtLeastOne<DataSeriesConfig>);
75
+ constructor(extentComponent: YExtentComponent, id: string, htId: number, parentId?: string | number | undefined, _config?: AtLeastOne<C>);
76
76
  protected doActivate(): void;
77
77
  /**
78
78
  * Sets the data points and recalculates internal state
@@ -66,7 +66,7 @@ export class DataSeriesModel extends ChartBaseElement {
66
66
  this._visualPoints = create2DArray(points);
67
67
  this._visualPointsFlat = this._visualPoints.flat();
68
68
  }
69
- constructor(extentComponent, id, htId, parentId, _config = cloneUnsafe(DEFAULT_DATA_SERIES_CONFIG)) {
69
+ constructor(extentComponent, id, htId, parentId, _config) {
70
70
  var _a;
71
71
  super();
72
72
  this.extentComponent = extentComponent;
@@ -130,7 +130,8 @@ export class DataSeriesModel extends ChartBaseElement {
130
130
  const points = this.visualPoints;
131
131
  return lastOf(points);
132
132
  };
133
- this.config = merge(_config, DEFAULT_DATA_SERIES_CONFIG);
133
+ const config = _config !== null && _config !== void 0 ? _config : cloneUnsafe(DEFAULT_DATA_SERIES_CONFIG);
134
+ this.config = merge(config, DEFAULT_DATA_SERIES_CONFIG);
134
135
  this.scale = extentComponent.scale;
135
136
  this.view = new DataSeriesView(this, this.scale, () => this.extentComponent.yAxis.getAxisType(), this.getBaseline);
136
137
  this.yAxisLabelProvider = new DataSeriesYAxisLabelsProvider(this, this.config, extentComponent.getYAxisBounds, (_a = extentComponent.yAxis) === null || _a === void 0 ? void 0 : _a.state);