@devexperts/dxcharts-lite 2.5.1 → 2.5.3
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/components/x_axis/x-axis-scale.handler.d.ts +4 -0
- package/dist/chart/components/x_axis/x-axis-scale.handler.js +8 -1
- package/dist/chart/components/x_axis/x-axis.component.d.ts +2 -0
- package/dist/chart/components/x_axis/x-axis.component.js +12 -0
- package/dist/chart/components/y_axis/y-axis-scale.handler.d.ts +5 -2
- package/dist/chart/components/y_axis/y-axis-scale.handler.js +11 -4
- package/dist/chart/components/y_axis/y-axis.component.d.ts +2 -0
- package/dist/chart/components/y_axis/y-axis.component.js +16 -2
- package/dist/chart/model/scale.model.js +2 -2
- package/dist/chart/model/visual-candle.js +1 -1
- package/dist/dxchart.min.js +4 -4
- package/package.json +1 -1
|
@@ -25,6 +25,8 @@ export declare class XAxisScaleHandler extends ChartBaseElement {
|
|
|
25
25
|
lastXStart: Unit;
|
|
26
26
|
lastXWidth: Unit;
|
|
27
27
|
lastXPxWidth: Pixel;
|
|
28
|
+
private dblClickCallback;
|
|
29
|
+
private dblTapCallback;
|
|
28
30
|
constructor(scale: ScaleModel, canvasInputListener: CanvasInputListenerComponent, canvasBoundsContainer: CanvasBoundsContainer, chartPanComponent: ChartPanComponent, chartModel: ChartModel, hitTestCanvasModel: HitTestCanvasModel);
|
|
29
31
|
/**
|
|
30
32
|
* This method is used to activate the canvas input listener and add a subscription to it.
|
|
@@ -38,4 +40,6 @@ export declare class XAxisScaleHandler extends ChartBaseElement {
|
|
|
38
40
|
private onXDragStart;
|
|
39
41
|
private onXDragTick;
|
|
40
42
|
private onXDragEnd;
|
|
43
|
+
setDblTapCallback: (cb: () => void) => () => void;
|
|
44
|
+
setDblClickCallback: (cb: () => void) => () => void;
|
|
41
45
|
}
|
|
@@ -46,6 +46,10 @@ export class XAxisScaleHandler extends ChartBaseElement {
|
|
|
46
46
|
// Continue redrawing hit test
|
|
47
47
|
this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(true);
|
|
48
48
|
};
|
|
49
|
+
this.setDblTapCallback = (cb) => this.dblTapCallback = cb;
|
|
50
|
+
this.setDblClickCallback = (cb) => this.dblClickCallback = cb;
|
|
51
|
+
this.dblClickCallback = () => chartModel.doBasicScale();
|
|
52
|
+
this.dblTapCallback = () => chartModel.doBasicScale();
|
|
49
53
|
const dragNDropXComponent = new DragNDropXComponent(this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.X_AXIS), {
|
|
50
54
|
onDragStart: this.onXDragStart,
|
|
51
55
|
onDragTick: this.onXDragTick,
|
|
@@ -67,7 +71,10 @@ export class XAxisScaleHandler extends ChartBaseElement {
|
|
|
67
71
|
super.doActivate();
|
|
68
72
|
this.addRxSubscription(this.canvasInputListener
|
|
69
73
|
.observeDbClick(this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.X_AXIS))
|
|
70
|
-
.subscribe(() => this.
|
|
74
|
+
.subscribe(() => this.dblClickCallback()));
|
|
75
|
+
this.addRxSubscription(this.canvasInputListener
|
|
76
|
+
.observeDbTap(this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.X_AXIS))
|
|
77
|
+
.subscribe(() => this.dblTapCallback()));
|
|
71
78
|
this.addRxSubscription(this.chartModel.candlesPrependSubject.subscribe(({ prependedCandlesWidth }) => (this.lastXStart += prependedCandlesWidth)));
|
|
72
79
|
}
|
|
73
80
|
}
|
|
@@ -71,4 +71,6 @@ export declare class XAxisComponent extends ChartBaseElement {
|
|
|
71
71
|
* If visible, when you can see the x-axis on the chart
|
|
72
72
|
*/
|
|
73
73
|
isVisible(): boolean;
|
|
74
|
+
setDblClickCallback: (cb: () => void) => () => void;
|
|
75
|
+
setDblTapCallback: (cb: () => void) => () => void;
|
|
74
76
|
}
|
|
@@ -29,6 +29,18 @@ export class XAxisComponent extends ChartBaseElement {
|
|
|
29
29
|
this.scale = scale;
|
|
30
30
|
this.chartResizeHandler = chartResizeHandler;
|
|
31
31
|
this.timeZoneModel = timeZoneModel;
|
|
32
|
+
/* This function assigns a callback to be executed when a double-click event is detected.
|
|
33
|
+
* It accepts one parameter `cb`, which is a callback function.
|
|
34
|
+
* When a double-click event occurs, the specified callback function `cb` will be invoked.
|
|
35
|
+
* By default it calls basic scale on XAxis
|
|
36
|
+
*/
|
|
37
|
+
this.setDblClickCallback = (cb) => this.xAxisScaleHandler.setDblClickCallback(cb);
|
|
38
|
+
/* This function assigns a callback to be executed when a double-tap event is detected.
|
|
39
|
+
* Similar to the dblclick function, it takes one parameter `cb`, which is a callback function.
|
|
40
|
+
* This function ensures that the callback `cb` is called whenever a double-tap event is triggered.
|
|
41
|
+
* By default it calls basic scale on XAxis
|
|
42
|
+
*/
|
|
43
|
+
this.setDblTapCallback = (cb) => this.xAxisScaleHandler.setDblTapCallback(cb);
|
|
32
44
|
const xAxisLabelsGenerator = new XAxisTimeLabelsGenerator(eventBus, config, chartComponent.chartModel, scale, timeZoneModel, this.canvasModel, canvasBoundsContainer);
|
|
33
45
|
this.xAxisLabelsGenerator = xAxisLabelsGenerator;
|
|
34
46
|
this.xAxisLabelsModel = new XAxisLabelsModel(eventBus, []);
|
|
@@ -24,16 +24,19 @@ export declare class YAxisScaleHandler extends ChartBaseElement {
|
|
|
24
24
|
private canvasInputListener;
|
|
25
25
|
private bounds;
|
|
26
26
|
private hitTest;
|
|
27
|
-
private autoScaleCallback;
|
|
28
27
|
private hitTestCanvasModel;
|
|
29
28
|
yAxisDragEndSubject: Subject<void>;
|
|
30
29
|
lastYStart: Unit;
|
|
31
30
|
lastYEnd: Unit;
|
|
32
31
|
lastYHeight: Unit;
|
|
33
32
|
lastYPxHeight: Pixel;
|
|
34
|
-
|
|
33
|
+
private dblClickCallback;
|
|
34
|
+
private dblTapCallback;
|
|
35
|
+
constructor(bus: EventBus, config: YAxisConfig, panning: ChartPanComponent, scale: ScaleModel, canvasInputListener: CanvasInputListenerComponent, bounds: CanvasBoundsContainer, hitTest: HitBoundsTest, hitTestCanvasModel: HitTestCanvasModel);
|
|
35
36
|
protected doActivate(): void;
|
|
36
37
|
private onYDragStart;
|
|
37
38
|
private onYDragTick;
|
|
38
39
|
private onYDragEnd;
|
|
40
|
+
setDblTapCallback: (cb: () => void) => () => void;
|
|
41
|
+
setDblClickCallback: (cb: () => void) => () => void;
|
|
39
42
|
}
|
|
@@ -14,7 +14,7 @@ const FULL_Y_HEIGHT_ZOOM_FACTOR = 10;
|
|
|
14
14
|
* @doc-tags scaling,zoom,viewport
|
|
15
15
|
*/
|
|
16
16
|
export class YAxisScaleHandler extends ChartBaseElement {
|
|
17
|
-
constructor(bus, config, panning, scale, canvasInputListener, bounds, hitTest,
|
|
17
|
+
constructor(bus, config, panning, scale, canvasInputListener, bounds, hitTest, hitTestCanvasModel) {
|
|
18
18
|
super();
|
|
19
19
|
this.bus = bus;
|
|
20
20
|
this.config = config;
|
|
@@ -22,7 +22,6 @@ export class YAxisScaleHandler extends ChartBaseElement {
|
|
|
22
22
|
this.canvasInputListener = canvasInputListener;
|
|
23
23
|
this.bounds = bounds;
|
|
24
24
|
this.hitTest = hitTest;
|
|
25
|
-
this.autoScaleCallback = autoScaleCallback;
|
|
26
25
|
this.hitTestCanvasModel = hitTestCanvasModel;
|
|
27
26
|
this.yAxisDragEndSubject = new Subject();
|
|
28
27
|
this.lastYStart = 0;
|
|
@@ -57,7 +56,7 @@ export class YAxisScaleHandler extends ChartBaseElement {
|
|
|
57
56
|
const newYEnd = this.lastYEnd + delta;
|
|
58
57
|
if (this.lastYStart !== newYStart || this.lastYEnd !== newYEnd) {
|
|
59
58
|
this.scale.setYScale(newYStart, newYEnd);
|
|
60
|
-
this.
|
|
59
|
+
this.scale.state.auto = false;
|
|
61
60
|
this.bus.fireDraw();
|
|
62
61
|
}
|
|
63
62
|
};
|
|
@@ -66,6 +65,10 @@ export class YAxisScaleHandler extends ChartBaseElement {
|
|
|
66
65
|
// Continue redrawing hit test
|
|
67
66
|
this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(true);
|
|
68
67
|
};
|
|
68
|
+
this.setDblTapCallback = (cb) => this.dblTapCallback = cb;
|
|
69
|
+
this.setDblClickCallback = (cb) => this.dblClickCallback = cb;
|
|
70
|
+
this.dblClickCallback = () => scale.autoScale(true);
|
|
71
|
+
this.dblTapCallback = () => scale.autoScale(true);
|
|
69
72
|
// drag to Y-scale and double click to auto scale
|
|
70
73
|
if (config.customScale) {
|
|
71
74
|
const dragNDropYComponent = new DragNDropYComponent(hitTest, {
|
|
@@ -81,7 +84,11 @@ export class YAxisScaleHandler extends ChartBaseElement {
|
|
|
81
84
|
doActivate() {
|
|
82
85
|
if (this.config.customScaleDblClick) {
|
|
83
86
|
this.addRxSubscription(this.canvasInputListener.observeDbClick(this.hitTest).subscribe(() => {
|
|
84
|
-
this.
|
|
87
|
+
this.dblClickCallback();
|
|
88
|
+
this.bus.fireDraw();
|
|
89
|
+
}));
|
|
90
|
+
this.addRxSubscription(this.canvasInputListener.observeDbTap(this.hitTest).subscribe(() => {
|
|
91
|
+
this.dblTapCallback();
|
|
85
92
|
this.bus.fireDraw();
|
|
86
93
|
}));
|
|
87
94
|
}
|
|
@@ -148,4 +148,6 @@ export declare class YAxisComponent extends ChartBaseElement {
|
|
|
148
148
|
* @returns {void}
|
|
149
149
|
*/
|
|
150
150
|
changeLabelsDescriptionVisibility(descVisibility: boolean): void;
|
|
151
|
+
setDblClickCallback: (cb: () => void) => () => void;
|
|
152
|
+
setDblTapCallback: (cb: () => void) => () => void;
|
|
151
153
|
}
|
|
@@ -12,6 +12,7 @@ import { LabelsGroups } from './price_labels/y-axis-labels.model';
|
|
|
12
12
|
import { YAxisScaleHandler } from './y-axis-scale.handler';
|
|
13
13
|
import { YAxisModel } from './y-axis.model';
|
|
14
14
|
import { merge as mergeObj } from '../../utils/merge.utils';
|
|
15
|
+
import { cloneUnsafe } from '../../utils/object.utils';
|
|
15
16
|
/**
|
|
16
17
|
* Y axis component. Contains all Y axis related logic.
|
|
17
18
|
*/
|
|
@@ -28,12 +29,25 @@ export class YAxisComponent extends ChartBaseElement {
|
|
|
28
29
|
this.extentIdx = extentIdx;
|
|
29
30
|
this.labelsColorByChartTypeMap = {};
|
|
30
31
|
this.axisTypeSetSubject = new Subject();
|
|
31
|
-
|
|
32
|
+
/* This function assigns a callback to be executed when a double-click event is detected.
|
|
33
|
+
* It accepts one parameter `cb`, which is a callback function.
|
|
34
|
+
* When a double-click event occurs, the specified callback function `cb` will be invoked.
|
|
35
|
+
* By default it calls auto scale on YAxis
|
|
36
|
+
*/
|
|
37
|
+
this.setDblClickCallback = (cb) => this.yAxisScaleHandler.setDblClickCallback(cb);
|
|
38
|
+
/* This function assigns a callback to be executed when a double-tap event is detected.
|
|
39
|
+
* Similar to the dblclick function, it takes one parameter `cb`, which is a callback function.
|
|
40
|
+
* This function ensures that the callback `cb` is called whenever a double-tap event is triggered.
|
|
41
|
+
* By default it calls auto scale on YAxis
|
|
42
|
+
*/
|
|
43
|
+
this.setDblTapCallback = (cb) => this.yAxisScaleHandler.setDblTapCallback(cb);
|
|
44
|
+
const initialStateCopy = initialState ? cloneUnsafe(initialState) : {};
|
|
45
|
+
this.state = mergeObj(initialStateCopy, config.components.yAxis, {
|
|
32
46
|
overrideExisting: false,
|
|
33
47
|
addIfMissing: true,
|
|
34
48
|
});
|
|
35
49
|
//#region init yAxisScaleHandler
|
|
36
|
-
this.yAxisScaleHandler = new YAxisScaleHandler(eventBus, this.state, chartPanComponent, scale, canvasInputListeners, canvasBoundsContainer, canvasBoundsContainer.getBoundsHitTest(CanvasElement.PANE_UUID_Y_AXIS(paneUUID, extentIdx)),
|
|
50
|
+
this.yAxisScaleHandler = new YAxisScaleHandler(eventBus, this.state, chartPanComponent, scale, canvasInputListeners, canvasBoundsContainer, canvasBoundsContainer.getBoundsHitTest(CanvasElement.PANE_UUID_Y_AXIS(paneUUID, extentIdx)), hitTestCanvasModel);
|
|
37
51
|
this.addChildEntity(this.yAxisScaleHandler);
|
|
38
52
|
//#endregion
|
|
39
53
|
this.model = new YAxisModel(this.paneUUID, eventBus, this.state, canvasBoundsContainer, canvasModel, scale, valueFormatter, dataSeriesProvider, extentIdx);
|
|
@@ -170,7 +170,7 @@ export class ScaleModel extends ViewportModel {
|
|
|
170
170
|
setXScale(xStart, xEnd, forceNoAnimation = true) {
|
|
171
171
|
const initialState = this.export();
|
|
172
172
|
const zoomX = this.calculateZoomX(xStart, xEnd);
|
|
173
|
-
if (initialState.xStart === xStart && initialState.xEnd === xEnd) {
|
|
173
|
+
if (initialState.xStart === xStart && initialState.xEnd === xEnd && initialState.zoomX > 0) {
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
176
|
const state = Object.assign(Object.assign({}, initialState), { zoomX, xStart, xEnd });
|
|
@@ -196,7 +196,7 @@ export class ScaleModel extends ViewportModel {
|
|
|
196
196
|
}
|
|
197
197
|
setYScale(yStart, yEnd, fire = false) {
|
|
198
198
|
const initialState = this.export();
|
|
199
|
-
if (initialState.yStart === yStart && initialState.yEnd === yEnd) {
|
|
199
|
+
if (initialState.yStart === yStart && initialState.yEnd === yEnd && initialState.zoomY > 0) {
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
202
202
|
super.setYScale(yStart, yEnd, fire);
|
|
@@ -40,7 +40,7 @@ export default class VisualCandle extends VisualSeriesPoint {
|
|
|
40
40
|
* @returns {Pixel} - The height of the body in pixels.
|
|
41
41
|
*/
|
|
42
42
|
bodyHeight(viewable) {
|
|
43
|
-
return floorToDPR(Math.abs(viewable.toY(this.open) - viewable.toY(this.close)));
|
|
43
|
+
return floorToDPR(Math.max(Math.abs(viewable.toY(this.open) - viewable.toY(this.close)), 1));
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Calculates the height of a candle in pixels based on the high and low values of the candle and the viewable area.
|