@devexperts/dxcharts-lite 2.0.2 → 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.
- 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/hover-producer.component.d.ts +1 -1
- package/dist/chart/inputhandlers/hover-producer.component.js +7 -7
- package/dist/chart/inputlisteners/canvas-input-listener.component.d.ts +2 -2
- package/dist/chart/inputlisteners/canvas-input-listener.component.js +9 -18
- 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 +7 -4
|
@@ -3,13 +3,13 @@
|
|
|
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 { getPrimaryLabelTextColor } from '../label-color.functions';
|
|
6
|
+
import { getPlainLabelTextColor, getPrimaryLabelTextColor } from '../label-color.functions';
|
|
7
7
|
import { lastOf } from '../../../utils/array.utils';
|
|
8
8
|
import { getLabelTextColorByBackgroundColor } from '../../../utils/canvas/canvas-text-functions.utils';
|
|
9
9
|
export class LastCandleLabelsProvider {
|
|
10
|
-
constructor(chartModel,
|
|
10
|
+
constructor(chartModel, chartConfig, yAxisConfig, lastCandleLabelsByChartType, resolveLabelColorFn) {
|
|
11
11
|
this.chartModel = chartModel;
|
|
12
|
-
this.
|
|
12
|
+
this.chartConfig = chartConfig;
|
|
13
13
|
this.yAxisConfig = yAxisConfig;
|
|
14
14
|
this.lastCandleLabelsByChartType = lastCandleLabelsByChartType;
|
|
15
15
|
this.resolveLabelColorFn = resolveLabelColorFn;
|
|
@@ -20,36 +20,37 @@ export class LastCandleLabelsProvider {
|
|
|
20
20
|
*/
|
|
21
21
|
getUnorderedLabels() {
|
|
22
22
|
const collectedLabels = [];
|
|
23
|
-
const visible = this.yAxisConfig.labels.settings.lastPrice.mode !== 'none';
|
|
24
|
-
if (visible) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.chartModel.candleSeries.forEach((series, index) => {
|
|
37
|
-
if (index === 0) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const yAxisVisualLabel = this.getYAxisVisualLabel(series);
|
|
41
|
-
const secondarySeriesVisualLabel = yAxisVisualLabel
|
|
42
|
-
? Object.assign(Object.assign({}, yAxisVisualLabel), this.getLabelDrawConfig(series, false)) : yAxisVisualLabel;
|
|
43
|
-
if (secondarySeriesVisualLabel) {
|
|
44
|
-
const secondarySeriesLabel = {
|
|
45
|
-
labels: [secondarySeriesVisualLabel],
|
|
46
|
-
};
|
|
47
|
-
const handler = this.lastCandleLabelsByChartType[series.config.type];
|
|
48
|
-
handler === null || handler === void 0 ? void 0 : handler(secondarySeriesLabel, this.chartModel.mainCandleSeries);
|
|
49
|
-
collectedLabels.push(secondarySeriesLabel);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
23
|
+
const visible = this.yAxisConfig.labels.settings.lastPrice.mode !== 'none' && this.yAxisConfig.visible;
|
|
24
|
+
if (!visible) {
|
|
25
|
+
return collectedLabels;
|
|
26
|
+
}
|
|
27
|
+
// main candle series
|
|
28
|
+
const yAxisVisualLabel = this.getYAxisVisualLabel(this.chartModel.mainCandleSeries);
|
|
29
|
+
const mainCandleSeriesVisualLabel = yAxisVisualLabel
|
|
30
|
+
? Object.assign(Object.assign({}, yAxisVisualLabel), this.getLabelDrawConfig(this.chartModel.mainCandleSeries, true)) : yAxisVisualLabel;
|
|
31
|
+
if (mainCandleSeriesVisualLabel) {
|
|
32
|
+
const mainCandleSeriesLabels = { labels: [mainCandleSeriesVisualLabel] };
|
|
33
|
+
const handler = this.lastCandleLabelsByChartType[this.chartConfig.components.chart.type];
|
|
34
|
+
handler === null || handler === void 0 ? void 0 : handler(mainCandleSeriesLabels, this.chartModel.mainCandleSeries);
|
|
35
|
+
collectedLabels.push(mainCandleSeriesLabels);
|
|
52
36
|
}
|
|
37
|
+
// compare candle series
|
|
38
|
+
this.chartModel.candleSeries.forEach((series, index) => {
|
|
39
|
+
if (index === 0) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const yAxisVisualLabel = this.getYAxisVisualLabel(series);
|
|
43
|
+
const secondarySeriesVisualLabel = yAxisVisualLabel
|
|
44
|
+
? Object.assign(Object.assign({}, yAxisVisualLabel), this.getLabelDrawConfig(series, false)) : yAxisVisualLabel;
|
|
45
|
+
if (secondarySeriesVisualLabel) {
|
|
46
|
+
const secondarySeriesLabel = {
|
|
47
|
+
labels: [secondarySeriesVisualLabel],
|
|
48
|
+
};
|
|
49
|
+
const handler = this.lastCandleLabelsByChartType[series.config.type];
|
|
50
|
+
handler === null || handler === void 0 ? void 0 : handler(secondarySeriesLabel, this.chartModel.mainCandleSeries);
|
|
51
|
+
collectedLabels.push(secondarySeriesLabel);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
53
54
|
return collectedLabels;
|
|
54
55
|
}
|
|
55
56
|
/**
|
|
@@ -79,22 +80,39 @@ export class LastCandleLabelsProvider {
|
|
|
79
80
|
/**
|
|
80
81
|
* Returns the configuration object for drawing the label of the Y-axis.
|
|
81
82
|
* @param {CandleSeriesModel} series - The series model for which the label configuration is to be returned.
|
|
82
|
-
* @param {boolean} primary - A boolean value indicating whether the label is
|
|
83
|
+
* @param {boolean} primary - A boolean value indicating whether the label is for the main series or not.
|
|
83
84
|
* @returns {YAxisLabelDrawConfig} - The configuration object for drawing the label of the Y-axis.
|
|
84
85
|
*/
|
|
85
86
|
getLabelDrawConfig(series, primary) {
|
|
87
|
+
const appearanceType = this.yAxisConfig.labels.settings.lastPrice.type;
|
|
86
88
|
const colors = series.colors.labels;
|
|
89
|
+
const { rectLabelTextColor = 'white', rectLabelInvertedTextColor = 'black' } = this.chartConfig.colors.yAxis;
|
|
87
90
|
const getLabelBoxColor = this.resolveLabelColorFn(series.config.type);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
if (!colors) {
|
|
92
|
+
return {
|
|
93
|
+
bgColor: '#FFFFFF',
|
|
94
|
+
textColor: getLabelTextColorByBackgroundColor('#FFFFFF', '#000000', rectLabelInvertedTextColor),
|
|
95
|
+
rounded: true,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const boxColor = getLabelBoxColor(series.lastPriceMovement, series.colors);
|
|
99
|
+
// if the label is for the main candle series
|
|
100
|
+
if (primary) {
|
|
101
|
+
const textColor = getPrimaryLabelTextColor(series.lastPriceMovement, colors);
|
|
102
|
+
return {
|
|
103
|
+
bgColor: boxColor,
|
|
104
|
+
textColor: appearanceType === 'plain'
|
|
105
|
+
? getPlainLabelTextColor(this.chartConfig.colors, textColor, rectLabelInvertedTextColor, this.yAxisConfig)
|
|
106
|
+
: getLabelTextColorByBackgroundColor(boxColor, textColor, rectLabelInvertedTextColor),
|
|
107
|
+
rounded: true,
|
|
108
|
+
};
|
|
94
109
|
}
|
|
110
|
+
// if the label is for the secondary candle series
|
|
95
111
|
return {
|
|
96
112
|
bgColor: boxColor,
|
|
97
|
-
textColor:
|
|
113
|
+
textColor: appearanceType === 'plain'
|
|
114
|
+
? getPlainLabelTextColor(this.chartConfig.colors, rectLabelTextColor, rectLabelInvertedTextColor, this.yAxisConfig)
|
|
115
|
+
: getLabelTextColorByBackgroundColor(boxColor, rectLabelTextColor, rectLabelInvertedTextColor),
|
|
98
116
|
rounded: true,
|
|
99
117
|
};
|
|
100
118
|
}
|
|
@@ -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 { CanvasBoundsContainer } from '../../../canvas/canvas-bounds-container';
|
|
7
|
-
import {
|
|
7
|
+
import { FullChartConfig } from '../../../chart.config';
|
|
8
8
|
import { Drawer } from '../../../drawers/drawing-manager';
|
|
9
9
|
import { CanvasModel } from '../../../model/canvas.model';
|
|
10
10
|
import { PaneManager } from '../../pane/pane-manager.component';
|
|
@@ -13,9 +13,9 @@ export declare class YAxisPriceLabelsDrawer implements Drawer {
|
|
|
13
13
|
private yAxisLabelsCanvasModel;
|
|
14
14
|
private backgroundCanvasModel;
|
|
15
15
|
private canvasBoundsContainer;
|
|
16
|
-
private
|
|
16
|
+
private fullConfig;
|
|
17
17
|
private paneManager;
|
|
18
|
-
constructor(yAxisLabelsCanvasModel: CanvasModel, backgroundCanvasModel: CanvasModel, canvasBoundsContainer: CanvasBoundsContainer,
|
|
18
|
+
constructor(yAxisLabelsCanvasModel: CanvasModel, backgroundCanvasModel: CanvasModel, canvasBoundsContainer: CanvasBoundsContainer, fullConfig: FullChartConfig, paneManager: PaneManager);
|
|
19
19
|
draw(): void;
|
|
20
20
|
drawHighlightedBackgroundBetweenLabels(orderedLabels: LabelGroup[]): void;
|
|
21
21
|
getCanvasIds(): Array<string>;
|
|
@@ -7,28 +7,30 @@ import { CanvasElement, CHART_UUID, limitYToBounds, } from '../../../canvas/canv
|
|
|
7
7
|
import { fillRect } from '../../../utils/canvas/canvas-drawing-functions.utils';
|
|
8
8
|
import { drawLabel } from './price-label.drawer';
|
|
9
9
|
export class YAxisPriceLabelsDrawer {
|
|
10
|
-
constructor(yAxisLabelsCanvasModel, backgroundCanvasModel, canvasBoundsContainer,
|
|
10
|
+
constructor(yAxisLabelsCanvasModel, backgroundCanvasModel, canvasBoundsContainer, fullConfig, paneManager) {
|
|
11
11
|
this.yAxisLabelsCanvasModel = yAxisLabelsCanvasModel;
|
|
12
12
|
this.backgroundCanvasModel = backgroundCanvasModel;
|
|
13
13
|
this.canvasBoundsContainer = canvasBoundsContainer;
|
|
14
|
-
this.
|
|
14
|
+
this.fullConfig = fullConfig;
|
|
15
15
|
this.paneManager = paneManager;
|
|
16
16
|
}
|
|
17
17
|
draw() {
|
|
18
18
|
const ctx = this.yAxisLabelsCanvasModel.ctx;
|
|
19
19
|
const backgroundCtx = this.backgroundCanvasModel.ctx;
|
|
20
20
|
this.paneManager.yExtents.forEach(extent => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
if (extent.yAxis.state.visible) {
|
|
22
|
+
const yAxisBounds = extent.getYAxisBounds();
|
|
23
|
+
const paneBounds = this.canvasBoundsContainer.getBounds(CanvasElement.ALL_PANES);
|
|
24
|
+
const orderedLabels = extent.yAxis.model.fancyLabelsModel.orderedLabels;
|
|
25
|
+
this.drawHighlightedBackgroundBetweenLabels(orderedLabels);
|
|
26
|
+
orderedLabels.forEach(l => {
|
|
27
|
+
var _a;
|
|
28
|
+
const bounds = (_a = l.bounds) !== null && _a !== void 0 ? _a : yAxisBounds;
|
|
29
|
+
l.labels.forEach(vl => drawLabel(ctx, backgroundCtx, bounds, paneBounds, vl, this.canvasBoundsContainer, extent.yAxis.state, this.fullConfig.colors.yAxis));
|
|
30
|
+
});
|
|
31
|
+
// TODO I added this as a simple mechanism to add custom labels, we need to review it
|
|
32
|
+
Object.values(extent.yAxis.model.fancyLabelsModel.customLabels).forEach(l => drawLabel(ctx, backgroundCtx, yAxisBounds, paneBounds, l, this.canvasBoundsContainer, extent.yAxis.state, this.fullConfig.colors.yAxis));
|
|
33
|
+
}
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
36
|
// this is a very simple solution which matches 2 labels with same "subGroupId"
|
|
@@ -56,7 +56,7 @@ export class YAxisScaleHandler extends ChartBaseElement {
|
|
|
56
56
|
};
|
|
57
57
|
// drag to Y-scale and double click to auto scale
|
|
58
58
|
if (config.customScale) {
|
|
59
|
-
const dragPredicate = () => config.type !== 'percent';
|
|
59
|
+
const dragPredicate = () => config.type !== 'percent' && config.visible;
|
|
60
60
|
const dragNDropYComponent = new DragNDropYComponent(hitTest, {
|
|
61
61
|
onDragTick: callIfPredicateTrue(this.onYDragTick, dragPredicate),
|
|
62
62
|
onDragStart: callIfPredicateTrue(this.onYDragStart, dragPredicate),
|
|
@@ -27,6 +27,7 @@ export type LabelColorResolver = (priceMovement: PriceMovement, colors: FullChar
|
|
|
27
27
|
*/
|
|
28
28
|
export declare class YAxisComponent extends ChartBaseElement {
|
|
29
29
|
private eventBus;
|
|
30
|
+
private config;
|
|
30
31
|
private canvasModel;
|
|
31
32
|
scale: ScaleModel;
|
|
32
33
|
private canvasBoundsContainer;
|
|
@@ -111,7 +112,7 @@ export declare class YAxisComponent extends ChartBaseElement {
|
|
|
111
112
|
*/
|
|
112
113
|
setYAxisAlign(align: YAxisAlign): void;
|
|
113
114
|
/**
|
|
114
|
-
* Controls visibility of the y-axis
|
|
115
|
+
* Controls visibility of the y-axis (additionally disable/enable component)
|
|
115
116
|
*/
|
|
116
117
|
setVisible(isVisible: boolean): void;
|
|
117
118
|
/**
|
|
@@ -19,6 +19,7 @@ export class YAxisComponent extends ChartBaseElement {
|
|
|
19
19
|
constructor(eventBus, config, canvasModel, scale, canvasInputListeners, canvasBoundsContainer, chartPanComponent, cursors, valueFormatter, dataSeriesProvider, paneUUID, extentIdx) {
|
|
20
20
|
super();
|
|
21
21
|
this.eventBus = eventBus;
|
|
22
|
+
this.config = config;
|
|
22
23
|
this.canvasModel = canvasModel;
|
|
23
24
|
this.scale = scale;
|
|
24
25
|
this.canvasBoundsContainer = canvasBoundsContainer;
|
|
@@ -166,11 +167,14 @@ export class YAxisComponent extends ChartBaseElement {
|
|
|
166
167
|
this.eventBus.fireDraw();
|
|
167
168
|
}
|
|
168
169
|
/**
|
|
169
|
-
* Controls visibility of the y-axis
|
|
170
|
+
* Controls visibility of the y-axis (additionally disable/enable component)
|
|
170
171
|
*/
|
|
171
172
|
setVisible(isVisible) {
|
|
172
173
|
this.state.visible = isVisible;
|
|
173
|
-
this.
|
|
174
|
+
this.config.components.yAxis.visible = isVisible;
|
|
175
|
+
isVisible ? this.enable() : this.disable();
|
|
176
|
+
this.model.fancyLabelsModel.updateLabels();
|
|
177
|
+
this.model.baseLabelsModel.updateLabels();
|
|
174
178
|
}
|
|
175
179
|
/**
|
|
176
180
|
* If visible, when you can see the y-axis on the chart
|
|
@@ -28,7 +28,7 @@ export class HTDataSeriesDrawer {
|
|
|
28
28
|
const drawer = this.seriesDrawers[paintTool];
|
|
29
29
|
if (drawer) {
|
|
30
30
|
const drawConfig = {
|
|
31
|
-
singleColor: this.canvasModel.idToColor(series.
|
|
31
|
+
singleColor: this.canvasModel.idToColor(series.htId),
|
|
32
32
|
forceBold: 7,
|
|
33
33
|
};
|
|
34
34
|
// +- 1 to correctly draw points which are partly inside bounds
|
|
@@ -55,7 +55,7 @@ export declare class HoverProducerComponent extends ChartBaseElement {
|
|
|
55
55
|
private formatterFactory;
|
|
56
56
|
hoverSubject: BehaviorSubject<Hover | null>;
|
|
57
57
|
get hover(): Hover | null;
|
|
58
|
-
private
|
|
58
|
+
private longTouchActivatedSubject;
|
|
59
59
|
private hoverProducerParts;
|
|
60
60
|
xFormatter: DateTimeFormatter;
|
|
61
61
|
constructor(crossEventProducer: CrossEventProducerComponent, scale: ScaleModel, config: FullChartConfig, chartModel: ChartModel, canvasInputListener: CanvasInputListenerComponent, canvasBoundsContainer: CanvasBoundsContainer, paneManager: PaneManager, timeZoneModel: TimeZoneModel, formatterFactory: (format: string) => (timestamp: number | Date) => string);
|
|
@@ -30,7 +30,7 @@ export class HoverProducerComponent extends ChartBaseElement {
|
|
|
30
30
|
this.timeZoneModel = timeZoneModel;
|
|
31
31
|
this.formatterFactory = formatterFactory;
|
|
32
32
|
this.hoverSubject = new BehaviorSubject(null);
|
|
33
|
-
this.
|
|
33
|
+
this.longTouchActivatedSubject = new BehaviorSubject(false);
|
|
34
34
|
this.xFormatter = () => '';
|
|
35
35
|
const candleHoverProducerPart = new CandleHoverProducerPart(this.chartModel);
|
|
36
36
|
const compareSeriesHoverProducerPart = new CompareSeriesHoverProducerPart(this.chartModel);
|
|
@@ -74,7 +74,7 @@ export class HoverProducerComponent extends ChartBaseElement {
|
|
|
74
74
|
}));
|
|
75
75
|
this.addRxSubscription(this.scale.xChanged.subscribe(() => this.fireLastCross()));
|
|
76
76
|
this.addRxSubscription(this.canvasInputListener.observeTouchStart().subscribe(event => {
|
|
77
|
-
const x = event.touches[0].clientX;
|
|
77
|
+
const x = event.touches[0].clientX - this.canvasBoundsContainer.canvasOnPageLocation.x;
|
|
78
78
|
const y = event.touches[0].clientY - this.canvasBoundsContainer.canvasOnPageLocation.y;
|
|
79
79
|
const candle = this.chartModel.candleFromX(x, true);
|
|
80
80
|
if (candle) {
|
|
@@ -86,15 +86,16 @@ export class HoverProducerComponent extends ChartBaseElement {
|
|
|
86
86
|
const hitTest = this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.ALL_PANES);
|
|
87
87
|
this.addRxSubscription(this.canvasInputListener.observeLongTouch(hitTest).subscribe(event => {
|
|
88
88
|
this.paneManager.chartPanComponent.deactivatePanHandlers();
|
|
89
|
-
this.
|
|
90
|
-
const x = event.touches[0].clientX;
|
|
89
|
+
this.longTouchActivatedSubject.next(true);
|
|
90
|
+
const x = event.touches[0].clientX - this.canvasBoundsContainer.canvasOnPageLocation.x;
|
|
91
91
|
const y = event.touches[0].clientY - this.canvasBoundsContainer.canvasOnPageLocation.y;
|
|
92
92
|
this.createAndFireHover([x, y, '']);
|
|
93
|
+
this.crossEventProducer.crossSubject.next([x, y, '']);
|
|
93
94
|
}));
|
|
94
95
|
this.addRxSubscription(this.canvasInputListener.observeTouchEndDocument().subscribe(() => {
|
|
95
96
|
this.paneManager.chartPanComponent.activateChartPanHandlers();
|
|
96
|
-
if (this.
|
|
97
|
-
this.
|
|
97
|
+
if (this.longTouchActivatedSubject.getValue()) {
|
|
98
|
+
this.longTouchActivatedSubject.next(false);
|
|
98
99
|
this.crossEventProducer.fireCrossClose();
|
|
99
100
|
}
|
|
100
101
|
}));
|
|
@@ -195,7 +196,6 @@ export class HoverProducerComponent extends ChartBaseElement {
|
|
|
195
196
|
const candle = (_a = hover.candleHover) === null || _a === void 0 ? void 0 : _a.visualCandle.candle;
|
|
196
197
|
candle && this.chartModel.mainCandleSeries.setActiveCandle(candle);
|
|
197
198
|
}
|
|
198
|
-
// const showCrossToolOverride = isMobile() ? this.longTouchActivated : showCrossTool;
|
|
199
199
|
this.hoverSubject.next(hover);
|
|
200
200
|
}
|
|
201
201
|
else {
|
|
@@ -85,9 +85,9 @@ export declare class CanvasInputListenerComponent extends ChartBaseElement {
|
|
|
85
85
|
private dragListener;
|
|
86
86
|
private updateElementOffsetListener;
|
|
87
87
|
private dragEndListener;
|
|
88
|
-
private clickHandler;
|
|
89
88
|
/**
|
|
90
|
-
*
|
|
89
|
+
* TODO: Do we need it?
|
|
90
|
+
* Prevents text selection inside chart-core canvas.
|
|
91
91
|
*/
|
|
92
92
|
private fixTextSelection;
|
|
93
93
|
doActivate(): void;
|
|
@@ -3,19 +3,13 @@
|
|
|
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 { subscribeListener } from '../utils/dom.utils';
|
|
6
|
+
import { MouseButton, leftMouseButtonListener, subscribeListener } from '../utils/dom.utils';
|
|
7
7
|
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
11
|
import { deviceDetector } from '../utils/device/device-detector.utils';
|
|
12
12
|
import { touchpadDetector } from '../utils/device/touchpad.utils';
|
|
13
|
-
var MouseButton;
|
|
14
|
-
(function (MouseButton) {
|
|
15
|
-
MouseButton[MouseButton["left"] = 0] = "left";
|
|
16
|
-
MouseButton[MouseButton["middle"] = 1] = "middle";
|
|
17
|
-
MouseButton[MouseButton["right"] = 2] = "right";
|
|
18
|
-
})(MouseButton || (MouseButton = {}));
|
|
19
13
|
/**
|
|
20
14
|
* Gathers user input on canvas element:
|
|
21
15
|
* Chart update order should be following:
|
|
@@ -114,7 +108,6 @@ class CanvasInputListenerComponent extends ChartBaseElement {
|
|
|
114
108
|
this.xDragEndSubject.next();
|
|
115
109
|
this.yDragEndSubject.next();
|
|
116
110
|
};
|
|
117
|
-
this.clickHandler = () => this.clickSubject.next(this.currentPoint);
|
|
118
111
|
this.updateCurrentPoints = (e) => {
|
|
119
112
|
this.updateCurrentDocumentPoint(e);
|
|
120
113
|
this.updateCurrentMousePoint(e);
|
|
@@ -155,7 +148,8 @@ class CanvasInputListenerComponent extends ChartBaseElement {
|
|
|
155
148
|
this.dragEndListener();
|
|
156
149
|
}
|
|
157
150
|
/**
|
|
158
|
-
*
|
|
151
|
+
* TODO: Do we need it?
|
|
152
|
+
* Prevents text selection inside chart-core canvas.
|
|
159
153
|
*/
|
|
160
154
|
fixTextSelection() {
|
|
161
155
|
const selectListener = (e) => {
|
|
@@ -185,11 +179,8 @@ class CanvasInputListenerComponent extends ChartBaseElement {
|
|
|
185
179
|
document.addEventListener(dragEndEvent, this.dragEndListener);
|
|
186
180
|
this.addSubscription(document.removeEventListener.bind(document, dragEndEvent, this.dragEndListener));
|
|
187
181
|
});
|
|
188
|
-
this.addSubscription(subscribeListener(this.element, this.
|
|
189
|
-
|
|
190
|
-
this.clickDocumentSubject.next(e);
|
|
191
|
-
};
|
|
192
|
-
this.addSubscription(subscribeListener(document, clickDocumentListener, 'click'));
|
|
182
|
+
this.addSubscription(subscribeListener(this.element, leftMouseButtonListener(() => this.clickSubject.next(this.currentPoint)), 'click'));
|
|
183
|
+
this.addSubscription(subscribeListener(document, leftMouseButtonListener(e => this.clickDocumentSubject.next(e)), 'click'));
|
|
193
184
|
const device = deviceDetector();
|
|
194
185
|
if (device === 'apple' || device === 'mobile') {
|
|
195
186
|
// workaround to handle double taps for iOS
|
|
@@ -237,7 +228,7 @@ class CanvasInputListenerComponent extends ChartBaseElement {
|
|
|
237
228
|
this.element.addEventListener('touchend', touchEnd);
|
|
238
229
|
};
|
|
239
230
|
this.addSubscription(subscribeListener(this.element, (e) => longTouchListener(e), 'touchstart'));
|
|
240
|
-
this.addSubscription(subscribeListener(this.element, () => this.dbClickSubject.next(this.currentPoint), 'dblclick'));
|
|
231
|
+
this.addSubscription(subscribeListener(this.element, leftMouseButtonListener(() => this.dbClickSubject.next(this.currentPoint)), 'dblclick'));
|
|
241
232
|
this.addSubscription(subscribeListener(this.element, (e) => this.touchStartSubject.next(e), 'touchstart'));
|
|
242
233
|
this.addSubscription(subscribeListener(this.element, (e) => this.touchMoveSubject.next(e), 'touchmove', true));
|
|
243
234
|
this.addSubscription(subscribeListener(this.element, (e) => this.touchEndSubject.next(e), 'touchend'));
|
|
@@ -260,9 +251,9 @@ class CanvasInputListenerComponent extends ChartBaseElement {
|
|
|
260
251
|
e.preventDefault(); // to disable the scroll over the document, if for example chart is used as widget
|
|
261
252
|
}, 'wheel'));
|
|
262
253
|
this.addSubscription(subscribeListener(this.element, (e) => this.contextMenuSubject.next(e), 'contextmenu'));
|
|
263
|
-
this.addSubscription(subscribeListener(this.element, () => this.mouseDownSubject.next(this.currentPoint), 'mousedown'));
|
|
264
|
-
this.addSubscription(subscribeListener(this.element, () => this.mouseUpSubject.next(this.currentPoint), 'mouseup'));
|
|
265
|
-
this.addSubscription(subscribeListener(document, () => this.mouseUpDocumentSubject.next(this.currentPoint), 'mouseup'));
|
|
254
|
+
this.addSubscription(subscribeListener(this.element, leftMouseButtonListener(() => this.mouseDownSubject.next(this.currentPoint)), 'mousedown'));
|
|
255
|
+
this.addSubscription(subscribeListener(this.element, leftMouseButtonListener(() => this.mouseUpSubject.next(this.currentPoint)), 'mouseup'));
|
|
256
|
+
this.addSubscription(subscribeListener(document, leftMouseButtonListener(() => this.mouseUpDocumentSubject.next(this.currentPoint)), 'mouseup'));
|
|
266
257
|
this.addRxSubscription(this.eventBus.observe(EVENT_RESIZED).subscribe(() => {
|
|
267
258
|
const bcr = this.element.getBoundingClientRect();
|
|
268
259
|
this.canvasBounds.x = bcr.left;
|
|
@@ -34,7 +34,7 @@ export declare class CandleSeriesModel extends DataSeriesModel<Candle, VisualCan
|
|
|
34
34
|
get instrument(): ChartInstrument;
|
|
35
35
|
set instrument(instrument: ChartInstrument);
|
|
36
36
|
meanCandleWidth: Unit;
|
|
37
|
-
constructor(extentComponent: YExtentComponent, id: number, eventBus: EventBus, scale: ScaleModel, instrument: ChartInstrument, candlesTransformersByChartType: Partial<Record<DataSeriesType, VisualCandleCalculator>>, candleWidthByChartType: Partial<Record<DataSeriesType, CandleWidthCalculator>>, colors?: CandleSeriesColors);
|
|
37
|
+
constructor(extentComponent: YExtentComponent, id: string, htId: number, eventBus: EventBus, scale: ScaleModel, instrument: ChartInstrument, candlesTransformersByChartType: Partial<Record<DataSeriesType, VisualCandleCalculator>>, candleWidthByChartType: Partial<Record<DataSeriesType, CandleWidthCalculator>>, colors?: CandleSeriesColors);
|
|
38
38
|
/**
|
|
39
39
|
* Recalculates data viewport indexes based on xStart and xEnd parameters or values from scaleModel.
|
|
40
40
|
* Calls superclass method for calculation, recalculates zipped high/low data points, and fires draw event.
|
|
@@ -31,8 +31,8 @@ export class CandleSeriesModel extends DataSeriesModel {
|
|
|
31
31
|
this._instrument = instrument;
|
|
32
32
|
this.pricePrecisions = PriceIncrementsUtils.computePrecisions((_a = instrument.priceIncrements) !== null && _a !== void 0 ? _a : [0.01]);
|
|
33
33
|
}
|
|
34
|
-
constructor(extentComponent, id, eventBus, scale, instrument, candlesTransformersByChartType, candleWidthByChartType, colors = DEFAULT_CANDLE_SERIES_CONFIG) {
|
|
35
|
-
super(extentComponent, id);
|
|
34
|
+
constructor(extentComponent, id, htId, eventBus, scale, instrument, candlesTransformersByChartType, candleWidthByChartType, colors = DEFAULT_CANDLE_SERIES_CONFIG) {
|
|
35
|
+
super(extentComponent, id, htId);
|
|
36
36
|
this.eventBus = eventBus;
|
|
37
37
|
this.candlesTransformersByChartType = candlesTransformersByChartType;
|
|
38
38
|
this.candleWidthByChartType = candleWidthByChartType;
|
|
@@ -8,7 +8,8 @@ import { BaseHover, HoverProducerPart } from '../inputhandlers/hover-producer.co
|
|
|
8
8
|
export interface CompareSeriesHover {
|
|
9
9
|
instrument: string;
|
|
10
10
|
price: string;
|
|
11
|
-
id:
|
|
11
|
+
id: string;
|
|
12
|
+
htId: number;
|
|
12
13
|
}
|
|
13
14
|
export declare class CompareSeriesHoverProducerPart implements HoverProducerPart<CompareSeriesHover[]> {
|
|
14
15
|
private chartModel;
|
|
@@ -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;
|