@devexperts/dxcharts-lite 2.5.8 → 2.6.0

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 (45) hide show
  1. package/dist/chart/__tests__/chart.test.js +5 -5
  2. package/dist/chart/__tests__/env.js +1 -1
  3. package/dist/chart/canvas/canvas-bounds-container.js +24 -3
  4. package/dist/chart/chart.config.d.ts +2 -0
  5. package/dist/chart/chart.config.js +2 -1
  6. package/dist/chart/components/chart/candle-transformer.functions.js +1 -1
  7. package/dist/chart/components/chart/candle.functions.d.ts +1 -1
  8. package/dist/chart/components/chart/candle.functions.js +3 -2
  9. package/dist/chart/components/chart/chart.component.d.ts +29 -8
  10. package/dist/chart/components/chart/chart.component.js +33 -4
  11. package/dist/chart/components/chart/chart.model.d.ts +41 -4
  12. package/dist/chart/components/chart/chart.model.js +90 -16
  13. package/dist/chart/components/chart/fake-candles.js +2 -0
  14. package/dist/chart/components/chart/fake-visual-candle.d.ts +4 -4
  15. package/dist/chart/components/chart/fake-visual-candle.js +4 -4
  16. package/dist/chart/components/volumes/separate-volumes.component.d.ts +1 -3
  17. package/dist/chart/components/volumes/separate-volumes.component.js +1 -3
  18. package/dist/chart/components/volumes/volumes.component.js +1 -1
  19. package/dist/chart/components/volumes/volumes.drawer.js +3 -3
  20. package/dist/chart/components/watermark/water-mark.component.d.ts +3 -12
  21. package/dist/chart/components/watermark/water-mark.component.js +1 -1
  22. package/dist/chart/components/x_axis/time/parser/time-formats-parser.functions.js +1 -1
  23. package/dist/chart/components/x_axis/x-axis-scale.handler.js +2 -2
  24. package/dist/chart/components/x_axis/x-axis.component.js +1 -1
  25. package/dist/chart/components/y_axis/y-axis-scale.handler.js +3 -3
  26. package/dist/chart/drawers/drawing-manager.d.ts +1 -1
  27. package/dist/chart/drawers/drawing-manager.js +0 -1
  28. package/dist/chart/inputhandlers/hover-producer.component.js +8 -2
  29. package/dist/chart/model/candle.model.d.ts +3 -0
  30. package/dist/chart/model/candle.model.js +7 -1
  31. package/dist/chart/model/data-series.model.d.ts +3 -3
  32. package/dist/chart/model/data-series.model.js +1 -1
  33. package/dist/chart/model/scale.model.js +1 -1
  34. package/dist/chart/model/scaling/viewport.model.d.ts +2 -1
  35. package/dist/chart/model/scaling/viewport.model.js +6 -1
  36. package/dist/chart/model/time-zone.model.js +1 -3
  37. package/dist/chart/utils/candles-generator-ts.utils.d.ts +1 -0
  38. package/dist/chart/utils/candles-generator.utils.d.ts +1 -0
  39. package/dist/chart/utils/candles-generator.utils.js +2 -0
  40. package/dist/chart/utils/string.utils.d.ts +6 -0
  41. package/dist/chart/utils/string.utils.js +19 -0
  42. package/dist/chart/utils/types.utils.d.ts +9 -0
  43. package/dist/chart/utils/types.utils.js +6 -0
  44. package/dist/dxchart.min.js +4 -4
  45. package/package.json +1 -1
@@ -7,10 +7,9 @@ import { ChartBaseElement } from '../../model/chart-base-element';
7
7
  import { createCandlesOffsetProvider } from '../chart/data-series.high-low-provider';
8
8
  import { volumeFormatter } from './volumes.formatter';
9
9
  class SeparateVolumesComponent extends ChartBaseElement {
10
- constructor(chartComponent, drawingManager, config, volumesModel, paneManager) {
10
+ constructor(chartComponent, config, volumesModel, paneManager) {
11
11
  super();
12
12
  this.chartComponent = chartComponent;
13
- this.drawingManager = drawingManager;
14
13
  this.config = config;
15
14
  this.volumesModel = volumesModel;
16
15
  this.paneManager = paneManager;
@@ -53,7 +52,6 @@ class SeparateVolumesComponent extends ChartBaseElement {
53
52
  deactiveSeparateVolumes() {
54
53
  this.paneManager.removePane(SeparateVolumesComponent.UUID);
55
54
  delete this.pane;
56
- this.drawingManager.removeDrawerByName('UNDERLAY_VOLUMES_AREA');
57
55
  }
58
56
  /**
59
57
  * Converts a pixel value from the Y-axis of the scale model to the corresponding data value.
@@ -23,7 +23,7 @@ export class VolumesComponent extends ChartBaseElement {
23
23
  const volumesModel = new VolumesModel(chartComponent, scale);
24
24
  this.volumesModel = volumesModel;
25
25
  this.addChildEntity(volumesModel);
26
- this.separateVolumes = new SeparateVolumesComponent(chartComponent, drawingManager, config, volumesModel, paneManager);
26
+ this.separateVolumes = new SeparateVolumesComponent(chartComponent, config, volumesModel, paneManager);
27
27
  this.volumesDrawer = new VolumesDrawer(config, this.volumesModel, chartComponent.chartModel, () => { var _a, _b; return (this.config.components.volumes.showSeparately ? (_b = (_a = this.separateVolumes.pane) === null || _a === void 0 ? void 0 : _a.scale) !== null && _b !== void 0 ? _b : scale : scale); }, this.volumesColorByChartTypeMap, () => true);
28
28
  config.components.volumes.visible && this.syncVolumesDynamicObject();
29
29
  this.addChildEntity(this.separateVolumes);
@@ -101,12 +101,12 @@ export class VolumesDrawer {
101
101
  const width = nextX !== undefined ? nextX - x : floorToDPR(unitToPixels(vCandle.width, viewportModel.zoomX));
102
102
  if (this.config.components.volumes.showSeparately) {
103
103
  const y = floorToDPR(viewportModel.toY(vCandle.candle.volume));
104
- const height = floorToDPR(viewportModel.toY(0)) - y;
104
+ const height = ceilToDPR(viewportModel.toY(0)) - y;
105
105
  this.drawVolume(canvasModel, vCandle, x, y, width, height);
106
106
  }
107
107
  else {
108
108
  const zoomY = volumeMax / (fullVHeight / OVERLAY_VOLUME_TOTAL_HEIGHT_DIVISOR);
109
- const height = Math.max(unitToPixels(vCandle.candle.volume, zoomY), 2);
109
+ const height = Math.max(ceilToDPR(unitToPixels(vCandle.candle.volume, zoomY)), 2);
110
110
  const y = floorToDPR(bounds.y + fullVHeight - height);
111
111
  this.drawVolume(canvasModel, vCandle, x, y, width, height);
112
112
  }
@@ -139,7 +139,7 @@ export class VolumesDrawer {
139
139
  ctx.stroke();
140
140
  }
141
141
  else {
142
- ctx.fillRect(x, y, width, ceilToDPR(height));
142
+ ctx.fillRect(x, y, width, height);
143
143
  }
144
144
  }
145
145
  }
@@ -5,21 +5,12 @@
5
5
  */
6
6
  import { CanvasBoundsContainer } from '../../canvas/canvas-bounds-container';
7
7
  import { ChartBaseElement } from '../../model/chart-base-element';
8
- import { FullChartConfig } from '../../chart.config';
8
+ import { ChartConfigComponentsWaterMark, FullChartConfig } from '../../chart.config';
9
9
  import { CanvasModel } from '../../model/canvas.model';
10
10
  import { DrawingManager } from '../../drawers/drawing-manager';
11
11
  import EventBus from '../../events/event-bus';
12
12
  import { ChartModel } from '../chart/chart.model';
13
13
  import { PaneManager } from '../pane/pane-manager.component';
14
- export interface WaterMarkConfig {
15
- isVisible?: boolean;
16
- fontFamily?: string;
17
- firstRowFontSize?: number;
18
- firstRowBottomPadding?: number;
19
- secondRowFontSize?: number;
20
- secondRowBottomPadding?: number;
21
- thirdRowFontSize?: number;
22
- }
23
14
  export interface WaterMarkData {
24
15
  firstRow?: string;
25
16
  secondRow?: string;
@@ -55,11 +46,11 @@ export declare class WaterMarkComponent extends ChartBaseElement {
55
46
  private getWaterMarkData;
56
47
  /**
57
48
  * Sets the watermark configuration for the chart.
58
- * @param {WaterMarkConfig} watermarkConfig - The configuration object for the watermark.
49
+ * @param {ChartConfigComponentsWaterMark} watermarkConfig - The configuration object for the watermark.
59
50
  * @returns {void}
60
51
 
61
52
  */
62
- setWaterMarkConfig(watermarkConfig: WaterMarkConfig): void;
53
+ setWaterMarkConfig(watermarkConfig: ChartConfigComponentsWaterMark): void;
63
54
  /**
64
55
  * Sets the logo image to be used as a watermark.
65
56
  * @param {CanvasImageSource} img - The image to be used as a watermark.
@@ -56,7 +56,7 @@ export class WaterMarkComponent extends ChartBaseElement {
56
56
  }
57
57
  /**
58
58
  * Sets the watermark configuration for the chart.
59
- * @param {WaterMarkConfig} watermarkConfig - The configuration object for the watermark.
59
+ * @param {ChartConfigComponentsWaterMark} watermarkConfig - The configuration object for the watermark.
60
60
  * @returns {void}
61
61
 
62
62
  */
@@ -75,7 +75,7 @@ export const parseTimeFormatsFromKey = (format) => {
75
75
  };
76
76
  }
77
77
  else {
78
- console.warn(`${format} is not fit, check the documentation to see available formats https://webdev.prosp.devexperts.com:8095/docs/chart/x-axis`);
78
+ console.warn(`${format} is not fit, check the documentation to see available formats in dxchart-lite documentation.`);
79
79
  return null;
80
80
  }
81
81
  };
@@ -47,8 +47,8 @@ export class XAxisScaleHandler extends ChartBaseElement {
47
47
  // Continue redrawing hit test
48
48
  this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(true);
49
49
  };
50
- this.setDblTapCallback = (cb) => this.dblTapCallback = cb;
51
- this.setDblClickCallback = (cb) => this.dblClickCallback = cb;
50
+ this.setDblTapCallback = (cb) => (this.dblTapCallback = cb);
51
+ this.setDblClickCallback = (cb) => (this.dblClickCallback = cb);
52
52
  this.dblClickCallback = () => chartModel.doBasicScale();
53
53
  this.dblTapCallback = () => chartModel.doBasicScale();
54
54
  const dragNDropXComponent = new DragNDropXComponent(hitTest, {
@@ -82,7 +82,7 @@ export class XAxisComponent extends ChartBaseElement {
82
82
  this.xAxisLabelsGenerator.recalculateLabels();
83
83
  }));
84
84
  this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject
85
- .pipe(map(() => lastOf(this.chartComponent.chartModel.mainCandleSeries.visualPoints)), distinctUntilChanged((a, b) => { var _a, _b; return ((_a = a === null || a === void 0 ? void 0 : a.candle) === null || _a === void 0 ? void 0 : _a.timestamp) === ((_b = b === null || b === void 0 ? void 0 : b.candle) === null || _b === void 0 ? void 0 : _b.timestamp); }), filter(notEmpty))
85
+ .pipe(map(() => lastOf(this.chartComponent.chartModel.mainCandleSeries.visualPoints)), distinctUntilChanged((a, b) => { var _a, _b; return ((_a = a === null || a === void 0 ? void 0 : a.candle) === null || _a === void 0 ? void 0 : _a.id) === ((_b = b === null || b === void 0 ? void 0 : b.candle) === null || _b === void 0 ? void 0 : _b.id); }), filter(notEmpty))
86
86
  .subscribe(x => { var _a, _b; return (_b = (_a = this.xAxisLabelsGenerator) === null || _a === void 0 ? void 0 : _a.updateLastLabel) === null || _b === void 0 ? void 0 : _b.call(_a, x); }));
87
87
  }
88
88
  /**
@@ -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 { Subject } from 'rxjs';
7
- import { CanvasElement, DEFAULT_MIN_PANE_HEIGHT } from '../../canvas/canvas-bounds-container';
7
+ import { CanvasElement, DEFAULT_MIN_PANE_HEIGHT, } from '../../canvas/canvas-bounds-container';
8
8
  import { ChartBaseElement } from '../../model/chart-base-element';
9
9
  import { DragNDropYComponent } from '../dran-n-drop_helper/drag-n-drop-y.component';
10
10
  // if you drag full Y height from top to bottom - you will have x3 zoom, and vice-versa
@@ -73,8 +73,8 @@ export class YAxisScaleHandler extends ChartBaseElement {
73
73
  // Continue redrawing hit test
74
74
  this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(true);
75
75
  };
76
- this.setDblTapCallback = (cb) => this.dblTapCallback = cb;
77
- this.setDblClickCallback = (cb) => this.dblClickCallback = cb;
76
+ this.setDblTapCallback = (cb) => (this.dblTapCallback = cb);
77
+ this.setDblClickCallback = (cb) => (this.dblClickCallback = cb);
78
78
  this.dblClickCallback = () => scale.autoScale(true);
79
79
  this.dblTapCallback = () => scale.autoScale(true);
80
80
  // drag to Y-scale and double click to auto scale
@@ -6,7 +6,7 @@
6
6
  import EventBus from '../events/event-bus';
7
7
  import { ChartResizeHandler } from '../inputhandlers/chart-resize.handler';
8
8
  export declare const HIT_TEST_PREFIX = "HIT_TEST_";
9
- declare const drawerTypes: readonly ["MAIN_BACKGROUND", "MAIN_CLEAR", "HIT_TEST_CLEAR", "YAXIS_CLEAR", "SERIES_CLEAR", "OVER_SERIES_CLEAR", "HIT_TEST_DRAWINGS", "GRID", "UNDERLAY_VOLUMES_AREA", "X_AXIS", "Y_AXIS", "HIGH_LOW", "DYNAMIC_OBJECTS", "N_MAP_CHART", "PL_CHART", "WATERMARK", "EMPTY_CHART", "OFFLINE_CHART", "LABELS", "EVENTS", "HIT_TEST_EVENTS", "ZERO_LINE", "PL_ZERO_LINE_BACKGROUND", "CROSS_TOOL"];
9
+ declare const drawerTypes: readonly ["MAIN_BACKGROUND", "MAIN_CLEAR", "HIT_TEST_CLEAR", "YAXIS_CLEAR", "SERIES_CLEAR", "OVER_SERIES_CLEAR", "HIT_TEST_DRAWINGS", "GRID", "X_AXIS", "Y_AXIS", "HIGH_LOW", "DYNAMIC_OBJECTS", "N_MAP_CHART", "PL_CHART", "WATERMARK", "EMPTY_CHART", "OFFLINE_CHART", "LABELS", "EVENTS", "HIT_TEST_EVENTS", "ZERO_LINE", "PL_ZERO_LINE_BACKGROUND", "CROSS_TOOL"];
10
10
  export type DrawerType = typeof drawerTypes[number];
11
11
  /**
12
12
  * Manages the drawing process.
@@ -18,7 +18,6 @@ const drawerTypes = [
18
18
  'OVER_SERIES_CLEAR',
19
19
  'HIT_TEST_DRAWINGS',
20
20
  'GRID',
21
- 'UNDERLAY_VOLUMES_AREA',
22
21
  'X_AXIS',
23
22
  'Y_AXIS',
24
23
  'HIGH_LOW',
@@ -4,6 +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 { BehaviorSubject, merge } from 'rxjs';
7
+ import { filter, switchMap } from 'rxjs/operators';
7
8
  import { CHART_UUID, CanvasElement } from '../canvas/canvas-bounds-container';
8
9
  import { CandleHoverProducerPart } from '../model/candle-hover';
9
10
  import { ChartBaseElement } from '../model/chart-base-element';
@@ -50,8 +51,13 @@ export class HoverProducerComponent extends ChartBaseElement {
50
51
  */
51
52
  doActivate() {
52
53
  super.doActivate();
53
- this.addRxSubscription(this.chartModel.candlesSetSubject.subscribe(() => {
54
- // required for initial legend initialization, do not show cross tool
54
+ this.addRxSubscription(
55
+ // required for initial legend initialization, do not show cross tool
56
+ this.chartModel.candlesSetSubject
57
+ .pipe(
58
+ // check the scale is valid before doing candle-based hover event
59
+ switchMap(() => this.scale.initialViewportValidSubject.pipe(filter(Boolean))))
60
+ .subscribe(() => {
55
61
  const lastCandle = this.chartModel.getLastVisualCandle();
56
62
  lastCandle && this.createAndFireHoverFromCandle(lastCandle);
57
63
  }));
@@ -11,6 +11,7 @@ export declare const BASIC_CANDLE_WIDTH: Unit;
11
11
  * @doc-tags-name Candle
12
12
  */
13
13
  export interface Candle {
14
+ readonly id: string;
14
15
  readonly hi: number;
15
16
  readonly lo: number;
16
17
  readonly open: number;
@@ -22,6 +23,8 @@ export interface Candle {
22
23
  readonly impVolatility?: number;
23
24
  readonly vwap?: number;
24
25
  }
26
+ export declare const defaultSortCandles: (candles: Candle[]) => Candle[];
27
+ export declare const generateCandleId: (timestamp: number, hashValue: number | string) => string;
25
28
  /**
26
29
  * Provides the name of candle difference
27
30
  * @param {Number} open
@@ -3,9 +3,14 @@
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 { hashCode } from '../utils/string.utils';
6
7
  // Has no specific rule, just any number to use in units calculation.
7
8
  // 1 - because why not? Easy to debug.
8
9
  export const BASIC_CANDLE_WIDTH = 1;
10
+ export const defaultSortCandles = (candles) => candles.slice().sort((a, b) => (a.timestamp === b.timestamp ? 0 : a.timestamp > b.timestamp ? 1 : -1));
11
+ export const generateCandleId = (timestamp, hashValue) => {
12
+ return `${timestamp}_${hashCode(hashValue.toString())}`;
13
+ };
9
14
  /**
10
15
  * Provides the name of candle difference
11
16
  * @param {Number} open
@@ -45,7 +50,7 @@ export function hollowDirection(open, close) {
45
50
  * @returns {Candle} A new Candle object with the same properties as the base object, with the option to modify the prices.
46
51
  */
47
52
  export function copyCandle(base, idx, pricesAsClose = false) {
48
- const { expansion, impVolatility, vwap, volume, timestamp } = base;
53
+ const { id, expansion, impVolatility, vwap, volume, timestamp } = base;
49
54
  let hi = base.hi;
50
55
  let lo = base.lo;
51
56
  let open = base.open;
@@ -60,6 +65,7 @@ export function copyCandle(base, idx, pricesAsClose = false) {
60
65
  _idx = idx;
61
66
  }
62
67
  return {
68
+ id,
63
69
  hi,
64
70
  lo,
65
71
  open,
@@ -11,7 +11,7 @@ import { DataSeriesView } from './data-series-view';
11
11
  import { DataSeriesConfig, DataSeriesPaintConfig, DataSeriesType } from './data-series.config';
12
12
  import { HighLowWithIndex, ScaleModel } from './scale.model';
13
13
  import { HighLowProvider } from './scaling/auto-scale.model';
14
- import { Index, Unit, Viewable } from './scaling/viewport.model';
14
+ import { Index, Pixel, Unit, Viewable } from './scaling/viewport.model';
15
15
  /**
16
16
  * Properties are named in order to match VisualCandle interface
17
17
  */
@@ -22,11 +22,11 @@ export declare class VisualSeriesPoint {
22
22
  /**
23
23
  * returns y coordinate in pixels
24
24
  */
25
- y(viewable: Viewable): Unit;
25
+ y(viewable: Viewable): Pixel;
26
26
  /**
27
27
  * returns x coordinate in pixels
28
28
  */
29
- x(viewable: Viewable): Unit;
29
+ x(viewable: Viewable): Pixel;
30
30
  clone(): VisualSeriesPoint;
31
31
  }
32
32
  export interface DataSeriesPoint {
@@ -30,7 +30,7 @@ export class VisualSeriesPoint {
30
30
  * returns x coordinate in pixels
31
31
  */
32
32
  x(viewable) {
33
- return floorToDPR(viewable.toX(this.centerUnit));
33
+ return viewable.toX(this.centerUnit);
34
34
  }
35
35
  clone() {
36
36
  return new VisualSeriesPoint(this.centerUnit, this.close);
@@ -125,7 +125,7 @@ export class ScaleModel extends ViewportModel {
125
125
  }
126
126
  }
127
127
  zoomXTo(state, zoomIn, forceNoAnimation) {
128
- const initialStateCopy = Object.assign({}, state);
128
+ const initialStateCopy = this.export();
129
129
  const constrainedState = this.scalePostProcessor(initialStateCopy, state);
130
130
  this.zoomReached = this.calculateZoomReached(constrainedState.zoomX, zoomIn);
131
131
  if (this.zoomReached.zoomIn || this.zoomReached.zoomOut) {
@@ -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 { Subject } from 'rxjs';
6
+ import { BehaviorSubject, Subject } from 'rxjs';
7
7
  import { ChartBaseElement } from '../chart-base-element';
8
8
  import { ViewportMovementAnimation } from '../../animation/types/viewport-movement-animation';
9
9
  import { Bounds } from '../bounds.model';
@@ -92,6 +92,7 @@ export declare abstract class ViewportModel extends ChartBaseElement implements
92
92
  start: number;
93
93
  end: number;
94
94
  }>;
95
+ initialViewportValidSubject: BehaviorSubject<boolean>;
95
96
  protected doActivate(): void;
96
97
  protected doDeactivate(): void;
97
98
  /**
@@ -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 { Subject } from 'rxjs';
6
+ import { BehaviorSubject, Subject } from 'rxjs';
7
7
  import { distinctUntilChanged, map, share } from 'rxjs/operators';
8
8
  import { ChartBaseElement } from '../chart-base-element';
9
9
  import { keys } from '../../utils/object.utils';
@@ -50,10 +50,15 @@ export class ViewportModel extends ChartBaseElement {
50
50
  start: this.yStart,
51
51
  end: this.yEnd,
52
52
  })), distinctUntilChanged((p, c) => p.start === c.start && p.end === c.end), share());
53
+ this.initialViewportValidSubject = new BehaviorSubject(false);
53
54
  }
54
55
  //endregion
55
56
  doActivate() {
56
57
  super.doActivate();
58
+ this.addRxSubscription(this.changed.subscribe(() => {
59
+ !this.initialViewportValidSubject.getValue() &&
60
+ this.initialViewportValidSubject.next(this.isViewportValid());
61
+ }));
57
62
  }
58
63
  doDeactivate() {
59
64
  super.doDeactivate();
@@ -87,9 +87,7 @@ export class TimeZoneModel {
87
87
  // In JS Date object is created with local tz offset,
88
88
  // so we have to subtract localOffset from current time
89
89
  return time => {
90
- return new Date(time +
91
- getTimezoneOffset(timezone, time) +
92
- new Date(time).getTimezoneOffset() * timeMultiplier);
90
+ return new Date(time + getTimezoneOffset(timezone, time) + new Date(time).getTimezoneOffset() * timeMultiplier);
93
91
  };
94
92
  }
95
93
  }
@@ -32,6 +32,7 @@ export interface GenerateCandlesDataConfig {
32
32
  * @doc-tags tricky
33
33
  */
34
34
  export declare function generateCandlesDataTS(config?: GenerateCandlesDataConfig): {
35
+ id: string;
35
36
  hi: number;
36
37
  lo: number;
37
38
  open: any;
@@ -4,6 +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
  export default function generateCandlesData(config: any): {
7
+ id: string;
7
8
  hi: number;
8
9
  lo: number;
9
10
  open: any;
@@ -5,6 +5,7 @@
5
5
  */
6
6
  /* eslint-disable */
7
7
  'use strict';
8
+ import { generateCandleId } from '../model/candle.model';
8
9
  export default function generateCandlesData(config) {
9
10
  // default generation config
10
11
  config = config || {};
@@ -78,6 +79,7 @@ function generateRandomCandle(from, to, candleAvgSize, type) {
78
79
  var high = Math.max(open, close) + Math.random() * candleAvgSize * 0.2;
79
80
  var low = Math.min(open, close) - Math.random() * candleAvgSize * 0.2;
80
81
  return {
82
+ id: generateCandleId(0, high + low + open + close),
81
83
  hi: high,
82
84
  lo: low,
83
85
  open: open,
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (C) 2019 - 2024 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 function hashCode(str: string): number;
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Copyright (C) 2019 - 2024 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 function hashCode(str) {
7
+ let hash = 0;
8
+ if (str.length === 0) {
9
+ return hash;
10
+ }
11
+ for (let i = 0; i < str.length; i++) {
12
+ const chr = str.charCodeAt(i);
13
+ // eslint-disable-next-line no-bitwise
14
+ hash = (hash << 5) - hash + chr;
15
+ // eslint-disable-next-line no-bitwise
16
+ hash |= 0; // Convert to 32bit integer
17
+ }
18
+ return hash;
19
+ }
@@ -0,0 +1,9 @@
1
+ /*
2
+ * Copyright (C) 2019 - 2024 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 type Mutable<T> = {
7
+ -readonly [P in keyof T]: T[P];
8
+ };
9
+ export type PartialExcept<T, K extends keyof T> = Partial<Omit<T, K>> & Pick<T, K>;
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (C) 2019 - 2024 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 {};