@devexperts/dxcharts-lite 2.4.3 → 2.4.4
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 +3 -3
- package/dist/chart/canvas/canvas-bounds-container.js +17 -19
- package/dist/chart/components/chart/chart-area-pan.handler.d.ts +4 -1
- package/dist/chart/components/chart/chart-area-pan.handler.js +14 -1
- package/dist/chart/components/chart/chart.component.d.ts +1 -1
- package/dist/chart/components/chart/chart.component.js +5 -5
- package/dist/chart/components/events/events-hit-test.drawer.d.ts +2 -1
- package/dist/chart/components/events/events-hit-test.drawer.js +32 -29
- package/dist/chart/components/events/events.component.js +1 -1
- package/dist/chart/components/high_low/high-low.drawer.js +3 -3
- package/dist/chart/components/pan/chart-pan.component.d.ts +3 -1
- package/dist/chart/components/pan/chart-pan.component.js +3 -2
- package/dist/chart/components/pane/pane-manager.component.d.ts +3 -1
- package/dist/chart/components/pane/pane-manager.component.js +4 -3
- package/dist/chart/components/pane/pane.component.d.ts +3 -1
- package/dist/chart/components/pane/pane.component.js +3 -2
- package/dist/chart/components/resizer/bar-resizer.component.d.ts +3 -1
- package/dist/chart/components/resizer/bar-resizer.component.js +6 -1
- package/dist/chart/components/x_axis/x-axis-scale.handler.d.ts +4 -1
- package/dist/chart/components/x_axis/x-axis-scale.handler.js +9 -1
- package/dist/chart/components/x_axis/x-axis.component.d.ts +2 -1
- package/dist/chart/components/x_axis/x-axis.component.js +2 -2
- package/dist/chart/components/y_axis/y-axis-labels.drawer.d.ts +0 -1
- package/dist/chart/components/y_axis/y-axis-labels.drawer.js +0 -1
- package/dist/chart/components/y_axis/y-axis-scale.handler.d.ts +3 -1
- package/dist/chart/components/y_axis/y-axis-scale.handler.js +6 -1
- package/dist/chart/components/y_axis/y-axis.component.d.ts +2 -1
- package/dist/chart/components/y_axis/y-axis.component.js +3 -3
- package/dist/chart/drawers/chart-background.drawer.d.ts +2 -2
- package/dist/chart/drawers/chart-background.drawer.js +3 -3
- package/dist/chart/drawers/ht-data-series.drawer.d.ts +2 -1
- package/dist/chart/drawers/ht-data-series.drawer.js +11 -8
- package/dist/chart/inputhandlers/cross-event-producer.component.d.ts +3 -0
- package/dist/chart/inputhandlers/hover-producer.component.js +7 -3
- package/dist/chart/model/hit-test-canvas.model.d.ts +2 -1
- package/dist/chart/model/hit-test-canvas.model.js +4 -1
- package/dist/dxchart.min.js +4 -4
- package/package.json +1 -1
|
@@ -11,13 +11,14 @@ import { DragNDropXComponent } from '../dran-n-drop_helper/drag-n-drop-x.compone
|
|
|
11
11
|
* @doc-tags scaling,zoom,viewport
|
|
12
12
|
*/
|
|
13
13
|
export class XAxisScaleHandler extends ChartBaseElement {
|
|
14
|
-
constructor(scale, canvasInputListener, canvasBoundsContainer, chartPanComponent, chartModel) {
|
|
14
|
+
constructor(scale, canvasInputListener, canvasBoundsContainer, chartPanComponent, chartModel, hitTestCanvasModel) {
|
|
15
15
|
super();
|
|
16
16
|
this.scale = scale;
|
|
17
17
|
this.canvasInputListener = canvasInputListener;
|
|
18
18
|
this.canvasBoundsContainer = canvasBoundsContainer;
|
|
19
19
|
this.chartPanComponent = chartPanComponent;
|
|
20
20
|
this.chartModel = chartModel;
|
|
21
|
+
this.hitTestCanvasModel = hitTestCanvasModel;
|
|
21
22
|
this.lastXStart = 0;
|
|
22
23
|
this.lastXWidth = 0;
|
|
23
24
|
this.lastXPxWidth = 0;
|
|
@@ -26,6 +27,8 @@ export class XAxisScaleHandler extends ChartBaseElement {
|
|
|
26
27
|
this.lastXWidth = this.scale.xEnd - this.scale.xStart;
|
|
27
28
|
const bounds = this.canvasBoundsContainer.getBounds(CanvasElement.X_AXIS);
|
|
28
29
|
this.lastXPxWidth = bounds.width - this.canvasInputListener.currentPoint.x;
|
|
30
|
+
// Stop redrawing hit test
|
|
31
|
+
this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(false);
|
|
29
32
|
};
|
|
30
33
|
this.onXDragTick = (dragInfo) => {
|
|
31
34
|
const { delta: absoluteXDelta } = dragInfo;
|
|
@@ -39,9 +42,14 @@ export class XAxisScaleHandler extends ChartBaseElement {
|
|
|
39
42
|
const newXStart = this.lastXStart + (this.lastXWidth - newWidth);
|
|
40
43
|
this.scale.setXScale(newXStart, this.scale.xEnd);
|
|
41
44
|
};
|
|
45
|
+
this.onXDragEnd = () => {
|
|
46
|
+
// Continue redrawing hit test
|
|
47
|
+
this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(true);
|
|
48
|
+
};
|
|
42
49
|
const dragNDropXComponent = new DragNDropXComponent(this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.X_AXIS), {
|
|
43
50
|
onDragStart: this.onXDragStart,
|
|
44
51
|
onDragTick: this.onXDragTick,
|
|
52
|
+
onDragEnd: this.onXDragEnd,
|
|
45
53
|
}, this.canvasInputListener, this.chartPanComponent, {
|
|
46
54
|
disableChartPanning: false,
|
|
47
55
|
});
|
|
@@ -22,6 +22,7 @@ import { XAxisLabelsGenerator } from './x-axis-labels.generator';
|
|
|
22
22
|
import { XAxisLabelsModel, XAxisLabelsProvider } from './x-axis-labels.model';
|
|
23
23
|
import { XAxisScaleHandler } from './x-axis-scale.handler';
|
|
24
24
|
import { XAxisTimeLabelsDrawer } from './x-axis-time-labels.drawer';
|
|
25
|
+
import { HitTestCanvasModel } from '../../model/hit-test-canvas.model';
|
|
25
26
|
/**
|
|
26
27
|
* X-axis component, contains all x-axis calculation and rendering logic.
|
|
27
28
|
*/
|
|
@@ -38,7 +39,7 @@ export declare class XAxisComponent extends ChartBaseElement {
|
|
|
38
39
|
xAxisLabelsGenerator: XAxisLabelsGenerator;
|
|
39
40
|
readonly xAxisLabelsModel: XAxisLabelsModel;
|
|
40
41
|
xAxisScaleHandler: XAxisScaleHandler;
|
|
41
|
-
constructor(eventBus: EventBus, config: FullChartConfig, canvasModel: CanvasModel, chartComponent: ChartComponent, scale: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, canvasInputListener: CanvasInputListenerComponent, chartResizeHandler: ChartResizeHandler, drawingManager: DrawingManager, timeZoneModel: TimeZoneModel, chartPanComponent: ChartPanComponent, cursorHandler: CursorHandler);
|
|
42
|
+
constructor(eventBus: EventBus, config: FullChartConfig, canvasModel: CanvasModel, chartComponent: ChartComponent, scale: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, canvasInputListener: CanvasInputListenerComponent, chartResizeHandler: ChartResizeHandler, drawingManager: DrawingManager, timeZoneModel: TimeZoneModel, chartPanComponent: ChartPanComponent, cursorHandler: CursorHandler, hitTestCanvasModel: HitTestCanvasModel);
|
|
42
43
|
/**
|
|
43
44
|
* This method is used to activate the chart and update the labels if there is a new data set or equivolume type.
|
|
44
45
|
* It subscribes to the chart type change, candles set subject, candles updated subject, and time zone change to generate new labels.
|
|
@@ -20,7 +20,7 @@ import { availableBarTypes } from '../../chart.config';
|
|
|
20
20
|
* X-axis component, contains all x-axis calculation and rendering logic.
|
|
21
21
|
*/
|
|
22
22
|
export class XAxisComponent extends ChartBaseElement {
|
|
23
|
-
constructor(eventBus, config, canvasModel, chartComponent, scale, canvasBoundsContainer, canvasInputListener, chartResizeHandler, drawingManager, timeZoneModel, chartPanComponent, cursorHandler) {
|
|
23
|
+
constructor(eventBus, config, canvasModel, chartComponent, scale, canvasBoundsContainer, canvasInputListener, chartResizeHandler, drawingManager, timeZoneModel, chartPanComponent, cursorHandler, hitTestCanvasModel) {
|
|
24
24
|
super();
|
|
25
25
|
this.eventBus = eventBus;
|
|
26
26
|
this.config = config;
|
|
@@ -38,7 +38,7 @@ export class XAxisComponent extends ChartBaseElement {
|
|
|
38
38
|
xAxisCompositeDrawer.addDrawer(this.xAxisDrawer);
|
|
39
39
|
this.xAxisLabelsDrawer = new XAxisLabelsDrawer(config, canvasModel, canvasBoundsContainer, this.xAxisLabelsModel);
|
|
40
40
|
xAxisCompositeDrawer.addDrawer(this.xAxisLabelsDrawer);
|
|
41
|
-
this.xAxisScaleHandler = new XAxisScaleHandler(scale, canvasInputListener, canvasBoundsContainer, chartPanComponent, this.chartComponent.chartModel);
|
|
41
|
+
this.xAxisScaleHandler = new XAxisScaleHandler(scale, canvasInputListener, canvasBoundsContainer, chartPanComponent, this.chartComponent.chartModel, hitTestCanvasModel);
|
|
42
42
|
this.addChildEntity(this.xAxisScaleHandler);
|
|
43
43
|
cursorHandler.setCursorForCanvasEl(CanvasElement.X_AXIS, config.components.xAxis.cursor);
|
|
44
44
|
}
|
|
@@ -61,7 +61,6 @@ export declare function drawRectLabel(ctx: CanvasRenderingContext2D, bounds: Bou
|
|
|
61
61
|
* @param yAxisState
|
|
62
62
|
* @param yAxisColors
|
|
63
63
|
* @param checkBoundaries
|
|
64
|
-
* @param backgroundCtx
|
|
65
64
|
*/
|
|
66
65
|
export declare function drawPlainLabel(ctx: CanvasRenderingContext2D, bounds: Bounds, text: string, centralY: number, config: YAxisLabelDrawConfig, yAxisState: YAxisConfig, yAxisColors: FullChartColors['yAxis'], checkBoundaries?: boolean): void;
|
|
67
66
|
/**
|
|
@@ -117,7 +117,6 @@ export function drawRectLabel(ctx, bounds, text, centralY, config, yAxisState, y
|
|
|
117
117
|
* @param yAxisState
|
|
118
118
|
* @param yAxisColors
|
|
119
119
|
* @param checkBoundaries
|
|
120
|
-
* @param backgroundCtx
|
|
121
120
|
*/
|
|
122
121
|
export function drawPlainLabel(ctx, bounds, text, centralY, config, yAxisState, yAxisColors, checkBoundaries = true) {
|
|
123
122
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
@@ -12,6 +12,7 @@ import { CanvasInputListenerComponent } from '../../inputlisteners/canvas-input-
|
|
|
12
12
|
import { Pixel, Unit } from '../../model/scaling/viewport.model';
|
|
13
13
|
import { ChartPanComponent } from '../pan/chart-pan.component';
|
|
14
14
|
import { ScaleModel } from '../../model/scale.model';
|
|
15
|
+
import { HitTestCanvasModel } from '../../model/hit-test-canvas.model';
|
|
15
16
|
/**
|
|
16
17
|
* Handles the mouse drag on Y axis - to zoom the viewport vertically.
|
|
17
18
|
* @doc-tags scaling,zoom,viewport
|
|
@@ -24,12 +25,13 @@ export declare class YAxisScaleHandler extends ChartBaseElement {
|
|
|
24
25
|
private bounds;
|
|
25
26
|
private hitTest;
|
|
26
27
|
private autoScaleCallback;
|
|
28
|
+
private hitTestCanvasModel;
|
|
27
29
|
yAxisDragEndSubject: Subject<void>;
|
|
28
30
|
lastYStart: Unit;
|
|
29
31
|
lastYEnd: Unit;
|
|
30
32
|
lastYHeight: Unit;
|
|
31
33
|
lastYPxHeight: Pixel;
|
|
32
|
-
constructor(bus: EventBus, config: YAxisConfig, panning: ChartPanComponent, scale: ScaleModel, canvasInputListener: CanvasInputListenerComponent, bounds: CanvasBoundsContainer, hitTest: HitBoundsTest, autoScaleCallback: (auto: boolean) => void);
|
|
34
|
+
constructor(bus: EventBus, config: YAxisConfig, panning: ChartPanComponent, scale: ScaleModel, canvasInputListener: CanvasInputListenerComponent, bounds: CanvasBoundsContainer, hitTest: HitBoundsTest, autoScaleCallback: (auto: boolean) => void, hitTestCanvasModel: HitTestCanvasModel);
|
|
33
35
|
protected doActivate(): void;
|
|
34
36
|
private onYDragStart;
|
|
35
37
|
private onYDragTick;
|
|
@@ -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, autoScaleCallback) {
|
|
17
|
+
constructor(bus, config, panning, scale, canvasInputListener, bounds, hitTest, autoScaleCallback, hitTestCanvasModel) {
|
|
18
18
|
super();
|
|
19
19
|
this.bus = bus;
|
|
20
20
|
this.config = config;
|
|
@@ -23,6 +23,7 @@ export class YAxisScaleHandler extends ChartBaseElement {
|
|
|
23
23
|
this.bounds = bounds;
|
|
24
24
|
this.hitTest = hitTest;
|
|
25
25
|
this.autoScaleCallback = autoScaleCallback;
|
|
26
|
+
this.hitTestCanvasModel = hitTestCanvasModel;
|
|
26
27
|
this.yAxisDragEndSubject = new Subject();
|
|
27
28
|
this.lastYStart = 0;
|
|
28
29
|
this.lastYEnd = 0;
|
|
@@ -35,6 +36,8 @@ export class YAxisScaleHandler extends ChartBaseElement {
|
|
|
35
36
|
this.lastYEnd = this.scale.yEnd;
|
|
36
37
|
this.lastYHeight = this.scale.yEnd - this.scale.yStart;
|
|
37
38
|
this.lastYPxHeight = this.bounds.getBounds(CanvasElement.Y_AXIS).height;
|
|
39
|
+
// Stop redrawing hit test
|
|
40
|
+
this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(false);
|
|
38
41
|
};
|
|
39
42
|
this.onYDragTick = (dragInfo) => {
|
|
40
43
|
const { delta: absoluteYDelta } = dragInfo;
|
|
@@ -60,6 +63,8 @@ export class YAxisScaleHandler extends ChartBaseElement {
|
|
|
60
63
|
};
|
|
61
64
|
this.onYDragEnd = () => {
|
|
62
65
|
this.yAxisDragEndSubject.next();
|
|
66
|
+
// Continue redrawing hit test
|
|
67
|
+
this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(true);
|
|
63
68
|
};
|
|
64
69
|
// drag to Y-scale and double click to auto scale
|
|
65
70
|
if (config.customScale) {
|
|
@@ -21,6 +21,7 @@ import { ChartPanComponent } from '../pan/chart-pan.component';
|
|
|
21
21
|
import { VisualYAxisLabel, YAxisLabelsProvider } from './price_labels/y-axis-labels.model';
|
|
22
22
|
import { YAxisScaleHandler } from './y-axis-scale.handler';
|
|
23
23
|
import { YAxisModel } from './y-axis.model';
|
|
24
|
+
import { HitTestCanvasModel } from '../../model/hit-test-canvas.model';
|
|
24
25
|
export type LabelColorResolver = (priceMovement: PriceMovement, colors: FullChartColors) => string;
|
|
25
26
|
/**
|
|
26
27
|
* Y axis component. Contains all Y axis related logic.
|
|
@@ -39,7 +40,7 @@ export declare class YAxisComponent extends ChartBaseElement {
|
|
|
39
40
|
model: YAxisModel;
|
|
40
41
|
axisTypeSetSubject: Subject<PriceAxisType>;
|
|
41
42
|
readonly state: YAxisConfig;
|
|
42
|
-
constructor(eventBus: EventBus, config: FullChartConfig, canvasModel: CanvasModel, scale: ScaleModel, canvasInputListeners: CanvasInputListenerComponent, canvasBoundsContainer: CanvasBoundsContainer, chartPanComponent: ChartPanComponent, cursors: CursorHandler, valueFormatter: (value: number) => string, dataSeriesProvider: () => DataSeriesModel | undefined, paneUUID: string, extentIdx: number);
|
|
43
|
+
constructor(eventBus: EventBus, config: FullChartConfig, canvasModel: CanvasModel, scale: ScaleModel, canvasInputListeners: CanvasInputListenerComponent, canvasBoundsContainer: CanvasBoundsContainer, chartPanComponent: ChartPanComponent, cursors: CursorHandler, valueFormatter: (value: number) => string, dataSeriesProvider: () => DataSeriesModel | undefined, paneUUID: string, extentIdx: number, hitTestCanvasModel: HitTestCanvasModel);
|
|
43
44
|
/**
|
|
44
45
|
* Registers default label color resolvers for different chart types.
|
|
45
46
|
* @private
|
|
@@ -8,7 +8,7 @@ import { CanvasElement } from '../../canvas/canvas-bounds-container';
|
|
|
8
8
|
import { ChartBaseElement } from '../../model/chart-base-element';
|
|
9
9
|
import { cloneUnsafe } from '../../utils/object.utils';
|
|
10
10
|
import { uuid } from '../../utils/uuid.utils';
|
|
11
|
-
import { resolveColorForArea, resolveColorForBar, resolveColorForBaseLine, resolveColorForCandle, resolveColorForHistogram, resolveColorForLine, resolveColorForScatterPlot, resolveColorForTrendAndHollow, resolveDefaultColorForLabel } from './label-color.functions';
|
|
11
|
+
import { resolveColorForArea, resolveColorForBar, resolveColorForBaseLine, resolveColorForCandle, resolveColorForHistogram, resolveColorForLine, resolveColorForScatterPlot, resolveColorForTrendAndHollow, resolveDefaultColorForLabel, } from './label-color.functions';
|
|
12
12
|
import { LabelsGroups } from './price_labels/y-axis-labels.model';
|
|
13
13
|
import { YAxisScaleHandler } from './y-axis-scale.handler';
|
|
14
14
|
import { YAxisModel } from './y-axis.model';
|
|
@@ -16,7 +16,7 @@ import { YAxisModel } from './y-axis.model';
|
|
|
16
16
|
* Y axis component. Contains all Y axis related logic.
|
|
17
17
|
*/
|
|
18
18
|
export class YAxisComponent extends ChartBaseElement {
|
|
19
|
-
constructor(eventBus, config, canvasModel, scale, canvasInputListeners, canvasBoundsContainer, chartPanComponent, cursors, valueFormatter, dataSeriesProvider, paneUUID, extentIdx) {
|
|
19
|
+
constructor(eventBus, config, canvasModel, scale, canvasInputListeners, canvasBoundsContainer, chartPanComponent, cursors, valueFormatter, dataSeriesProvider, paneUUID, extentIdx, hitTestCanvasModel) {
|
|
20
20
|
super();
|
|
21
21
|
this.eventBus = eventBus;
|
|
22
22
|
this.config = config;
|
|
@@ -30,7 +30,7 @@ export class YAxisComponent extends ChartBaseElement {
|
|
|
30
30
|
this.axisTypeSetSubject = new Subject();
|
|
31
31
|
this.state = cloneUnsafe(config.components.yAxis);
|
|
32
32
|
//#region init yAxisScaleHandler
|
|
33
|
-
this.yAxisScaleHandler = new YAxisScaleHandler(eventBus, this.state, chartPanComponent, scale, canvasInputListeners, canvasBoundsContainer, canvasBoundsContainer.getBoundsHitTest(CanvasElement.PANE_UUID_Y_AXIS(paneUUID, extentIdx)), auto => scale.autoScale(auto));
|
|
33
|
+
this.yAxisScaleHandler = new YAxisScaleHandler(eventBus, this.state, chartPanComponent, scale, canvasInputListeners, canvasBoundsContainer, canvasBoundsContainer.getBoundsHitTest(CanvasElement.PANE_UUID_Y_AXIS(paneUUID, extentIdx)), auto => scale.autoScale(auto), hitTestCanvasModel);
|
|
34
34
|
this.addChildEntity(this.yAxisScaleHandler);
|
|
35
35
|
//#endregion
|
|
36
36
|
this.model = new YAxisModel(this.paneUUID, eventBus, this.state, canvasBoundsContainer, canvasModel, scale, valueFormatter, dataSeriesProvider, extentIdx);
|
|
@@ -9,8 +9,8 @@ import { FullChartConfig } from '../chart.config';
|
|
|
9
9
|
export declare class BackgroundDrawer implements Drawer {
|
|
10
10
|
private canvasModel;
|
|
11
11
|
private config;
|
|
12
|
-
private
|
|
13
|
-
constructor(canvasModel: CanvasModel, config: FullChartConfig,
|
|
12
|
+
private drawPredicate;
|
|
13
|
+
constructor(canvasModel: CanvasModel, config: FullChartConfig, drawPredicate?: () => boolean);
|
|
14
14
|
private prevState;
|
|
15
15
|
draw(): void;
|
|
16
16
|
getCanvasIds(): Array<string>;
|
|
@@ -7,15 +7,15 @@ import { getDPR } from '../utils/device/device-pixel-ratio.utils';
|
|
|
7
7
|
import { floor } from '../utils/math.utils';
|
|
8
8
|
import { deepEqual } from '../utils/object.utils';
|
|
9
9
|
export class BackgroundDrawer {
|
|
10
|
-
constructor(canvasModel, config,
|
|
10
|
+
constructor(canvasModel, config, drawPredicate = () => true) {
|
|
11
11
|
this.canvasModel = canvasModel;
|
|
12
12
|
this.config = config;
|
|
13
|
-
this.
|
|
13
|
+
this.drawPredicate = drawPredicate;
|
|
14
14
|
// we need to save previous state to avoid unnecessary redraws
|
|
15
15
|
this.prevState = {};
|
|
16
16
|
}
|
|
17
17
|
draw() {
|
|
18
|
-
if (this.
|
|
18
|
+
if (this.drawPredicate() || !deepEqual(this.config.colors.chartAreaTheme, this.prevState)) {
|
|
19
19
|
this.canvasModel.clear();
|
|
20
20
|
const ctx = this.canvasModel.ctx;
|
|
21
21
|
if (this.config.colors.chartAreaTheme.backgroundMode === 'gradient') {
|
|
@@ -15,7 +15,8 @@ export declare class HTDataSeriesDrawer implements Drawer {
|
|
|
15
15
|
private readonly seriesDrawers;
|
|
16
16
|
private canvasModel;
|
|
17
17
|
private paneManager;
|
|
18
|
-
|
|
18
|
+
private drawPredicate;
|
|
19
|
+
constructor(seriesDrawers: Record<string, SeriesDrawer>, canvasModel: HitTestCanvasModel, paneManager: PaneManager, drawPredicate?: () => boolean);
|
|
19
20
|
draw(): void;
|
|
20
21
|
drawSeries(ctx: CanvasRenderingContext2D, series: DataSeriesModel): void;
|
|
21
22
|
getCanvasIds(): Array<string>;
|
|
@@ -8,19 +8,22 @@ import { clipToBounds } from '../utils/canvas/canvas-drawing-functions.utils';
|
|
|
8
8
|
* HitTest Chart drawer. It's used to draw hit test for chart types on the hit-test canvas.
|
|
9
9
|
*/
|
|
10
10
|
export class HTDataSeriesDrawer {
|
|
11
|
-
constructor(seriesDrawers, canvasModel, paneManager) {
|
|
11
|
+
constructor(seriesDrawers, canvasModel, paneManager, drawPredicate = () => true) {
|
|
12
12
|
this.seriesDrawers = seriesDrawers;
|
|
13
13
|
this.canvasModel = canvasModel;
|
|
14
14
|
this.paneManager = paneManager;
|
|
15
|
+
this.drawPredicate = drawPredicate;
|
|
15
16
|
}
|
|
16
17
|
draw() {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
if (this.drawPredicate()) {
|
|
19
|
+
const ctx = this.canvasModel.ctx;
|
|
20
|
+
this.paneManager.yExtents.forEach(comp => {
|
|
21
|
+
ctx.save();
|
|
22
|
+
clipToBounds(ctx, comp.getBounds());
|
|
23
|
+
comp.dataSeries.forEach(series => this.drawSeries(ctx, series));
|
|
24
|
+
ctx.restore();
|
|
25
|
+
});
|
|
26
|
+
}
|
|
24
27
|
}
|
|
25
28
|
drawSeries(ctx, series) {
|
|
26
29
|
if (series.config.visible) {
|
|
@@ -8,6 +8,9 @@ import { CanvasBoundsContainer, HitBoundsTest, HitBoundsTestOptionsPartial } fro
|
|
|
8
8
|
import { CanvasInputListenerComponent } from '../inputlisteners/canvas-input-listener.component';
|
|
9
9
|
import { ChartBaseElement } from '../model/chart-base-element';
|
|
10
10
|
import { Unsubscriber } from '../utils/function.utils';
|
|
11
|
+
/**
|
|
12
|
+
* [x, y, uuid - Unique identifier for the subscription]
|
|
13
|
+
*/
|
|
11
14
|
export type CrossEvent = [number, number, string];
|
|
12
15
|
export declare class CrossEventProducerComponent extends ChartBaseElement {
|
|
13
16
|
private canvasInputListener;
|
|
@@ -74,23 +74,27 @@ 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
|
+
var _a;
|
|
77
78
|
const x = event.touches[0].clientX - this.canvasBoundsContainer.canvasOnPageLocation.x;
|
|
78
79
|
const y = event.touches[0].clientY - this.canvasBoundsContainer.canvasOnPageLocation.y;
|
|
79
80
|
const candle = this.chartModel.candleFromX(x, true);
|
|
81
|
+
const paneId = ((_a = this.paneManager.getPaneIfHit({ x, y })) === null || _a === void 0 ? void 0 : _a.uuid) || '';
|
|
80
82
|
if (candle) {
|
|
81
|
-
this.createAndFireHover([x, y,
|
|
83
|
+
this.createAndFireHover([x, y, paneId]);
|
|
82
84
|
}
|
|
83
85
|
}));
|
|
84
86
|
// special handling for mobile
|
|
85
87
|
// on long touch - disable panning and show cross tool
|
|
86
88
|
const hitTest = this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.ALL_PANES);
|
|
87
89
|
this.addRxSubscription(this.canvasInputListener.observeLongTouchStart(hitTest).subscribe(event => {
|
|
90
|
+
var _a;
|
|
88
91
|
this.paneManager.chartPanComponent.deactivatePanHandlers();
|
|
89
92
|
this.longTouchActivatedSubject.next(true);
|
|
90
93
|
const x = event.touches[0].clientX - this.canvasBoundsContainer.canvasOnPageLocation.x;
|
|
91
94
|
const y = event.touches[0].clientY - this.canvasBoundsContainer.canvasOnPageLocation.y;
|
|
92
|
-
this.
|
|
93
|
-
this.
|
|
95
|
+
const paneId = ((_a = this.paneManager.getPaneIfHit({ x, y })) === null || _a === void 0 ? void 0 : _a.uuid) || '';
|
|
96
|
+
this.createAndFireHover([x, y, paneId]);
|
|
97
|
+
this.crossEventProducer.crossSubject.next([x, y, paneId]);
|
|
94
98
|
}));
|
|
95
99
|
this.addRxSubscription(this.canvasInputListener.observeTouchEndDocument().subscribe(() => {
|
|
96
100
|
this.paneManager.chartPanComponent.activateChartPanHandlers();
|
|
@@ -3,7 +3,7 @@
|
|
|
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 { Observable } from 'rxjs';
|
|
6
|
+
import { Observable, BehaviorSubject } from 'rxjs';
|
|
7
7
|
import { CanvasBoundsContainer } from '../canvas/canvas-bounds-container';
|
|
8
8
|
import { CursorType, FullChartConfig } from '../chart.config';
|
|
9
9
|
import { CanvasModel } from './canvas.model';
|
|
@@ -28,6 +28,7 @@ export declare class HitTestCanvasModel extends CanvasModel {
|
|
|
28
28
|
private touchStartSubject;
|
|
29
29
|
private dblClickSubject;
|
|
30
30
|
private rightClickSubject;
|
|
31
|
+
hitTestDrawersPredicateSubject: BehaviorSubject<boolean>;
|
|
31
32
|
constructor(eventBus: EventBus, canvas: HTMLCanvasElement, canvasInputListener: CanvasInputListenerComponent, canvasBoundsContainer: CanvasBoundsContainer, drawingManager: DrawingManager, chartConfig: FullChartConfig, canvasModels: CanvasModel[], resizer?: HTMLElement);
|
|
32
33
|
/**
|
|
33
34
|
* Enables HitTestCanvasModel events listeners.
|
|
@@ -3,7 +3,7 @@
|
|
|
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 { merge, Subject, animationFrameScheduler } from 'rxjs';
|
|
6
|
+
import { merge, Subject, animationFrameScheduler, BehaviorSubject } from 'rxjs';
|
|
7
7
|
import { map, throttleTime } from 'rxjs/operators';
|
|
8
8
|
import { CanvasElement } from '../canvas/canvas-bounds-container';
|
|
9
9
|
import { CanvasModel, initCanvasWithConfig } from './canvas.model';
|
|
@@ -26,6 +26,7 @@ export class HitTestCanvasModel extends CanvasModel {
|
|
|
26
26
|
constructor(eventBus, canvas, canvasInputListener, canvasBoundsContainer, drawingManager, chartConfig, canvasModels, resizer) {
|
|
27
27
|
super(eventBus, canvas, drawingManager, canvasModels, resizer, {
|
|
28
28
|
willReadFrequently: true,
|
|
29
|
+
// set to false to visually see hit test drawers objects (the canvas should also be visible)
|
|
29
30
|
desynchronized: true,
|
|
30
31
|
});
|
|
31
32
|
this.canvasInputListener = canvasInputListener;
|
|
@@ -36,6 +37,8 @@ export class HitTestCanvasModel extends CanvasModel {
|
|
|
36
37
|
this.touchStartSubject = new Subject();
|
|
37
38
|
this.dblClickSubject = new Subject();
|
|
38
39
|
this.rightClickSubject = new Subject();
|
|
40
|
+
// This predicate is used to detect whenever hit test should or shouldn't redraw hit test canvas image objects
|
|
41
|
+
this.hitTestDrawersPredicateSubject = new BehaviorSubject(true);
|
|
39
42
|
this.curImgData = new Uint8ClampedArray(4);
|
|
40
43
|
this.prevAnimationFrameId = -1;
|
|
41
44
|
initCanvasWithConfig(this, chartConfig);
|