@devexperts/dxcharts-lite 2.0.2 → 2.2.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.
- package/README.md +1 -1
- package/dist/chart/__tests__/chart.test.d.ts +6 -0
- package/dist/chart/__tests__/chart.test.js +51 -0
- package/dist/chart/__tests__/env.d.ts +5 -0
- package/dist/chart/__tests__/env.js +28 -0
- package/dist/chart/bootstrap.js +2 -2
- package/dist/chart/chart.config.d.ts +4 -1
- package/dist/chart/chart.config.js +1 -1
- package/dist/chart/components/chart/chart-base.model.d.ts +1 -1
- package/dist/chart/components/chart/chart.component.js +13 -3
- package/dist/chart/components/chart/chart.model.d.ts +2 -2
- package/dist/chart/components/chart/chart.model.js +9 -7
- package/dist/chart/components/cross_tool/cross-tool.component.d.ts +2 -1
- package/dist/chart/components/cross_tool/cross-tool.component.js +4 -3
- package/dist/chart/components/cross_tool/cross-tool.model.js +1 -0
- package/dist/chart/components/cross_tool/types/cross-and-labels.drawer.d.ts +3 -1
- package/dist/chart/components/cross_tool/types/cross-and-labels.drawer.js +3 -2
- package/dist/chart/components/dynamic-objects/dynamic-objects.component.js +1 -1
- package/dist/chart/components/dynamic-objects/dynamic-objects.model.d.ts +30 -10
- package/dist/chart/components/dynamic-objects/dynamic-objects.model.js +119 -57
- package/dist/chart/components/grid/grid.drawer.js +3 -1
- package/dist/chart/components/pane/extent/y-extent-component.js +2 -1
- package/dist/chart/components/pane/pane-hit-test.controller.js +2 -2
- package/dist/chart/components/volumes/volumes.component.d.ts +3 -0
- package/dist/chart/components/volumes/volumes.component.js +21 -4
- package/dist/chart/components/volumes/volumes.model.d.ts +2 -0
- package/dist/chart/components/volumes/volumes.model.js +2 -0
- package/dist/chart/components/x_axis/x-axis.component.js +2 -2
- package/dist/chart/components/y_axis/label-color.functions.d.ts +2 -1
- package/dist/chart/components/y_axis/label-color.functions.js +17 -0
- package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.d.ts +2 -2
- package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.js +27 -25
- package/dist/chart/components/y_axis/price_labels/labels-positions-calculator.js +24 -13
- package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.d.ts +3 -3
- package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.js +58 -40
- package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.d.ts +3 -3
- package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.js +15 -13
- package/dist/chart/components/y_axis/y-axis-scale.handler.js +1 -1
- package/dist/chart/components/y_axis/y-axis.component.d.ts +2 -1
- package/dist/chart/components/y_axis/y-axis.component.js +6 -2
- package/dist/chart/drawers/ht-data-series.drawer.js +1 -1
- package/dist/chart/inputhandlers/cross-event-producer.component.js +2 -1
- package/dist/chart/inputhandlers/hover-producer.component.d.ts +1 -1
- package/dist/chart/inputhandlers/hover-producer.component.js +8 -8
- package/dist/chart/inputlisteners/canvas-input-listener.component.d.ts +12 -5
- package/dist/chart/inputlisteners/canvas-input-listener.component.js +74 -62
- package/dist/chart/model/candle-series.model.d.ts +1 -1
- package/dist/chart/model/candle-series.model.js +2 -2
- package/dist/chart/model/compare-series-hover.d.ts +2 -1
- package/dist/chart/model/compare-series-hover.js +1 -0
- package/dist/chart/model/data-series.model.d.ts +3 -2
- package/dist/chart/model/data-series.model.js +2 -1
- package/dist/chart/model/main-candle-series.model.d.ts +1 -1
- package/dist/chart/model/main-candle-series.model.js +2 -2
- package/dist/chart/model/scale.model.d.ts +2 -0
- package/dist/chart/model/scale.model.js +11 -2
- package/dist/chart/utils/dom.utils.d.ts +7 -0
- package/dist/chart/utils/dom.utils.js +12 -0
- package/dist/chart/utils/linkedList.utils.d.ts +3 -3
- package/dist/chart/utils/linkedList.utils.js +55 -57
- package/dist/dxchart.min.js +4 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -8
- package/package.json +10 -4
|
@@ -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:
|
|
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,
|
|
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):
|
|
21
|
-
insertAt(position: number, data: T):
|
|
22
|
-
removeAt(position: number):
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
54
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
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 (
|
|
114
|
-
if (
|
|
111
|
+
while (current) {
|
|
112
|
+
if (current.data === node.data) {
|
|
115
113
|
return index;
|
|
116
114
|
}
|
|
117
|
-
current = current
|
|
115
|
+
current = current.next;
|
|
118
116
|
index++;
|
|
119
117
|
}
|
|
120
118
|
return -1;
|