@devexperts/dxcharts-lite 2.4.5 → 2.4.6
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/dist/chart/bootstrap.js +1 -1
- package/dist/chart/chart.config.d.ts +4 -10
- package/dist/chart/chart.config.js +0 -2
- package/dist/chart/components/chart/chart-area-pan.handler.d.ts +8 -1
- package/dist/chart/components/chart/chart-area-pan.handler.js +40 -30
- package/dist/chart/components/chart/chart.model.d.ts +0 -1
- package/dist/chart/components/chart/chart.model.js +0 -1
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop.component.d.ts +1 -1
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop.component.js +20 -15
- package/dist/chart/components/dynamic-objects/dynamic-objects.model.d.ts +6 -3
- package/dist/chart/components/dynamic-objects/dynamic-objects.model.js +14 -3
- package/dist/chart/components/hit-test/hit-test.component.d.ts +3 -1
- package/dist/chart/components/hit-test/hit-test.component.js +6 -1
- package/dist/chart/components/pan/chart-pan.component.d.ts +1 -0
- package/dist/chart/components/pan/chart-pan.component.js +3 -0
- package/dist/chart/components/pane/extent/y-extent-component.d.ts +2 -0
- package/dist/chart/components/pane/pane.component.js +2 -1
- package/dist/chart/components/resizer/bar-resizer.component.js +6 -5
- package/dist/chart/components/x_axis/x-axis-scale.handler.js +1 -1
- package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.d.ts +1 -3
- package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.js +1 -3
- package/dist/chart/components/y_axis/y-axis-scale.handler.js +4 -6
- package/dist/chart/components/y_axis/y-axis.component.d.ts +1 -1
- package/dist/chart/components/y_axis/y-axis.component.js +6 -3
- package/dist/chart/inputhandlers/main-canvas-touch.handler.d.ts +1 -6
- package/dist/chart/inputhandlers/main-canvas-touch.handler.js +1 -6
- package/dist/chart/inputlisteners/canvas-input-listener.component.d.ts +0 -14
- package/dist/chart/inputlisteners/canvas-input-listener.component.js +1 -35
- package/dist/chart/model/candle-series.model.d.ts +10 -1
- package/dist/chart/model/candle-series.model.js +20 -2
- package/dist/chart/model/data-series.model.js +5 -3
- package/dist/chart/utils/timezone.utils.js +3 -3
- package/dist/dxchart.min.js +4 -4
- package/package.json +1 -1
|
@@ -8,7 +8,6 @@ import { merge, Subject } from 'rxjs';
|
|
|
8
8
|
import { ChartBaseElement } from '../model/chart-base-element';
|
|
9
9
|
import { distinctUntilChanged, filter, map, tap } from 'rxjs/operators';
|
|
10
10
|
import { EVENT_RESIZED } from '../events/events';
|
|
11
|
-
import { touchpadDetector } from '../utils/device/touchpad.utils';
|
|
12
11
|
import { deviceDetector } from '../utils/device/device-detector.utils';
|
|
13
12
|
/**
|
|
14
13
|
* Gathers user input on canvas element:
|
|
@@ -53,8 +52,6 @@ class CanvasInputListenerComponent extends ChartBaseElement {
|
|
|
53
52
|
this.longTouchStartSubject = new Subject();
|
|
54
53
|
this.longTouchEndSubject = new Subject();
|
|
55
54
|
this.contextMenuSubject = new Subject();
|
|
56
|
-
this.pinchSubject = new Subject();
|
|
57
|
-
this.scrollGestureSubject = new Subject();
|
|
58
55
|
this.fastTouchScroll = new Subject();
|
|
59
56
|
this.mouseLeavesCanvasSubject = new Subject();
|
|
60
57
|
// point at which start dragging
|
|
@@ -269,20 +266,7 @@ class CanvasInputListenerComponent extends ChartBaseElement {
|
|
|
269
266
|
this.addSubscription(subscribeListener(this.element, (e) => this.touchEndSubject.next(e), 'touchend'));
|
|
270
267
|
this.addSubscription(subscribeListener(this.element, (e) => this.touchCancelSubject.next(e), 'touchcancel'));
|
|
271
268
|
this.addSubscription(subscribeListener(this.element, (e) => {
|
|
272
|
-
|
|
273
|
-
if (e.ctrlKey) {
|
|
274
|
-
this.pinchSubject.next(e);
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
// mouse wheel or scroll gesture
|
|
278
|
-
const isTouchpad = touchpadDetector(e);
|
|
279
|
-
if (isTouchpad) {
|
|
280
|
-
this.scrollGestureSubject.next(e);
|
|
281
|
-
}
|
|
282
|
-
else {
|
|
283
|
-
this.wheelSubject.next(e);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
269
|
+
this.wheelSubject.next(e);
|
|
286
270
|
e.preventDefault(); // to disable the scroll over the document, if for example chart is used as widget
|
|
287
271
|
}, 'wheel'));
|
|
288
272
|
this.addSubscription(subscribeListener(this.element, (e) => this.contextMenuSubject.next(e), 'contextmenu'));
|
|
@@ -557,24 +541,6 @@ class CanvasInputListenerComponent extends ChartBaseElement {
|
|
|
557
541
|
.asObservable()
|
|
558
542
|
.pipe(filter(() => hitBoundsTest(this.currentPoint.x, this.currentPoint.y)));
|
|
559
543
|
}
|
|
560
|
-
/**
|
|
561
|
-
* Returns an Observable that emits WheelEvent when a pinch event occurs and the hitBoundsTest function returns true for the current point.
|
|
562
|
-
* @param {HitBoundsTest} hitBoundsTest - A function that takes the current point's x and y coordinates as arguments and returns a boolean indicating whether the point is within the desired bounds.
|
|
563
|
-
* @returns {Observable<WheelEvent>} - An Observable that emits WheelEvent when a pinch event occurs and the hitBoundsTest function returns true for the current point.
|
|
564
|
-
*/
|
|
565
|
-
observePinch(hitBoundsTest = () => true) {
|
|
566
|
-
return this.pinchSubject
|
|
567
|
-
.asObservable()
|
|
568
|
-
.pipe(filter(() => hitBoundsTest(this.currentPoint.x, this.currentPoint.y)));
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
* Returns an Observable that emits a WheelEvent whenever a scroll gesture is detected.
|
|
572
|
-
* The Observable is created from a Subject that is subscribed to by the component's template.
|
|
573
|
-
* @returns {Observable<WheelEvent>} An Observable that emits a WheelEvent whenever a scroll gesture is detected.
|
|
574
|
-
*/
|
|
575
|
-
observeScrollGesture() {
|
|
576
|
-
return this.scrollGestureSubject.asObservable();
|
|
577
|
-
}
|
|
578
544
|
/**
|
|
579
545
|
* Returns an Observable that emits TouchEvent when a touchstart event occurs within the bounds of the current point.
|
|
580
546
|
* @param {HitBoundsTest} [hitBoundsTest=() => true] - A function that tests if the touch event occurred within the bounds of the current point.
|
|
@@ -12,7 +12,7 @@ import EventBus from '../events/event-bus';
|
|
|
12
12
|
import { DeepPartial } from '../utils/object.utils';
|
|
13
13
|
import { Candle } from './candle.model';
|
|
14
14
|
import { DataSeriesType } from './data-series.config';
|
|
15
|
-
import { DataSeriesModel } from './data-series.model';
|
|
15
|
+
import { DataSeriesModel, DataSeriesViewportIndexes } from './data-series.model';
|
|
16
16
|
import { HighLowWithIndex, ScaleModel } from './scale.model';
|
|
17
17
|
import { Unit } from './scaling/viewport.model';
|
|
18
18
|
import VisualCandle from './visual-candle';
|
|
@@ -44,6 +44,15 @@ export declare class CandleSeriesModel extends DataSeriesModel<Candle, VisualCan
|
|
|
44
44
|
* @returns {void}
|
|
45
45
|
*/
|
|
46
46
|
recalculateDataViewportIndexes(xStart?: number, xEnd?: number): void;
|
|
47
|
+
/**
|
|
48
|
+
* Calculates and returns the indexes of the start and end points of the data viewport,
|
|
49
|
+
* based on the given start and end units on the x-axis.
|
|
50
|
+
*
|
|
51
|
+
* @param {Unit} xStart - The start value of the viewport on the x-axis.
|
|
52
|
+
* @param {Unit} xEnd - The end value of the viewport on the x-axis.
|
|
53
|
+
* @returns {DataSeriesViewportIndexes} An object containing the calculated start and end indexes of the data viewport.
|
|
54
|
+
*/
|
|
55
|
+
calculateDataViewportIndexes(xStart: Unit, xEnd: Unit): DataSeriesViewportIndexes;
|
|
47
56
|
/**
|
|
48
57
|
* Calculates the price movement of the last candle by comparing the open and close prices.
|
|
49
58
|
* Sets the lastPriceMovement property of the instance with the name of the direction of the price movement.
|
|
@@ -7,7 +7,7 @@ import { Subject } from 'rxjs';
|
|
|
7
7
|
import { getDefaultConfig } from '../chart.config';
|
|
8
8
|
import { defaultCandleTransformer } from '../components/chart/candle-transformer.functions';
|
|
9
9
|
import { calculateCandleWidth } from '../components/chart/candle-width-calculator.functions';
|
|
10
|
-
import { lastOf } from '../utils/array.utils';
|
|
10
|
+
import { binarySearch, lastOf } from '../utils/array.utils';
|
|
11
11
|
import { merge } from '../utils/merge.utils';
|
|
12
12
|
import { PriceIncrementsUtils } from '../utils/price-increments.utils';
|
|
13
13
|
import { calculateCandlesHighLow, createCandleSeriesHighLowProvider } from './candle-series-high-low.provider';
|
|
@@ -58,10 +58,28 @@ export class CandleSeriesModel extends DataSeriesModel {
|
|
|
58
58
|
* @returns {void}
|
|
59
59
|
*/
|
|
60
60
|
recalculateDataViewportIndexes(xStart = this.scale.xStart, xEnd = this.scale.xEnd) {
|
|
61
|
-
|
|
61
|
+
const { dataIdxStart, dataIdxEnd } = this.calculateDataViewportIndexes(xStart, xEnd);
|
|
62
|
+
this.dataIdxStart = dataIdxStart;
|
|
63
|
+
this.dataIdxEnd = dataIdxEnd;
|
|
62
64
|
this.recalculateZippedHighLow();
|
|
63
65
|
this.eventBus.fireDraw();
|
|
64
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Calculates and returns the indexes of the start and end points of the data viewport,
|
|
69
|
+
* based on the given start and end units on the x-axis.
|
|
70
|
+
*
|
|
71
|
+
* @param {Unit} xStart - The start value of the viewport on the x-axis.
|
|
72
|
+
* @param {Unit} xEnd - The end value of the viewport on the x-axis.
|
|
73
|
+
* @returns {DataSeriesViewportIndexes} An object containing the calculated start and end indexes of the data viewport.
|
|
74
|
+
*/
|
|
75
|
+
calculateDataViewportIndexes(xStart, xEnd) {
|
|
76
|
+
const dataIdxStart = binarySearch(this.visualPoints, xStart, (it) => it.startUnit).index;
|
|
77
|
+
const dataIdxEnd = binarySearch(this.visualPoints, xEnd, (it) => it.startUnit).index;
|
|
78
|
+
return {
|
|
79
|
+
dataIdxStart,
|
|
80
|
+
dataIdxEnd,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
65
83
|
/**
|
|
66
84
|
* Calculates the price movement of the last candle by comparing the open and close prices.
|
|
67
85
|
* Sets the lastPriceMovement property of the instance with the name of the direction of the price movement.
|
|
@@ -138,7 +138,9 @@ export class DataSeriesModel extends ChartBaseElement {
|
|
|
138
138
|
}
|
|
139
139
|
doActivate() {
|
|
140
140
|
this.addRxSubscription(this.scale.xChanged.subscribe(() => this.recalculateDataViewportIndexes()));
|
|
141
|
-
this.addRxSubscription(this.scale.scaleInversedSubject.subscribe(() => {
|
|
141
|
+
this.addRxSubscription(this.scale.scaleInversedSubject.subscribe(() => {
|
|
142
|
+
this.recalculateVisualPoints();
|
|
143
|
+
}));
|
|
142
144
|
}
|
|
143
145
|
/**
|
|
144
146
|
* Sets the data points and recalculates internal state
|
|
@@ -215,8 +217,8 @@ export class DataSeriesModel extends ChartBaseElement {
|
|
|
215
217
|
* @returns {DataSeriesViewportIndexes} An object containing the calculated start and end indexes of the data viewport.
|
|
216
218
|
*/
|
|
217
219
|
calculateDataViewportIndexes(xStart, xEnd) {
|
|
218
|
-
const dataIdxStart = binarySearch(this.visualPoints, xStart, i => i.centerUnit).index;
|
|
219
|
-
const dataIdxEnd = binarySearch(this.visualPoints, xEnd, i => i.centerUnit).index;
|
|
220
|
+
const dataIdxStart = binarySearch(this.visualPoints, xStart, (i) => i.centerUnit).index;
|
|
221
|
+
const dataIdxEnd = binarySearch(this.visualPoints, xEnd, (i) => i.centerUnit).index;
|
|
220
222
|
return {
|
|
221
223
|
dataIdxStart,
|
|
222
224
|
dataIdxEnd,
|
|
@@ -35,10 +35,10 @@ export function getDateTimeFormat(timeZone) {
|
|
|
35
35
|
export const getTimezoneOffset = (timeZone, timestamp = Date.now()) => {
|
|
36
36
|
const formatter = getDateTimeFormat(timeZone);
|
|
37
37
|
const dateString = formatter.format(timestamp);
|
|
38
|
-
// exec() returns [, fMonth, fDay, fYear, fHour, fMinute]
|
|
39
|
-
const tokens = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+)/.exec(dateString);
|
|
38
|
+
// exec() returns [, fMonth, fDay, fYear, fHour, fMinute, fSeconds]
|
|
39
|
+
const tokens = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(dateString);
|
|
40
40
|
if (tokens) {
|
|
41
|
-
const asUTC = Date.UTC(+tokens[3], +tokens[1] - 1, +tokens[2], +tokens[4] % 24, +tokens[5],
|
|
41
|
+
const asUTC = Date.UTC(+tokens[3], +tokens[1] - 1, +tokens[2], +tokens[4] % 24, +tokens[5], +tokens[6]);
|
|
42
42
|
let asTimezone = timestamp;
|
|
43
43
|
const over = asTimezone % 1000;
|
|
44
44
|
asTimezone -= over >= 0 ? over : 1000 + over;
|