@devexperts/dxcharts-lite 2.5.6 → 2.5.8
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.d.ts +21 -0
- package/dist/chart/canvas/canvas-bounds-container.js +30 -0
- package/dist/chart/chart.js +2 -1
- package/dist/chart/components/chart/basic-scale.d.ts +5 -1
- package/dist/chart/components/chart/basic-scale.js +10 -6
- package/dist/chart/components/chart/chart.model.d.ts +1 -22
- package/dist/chart/components/chart/chart.model.js +12 -36
- package/dist/chart/components/pan/chart-pan.component.js +2 -1
- package/dist/chart/components/pane/pane-manager.component.d.ts +3 -1
- package/dist/chart/components/pane/pane-manager.component.js +3 -2
- package/dist/chart/components/pane/pane.component.d.ts +3 -1
- package/dist/chart/components/pane/pane.component.js +6 -5
- package/dist/chart/components/x_axis/x-axis-labels.generator.d.ts +2 -2
- package/dist/chart/components/x_axis/x-axis-labels.generator.js +6 -6
- package/dist/chart/components/x_axis/x-axis-scale.handler.d.ts +4 -2
- package/dist/chart/components/x_axis/x-axis-scale.handler.js +16 -8
- package/dist/chart/components/x_axis/x-axis.component.js +1 -1
- package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.d.ts +3 -1
- package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.js +5 -3
- package/dist/chart/components/y_axis/y-axis-scale.handler.d.ts +1 -0
- package/dist/chart/components/y_axis/y-axis-scale.handler.js +18 -1
- package/dist/chart/components/y_axis/y-axis.component.d.ts +3 -1
- package/dist/chart/components/y_axis/y-axis.component.js +3 -2
- package/dist/chart/components/y_axis/y-axis.model.d.ts +2 -1
- package/dist/chart/components/y_axis/y-axis.model.js +2 -2
- package/dist/chart/inputhandlers/main-canvas-touch.handler.d.ts +3 -1
- package/dist/chart/inputhandlers/main-canvas-touch.handler.js +5 -4
- package/dist/chart/model/scale.model.d.ts +4 -4
- package/dist/chart/model/scale.model.js +14 -12
- package/dist/chart/utils/color.utils.d.ts +3 -0
- package/dist/chart/utils/color.utils.js +5 -1
- package/dist/dxchart.min.js +4 -4
- package/package.json +1 -1
package/dist/chart/bootstrap.js
CHANGED
|
@@ -130,7 +130,7 @@ export default class ChartBootstrap {
|
|
|
130
130
|
const hitTestComponent = new HitTestComponent(hitTestCanvasModel, canvasAnimation, eventBus);
|
|
131
131
|
this.hitTestComponent = hitTestComponent;
|
|
132
132
|
this.chartComponents.push(hitTestComponent);
|
|
133
|
-
const paneManager = new PaneManager(chartBaseModel, this.dynamicObjectsCanvasModel, this.userInputListenerComponents, eventBus, scaleModel, canvasBoundsContainer, config, canvasAnimation, canvasInputListener, drawingManager, this.cursorHandler, this.crossEventProducer, chartPanComponent, mainCanvasModel, yAxisLabelsCanvasModel, this.hitTestCanvasModel);
|
|
133
|
+
const paneManager = new PaneManager(chartBaseModel, this.dynamicObjectsCanvasModel, this.userInputListenerComponents, eventBus, scaleModel, canvasBoundsContainer, config, canvasAnimation, canvasInputListener, drawingManager, this.cursorHandler, this.crossEventProducer, chartPanComponent, mainCanvasModel, yAxisLabelsCanvasModel, this.hitTestCanvasModel, this.chartResizeHandler);
|
|
134
134
|
this.paneManager = paneManager;
|
|
135
135
|
const mainPane = this.paneManager.panes[CHART_UUID];
|
|
136
136
|
this.mainPane = mainPane;
|
|
@@ -180,8 +180,8 @@ export default class ChartBootstrap {
|
|
|
180
180
|
this.volumesComponent = new VolumesComponent(this.dynamicObjectsCanvasModel, chartComponent, scaleModel, canvasBoundsContainer, drawingManager, config, paneManager, this.dynamicObjects);
|
|
181
181
|
this.chartComponents.push(this.volumesComponent);
|
|
182
182
|
// grid component
|
|
183
|
-
const
|
|
184
|
-
this.chartComponents.push(
|
|
183
|
+
const verticalGridComponent = new GridComponent(mainCanvasModel, scaleModel, config, this.yAxisComponent.state, 'GRID', drawingManager, () => this.canvasBoundsContainer.getBounds(CanvasElement.ALL_PANES), () => this.canvasBoundsContainer.getBounds(chartPaneId), () => this.xAxisComponent.xAxisLabelsGenerator.labels, () => [], undefined, () => config.components.grid.visible);
|
|
184
|
+
this.chartComponents.push(verticalGridComponent);
|
|
185
185
|
this.hoverProducer = new HoverProducerComponent(this.crossEventProducer, scaleModel, config, chartModel, canvasInputListener, this.canvasBoundsContainer, this.paneManager, timeZoneModel, formatterFactory);
|
|
186
186
|
this.chartComponents.push(this.hoverProducer);
|
|
187
187
|
this.crossToolComponent = new CrossToolComponent(config, crossToolCanvasModel, canvasBoundsContainer, drawingManager, paneManager, this.crossEventProducer, this.hoverProducer);
|
|
@@ -328,6 +328,27 @@ export declare class CanvasBoundsContainer {
|
|
|
328
328
|
* @deprecated This method should be removed as candleSeries is not a part of CanvasBoundsContainer.
|
|
329
329
|
*/
|
|
330
330
|
setMainCandleSeries(candleSeries: CandleSeriesModel): void;
|
|
331
|
+
/**
|
|
332
|
+
* Returns the effective width of the Y axis.
|
|
333
|
+
*
|
|
334
|
+
* @function
|
|
335
|
+
* @name getEffectiveYAxisWidth
|
|
336
|
+
* @returns {number} The effective width of the Y axis.
|
|
337
|
+
*/
|
|
338
|
+
getEffectiveYAxisWidth(): number;
|
|
339
|
+
/**
|
|
340
|
+
* Returns the effective width of the chart.
|
|
341
|
+
*
|
|
342
|
+
* @function
|
|
343
|
+
* @returns {number} The effective width of the chart.
|
|
344
|
+
*/
|
|
345
|
+
getEffectiveChartWidth(): number;
|
|
346
|
+
/**
|
|
347
|
+
* Returns the effective height of the chart.
|
|
348
|
+
*
|
|
349
|
+
* @returns {number} The effective height of the chart.
|
|
350
|
+
*/
|
|
351
|
+
getEffectiveChartHeight(): number;
|
|
331
352
|
}
|
|
332
353
|
export declare const getHeightRatios: (pecLength: number) => [number, number];
|
|
333
354
|
export declare const isInBounds: (point: Point, bounds: Bounds) => boolean;
|
|
@@ -824,6 +824,36 @@ export class CanvasBoundsContainer {
|
|
|
824
824
|
setMainCandleSeries(candleSeries) {
|
|
825
825
|
this.mainCandleSeries = candleSeries;
|
|
826
826
|
}
|
|
827
|
+
/**
|
|
828
|
+
* Returns the effective width of the Y axis.
|
|
829
|
+
*
|
|
830
|
+
* @function
|
|
831
|
+
* @name getEffectiveYAxisWidth
|
|
832
|
+
* @returns {number} The effective width of the Y axis.
|
|
833
|
+
*/
|
|
834
|
+
getEffectiveYAxisWidth() {
|
|
835
|
+
const yAxis = this.getBounds(CanvasElement.PANE_UUID_Y_AXIS(CHART_UUID));
|
|
836
|
+
return yAxis.width;
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Returns the effective width of the chart.
|
|
840
|
+
*
|
|
841
|
+
* @function
|
|
842
|
+
* @returns {number} The effective width of the chart.
|
|
843
|
+
*/
|
|
844
|
+
getEffectiveChartWidth() {
|
|
845
|
+
const chart = this.getBounds(CanvasElement.PANE_UUID(CHART_UUID));
|
|
846
|
+
return chart.width;
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Returns the effective height of the chart.
|
|
850
|
+
*
|
|
851
|
+
* @returns {number} The effective height of the chart.
|
|
852
|
+
*/
|
|
853
|
+
getEffectiveChartHeight() {
|
|
854
|
+
const chart = this.getBounds(CanvasElement.PANE_UUID(CHART_UUID));
|
|
855
|
+
return chart.height;
|
|
856
|
+
}
|
|
827
857
|
}
|
|
828
858
|
// paneCounter=chartHeightRatio: 0=1, 1=0.8, 2=0.6, 3=0.5, 4=0.4, 5=0.4
|
|
829
859
|
const DEFAULT_RATIOS = {
|
package/dist/chart/chart.js
CHANGED
|
@@ -100,7 +100,8 @@ export class Chart extends ChartBootstrap {
|
|
|
100
100
|
this.bus.fireDraw();
|
|
101
101
|
}
|
|
102
102
|
setChartType(type) {
|
|
103
|
-
this.
|
|
103
|
+
this.data.setChartType(type);
|
|
104
|
+
this.yAxis.updateOrderedLabels();
|
|
104
105
|
}
|
|
105
106
|
createPane() {
|
|
106
107
|
return this.paneManager.createPane();
|
|
@@ -7,12 +7,16 @@ import { ScaleModel } from '../../model/scale.model';
|
|
|
7
7
|
import VisualCandle from '../../model/visual-candle';
|
|
8
8
|
import { Timestamp } from '../../model/scaling/viewport.model';
|
|
9
9
|
import { ChartModel } from './chart.model';
|
|
10
|
+
export interface BasicScaleOptions {
|
|
11
|
+
xScale?: boolean;
|
|
12
|
+
yScale?: boolean;
|
|
13
|
+
}
|
|
10
14
|
/**
|
|
11
15
|
* Calculates the initial viewport.
|
|
12
16
|
* @param scaleModel
|
|
13
17
|
* @doc-tags scaling,viewport
|
|
14
18
|
*/
|
|
15
|
-
export declare const createBasicScaleViewportTransformer: (scale: ScaleModel) => (visualCandleSource: VisualCandle[]) => void;
|
|
19
|
+
export declare const createBasicScaleViewportTransformer: (scale: ScaleModel) => (visualCandleSource: VisualCandle[], scaleOptions?: BasicScaleOptions) => void;
|
|
16
20
|
/**
|
|
17
21
|
* Moves the viewport between 2 timestamps.
|
|
18
22
|
* @param scaleModel
|
|
@@ -8,13 +8,17 @@
|
|
|
8
8
|
* @param scaleModel
|
|
9
9
|
* @doc-tags scaling,viewport
|
|
10
10
|
*/
|
|
11
|
-
export const createBasicScaleViewportTransformer = (scale) => (visualCandleSource) => {
|
|
11
|
+
export const createBasicScaleViewportTransformer = (scale) => (visualCandleSource, scaleOptions = { xScale: true, yScale: true }) => {
|
|
12
12
|
if (visualCandleSource.length !== 0) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
if (scaleOptions.xScale) {
|
|
14
|
+
const vCandles = visualCandleSource.slice(Math.max(visualCandleSource.length - scale.state.defaultViewportItems, 0));
|
|
15
|
+
const startCandle = vCandles[0];
|
|
16
|
+
const endCandle = vCandles[vCandles.length - 1];
|
|
17
|
+
scale.setXScale(startCandle.startUnit, endCandle.startUnit + endCandle.width + scale.offsets.right);
|
|
18
|
+
}
|
|
19
|
+
if (scaleOptions.yScale) {
|
|
20
|
+
scale.doAutoScale(true);
|
|
21
|
+
}
|
|
18
22
|
scale.fireChanged();
|
|
19
23
|
}
|
|
20
24
|
};
|
|
@@ -54,7 +54,7 @@ export declare class ChartModel extends ChartBaseElement {
|
|
|
54
54
|
private candleWidthByChartType;
|
|
55
55
|
secondaryChartColors: SecondaryChartColorsPool;
|
|
56
56
|
lastTimeFrame: TimeFrameRange;
|
|
57
|
-
basicScaleViewportTransformer: (visualCandleSource: VisualCandle[]) => void;
|
|
57
|
+
basicScaleViewportTransformer: (visualCandleSource: VisualCandle[], scaleOptions?: import("./basic-scale").BasicScaleOptions) => void;
|
|
58
58
|
timeFrameViewportTransformer: (timeframe: [number, number], zoomIn?: boolean | null) => void;
|
|
59
59
|
private FAKE_CANDLES_DEFAULT;
|
|
60
60
|
readonly pane: PaneComponent;
|
|
@@ -173,27 +173,6 @@ export declare class ChartModel extends ChartBaseElement {
|
|
|
173
173
|
* @returns {void}
|
|
174
174
|
*/
|
|
175
175
|
setAutoScale(auto: boolean): void;
|
|
176
|
-
/**
|
|
177
|
-
* Returns the effective width of the Y axis.
|
|
178
|
-
*
|
|
179
|
-
* @function
|
|
180
|
-
* @name getEffectiveYAxisWidth
|
|
181
|
-
* @returns {number} The effective width of the Y axis.
|
|
182
|
-
*/
|
|
183
|
-
getEffectiveYAxisWidth(): number;
|
|
184
|
-
/**
|
|
185
|
-
* Returns the effective width of the chart.
|
|
186
|
-
*
|
|
187
|
-
* @function
|
|
188
|
-
* @returns {number} The effective width of the chart.
|
|
189
|
-
*/
|
|
190
|
-
getEffectiveChartWidth(): number;
|
|
191
|
-
/**
|
|
192
|
-
* Returns the effective height of the chart.
|
|
193
|
-
*
|
|
194
|
-
* @returns {number} The effective height of the chart.
|
|
195
|
-
*/
|
|
196
|
-
getEffectiveChartHeight(): number;
|
|
197
176
|
/**
|
|
198
177
|
* Updates the offsets of the chart components and redraws the chart.
|
|
199
178
|
* @param {Partial<ChartConfigComponentsOffsets>} offsets - The new offsets to be applied to the chart components.
|
|
@@ -64,7 +64,9 @@ export class ChartModel extends ChartBaseElement {
|
|
|
64
64
|
const candleSeries = new MainCandleSeriesModel(this.chartBaseModel, this.paneManager.panes[CHART_UUID].mainExtent, uuid(), this.paneManager.hitTestController.getNewDataSeriesHitTestId(), this.bus, this.scale, new ChartInstrument(), this.candlesTransformersByChartType, this.candleWidthByChartType, Object.assign({}, this.config.colors));
|
|
65
65
|
candleSeries.config.type = this.config.components.chart.type;
|
|
66
66
|
this.candleSeries.push(candleSeries);
|
|
67
|
-
|
|
67
|
+
if (this.config.components.chart.minCandlesOffset > 0) {
|
|
68
|
+
scale.addXConstraint((_, state) => candleEdgesConstrait(state, this.mainCandleSeries.visualPoints, this.config.components.chart.minCandlesOffset, scale.getBounds()));
|
|
69
|
+
}
|
|
68
70
|
this.basicScaleViewportTransformer = createBasicScaleViewportTransformer(scale);
|
|
69
71
|
this.timeFrameViewportTransformer = createTimeFrameViewportTransformer(scale, this);
|
|
70
72
|
this.pane = this.paneManager.panes[CHART_UUID];
|
|
@@ -103,8 +105,8 @@ export class ChartModel extends ChartBaseElement {
|
|
|
103
105
|
*/
|
|
104
106
|
handleChartResize(nextCB) {
|
|
105
107
|
if (nextCB.width > MIN_SUPPORTED_CANVAS_SIZE.width && nextCB.height > MIN_SUPPORTED_CANVAS_SIZE.height) {
|
|
106
|
-
const nextChartWidth = this.getEffectiveChartWidth();
|
|
107
|
-
const nextYAxisWidth = this.getEffectiveYAxisWidth();
|
|
108
|
+
const nextChartWidth = this.canvasBoundsContainer.getEffectiveChartWidth();
|
|
109
|
+
const nextYAxisWidth = this.canvasBoundsContainer.getEffectiveYAxisWidth();
|
|
108
110
|
if (this.prevChartWidth === 0) {
|
|
109
111
|
this.scale.isViewportValid() ? this.scale.recalculateZoom() : this.doBasicScale();
|
|
110
112
|
this.prevChartWidth = nextChartWidth;
|
|
@@ -217,7 +219,9 @@ export class ChartModel extends ChartBaseElement {
|
|
|
217
219
|
});
|
|
218
220
|
this.chartBaseModel.recalculatePeriod();
|
|
219
221
|
this.autoScaleOnCandles();
|
|
220
|
-
this.scale.
|
|
222
|
+
if (this.config.scale.auto) {
|
|
223
|
+
this.scale.doAutoScale();
|
|
224
|
+
}
|
|
221
225
|
this.candlesSetSubject.next();
|
|
222
226
|
this.canvasModel.fireDraw();
|
|
223
227
|
}
|
|
@@ -420,36 +424,6 @@ export class ChartModel extends ChartBaseElement {
|
|
|
420
424
|
setAutoScale(auto) {
|
|
421
425
|
this.scale.autoScale(auto);
|
|
422
426
|
}
|
|
423
|
-
/**
|
|
424
|
-
* Returns the effective width of the Y axis.
|
|
425
|
-
*
|
|
426
|
-
* @function
|
|
427
|
-
* @name getEffectiveYAxisWidth
|
|
428
|
-
* @returns {number} The effective width of the Y axis.
|
|
429
|
-
*/
|
|
430
|
-
getEffectiveYAxisWidth() {
|
|
431
|
-
const yAxis = this.canvasBoundsContainer.getBounds(CanvasElement.PANE_UUID_Y_AXIS(CHART_UUID));
|
|
432
|
-
return yAxis.width;
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Returns the effective width of the chart.
|
|
436
|
-
*
|
|
437
|
-
* @function
|
|
438
|
-
* @returns {number} The effective width of the chart.
|
|
439
|
-
*/
|
|
440
|
-
getEffectiveChartWidth() {
|
|
441
|
-
const chart = this.canvasBoundsContainer.getBounds(CanvasElement.PANE_UUID(CHART_UUID));
|
|
442
|
-
return chart.width;
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Returns the effective height of the chart.
|
|
446
|
-
*
|
|
447
|
-
* @returns {number} The effective height of the chart.
|
|
448
|
-
*/
|
|
449
|
-
getEffectiveChartHeight() {
|
|
450
|
-
const chart = this.canvasBoundsContainer.getBounds(CanvasElement.PANE_UUID(CHART_UUID));
|
|
451
|
-
return chart.height;
|
|
452
|
-
}
|
|
453
427
|
/**
|
|
454
428
|
* Updates the offsets of the chart components and redraws the chart.
|
|
455
429
|
* @param {Partial<ChartConfigComponentsOffsets>} offsets - The new offsets to be applied to the chart components.
|
|
@@ -682,7 +656,7 @@ export class ChartModel extends ChartBaseElement {
|
|
|
682
656
|
* @returns {number} - The maximum number of candles that can fit in the chart width
|
|
683
657
|
*/
|
|
684
658
|
getMaxCandlesFitLength() {
|
|
685
|
-
return floor(this.getEffectiveChartWidth() / this.config.components.chart.minWidth);
|
|
659
|
+
return floor(this.canvasBoundsContainer.getEffectiveChartWidth() / this.config.components.chart.minWidth);
|
|
686
660
|
}
|
|
687
661
|
/**
|
|
688
662
|
* Returns an array of CandleSeriesModel objects representing the secondary candle series.
|
|
@@ -809,7 +783,9 @@ export class ChartModel extends ChartBaseElement {
|
|
|
809
783
|
series.recalculateVisualPoints();
|
|
810
784
|
}
|
|
811
785
|
});
|
|
812
|
-
this.scale.
|
|
786
|
+
if (this.config.scale.auto) {
|
|
787
|
+
this.scale.doAutoScale();
|
|
788
|
+
}
|
|
813
789
|
this.candlesUpdatedSubject.next();
|
|
814
790
|
}
|
|
815
791
|
/**
|
|
@@ -3,6 +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 { CanvasElement } from '../../canvas/canvas-bounds-container';
|
|
6
7
|
import { ChartBaseElement } from '../../model/chart-base-element';
|
|
7
8
|
import { ChartAreaPanHandler } from '../chart/chart-area-pan.handler';
|
|
8
9
|
import { MainCanvasTouchHandler } from '../../inputhandlers/main-canvas-touch.handler';
|
|
@@ -20,7 +21,7 @@ export class ChartPanComponent extends ChartBaseElement {
|
|
|
20
21
|
this.hitTestCanvasModel = hitTestCanvasModel;
|
|
21
22
|
this.chartAreaPanHandler = new ChartAreaPanHandler(this.eventBus, this.config, this.mainScale, this.canvasInputListener, this.canvasBoundsContainer, this.canvasAnimation, this, this.hitTestCanvasModel);
|
|
22
23
|
this.addChildEntity(this.chartAreaPanHandler);
|
|
23
|
-
this.mainCanvasTouchHandler = new MainCanvasTouchHandler(this.chartAreaPanHandler, this.mainScale, this.canvasInputListener, this.mainCanvasParent);
|
|
24
|
+
this.mainCanvasTouchHandler = new MainCanvasTouchHandler(this.chartAreaPanHandler, this.mainScale, this.canvasInputListener, this.mainCanvasParent, this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.ALL_PANES));
|
|
24
25
|
this.addChildEntity(this.mainCanvasTouchHandler);
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
@@ -23,6 +23,7 @@ import { PaneHitTestController } from './pane-hit-test.controller';
|
|
|
23
23
|
import { PaneComponent } from './pane.component';
|
|
24
24
|
import { DataSeriesModel } from '../../model/data-series.model';
|
|
25
25
|
import { HitTestCanvasModel } from '../../model/hit-test-canvas.model';
|
|
26
|
+
import { ChartResizeHandler } from '../../inputhandlers/chart-resize.handler';
|
|
26
27
|
export declare class PaneManager extends ChartBaseElement {
|
|
27
28
|
private chartBaseModel;
|
|
28
29
|
private dynamicObjectsCanvasModel;
|
|
@@ -40,6 +41,7 @@ export declare class PaneManager extends ChartBaseElement {
|
|
|
40
41
|
private mainCanvasModel;
|
|
41
42
|
private yAxisLabelsCanvasModel;
|
|
42
43
|
private hitTestCanvasModel;
|
|
44
|
+
private chartResizeHandler;
|
|
43
45
|
panes: Record<string, PaneComponent>;
|
|
44
46
|
paneRemovedSubject: Subject<PaneComponent>;
|
|
45
47
|
paneAddedSubject: Subject<Record<string, PaneComponent>>;
|
|
@@ -50,7 +52,7 @@ export declare class PaneManager extends ChartBaseElement {
|
|
|
50
52
|
* Returns order of panes in the chart from top to bottom.
|
|
51
53
|
*/
|
|
52
54
|
get panesOrder(): string[];
|
|
53
|
-
constructor(chartBaseModel: ChartBaseModel<'candle'>, dynamicObjectsCanvasModel: CanvasModel, userInputListenerComponents: ChartEntity[], eventBus: EventBus, mainScale: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, config: FullChartConfig, canvasAnimation: CanvasAnimation, canvasInputListener: CanvasInputListenerComponent, drawingManager: DrawingManager, cursorHandler: CursorHandler, crossEventProducer: CrossEventProducerComponent, chartPanComponent: ChartPanComponent, mainCanvasModel: CanvasModel, yAxisLabelsCanvasModel: CanvasModel, hitTestCanvasModel: HitTestCanvasModel);
|
|
55
|
+
constructor(chartBaseModel: ChartBaseModel<'candle'>, dynamicObjectsCanvasModel: CanvasModel, userInputListenerComponents: ChartEntity[], eventBus: EventBus, mainScale: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, config: FullChartConfig, canvasAnimation: CanvasAnimation, canvasInputListener: CanvasInputListenerComponent, drawingManager: DrawingManager, cursorHandler: CursorHandler, crossEventProducer: CrossEventProducerComponent, chartPanComponent: ChartPanComponent, mainCanvasModel: CanvasModel, yAxisLabelsCanvasModel: CanvasModel, hitTestCanvasModel: HitTestCanvasModel, chartResizeHandler: ChartResizeHandler);
|
|
54
56
|
private addBounds;
|
|
55
57
|
/**
|
|
56
58
|
* Adds a resizer to the canvas bounds container for the given uuid.
|
|
@@ -20,7 +20,7 @@ export class PaneManager extends ChartBaseElement {
|
|
|
20
20
|
get panesOrder() {
|
|
21
21
|
return this.canvasBoundsContainer.panesOrder;
|
|
22
22
|
}
|
|
23
|
-
constructor(chartBaseModel, dynamicObjectsCanvasModel, userInputListenerComponents, eventBus, mainScale, canvasBoundsContainer, config, canvasAnimation, canvasInputListener, drawingManager, cursorHandler, crossEventProducer, chartPanComponent, mainCanvasModel, yAxisLabelsCanvasModel, hitTestCanvasModel) {
|
|
23
|
+
constructor(chartBaseModel, dynamicObjectsCanvasModel, userInputListenerComponents, eventBus, mainScale, canvasBoundsContainer, config, canvasAnimation, canvasInputListener, drawingManager, cursorHandler, crossEventProducer, chartPanComponent, mainCanvasModel, yAxisLabelsCanvasModel, hitTestCanvasModel, chartResizeHandler) {
|
|
24
24
|
super();
|
|
25
25
|
this.chartBaseModel = chartBaseModel;
|
|
26
26
|
this.dynamicObjectsCanvasModel = dynamicObjectsCanvasModel;
|
|
@@ -38,6 +38,7 @@ export class PaneManager extends ChartBaseElement {
|
|
|
38
38
|
this.mainCanvasModel = mainCanvasModel;
|
|
39
39
|
this.yAxisLabelsCanvasModel = yAxisLabelsCanvasModel;
|
|
40
40
|
this.hitTestCanvasModel = hitTestCanvasModel;
|
|
41
|
+
this.chartResizeHandler = chartResizeHandler;
|
|
41
42
|
this.panes = {};
|
|
42
43
|
this.paneRemovedSubject = new Subject();
|
|
43
44
|
this.paneAddedSubject = new Subject();
|
|
@@ -95,7 +96,7 @@ export class PaneManager extends ChartBaseElement {
|
|
|
95
96
|
if (this.panes[uuid] !== undefined) {
|
|
96
97
|
return this.panes[uuid];
|
|
97
98
|
}
|
|
98
|
-
const paneComponent = new PaneComponent(this.chartBaseModel, this.mainCanvasModel, this.yAxisLabelsCanvasModel, this.dynamicObjectsCanvasModel, this.hitTestController, this.config, this.mainScale, this.drawingManager, this.chartPanComponent, this.canvasInputListener, this.canvasAnimation, this.cursorHandler, this.eventBus, this.canvasBoundsContainer, uuid, this.dataSeriesAddedSubject, this.dataSeriesRemovedSubject, this.hitTestCanvasModel, options);
|
|
99
|
+
const paneComponent = new PaneComponent(this.chartBaseModel, this.mainCanvasModel, this.yAxisLabelsCanvasModel, this.dynamicObjectsCanvasModel, this.hitTestController, this.config, this.mainScale, this.drawingManager, this.chartPanComponent, this.canvasInputListener, this.canvasAnimation, this.cursorHandler, this.eventBus, this.canvasBoundsContainer, uuid, this.dataSeriesAddedSubject, this.dataSeriesRemovedSubject, this.hitTestCanvasModel, this.chartResizeHandler, options);
|
|
99
100
|
// TODO: is resizer should be added always?
|
|
100
101
|
if (this.config.components.paneResizer.visible) {
|
|
101
102
|
paneComponent.addChildEntity(this.addResizer(uuid));
|
|
@@ -25,6 +25,7 @@ import { YAxisComponent } from '../y_axis/y-axis.component';
|
|
|
25
25
|
import { YExtentComponent, YExtentCreationOptions } from './extent/y-extent-component';
|
|
26
26
|
import { PaneHitTestController } from './pane-hit-test.controller';
|
|
27
27
|
import { HitTestCanvasModel } from '../../model/hit-test-canvas.model';
|
|
28
|
+
import { ChartResizeHandler } from '../../inputhandlers/chart-resize.handler';
|
|
28
29
|
export declare class PaneComponent extends ChartBaseElement {
|
|
29
30
|
chartBaseModel: ChartBaseModel<'candle'>;
|
|
30
31
|
private mainCanvasModel;
|
|
@@ -44,6 +45,7 @@ export declare class PaneComponent extends ChartBaseElement {
|
|
|
44
45
|
seriesAddedSubject: Subject<DataSeriesModel>;
|
|
45
46
|
seriesRemovedSubject: Subject<DataSeriesModel>;
|
|
46
47
|
private hitTestCanvasModel;
|
|
48
|
+
private chartResizeHandler;
|
|
47
49
|
/**
|
|
48
50
|
* Pane hit test (without Y-Axis and resizer)
|
|
49
51
|
*/
|
|
@@ -54,7 +56,7 @@ export declare class PaneComponent extends ChartBaseElement {
|
|
|
54
56
|
get dataSeries(): DataSeriesModel<import("../../model/data-series.model").DataSeriesPoint, import("../../model/data-series.model").VisualSeriesPoint>[];
|
|
55
57
|
get visible(): boolean;
|
|
56
58
|
mainExtent: YExtentComponent;
|
|
57
|
-
constructor(chartBaseModel: ChartBaseModel<'candle'>, mainCanvasModel: CanvasModel, yAxisLabelsCanvasModel: CanvasModel, dynamicObjectsCanvasModel: CanvasModel, hitTestController: PaneHitTestController, config: FullChartConfig, mainScale: ScaleModel, drawingManager: DrawingManager, chartPanComponent: ChartPanComponent, canvasInputListener: CanvasInputListenerComponent, canvasAnimation: CanvasAnimation, cursorHandler: CursorHandler, eventBus: EventBus, canvasBoundsContainer: CanvasBoundsContainer, uuid: string, seriesAddedSubject: Subject<DataSeriesModel>, seriesRemovedSubject: Subject<DataSeriesModel>, hitTestCanvasModel: HitTestCanvasModel, options?: AtLeastOne<YExtentCreationOptions>);
|
|
59
|
+
constructor(chartBaseModel: ChartBaseModel<'candle'>, mainCanvasModel: CanvasModel, yAxisLabelsCanvasModel: CanvasModel, dynamicObjectsCanvasModel: CanvasModel, hitTestController: PaneHitTestController, config: FullChartConfig, mainScale: ScaleModel, drawingManager: DrawingManager, chartPanComponent: ChartPanComponent, canvasInputListener: CanvasInputListenerComponent, canvasAnimation: CanvasAnimation, cursorHandler: CursorHandler, eventBus: EventBus, canvasBoundsContainer: CanvasBoundsContainer, uuid: string, seriesAddedSubject: Subject<DataSeriesModel>, seriesRemovedSubject: Subject<DataSeriesModel>, hitTestCanvasModel: HitTestCanvasModel, chartResizeHandler: ChartResizeHandler, options?: AtLeastOne<YExtentCreationOptions>);
|
|
58
60
|
/**
|
|
59
61
|
* Method that activates the canvas bounds container and recalculates the zoom Y of the scale model.
|
|
60
62
|
* @protected
|
|
@@ -25,7 +25,7 @@ export class PaneComponent extends ChartBaseElement {
|
|
|
25
25
|
get visible() {
|
|
26
26
|
return this.canvasBoundsContainer.graphsHeightRatio[this.uuid] > 0;
|
|
27
27
|
}
|
|
28
|
-
constructor(chartBaseModel, mainCanvasModel, yAxisLabelsCanvasModel, dynamicObjectsCanvasModel, hitTestController, config, mainScale, drawingManager, chartPanComponent, canvasInputListener, canvasAnimation, cursorHandler, eventBus, canvasBoundsContainer, uuid, seriesAddedSubject, seriesRemovedSubject, hitTestCanvasModel, options) {
|
|
28
|
+
constructor(chartBaseModel, mainCanvasModel, yAxisLabelsCanvasModel, dynamicObjectsCanvasModel, hitTestController, config, mainScale, drawingManager, chartPanComponent, canvasInputListener, canvasAnimation, cursorHandler, eventBus, canvasBoundsContainer, uuid, seriesAddedSubject, seriesRemovedSubject, hitTestCanvasModel, chartResizeHandler, options) {
|
|
29
29
|
super();
|
|
30
30
|
this.chartBaseModel = chartBaseModel;
|
|
31
31
|
this.mainCanvasModel = mainCanvasModel;
|
|
@@ -45,6 +45,7 @@ export class PaneComponent extends ChartBaseElement {
|
|
|
45
45
|
this.seriesAddedSubject = seriesAddedSubject;
|
|
46
46
|
this.seriesRemovedSubject = seriesRemovedSubject;
|
|
47
47
|
this.hitTestCanvasModel = hitTestCanvasModel;
|
|
48
|
+
this.chartResizeHandler = chartResizeHandler;
|
|
48
49
|
this.yExtentComponents = [];
|
|
49
50
|
this.getYAxisBounds = () => {
|
|
50
51
|
return this.canvasBoundsContainer.getBounds(CanvasElement.PANE_UUID_Y_AXIS(this.uuid));
|
|
@@ -87,9 +88,9 @@ export class PaneComponent extends ChartBaseElement {
|
|
|
87
88
|
* @param {NumericYAxisLabelsGenerator} yAxisLabelsGenerator - The generator used to create the labels for the y-axis.
|
|
88
89
|
* @returns {GridComponent} - The newly created GridComponent instance.
|
|
89
90
|
*/
|
|
90
|
-
createGridComponent(uuid, scale,
|
|
91
|
+
createGridComponent(uuid, scale, yAxisState, yAxisLabelsGetter, yAxisBaselineGetter) {
|
|
91
92
|
const chartPaneId = CanvasElement.PANE_UUID(uuid);
|
|
92
|
-
const gridComponent = new GridComponent(this.mainCanvasModel, scale, this.config, yAxisState, `PANE_${uuid}_grid_drawer`, this.drawingManager, () => this.canvasBoundsContainer.getBounds(chartPaneId), () => this.canvasBoundsContainer.getBounds(chartPaneId), () => [], () =>
|
|
93
|
+
const gridComponent = new GridComponent(this.mainCanvasModel, scale, this.config, yAxisState, `PANE_${uuid}_grid_drawer`, this.drawingManager, () => this.canvasBoundsContainer.getBounds(chartPaneId), () => this.canvasBoundsContainer.getBounds(chartPaneId), () => [], yAxisLabelsGetter, yAxisBaselineGetter, () => this.config.components.grid.visible);
|
|
93
94
|
return gridComponent;
|
|
94
95
|
}
|
|
95
96
|
/**
|
|
@@ -125,7 +126,7 @@ export class PaneComponent extends ChartBaseElement {
|
|
|
125
126
|
const [unsub, dragNDrop] = this.createYPanHandler(this.uuid, scaleModel);
|
|
126
127
|
// creating partially resolved constructor except formatter & dataSeriesProvider - bcs it's not possible to provide formatter
|
|
127
128
|
// before y-extent is created
|
|
128
|
-
const createYAxisComponent = (formatter, dataSeriesProvider) => new YAxisComponent(this.eventBus, this.config, this.yAxisLabelsCanvasModel, scaleModel, this.canvasInputListener, this.canvasBoundsContainer, this.chartPanComponent, this.cursorHandler, formatter, dataSeriesProvider, this.uuid, extentIdx, this.hitTestCanvasModel, initialYAxisState);
|
|
129
|
+
const createYAxisComponent = (formatter, dataSeriesProvider) => new YAxisComponent(this.eventBus, this.config, this.yAxisLabelsCanvasModel, scaleModel, this.canvasInputListener, this.canvasBoundsContainer, this.chartPanComponent, this.cursorHandler, formatter, dataSeriesProvider, this.uuid, extentIdx, this.hitTestCanvasModel, this.chartResizeHandler, initialYAxisState);
|
|
129
130
|
const yExtentComponent = new YExtentComponent(this.uuid, extentIdx, this, this.chartBaseModel, this.canvasBoundsContainer, this.hitTestController, this.dynamicObjectsCanvasModel, scaleModel, createYAxisComponent, dragNDrop);
|
|
130
131
|
yExtentComponent.addSubscription(unsub);
|
|
131
132
|
yExtentComponent.addSubscription(this.addCursors(extentIdx, yExtentComponent.yAxis));
|
|
@@ -134,7 +135,7 @@ export class PaneComponent extends ChartBaseElement {
|
|
|
134
135
|
if (useDefaultHighLow) {
|
|
135
136
|
scaleModel.autoScaleModel.setHighLowProvider('default', createCandlesOffsetProvider(() => ({ top: 10, bottom: 10, left: 0, right: 0, visible: true }), createDefaultYExtentHighLowProvider(yExtentComponent)));
|
|
136
137
|
}
|
|
137
|
-
const gridComponent = this.createGridComponent(this.uuid, scaleModel, yExtentComponent.yAxis.model.
|
|
138
|
+
const gridComponent = this.createGridComponent(this.uuid, scaleModel, yExtentComponent.yAxis.state, () => yExtentComponent.yAxis.model.baseLabelsModel.labels, () => yExtentComponent.toY(yExtentComponent.getBaseline()));
|
|
138
139
|
yExtentComponent.addChildEntity(gridComponent);
|
|
139
140
|
yExtentComponent.activate();
|
|
140
141
|
this.yExtentComponents.push(yExtentComponent);
|
|
@@ -18,7 +18,7 @@ export interface XAxisLabelsGenerator {
|
|
|
18
18
|
/**
|
|
19
19
|
* Generates x-axis labels from scratch. Heavy operation.
|
|
20
20
|
*/
|
|
21
|
-
generateLabels(): void;
|
|
21
|
+
generateLabels(prependedCandles?: VisualCandle[]): void;
|
|
22
22
|
/**
|
|
23
23
|
* Updates current labels state (x-position). Lightweight operation.
|
|
24
24
|
*/
|
|
@@ -107,7 +107,7 @@ export declare class XAxisTimeLabelsGenerator implements XAxisLabelsGenerator {
|
|
|
107
107
|
* Calls the method generateWeightedLabels to generate labels.
|
|
108
108
|
* @returns {void}
|
|
109
109
|
*/
|
|
110
|
-
generateLabels(): void;
|
|
110
|
+
generateLabels(prependedCandles?: VisualCandle[]): void;
|
|
111
111
|
/**
|
|
112
112
|
* Recalculates the labels by calling the method recalculateCachedLabels.
|
|
113
113
|
* @returns {void}
|
|
@@ -86,14 +86,14 @@ export class XAxisTimeLabelsGenerator {
|
|
|
86
86
|
/**
|
|
87
87
|
* Make a prediction(750) about how many candles we need to fake to fill all X axis by labels
|
|
88
88
|
*/
|
|
89
|
-
getAllCandlesWithFake() {
|
|
89
|
+
getAllCandlesWithFake(prependedCandles = []) {
|
|
90
90
|
const visualCandles = this.chartModel.mainCandleSeries.visualPoints;
|
|
91
91
|
if (visualCandles.length === 0) {
|
|
92
92
|
return [];
|
|
93
93
|
}
|
|
94
94
|
const fakeCandlesForSides = Array.from({ length: 750 });
|
|
95
95
|
const appendFakeCandle = fakeCandlesForSides.map((_, idx) => fakeVisualCandle(this.chartModel.mainCandleSeries.dataPoints, this.chartModel.mainCandleSeries.visualPoints, this.chartModel.mainCandleSeries.meanCandleWidth, visualCandles.length + idx, this.chartModel.getPeriod()));
|
|
96
|
-
return [...visualCandles, ...appendFakeCandle];
|
|
96
|
+
return [...prependedCandles, ...visualCandles, ...appendFakeCandle];
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
99
|
* Maps an array of weighted points to an array of XAxisLabelWeighted objects.
|
|
@@ -139,8 +139,8 @@ export class XAxisTimeLabelsGenerator {
|
|
|
139
139
|
* @function
|
|
140
140
|
* @returns {void}
|
|
141
141
|
*/
|
|
142
|
-
generateWeightedLabels() {
|
|
143
|
-
const allCandlesWithFake = this.getAllCandlesWithFake();
|
|
142
|
+
generateWeightedLabels(prependedCandles = []) {
|
|
143
|
+
const allCandlesWithFake = this.getAllCandlesWithFake(prependedCandles);
|
|
144
144
|
const weightedPoints = mapCandlesToWeightedPoints(allCandlesWithFake, this.weightToTimeFormatMatcherArray, this.timeZoneModel.tzOffset(this.config.timezone));
|
|
145
145
|
const weightedLabels = this.mapWeightedPointsToLabels(weightedPoints, allCandlesWithFake);
|
|
146
146
|
this.labelsGroupedByWeight = groupLabelsByWeight(weightedLabels);
|
|
@@ -253,8 +253,8 @@ export class XAxisTimeLabelsGenerator {
|
|
|
253
253
|
* Calls the method generateWeightedLabels to generate labels.
|
|
254
254
|
* @returns {void}
|
|
255
255
|
*/
|
|
256
|
-
generateLabels() {
|
|
257
|
-
this.generateWeightedLabels();
|
|
256
|
+
generateLabels(prependedCandles) {
|
|
257
|
+
this.generateWeightedLabels(prependedCandles);
|
|
258
258
|
}
|
|
259
259
|
/**
|
|
260
260
|
* Recalculates the labels by calling the method recalculateCachedLabels.
|
|
@@ -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 { ChartBaseElement } from '../../model/chart-base-element';
|
|
7
|
-
import { CanvasBoundsContainer } from '../../canvas/canvas-bounds-container';
|
|
7
|
+
import { CanvasBoundsContainer, HitBoundsTest } from '../../canvas/canvas-bounds-container';
|
|
8
8
|
import { CanvasInputListenerComponent } from '../../inputlisteners/canvas-input-listener.component';
|
|
9
9
|
import { ScaleModel } from '../../model/scale.model';
|
|
10
10
|
import { Pixel, Unit } from '../../model/scaling/viewport.model';
|
|
@@ -21,13 +21,15 @@ export declare class XAxisScaleHandler extends ChartBaseElement {
|
|
|
21
21
|
private canvasBoundsContainer;
|
|
22
22
|
private chartPanComponent;
|
|
23
23
|
private chartModel;
|
|
24
|
+
private hitTest;
|
|
24
25
|
private hitTestCanvasModel;
|
|
25
26
|
lastXStart: Unit;
|
|
26
27
|
lastXWidth: Unit;
|
|
27
28
|
lastXPxWidth: Pixel;
|
|
28
29
|
private dblClickCallback;
|
|
30
|
+
private touches;
|
|
29
31
|
private dblTapCallback;
|
|
30
|
-
constructor(scale: ScaleModel, canvasInputListener: CanvasInputListenerComponent, canvasBoundsContainer: CanvasBoundsContainer, chartPanComponent: ChartPanComponent, chartModel: ChartModel, hitTestCanvasModel: HitTestCanvasModel);
|
|
32
|
+
constructor(scale: ScaleModel, canvasInputListener: CanvasInputListenerComponent, canvasBoundsContainer: CanvasBoundsContainer, chartPanComponent: ChartPanComponent, chartModel: ChartModel, hitTest: HitBoundsTest, hitTestCanvasModel: HitTestCanvasModel);
|
|
31
33
|
/**
|
|
32
34
|
* This method is used to activate the canvas input listener and add a subscription to it.
|
|
33
35
|
* It calls the parent class's doActivate method and then subscribes to the canvasInputListener's observeDbClick method.
|
|
@@ -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, hitTestCanvasModel) {
|
|
14
|
+
constructor(scale, canvasInputListener, canvasBoundsContainer, chartPanComponent, chartModel, hitTest, 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.hitTest = hitTest;
|
|
21
22
|
this.hitTestCanvasModel = hitTestCanvasModel;
|
|
22
23
|
this.lastXStart = 0;
|
|
23
24
|
this.lastXWidth = 0;
|
|
@@ -50,7 +51,7 @@ export class XAxisScaleHandler extends ChartBaseElement {
|
|
|
50
51
|
this.setDblClickCallback = (cb) => this.dblClickCallback = cb;
|
|
51
52
|
this.dblClickCallback = () => chartModel.doBasicScale();
|
|
52
53
|
this.dblTapCallback = () => chartModel.doBasicScale();
|
|
53
|
-
const dragNDropXComponent = new DragNDropXComponent(
|
|
54
|
+
const dragNDropXComponent = new DragNDropXComponent(hitTest, {
|
|
54
55
|
onDragStart: this.onXDragStart,
|
|
55
56
|
onDragTick: this.onXDragTick,
|
|
56
57
|
onDragEnd: this.onXDragEnd,
|
|
@@ -69,12 +70,19 @@ export class XAxisScaleHandler extends ChartBaseElement {
|
|
|
69
70
|
*/
|
|
70
71
|
doActivate() {
|
|
71
72
|
super.doActivate();
|
|
72
|
-
this.addRxSubscription(this.canvasInputListener
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
this.addRxSubscription(this.canvasInputListener.observeDbClick(this.hitTest).subscribe(() => this.dblClickCallback()));
|
|
74
|
+
this.addRxSubscription(this.canvasInputListener.observeDbTap(this.hitTest).subscribe(() => {
|
|
75
|
+
var _a;
|
|
76
|
+
// apply dbl tap only if single finger taps are made
|
|
77
|
+
if (this.touches && ((_a = this.touches) === null || _a === void 0 ? void 0 : _a.length) > 1) {
|
|
78
|
+
this.touches = undefined;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
this.dblTapCallback();
|
|
82
|
+
}));
|
|
83
|
+
this.addRxSubscription(this.canvasInputListener.observeTouchStart(this.hitTest).subscribe(e => {
|
|
84
|
+
this.touches = e.touches;
|
|
85
|
+
}));
|
|
78
86
|
this.addRxSubscription(this.chartModel.candlesPrependSubject.subscribe(({ prependedCandlesWidth }) => (this.lastXStart += prependedCandlesWidth)));
|
|
79
87
|
}
|
|
80
88
|
}
|
|
@@ -50,7 +50,7 @@ export class XAxisComponent extends ChartBaseElement {
|
|
|
50
50
|
xAxisCompositeDrawer.addDrawer(this.xAxisDrawer);
|
|
51
51
|
this.xAxisLabelsDrawer = new XAxisLabelsDrawer(config, canvasModel, canvasBoundsContainer, this.xAxisLabelsModel);
|
|
52
52
|
xAxisCompositeDrawer.addDrawer(this.xAxisLabelsDrawer);
|
|
53
|
-
this.xAxisScaleHandler = new XAxisScaleHandler(scale, canvasInputListener, canvasBoundsContainer, chartPanComponent, this.chartComponent.chartModel, hitTestCanvasModel);
|
|
53
|
+
this.xAxisScaleHandler = new XAxisScaleHandler(scale, canvasInputListener, canvasBoundsContainer, chartPanComponent, this.chartComponent.chartModel, canvasBoundsContainer.getBoundsHitTest(CanvasElement.X_AXIS), hitTestCanvasModel);
|
|
54
54
|
this.addChildEntity(this.xAxisScaleHandler);
|
|
55
55
|
cursorHandler.setCursorForCanvasEl(CanvasElement.X_AXIS, config.components.xAxis.cursor);
|
|
56
56
|
}
|
|
@@ -13,6 +13,7 @@ import { ChartBaseElement } from '../../../model/chart-base-element';
|
|
|
13
13
|
import { ScaleModel } from '../../../model/scale.model';
|
|
14
14
|
import { Unit } from '../../../model/scaling/viewport.model';
|
|
15
15
|
import { YAxisLabelDrawConfig } from '../y-axis-labels.drawer';
|
|
16
|
+
import { ChartResizeHandler } from '../../../inputhandlers/chart-resize.handler';
|
|
16
17
|
export type YAxisVisualLabelType = 'badge' | 'rectangle' | 'plain';
|
|
17
18
|
export interface VisualYAxisLabel extends YAxisLabelDrawConfig {
|
|
18
19
|
y: Unit;
|
|
@@ -53,6 +54,7 @@ export declare class FancyYAxisLabelsModel extends ChartBaseElement {
|
|
|
53
54
|
private canvasModel;
|
|
54
55
|
private paneUUID;
|
|
55
56
|
private updateYAxisWidth;
|
|
57
|
+
private chartResizeHandler;
|
|
56
58
|
orderedLabels: LabelGroup[];
|
|
57
59
|
/**
|
|
58
60
|
* an easier way to manage custom y-axis labels, than y-axis labels providers, but doesn't support overlapping avoidance
|
|
@@ -61,7 +63,7 @@ export declare class FancyYAxisLabelsModel extends ChartBaseElement {
|
|
|
61
63
|
private labelsProviders;
|
|
62
64
|
private labelsPositionRecalculatedSubject;
|
|
63
65
|
private animFrameId;
|
|
64
|
-
constructor(eventBus: EventBus, scale: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, state: YAxisConfig, canvasModel: CanvasModel, paneUUID: string, updateYAxisWidth: () => void);
|
|
66
|
+
constructor(eventBus: EventBus, scale: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, state: YAxisConfig, canvasModel: CanvasModel, paneUUID: string, updateYAxisWidth: () => void, chartResizeHandler: ChartResizeHandler);
|
|
65
67
|
/**
|
|
66
68
|
* This method is used to activate the chart and subscribe to the observables that will trigger the update of the labels.
|
|
67
69
|
* It calls the parent method doActivate() and adds a new Rx subscription to the merge of the following observables:
|
|
@@ -3,7 +3,8 @@
|
|
|
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 } from 'rxjs';
|
|
6
|
+
import { animationFrameScheduler, merge, Subject } from 'rxjs';
|
|
7
|
+
import { throttleTime } from 'rxjs/operators';
|
|
7
8
|
import { CanvasElement } from '../../../canvas/canvas-bounds-container';
|
|
8
9
|
import { ChartBaseElement } from '../../../model/chart-base-element';
|
|
9
10
|
import { flat } from '../../../utils/array.utils';
|
|
@@ -26,7 +27,7 @@ export const LabelsGroups = {
|
|
|
26
27
|
* Anything but the base labels which are generated in other component {@link YAxisBaseLabelsModel}
|
|
27
28
|
*/
|
|
28
29
|
export class FancyYAxisLabelsModel extends ChartBaseElement {
|
|
29
|
-
constructor(eventBus, scale, canvasBoundsContainer, state, canvasModel, paneUUID, updateYAxisWidth) {
|
|
30
|
+
constructor(eventBus, scale, canvasBoundsContainer, state, canvasModel, paneUUID, updateYAxisWidth, chartResizeHandler) {
|
|
30
31
|
super();
|
|
31
32
|
this.eventBus = eventBus;
|
|
32
33
|
this.scale = scale;
|
|
@@ -35,6 +36,7 @@ export class FancyYAxisLabelsModel extends ChartBaseElement {
|
|
|
35
36
|
this.canvasModel = canvasModel;
|
|
36
37
|
this.paneUUID = paneUUID;
|
|
37
38
|
this.updateYAxisWidth = updateYAxisWidth;
|
|
39
|
+
this.chartResizeHandler = chartResizeHandler;
|
|
38
40
|
this.orderedLabels = [];
|
|
39
41
|
/**
|
|
40
42
|
* an easier way to manage custom y-axis labels, than y-axis labels providers, but doesn't support overlapping avoidance
|
|
@@ -56,7 +58,7 @@ export class FancyYAxisLabelsModel extends ChartBaseElement {
|
|
|
56
58
|
*/
|
|
57
59
|
doActivate() {
|
|
58
60
|
super.doActivate();
|
|
59
|
-
this.addRxSubscription(merge(this.canvasBoundsContainer.observeBoundsChanged(CanvasElement.PANE_UUID(this.paneUUID)), this.
|
|
61
|
+
this.addRxSubscription(merge(this.canvasBoundsContainer.barResizerChangedSubject, this.scale.changed, merge(this.canvasBoundsContainer.observeBoundsChanged(CanvasElement.PANE_UUID(this.paneUUID)), this.chartResizeHandler.canvasResized).pipe(throttleTime(50, animationFrameScheduler, { trailing: true, leading: true }))).subscribe(() => {
|
|
60
62
|
this.updateLabels();
|
|
61
63
|
}));
|
|
62
64
|
}
|