@devexperts/dxcharts-lite 2.0.1 → 2.1.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 (71) hide show
  1. package/README.md +28 -29
  2. package/dist/chart/__tests__/chart.test.d.ts +6 -0
  3. package/dist/chart/__tests__/chart.test.js +51 -0
  4. package/dist/chart/{chart-container.js → __tests__/env.d.ts} +0 -1
  5. package/dist/chart/__tests__/env.js +28 -0
  6. package/dist/chart/bootstrap.d.ts +7 -2
  7. package/dist/chart/bootstrap.js +2 -2
  8. package/dist/chart/chart.config.d.ts +4 -1
  9. package/dist/chart/chart.config.js +1 -1
  10. package/dist/chart/chart.d.ts +2 -0
  11. package/dist/chart/chart.js +3 -1
  12. package/dist/chart/components/chart/candle-transformer.functions.d.ts +1 -0
  13. package/dist/chart/components/chart/candle-transformer.functions.js +1 -0
  14. package/dist/chart/components/chart/chart-base.model.d.ts +2 -2
  15. package/dist/chart/components/chart/chart-base.model.js +2 -2
  16. package/dist/chart/components/chart/chart.component.d.ts +6 -0
  17. package/dist/chart/components/chart/chart.component.js +23 -4
  18. package/dist/chart/components/chart/chart.model.d.ts +9 -3
  19. package/dist/chart/components/chart/chart.model.js +35 -13
  20. package/dist/chart/components/cross_tool/cross-tool.component.d.ts +2 -1
  21. package/dist/chart/components/cross_tool/cross-tool.component.js +4 -3
  22. package/dist/chart/components/cross_tool/cross-tool.model.js +1 -0
  23. package/dist/chart/components/cross_tool/types/cross-and-labels.drawer.d.ts +3 -1
  24. package/dist/chart/components/cross_tool/types/cross-and-labels.drawer.js +3 -2
  25. package/dist/chart/components/dynamic-objects/dynamic-objects.component.js +1 -1
  26. package/dist/chart/components/dynamic-objects/dynamic-objects.model.d.ts +30 -10
  27. package/dist/chart/components/dynamic-objects/dynamic-objects.model.js +119 -57
  28. package/dist/chart/components/grid/grid.drawer.js +3 -1
  29. package/dist/chart/components/pane/extent/y-extent-component.js +2 -1
  30. package/dist/chart/components/pane/pane-hit-test.controller.js +2 -2
  31. package/dist/chart/components/volumes/volumes.component.d.ts +3 -0
  32. package/dist/chart/components/volumes/volumes.component.js +21 -4
  33. package/dist/chart/components/volumes/volumes.model.d.ts +2 -0
  34. package/dist/chart/components/volumes/volumes.model.js +2 -0
  35. package/dist/chart/components/x_axis/x-axis.component.js +2 -2
  36. package/dist/chart/components/y_axis/label-color.functions.d.ts +2 -1
  37. package/dist/chart/components/y_axis/label-color.functions.js +17 -0
  38. package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.d.ts +2 -2
  39. package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.js +27 -25
  40. package/dist/chart/components/y_axis/price_labels/labels-positions-calculator.js +24 -13
  41. package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.d.ts +3 -3
  42. package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.js +58 -40
  43. package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.d.ts +3 -3
  44. package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.js +15 -13
  45. package/dist/chart/components/y_axis/y-axis-scale.handler.js +1 -1
  46. package/dist/chart/components/y_axis/y-axis.component.d.ts +2 -1
  47. package/dist/chart/components/y_axis/y-axis.component.js +6 -2
  48. package/dist/chart/drawers/ht-data-series.drawer.js +1 -1
  49. package/dist/chart/inputhandlers/hover-producer.component.d.ts +1 -1
  50. package/dist/chart/inputhandlers/hover-producer.component.js +7 -7
  51. package/dist/chart/inputlisteners/canvas-input-listener.component.d.ts +9 -2
  52. package/dist/chart/inputlisteners/canvas-input-listener.component.js +21 -19
  53. package/dist/chart/model/candle-series.model.d.ts +1 -1
  54. package/dist/chart/model/candle-series.model.js +2 -2
  55. package/dist/chart/model/compare-series-hover.d.ts +2 -1
  56. package/dist/chart/model/compare-series-hover.js +1 -0
  57. package/dist/chart/model/data-series.model.d.ts +3 -2
  58. package/dist/chart/model/data-series.model.js +2 -1
  59. package/dist/chart/model/main-candle-series.model.d.ts +1 -1
  60. package/dist/chart/model/main-candle-series.model.js +2 -2
  61. package/dist/chart/model/scale.model.d.ts +2 -0
  62. package/dist/chart/model/scale.model.js +11 -2
  63. package/dist/chart/utils/dom.utils.d.ts +7 -0
  64. package/dist/chart/utils/dom.utils.js +12 -0
  65. package/dist/chart/utils/linkedList.utils.d.ts +3 -3
  66. package/dist/chart/utils/linkedList.utils.js +55 -57
  67. package/dist/dxchart.min.js +4 -4
  68. package/dist/index.d.ts +2 -1
  69. package/dist/index.js +2 -8
  70. package/package.json +18 -4
  71. package/dist/chart/chart-container.d.ts +0 -18
@@ -23,6 +23,7 @@ export class CompareSeriesHoverProducerPart {
23
23
  instrument: series.instrument.symbol,
24
24
  price: priceToShow,
25
25
  id: series.id,
26
+ htId: series.htId,
26
27
  };
27
28
  });
28
29
  return compareSeriesHover;
@@ -45,7 +45,8 @@ export interface DataSeriesViewportIndexes {
45
45
  */
46
46
  export declare class DataSeriesModel<D extends DataSeriesPoint = DataSeriesPoint, V extends VisualSeriesPoint = VisualSeriesPoint> extends ChartBaseElement {
47
47
  extentComponent: YExtentComponent;
48
- id: number;
48
+ id: string;
49
+ htId: number;
49
50
  name: string;
50
51
  hovered: boolean;
51
52
  yAxisLabelProvider: DataSeriesYAxisLabelsProvider;
@@ -70,7 +71,7 @@ export declare class DataSeriesModel<D extends DataSeriesPoint = DataSeriesPoint
70
71
  get visualPoints(): V[];
71
72
  get visualPoints2D(): V[][];
72
73
  set visualPoints(points: V[][] | V[]);
73
- constructor(extentComponent: YExtentComponent, id: number, _config?: AtLeastOne<DataSeriesConfig>);
74
+ constructor(extentComponent: YExtentComponent, id: string, htId: number, _config?: AtLeastOne<DataSeriesConfig>);
74
75
  protected doActivate(): void;
75
76
  /**
76
77
  * Sets the data points and recalculates internal state
@@ -65,11 +65,12 @@ export class DataSeriesModel extends ChartBaseElement {
65
65
  this._visualPoints = create2DArray(points);
66
66
  this._visualPointsFlat = this._visualPoints.flat();
67
67
  }
68
- constructor(extentComponent, id, _config = cloneUnsafe(DEFAULT_DATA_SERIES_CONFIG)) {
68
+ constructor(extentComponent, id, htId, _config = cloneUnsafe(DEFAULT_DATA_SERIES_CONFIG)) {
69
69
  var _a;
70
70
  super();
71
71
  this.extentComponent = extentComponent;
72
72
  this.id = id;
73
+ this.htId = htId;
73
74
  this.name = '';
74
75
  this.hovered = false;
75
76
  this._dataPoints = [];
@@ -18,7 +18,7 @@ import VisualCandle from './visual-candle';
18
18
  */
19
19
  export declare class MainCandleSeriesModel extends CandleSeriesModel {
20
20
  private readonly baseModel;
21
- constructor(baseModel: ChartBaseModel<'candle'>, extentComponent: YExtentComponent, id: number, eventBus: EventBus, scale: ScaleModel, instrument: ChartInstrument, candlesTransformersByChartType: Partial<Record<DataSeriesType, VisualCandleCalculator>>, candleWidthByChartType: Partial<Record<DataSeriesType, CandleWidthCalculator>>, colors: CandleSeriesColors);
21
+ constructor(baseModel: ChartBaseModel<'candle'>, extentComponent: YExtentComponent, id: string, htId: number, eventBus: EventBus, scale: ScaleModel, instrument: ChartInstrument, candlesTransformersByChartType: Partial<Record<DataSeriesType, VisualCandleCalculator>>, candleWidthByChartType: Partial<Record<DataSeriesType, CandleWidthCalculator>>, colors: CandleSeriesColors);
22
22
  set visualPoints(candles: VisualCandle[] | VisualCandle[][]);
23
23
  get visualPoints(): VisualCandle[];
24
24
  set dataPoints(candles: Candle[] | Candle[][]);
@@ -8,8 +8,8 @@ import { CandleSeriesModel } from './candle-series.model';
8
8
  * This model represents main chart data series and is highly tied to chartBaseModel, @see ChartBaseModel
9
9
  */
10
10
  export class MainCandleSeriesModel extends CandleSeriesModel {
11
- constructor(baseModel, extentComponent, id, eventBus, scale, instrument, candlesTransformersByChartType, candleWidthByChartType, colors) {
12
- super(extentComponent, id, eventBus, scale, instrument, candlesTransformersByChartType, candleWidthByChartType, colors);
11
+ constructor(baseModel, extentComponent, id, htId, eventBus, scale, instrument, candlesTransformersByChartType, candleWidthByChartType, colors) {
12
+ super(extentComponent, id, htId, eventBus, scale, instrument, candlesTransformersByChartType, candleWidthByChartType, colors);
13
13
  this.baseModel = baseModel;
14
14
  }
15
15
  set visualPoints(candles) {
@@ -91,6 +91,7 @@ export declare class ScaleModel extends ViewportModel {
91
91
  setXScale(xStart: Unit, xEnd: Unit): void;
92
92
  /**
93
93
  * Moves both xStart and xEnd without changing the viewport width (zoom).
94
+ * Works without animation.
94
95
  * WILL CHANGE the Y axis if scale.auto=true.
95
96
  * @param xStart - starting point in units
96
97
  */
@@ -98,6 +99,7 @@ export declare class ScaleModel extends ViewportModel {
98
99
  private scalePostProcessor;
99
100
  /**
100
101
  * Moves both yStart and yEnd without changing the viewport height (zoom).
102
+ * Works without animation.
101
103
  * Will not move viewport if scale.auto=true
102
104
  * @param yStart - starting point in units
103
105
  */
@@ -82,10 +82,14 @@ export class ScaleModel extends ViewportModel {
82
82
  * @param zoomSensitivity The sensitivity of the zoom.
83
83
  */
84
84
  zoomXToPercent(viewportPercent, zoomIn, forceNoAnimation = false, zoomSensitivity = this.config.scale.zoomSensitivity) {
85
+ const disabledAnimations = this.config.scale.disableAnimations || forceNoAnimation;
86
+ if (disabledAnimations) {
87
+ this.haltAnimation();
88
+ }
85
89
  this.beforeStartAnimationSubject.next();
86
90
  const state = this.export();
87
91
  zoomXToPercentViewportCalculator(this, state, viewportPercent, zoomSensitivity, zoomIn);
88
- this.zoomXTo(state, forceNoAnimation);
92
+ this.zoomXTo(state, disabledAnimations);
89
93
  }
90
94
  /**
91
95
  * Zooms the X axis of the chart relativly to the end of the data range.
@@ -93,10 +97,13 @@ export class ScaleModel extends ViewportModel {
93
97
  * @param zoomSensitivity - The sensitivity of the zoom. Default value is taken from the configuration object.
94
98
  */
95
99
  zoomXToEnd(zoomIn, zoomSensitivity = this.config.scale.zoomSensitivity) {
100
+ if (this.config.scale.disableAnimations) {
101
+ this.haltAnimation();
102
+ }
96
103
  this.beforeStartAnimationSubject.next();
97
104
  const state = this.export();
98
105
  zoomXToEndViewportCalculator(this, state, zoomSensitivity, zoomIn);
99
- this.zoomXTo(state);
106
+ this.zoomXTo(state, this.config.scale.disableAnimations);
100
107
  }
101
108
  haltAnimation() {
102
109
  var _a;
@@ -144,6 +151,7 @@ export class ScaleModel extends ViewportModel {
144
151
  }
145
152
  /**
146
153
  * Moves both xStart and xEnd without changing the viewport width (zoom).
154
+ * Works without animation.
147
155
  * WILL CHANGE the Y axis if scale.auto=true.
148
156
  * @param xStart - starting point in units
149
157
  */
@@ -162,6 +170,7 @@ export class ScaleModel extends ViewportModel {
162
170
  }
163
171
  /**
164
172
  * Moves both yStart and yEnd without changing the viewport height (zoom).
173
+ * Works without animation.
165
174
  * Will not move viewport if scale.auto=true
166
175
  * @param yStart - starting point in units
167
176
  */
@@ -3,6 +3,12 @@
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
+ export declare const MouseButton: {
7
+ left: number;
8
+ middle: number;
9
+ right: number;
10
+ };
11
+ export type MouseButtonType = typeof MouseButton[keyof typeof MouseButton];
6
12
  /**
7
13
  * @param {Element} element
8
14
  * @param {function} listener
@@ -11,3 +17,4 @@
11
17
  * @return {Function}
12
18
  */
13
19
  export declare function subscribeListener<K extends keyof GlobalEventHandlersEventMap>(element: EventTarget, listener: (e: GlobalEventHandlersEventMap[K]) => void, eventType: K, useCapture?: boolean): () => void;
20
+ export declare function leftMouseButtonListener(cb: (e: MouseEvent) => void): (e: MouseEvent) => void;
@@ -3,6 +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
+ export const MouseButton = {
7
+ left: 0,
8
+ middle: 1,
9
+ right: 2,
10
+ };
6
11
  /**
7
12
  * @param {Element} element
8
13
  * @param {function} listener
@@ -18,3 +23,10 @@ export function subscribeListener(element, listener, eventType, useCapture) {
18
23
  element.removeEventListener(eventType, listener, useCapture);
19
24
  };
20
25
  }
26
+ export function leftMouseButtonListener(cb) {
27
+ return (e) => {
28
+ if (e.button === MouseButton.left) {
29
+ cb(e);
30
+ }
31
+ };
32
+ }
@@ -17,9 +17,9 @@ export declare class LinkedList<T> {
17
17
  private _tail;
18
18
  private length;
19
19
  constructor(head?: ListNode<T>);
20
- insertAtEnd(data: T): ListNode<T>;
21
- insertAt(position: number, data: T): ListNode<T> | null;
22
- removeAt(position: number): ListNode<T> | null;
20
+ insertAtEnd(data: T): void;
21
+ insertAt(position: number, data: T): null | undefined;
22
+ removeAt(position: number): null | undefined;
23
23
  getNodePosition(node: ListNode<T>): number;
24
24
  size(): number;
25
25
  get head(): ListNode<T> | null;
@@ -19,102 +19,100 @@ export class LinkedList {
19
19
  this._tail = null;
20
20
  this.length = 0;
21
21
  this._head = head !== null && head !== void 0 ? head : null;
22
- // init tail
23
22
  if (this.head !== null) {
24
- let current;
25
- current = this.head;
23
+ // init tail
24
+ let current = this.head;
26
25
  while (current.next) {
27
26
  current = current.next;
28
27
  }
29
28
  this._tail = current;
29
+ this.length++;
30
30
  }
31
31
  }
32
32
  insertAtEnd(data) {
33
33
  const node = new ListNode(data);
34
- let current;
35
34
  if (this.head === null) {
36
35
  this._head = node;
37
36
  }
38
37
  else {
39
- current = this.head;
38
+ let current = this.head;
39
+ // iterate till the end of the list
40
40
  while (current.next) {
41
41
  current = current.next;
42
42
  }
43
+ // insert the node at the end
43
44
  current.next = node;
44
45
  }
45
46
  this._tail = node;
46
47
  this.length++;
47
- return node;
48
48
  }
49
49
  insertAt(position, data) {
50
- if (position > -1 && position < this.length && this.head) {
50
+ // falsy cases
51
+ if (!this.head || position < 0 || position > this.length) {
52
+ return null;
53
+ }
54
+ const node = new ListNode(data);
55
+ // if position === 0 it means that we need to insert the node in the head
56
+ if (position === 0) {
57
+ node.next = this.head;
58
+ this._head = node;
59
+ }
60
+ else {
51
61
  let current = this.head;
62
+ let previous = current;
52
63
  let index = 0;
53
- let previous = null;
54
- const node = new ListNode(data);
64
+ // iterate till the index === position
65
+ while (current && index < position) {
66
+ index++;
67
+ previous = current;
68
+ current = current.next;
69
+ }
70
+ // insert an element
71
+ node.next = current;
72
+ previous.next = node;
73
+ // update tail
55
74
  if (position === this.length - 1) {
56
75
  this._tail = node;
57
76
  }
58
- if (position === 0) {
59
- node.next = current;
60
- this._head = node;
61
- }
62
- else {
63
- while (index < position && current.next) {
64
- index++;
65
- previous = current;
66
- current = current.next;
67
- }
68
- node.next = current;
69
- if (previous) {
70
- previous.next = node;
71
- }
72
- }
73
- this.length++;
74
- return current;
75
- }
76
- else {
77
- this._head = new ListNode(data);
78
- this.length++;
79
- return this.head;
80
77
  }
78
+ this.length++;
81
79
  }
82
80
  removeAt(position) {
83
- if (position > -1 && position < this.length && this.head) {
84
- let current = this.head;
85
- let previous = null;
86
- let index = 0;
87
- if (position === 0) {
88
- this._head = current.next;
89
- }
90
- else {
91
- while (index < position && current.next) {
92
- index++;
93
- previous = current;
94
- current = current.next;
95
- }
96
- if (previous) {
97
- previous.next = current.next;
98
- }
99
- if (position === this.length - 1) {
100
- this._tail = current;
101
- }
102
- }
103
- this.length--;
104
- return current;
81
+ // falsy cases
82
+ if (!this.head || position < 0 || position >= this.length) {
83
+ return null;
84
+ }
85
+ let current = this.head;
86
+ let previous = current;
87
+ let index = 0;
88
+ // if position === 0 it means that we need to delete the first node
89
+ if (position === 0) {
90
+ this._head = current.next;
105
91
  }
106
92
  else {
107
- return null;
93
+ // iterate till the index === position
94
+ while (current.next && index < position) {
95
+ index++;
96
+ previous = current;
97
+ current = current.next;
98
+ }
99
+ // remove the element
100
+ previous.next = current.next;
101
+ // update tail
102
+ if (position === this.length - 1) {
103
+ this._tail = previous;
104
+ }
108
105
  }
106
+ this.length--;
109
107
  }
110
108
  getNodePosition(node) {
111
109
  let index = 0;
112
110
  let current = this.head;
113
- while (node) {
114
- if ((current === null || current === void 0 ? void 0 : current.data) === node.data) {
111
+ while (current) {
112
+ if (current.data === node.data) {
115
113
  return index;
116
114
  }
117
- current = current && current.next;
115
+ current = current.next;
118
116
  index++;
119
117
  }
120
118
  return -1;