@devexperts/dxcharts-lite 2.7.2 → 2.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chart/bootstrap.js +7 -4
- package/dist/chart/canvas/canvas-chart-html.js +1 -0
- package/dist/chart/canvas/chart-elements.d.ts +1 -0
- package/dist/chart/components/chart/chart.component.d.ts +8 -6
- package/dist/chart/components/chart/chart.component.js +16 -8
- package/dist/chart/components/y_axis/price_labels/price-label.drawer.d.ts +1 -1
- package/dist/chart/components/y_axis/price_labels/price-label.drawer.js +3 -2
- package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.d.ts +2 -1
- package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.js +5 -3
- package/dist/chart/components/y_axis/y-axis-base-labels.model.d.ts +5 -0
- package/dist/chart/components/y_axis/y-axis-base-labels.model.js +9 -0
- package/dist/chart/components/y_axis/y-axis.component.d.ts +1 -0
- package/dist/chart/components/y_axis/y-axis.component.js +3 -0
- package/dist/chart/drawers/chart-background.drawer.d.ts +1 -0
- package/dist/chart/drawers/chart-background.drawer.js +2 -1
- package/dist/chart/utils/numeric-constants.utils.d.ts +6 -0
- package/dist/chart/utils/numeric-constants.utils.js +6 -0
- package/dist/dxchart.min.js +5 -4
- package/package.json +1 -1
package/dist/chart/bootstrap.js
CHANGED
|
@@ -88,6 +88,7 @@ export default class ChartBootstrap {
|
|
|
88
88
|
const dataSeriesCanvasClearDrawer = new ClearCanvasDrawer(this.dynamicObjectsCanvasModel);
|
|
89
89
|
drawingManager.addDrawer(dataSeriesCanvasClearDrawer, 'SERIES_CLEAR');
|
|
90
90
|
const yAxisLabelsCanvasModel = createCanvasModel(eventBus, elements.yAxisLabelsCanvas, config, drawingManager, this.canvasModels, elements.chartResizer);
|
|
91
|
+
const yAxisDescriptionsCanvasModel = createCanvasModel(eventBus, elements.yAxisDescriptionsCanvas, config, drawingManager, this.canvasModels, elements.chartResizer);
|
|
91
92
|
const canvasBoundsContainer = new CanvasBoundsContainer(config, eventBus, mainCanvasModel, formatterFactory, chartResizeHandler);
|
|
92
93
|
this.canvasBoundsContainer = canvasBoundsContainer;
|
|
93
94
|
//#region main canvas user input listeners
|
|
@@ -172,7 +173,7 @@ export default class ChartBootstrap {
|
|
|
172
173
|
// high low component
|
|
173
174
|
const highLowComponent = new HighLowComponent(config, this.dynamicObjectsCanvasModel, chartModel, canvasBoundsContainer, drawingManager);
|
|
174
175
|
this.chartComponents.push(highLowComponent);
|
|
175
|
-
this.initYAxisDrawer(yAxisLabelsCanvasModel);
|
|
176
|
+
this.initYAxisDrawer(yAxisLabelsCanvasModel, yAxisDescriptionsCanvasModel);
|
|
176
177
|
this.yAxisComponent = mainPane.mainExtent.yAxis;
|
|
177
178
|
// default labels provider
|
|
178
179
|
const lastCandleLabelsProvider = new LastCandleLabelsProvider(this.chartModel, this.config, mainPane.mainExtent.yAxis.state, this.chartModel.lastCandleLabelsByChartType, this.yAxisComponent.getLabelsColorResolver.bind(this.yAxisComponent));
|
|
@@ -201,15 +202,17 @@ export default class ChartBootstrap {
|
|
|
201
202
|
drawingManager.reorderDrawers(config.drawingOrder);
|
|
202
203
|
this.clearer = clearerSafe(this.components);
|
|
203
204
|
}
|
|
204
|
-
initYAxisDrawer(yAxisLabelsCanvasModel) {
|
|
205
|
+
initYAxisDrawer(yAxisLabelsCanvasModel, yAxisDescriptionsCanvasModel) {
|
|
205
206
|
const yAxisCompositeDrawer = new CompositeDrawer();
|
|
206
207
|
const clearYAxis = new ClearCanvasDrawer(yAxisLabelsCanvasModel);
|
|
208
|
+
const clearYAxisDescriptions = new ClearCanvasDrawer(yAxisDescriptionsCanvasModel);
|
|
207
209
|
yAxisCompositeDrawer.addDrawer(clearYAxis, 'YAXIS_CLEAR');
|
|
210
|
+
yAxisCompositeDrawer.addDrawer(clearYAxisDescriptions, 'Y_AXIS_DESCRIPTIONS_CLEAR');
|
|
208
211
|
this.drawingManager.addDrawer(yAxisCompositeDrawer, 'Y_AXIS');
|
|
209
212
|
const yAxisDrawer = new YAxisDrawer(this.config, yAxisLabelsCanvasModel, this.paneManager);
|
|
210
213
|
yAxisCompositeDrawer.addDrawer(yAxisDrawer);
|
|
211
|
-
const
|
|
212
|
-
|
|
214
|
+
const yAxisPriceLabelsDrawer = new YAxisPriceLabelsDrawer(yAxisLabelsCanvasModel, yAxisDescriptionsCanvasModel, this.backgroundCanvasModel, this.canvasBoundsContainer, this.config, this.paneManager);
|
|
215
|
+
this.drawingManager.addDrawer(yAxisPriceLabelsDrawer, 'Y_AXIS_PRICE_LABELS');
|
|
213
216
|
}
|
|
214
217
|
// TODO remove chartModel dependency, put period to global config somewhere
|
|
215
218
|
/**
|
|
@@ -11,6 +11,7 @@ export default (devexpertsPromoLink) => '<div data-element="chartResizer" style=
|
|
|
11
11
|
'\t\t\t<canvas data-element="mainCanvas"></canvas>\n' +
|
|
12
12
|
'\t\t\t<canvas data-element="yAxisLabelsCanvas"></canvas>\n' +
|
|
13
13
|
'\t\t\t<canvas data-element="dynamicObjectsCanvas"></canvas>\n' +
|
|
14
|
+
'\t\t\t<canvas data-element="yAxisDescriptionsCanvas"></canvas>\n' +
|
|
14
15
|
'\t\t\t<canvas data-element="crossToolCanvas"></canvas>\n' +
|
|
15
16
|
'\t\t\t<canvas data-element="hitTestCanvas"></canvas>\n' +
|
|
16
17
|
`${devexpertsPromoLink
|
|
@@ -10,6 +10,7 @@ export interface ChartElements {
|
|
|
10
10
|
mainCanvas?: HTMLCanvasElement;
|
|
11
11
|
dynamicObjectsCanvas?: HTMLCanvasElement;
|
|
12
12
|
yAxisLabelsCanvas?: HTMLCanvasElement;
|
|
13
|
+
yAxisDescriptionsCanvas?: HTMLCanvasElement;
|
|
13
14
|
crossToolCanvas?: HTMLCanvasElement;
|
|
14
15
|
hitTestCanvas?: HTMLCanvasElement;
|
|
15
16
|
chartResizer?: HTMLElement;
|
|
@@ -117,6 +117,7 @@ export declare class ChartComponent extends ChartBaseElement {
|
|
|
117
117
|
* Sets the timestamp range of the chart by setting the x-axis scale.
|
|
118
118
|
* @param {Timestamp} start - The start timestamp of the range.
|
|
119
119
|
* @param {Timestamp} end - The end timestamp of the range.
|
|
120
|
+
* @param {boolean} forceNoAnimation - true by default
|
|
120
121
|
* @returns {void}
|
|
121
122
|
*/
|
|
122
123
|
setTimestampRange(start: Timestamp, end: Timestamp, forceNoAnimation?: boolean): void;
|
|
@@ -124,6 +125,7 @@ export declare class ChartComponent extends ChartBaseElement {
|
|
|
124
125
|
* Moves the viewport to exactly xStart..xEnd place.
|
|
125
126
|
* @param xStart - viewport start in units
|
|
126
127
|
* @param xEnd - viewport end in units
|
|
128
|
+
* @param {boolean} forceNoAnimation - true by default
|
|
127
129
|
*/
|
|
128
130
|
setXScale(xStart: Unit, xEnd: Unit, forceNoAnimation?: boolean): void;
|
|
129
131
|
/**
|
|
@@ -182,12 +184,12 @@ export declare class ChartComponent extends ChartBaseElement {
|
|
|
182
184
|
/**
|
|
183
185
|
* Removes all data points from the main candle series that are newer than the given timestamp.
|
|
184
186
|
* Can be useful for data replay.
|
|
185
|
-
* @param
|
|
187
|
+
* @param {Timestamp } timestamp
|
|
186
188
|
*/
|
|
187
189
|
removeDataFrom(timestamp: Timestamp): void;
|
|
188
190
|
/**
|
|
189
191
|
* Removes chart candles series.
|
|
190
|
-
* @param
|
|
192
|
+
* @param {CandleSeriesModel} series
|
|
191
193
|
*/
|
|
192
194
|
removeSecondarySeries(series: CandleSeriesModel): void;
|
|
193
195
|
/**
|
|
@@ -234,13 +236,13 @@ export declare class ChartComponent extends ChartBaseElement {
|
|
|
234
236
|
/**
|
|
235
237
|
* Updates last candle value
|
|
236
238
|
* @param candle - updated candle
|
|
237
|
-
* @param instrumentSymbol - name of the instrument to update
|
|
239
|
+
* @param {string} instrumentSymbol - name of the instrument to update
|
|
238
240
|
*/
|
|
239
241
|
updateLastCandle(candle: Candle, instrumentSymbol?: string): void;
|
|
240
242
|
/**
|
|
241
243
|
* Updates candle series for instrument. By default takes main instrument.
|
|
242
|
-
* @param candles
|
|
243
|
-
* @param instrument
|
|
244
|
+
* @param {Array<Candle>} candles
|
|
245
|
+
* @param {string} instrumentSymbol - name of the instrument to update
|
|
244
246
|
*/
|
|
245
247
|
updateCandles(candles: Array<Candle>, instrumentSymbol?: string): void;
|
|
246
248
|
/**
|
|
@@ -257,7 +259,7 @@ export declare class ChartComponent extends ChartBaseElement {
|
|
|
257
259
|
/**
|
|
258
260
|
* Registers a new chart type drawer or overrides default drawer if drawerType is {BarType}.
|
|
259
261
|
* @param drawerType {string} - a unique name for the drawer, could be {BarType} - in this case will override default drawer for the type
|
|
260
|
-
* @param drawer {
|
|
262
|
+
* @param drawer {SeriesDrawer} - an implementation of the drawer
|
|
261
263
|
*/
|
|
262
264
|
registerDataSeriesTypeDrawer(drawerType: DataSeriesType, drawer: SeriesDrawer): void;
|
|
263
265
|
/**
|
|
@@ -27,10 +27,12 @@ import { HIT_TEST_PREFIX } from '../../drawers/drawing-manager';
|
|
|
27
27
|
import { HTDataSeriesDrawer } from '../../drawers/ht-data-series.drawer';
|
|
28
28
|
import { BaselineModel } from '../../model/baseline.model';
|
|
29
29
|
import { keys } from '../../utils/object.utils';
|
|
30
|
+
import { ONE_FRAME_MS } from '../../utils/numeric-constants.utils';
|
|
30
31
|
import { PriceIncrementsUtils } from '../../utils/price-increments.utils';
|
|
31
32
|
import { defaultCandleTransformer, hollowCandleTransformer, lineCandleTransformer, trendCandleTransformer, } from './candle-transformer.functions';
|
|
32
33
|
import { deleteCandlesIndex } from './candle.functions';
|
|
33
34
|
import { TrendHistogramDrawer } from '../../drawers/data-series-drawers/trend-histogram.drawer';
|
|
35
|
+
import { debounce } from '../../utils/performance/debounce.utils';
|
|
34
36
|
/**
|
|
35
37
|
* Represents a financial instrument to be displayed on a chart
|
|
36
38
|
* @class
|
|
@@ -109,9 +111,13 @@ export class ChartComponent extends ChartBaseElement {
|
|
|
109
111
|
this.dynamicObjects.model.removeObject(series.id);
|
|
110
112
|
}));
|
|
111
113
|
// redraw background only when chart is resized
|
|
112
|
-
this.addRxSubscription(this.canvasBoundsContainer.observeAnyBoundsChanged().subscribe(() => {
|
|
114
|
+
this.addRxSubscription(this.canvasBoundsContainer.observeAnyBoundsChanged().subscribe(debounce(() => {
|
|
115
|
+
// there is multiple calls on this bounds change on lots of sources,
|
|
116
|
+
// and sometimes this calls mixes with this.chartResizeHandler.canvasResized
|
|
117
|
+
// and this leads to change of background in situations when it's not needed,
|
|
118
|
+
// so on multiple calls in one frame we debounced it to avoid that collisions and steam races
|
|
113
119
|
this.backgroundDrawerPredicateSubject.next(false);
|
|
114
|
-
}));
|
|
120
|
+
}, ONE_FRAME_MS)));
|
|
115
121
|
this.addRxSubscription(this.chartResizeHandler.canvasResized.subscribe(() => {
|
|
116
122
|
this.backgroundDrawerPredicateSubject.next(true);
|
|
117
123
|
}));
|
|
@@ -206,6 +212,7 @@ export class ChartComponent extends ChartBaseElement {
|
|
|
206
212
|
* Sets the timestamp range of the chart by setting the x-axis scale.
|
|
207
213
|
* @param {Timestamp} start - The start timestamp of the range.
|
|
208
214
|
* @param {Timestamp} end - The end timestamp of the range.
|
|
215
|
+
* @param {boolean} forceNoAnimation - true by default
|
|
209
216
|
* @returns {void}
|
|
210
217
|
*/
|
|
211
218
|
setTimestampRange(start, end, forceNoAnimation = true) {
|
|
@@ -215,6 +222,7 @@ export class ChartComponent extends ChartBaseElement {
|
|
|
215
222
|
* Moves the viewport to exactly xStart..xEnd place.
|
|
216
223
|
* @param xStart - viewport start in units
|
|
217
224
|
* @param xEnd - viewport end in units
|
|
225
|
+
* @param {boolean} forceNoAnimation - true by default
|
|
218
226
|
*/
|
|
219
227
|
setXScale(xStart, xEnd, forceNoAnimation = true) {
|
|
220
228
|
return this.scale.setXScale(xStart, xEnd, forceNoAnimation);
|
|
@@ -325,14 +333,14 @@ export class ChartComponent extends ChartBaseElement {
|
|
|
325
333
|
/**
|
|
326
334
|
* Removes all data points from the main candle series that are newer than the given timestamp.
|
|
327
335
|
* Can be useful for data replay.
|
|
328
|
-
* @param
|
|
336
|
+
* @param {Timestamp } timestamp
|
|
329
337
|
*/
|
|
330
338
|
removeDataFrom(timestamp) {
|
|
331
339
|
this.chartModel.removeDataFrom(timestamp);
|
|
332
340
|
}
|
|
333
341
|
/**
|
|
334
342
|
* Removes chart candles series.
|
|
335
|
-
* @param
|
|
343
|
+
* @param {CandleSeriesModel} series
|
|
336
344
|
*/
|
|
337
345
|
removeSecondarySeries(series) {
|
|
338
346
|
this.chartModel.removeSecondaryCandleSeries(series);
|
|
@@ -393,15 +401,15 @@ export class ChartComponent extends ChartBaseElement {
|
|
|
393
401
|
/**
|
|
394
402
|
* Updates last candle value
|
|
395
403
|
* @param candle - updated candle
|
|
396
|
-
* @param instrumentSymbol - name of the instrument to update
|
|
404
|
+
* @param {string} instrumentSymbol - name of the instrument to update
|
|
397
405
|
*/
|
|
398
406
|
updateLastCandle(candle, instrumentSymbol) {
|
|
399
407
|
this.chartModel.updateLastCandle(candle, instrumentSymbol);
|
|
400
408
|
}
|
|
401
409
|
/**
|
|
402
410
|
* Updates candle series for instrument. By default takes main instrument.
|
|
403
|
-
* @param candles
|
|
404
|
-
* @param instrument
|
|
411
|
+
* @param {Array<Candle>} candles
|
|
412
|
+
* @param {string} instrumentSymbol - name of the instrument to update
|
|
405
413
|
*/
|
|
406
414
|
updateCandles(candles, instrumentSymbol) {
|
|
407
415
|
this.chartModel.updateCandles(candles, instrumentSymbol);
|
|
@@ -424,7 +432,7 @@ export class ChartComponent extends ChartBaseElement {
|
|
|
424
432
|
/**
|
|
425
433
|
* Registers a new chart type drawer or overrides default drawer if drawerType is {BarType}.
|
|
426
434
|
* @param drawerType {string} - a unique name for the drawer, could be {BarType} - in this case will override default drawer for the type
|
|
427
|
-
* @param drawer {
|
|
435
|
+
* @param drawer {SeriesDrawer} - an implementation of the drawer
|
|
428
436
|
*/
|
|
429
437
|
registerDataSeriesTypeDrawer(drawerType, drawer) {
|
|
430
438
|
this._dataSeriesDrawers[drawerType] = drawer;
|
|
@@ -19,5 +19,5 @@ export declare const priceLabelDrawersMap: Record<YAxisVisualLabelType, LabelDra
|
|
|
19
19
|
* @param canvasBoundsContainer
|
|
20
20
|
* @param config
|
|
21
21
|
*/
|
|
22
|
-
export declare function drawLabel(ctx: CanvasRenderingContext2D, backgroundCtx: CanvasRenderingContext2D, bounds: Bounds, paneBounds: Bounds, visualLabel: VisualYAxisLabel, canvasBoundsContainer: CanvasBoundsContainer, config: YAxisConfig, colors: FullChartColors): void;
|
|
22
|
+
export declare function drawLabel(ctx: CanvasRenderingContext2D, yAxisDescriptionsCtx: CanvasRenderingContext2D, backgroundCtx: CanvasRenderingContext2D, bounds: Bounds, paneBounds: Bounds, visualLabel: VisualYAxisLabel, canvasBoundsContainer: CanvasBoundsContainer, config: YAxisConfig, colors: FullChartColors): void;
|
|
23
23
|
export {};
|
|
@@ -25,7 +25,7 @@ export const priceLabelDrawersMap = {
|
|
|
25
25
|
* @param canvasBoundsContainer
|
|
26
26
|
* @param config
|
|
27
27
|
*/
|
|
28
|
-
export function drawLabel(ctx, backgroundCtx, bounds, paneBounds, visualLabel, canvasBoundsContainer, config, colors) {
|
|
28
|
+
export function drawLabel(ctx, yAxisDescriptionsCtx, backgroundCtx, bounds, paneBounds, visualLabel, canvasBoundsContainer, config, colors) {
|
|
29
29
|
var _a, _b, _c, _d, _e;
|
|
30
30
|
const centralY = visualLabel.y;
|
|
31
31
|
const text = visualLabel.labelText;
|
|
@@ -48,7 +48,8 @@ export function drawLabel(ctx, backgroundCtx, bounds, paneBounds, visualLabel, c
|
|
|
48
48
|
const drawLabel = priceLabelDrawersMap[appearanceType];
|
|
49
49
|
const showDescription = config.labels.descriptions;
|
|
50
50
|
const showLine = isLineVisible(bounds, labelY, labelBoxHeight);
|
|
51
|
-
const _drawDescription = () => showDescription &&
|
|
51
|
+
const _drawDescription = () => showDescription &&
|
|
52
|
+
drawDescription(backgroundCtx, yAxisDescriptionsCtx, bounds, paneBounds, visualLabel, config);
|
|
52
53
|
let lineXStart;
|
|
53
54
|
let lineXEnd;
|
|
54
55
|
// line should touch the label
|
|
@@ -11,11 +11,12 @@ import { PaneManager } from '../../pane/pane-manager.component';
|
|
|
11
11
|
import { LabelGroup } from './y-axis-labels.model';
|
|
12
12
|
export declare class YAxisPriceLabelsDrawer implements Drawer {
|
|
13
13
|
private yAxisLabelsCanvasModel;
|
|
14
|
+
private yAxisDescriptionsCanvasModel;
|
|
14
15
|
private backgroundCanvasModel;
|
|
15
16
|
private canvasBoundsContainer;
|
|
16
17
|
private fullConfig;
|
|
17
18
|
private paneManager;
|
|
18
|
-
constructor(yAxisLabelsCanvasModel: CanvasModel, backgroundCanvasModel: CanvasModel, canvasBoundsContainer: CanvasBoundsContainer, fullConfig: FullChartConfig, paneManager: PaneManager);
|
|
19
|
+
constructor(yAxisLabelsCanvasModel: CanvasModel, yAxisDescriptionsCanvasModel: CanvasModel, backgroundCanvasModel: CanvasModel, canvasBoundsContainer: CanvasBoundsContainer, fullConfig: FullChartConfig, paneManager: PaneManager);
|
|
19
20
|
draw(): void;
|
|
20
21
|
drawHighlightedBackgroundBetweenLabels(orderedLabels: LabelGroup[]): void;
|
|
21
22
|
getCanvasIds(): Array<string>;
|
|
@@ -7,8 +7,9 @@ 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, fullConfig, paneManager) {
|
|
10
|
+
constructor(yAxisLabelsCanvasModel, yAxisDescriptionsCanvasModel, backgroundCanvasModel, canvasBoundsContainer, fullConfig, paneManager) {
|
|
11
11
|
this.yAxisLabelsCanvasModel = yAxisLabelsCanvasModel;
|
|
12
|
+
this.yAxisDescriptionsCanvasModel = yAxisDescriptionsCanvasModel;
|
|
12
13
|
this.backgroundCanvasModel = backgroundCanvasModel;
|
|
13
14
|
this.canvasBoundsContainer = canvasBoundsContainer;
|
|
14
15
|
this.fullConfig = fullConfig;
|
|
@@ -17,6 +18,7 @@ export class YAxisPriceLabelsDrawer {
|
|
|
17
18
|
draw() {
|
|
18
19
|
const ctx = this.yAxisLabelsCanvasModel.ctx;
|
|
19
20
|
const backgroundCtx = this.backgroundCanvasModel.ctx;
|
|
21
|
+
const descriptionsCtx = this.yAxisDescriptionsCanvasModel.ctx;
|
|
20
22
|
this.paneManager.yExtents.forEach(extent => {
|
|
21
23
|
if (extent.yAxis.state.visible) {
|
|
22
24
|
const yAxisBounds = extent.getYAxisBounds();
|
|
@@ -26,10 +28,10 @@ export class YAxisPriceLabelsDrawer {
|
|
|
26
28
|
orderedLabels.forEach(l => {
|
|
27
29
|
var _a;
|
|
28
30
|
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));
|
|
31
|
+
l.labels.forEach(vl => drawLabel(ctx, descriptionsCtx, backgroundCtx, bounds, paneBounds, vl, this.canvasBoundsContainer, extent.yAxis.state, this.fullConfig.colors));
|
|
30
32
|
});
|
|
31
33
|
// 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));
|
|
34
|
+
Object.values(extent.yAxis.model.fancyLabelsModel.customLabels).forEach(l => drawLabel(ctx, descriptionsCtx, backgroundCtx, yAxisBounds, paneBounds, l, this.canvasBoundsContainer, extent.yAxis.state, this.fullConfig.colors));
|
|
33
35
|
}
|
|
34
36
|
});
|
|
35
37
|
}
|
|
@@ -25,6 +25,11 @@ export declare class YAxisBaseLabelsModel extends ChartBaseElement {
|
|
|
25
25
|
* If the height of the canvas bounds changes by more than 1.5 times the previous height, the labels cache is invalidated and the previous y-axis height is updated.
|
|
26
26
|
*/
|
|
27
27
|
protected doActivate(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Generates new labels with labelsGenerator
|
|
30
|
+
* Then, it calls the updateYAxisWidth method to update the width of the y-axis.
|
|
31
|
+
*/
|
|
32
|
+
recalculateLabels(): void;
|
|
28
33
|
/**
|
|
29
34
|
* Updates the labels of the chart's y-axis by generating new numeric labels using the yAxisLabelsGenerator object.
|
|
30
35
|
* Then, it calls the updateYAxisWidth method to update the width of the y-axis.
|
|
@@ -41,6 +41,15 @@ export class YAxisBaseLabelsModel extends ChartBaseElement {
|
|
|
41
41
|
this.prevYAxisHeight = height;
|
|
42
42
|
}))).subscribe(() => this.updateLabels()));
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Generates new labels with labelsGenerator
|
|
46
|
+
* Then, it calls the updateYAxisWidth method to update the width of the y-axis.
|
|
47
|
+
*/
|
|
48
|
+
recalculateLabels() {
|
|
49
|
+
const labels = this.labelsGenerator.doGenerateLabels();
|
|
50
|
+
this.labels = labels;
|
|
51
|
+
animationFrameThrottledPrior(this.animFrameId, () => this.canvasBoundsContainer.updateYAxisWidths());
|
|
52
|
+
}
|
|
44
53
|
/**
|
|
45
54
|
* Updates the labels of the chart's y-axis by generating new numeric labels using the yAxisLabelsGenerator object.
|
|
46
55
|
* Then, it calls the updateYAxisWidth method to update the width of the y-axis.
|
|
@@ -45,6 +45,7 @@ export declare class YAxisComponent extends ChartBaseElement {
|
|
|
45
45
|
model: YAxisModel;
|
|
46
46
|
axisTypeSetSubject: Subject<PriceAxisType>;
|
|
47
47
|
axisAlignSetSubject: Subject<YAxisAlign>;
|
|
48
|
+
axisAlignMovedSubject: Subject<YAxisAlign>;
|
|
48
49
|
readonly state: YAxisConfig;
|
|
49
50
|
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, chartResizeHandler: ChartResizeHandler, initialState?: YAxisConfig);
|
|
50
51
|
setExtentIdx(extentIdx: number): void;
|
|
@@ -34,6 +34,7 @@ export class YAxisComponent extends ChartBaseElement {
|
|
|
34
34
|
this.labelsColorByChartTypeMap = {};
|
|
35
35
|
this.axisTypeSetSubject = new Subject();
|
|
36
36
|
this.axisAlignSetSubject = new Subject();
|
|
37
|
+
this.axisAlignMovedSubject = new Subject();
|
|
37
38
|
/* This function assigns a callback to be executed when a double-click event is detected.
|
|
38
39
|
* It accepts one parameter `cb`, which is a callback function.
|
|
39
40
|
* When a double-click event occurs, the specified callback function `cb` will be invoked.
|
|
@@ -246,7 +247,9 @@ export class YAxisComponent extends ChartBaseElement {
|
|
|
246
247
|
togglePriceScaleInverse(inverse) {
|
|
247
248
|
this.scale.state.inverse = inverse;
|
|
248
249
|
this.scale.inverseY = inverse;
|
|
250
|
+
this.model.fancyLabelsModel.updateLabels();
|
|
249
251
|
this.scale.scaleInversedSubject.next(inverse);
|
|
252
|
+
this.canvasModel.fireDraw();
|
|
250
253
|
}
|
|
251
254
|
/**
|
|
252
255
|
* Changes the visibility of the labels' descriptions.
|
|
@@ -12,6 +12,7 @@ export declare class BackgroundDrawer implements Drawer {
|
|
|
12
12
|
private drawPredicate;
|
|
13
13
|
constructor(canvasModel: CanvasModel, config: FullChartConfig, drawPredicate?: () => boolean);
|
|
14
14
|
private prevState;
|
|
15
|
+
isColorsChanged: () => boolean;
|
|
15
16
|
draw(): void;
|
|
16
17
|
getCanvasIds(): Array<string>;
|
|
17
18
|
}
|
|
@@ -13,9 +13,10 @@ export class BackgroundDrawer {
|
|
|
13
13
|
this.drawPredicate = drawPredicate;
|
|
14
14
|
// we need to save previous state to avoid unnecessary redraws
|
|
15
15
|
this.prevState = {};
|
|
16
|
+
this.isColorsChanged = () => !deepEqual(this.config.colors.chartAreaTheme, this.prevState);
|
|
16
17
|
}
|
|
17
18
|
draw() {
|
|
18
|
-
if (this.drawPredicate() ||
|
|
19
|
+
if (this.drawPredicate() || this.isColorsChanged()) {
|
|
19
20
|
this.canvasModel.clear();
|
|
20
21
|
const ctx = this.canvasModel.ctx;
|
|
21
22
|
if (this.config.colors.chartAreaTheme.backgroundMode === 'gradient') {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2019 - 2025 Devexperts Solutions IE Limited
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
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
|
+
*/
|
|
6
|
+
export declare const ONE_FRAME_MS = 16;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2019 - 2025 Devexperts Solutions IE Limited
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
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
|
+
*/
|
|
6
|
+
export const ONE_FRAME_MS = 16; // 60 frames per second is ~16ms
|