Skip to content

Commit

Permalink
Pull request #5302: [DXCF-5632] Legend (data box) - Time displayed in…
Browse files Browse the repository at this point in the history
… the legend not aligned with the last candle's time // init

Merge in DXCHARTS/dxchart5 from bugfix/DXCF-5632-legend-data-box-time-displayed-in-the-legend-not-aligned-with-the-last-candle-s to master

* commit 'f5487b669849667d3e4de98b29b597139fe25f69':
  [DXCF-5632] Legend (data box) - Time displayed in the legend not aligned with the last candle's time // init
  [DXCF-5632] Legend (data box) - Time displayed in the legend not aligned with the last candle's time // init
  [DXCF-5632] Legend (data box) - Time displayed in the legend not aligned with the last candle's time // init

GitOrigin-RevId: da85659631588227078f467725eaf008d53eaa51
  • Loading branch information
Keelaro1 authored and dxcity committed Nov 19, 2024
1 parent 1daceab commit e08d646
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
18 changes: 12 additions & 6 deletions src/chart/inputhandlers/hover-producer.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/*
* Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
* Copyright (C) 2019 - 2024 Devexperts Solutions IE Limited
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { BehaviorSubject, merge } from 'rxjs';
import { filter, switchMap } from 'rxjs/operators';
import { CHART_UUID, CanvasBoundsContainer, CanvasElement } from '../canvas/canvas-bounds-container';
import { FullChartConfig } from '../chart.config';
import { ChartModel } from '../components/chart/chart.model';
Expand Down Expand Up @@ -94,11 +95,16 @@ export class HoverProducerComponent extends ChartBaseElement {
protected doActivate() {
super.doActivate();
this.addRxSubscription(
this.chartModel.candlesSetSubject.subscribe(() => {
// required for initial legend initialization, do not show cross tool
const lastCandle = this.chartModel.getLastVisualCandle();
lastCandle && this.createAndFireHoverFromCandle(lastCandle);
}),
// required for initial legend initialization, do not show cross tool
this.chartModel.candlesSetSubject
.pipe(
// check the scale is valid before doing candle-based hover event
switchMap(() => this.scale.initialViewportValidSubject.pipe(filter(Boolean))),
)
.subscribe(() => {
const lastCandle = this.chartModel.getLastVisualCandle();
lastCandle && this.createAndFireHoverFromCandle(lastCandle);
}),
);
this.addRxSubscription(
this.chartModel.candlesUpdatedSubject.subscribe(() => {
Expand Down
12 changes: 10 additions & 2 deletions src/chart/model/scaling/viewport.model.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
* Copyright (C) 2019 - 2024 Devexperts Solutions IE Limited
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { Subject } from 'rxjs';
import { BehaviorSubject, Subject } from 'rxjs';
import { distinctUntilChanged, map, share } from 'rxjs/operators';
import { ChartBaseElement } from '../chart-base-element';
import { ViewportMovementAnimation } from '../../animation/types/viewport-movement-animation';
Expand Down Expand Up @@ -151,10 +151,18 @@ export abstract class ViewportModel extends ChartBaseElement implements Viewable
distinctUntilChanged((p, c) => p.start === c.start && p.end === c.end),
share(),
);
public initialViewportValidSubject = new BehaviorSubject(false);
//endregion

protected doActivate(): void {
super.doActivate();

this.addRxSubscription(
this.changed.subscribe(() => {
!this.initialViewportValidSubject.getValue() &&
this.initialViewportValidSubject.next(this.isViewportValid());
}),
);
}

protected doDeactivate(): void {
Expand Down

0 comments on commit e08d646

Please sign in to comment.