@devexperts/dxcharts-lite 2.7.1 → 2.7.2
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/animation/canvas-animation.d.ts +19 -21
- package/dist/chart/animation/canvas-animation.js +19 -19
- package/dist/chart/animation/types/animation.d.ts +5 -17
- package/dist/chart/animation/types/animation.js +12 -17
- package/dist/chart/animation/types/color-alpha-animation.js +11 -21
- package/dist/chart/animation/types/viewport-movement-animation.d.ts +1 -1
- package/dist/chart/animation/viewport-model-animation.js +2 -2
- package/dist/chart/chart.config.d.ts +7 -0
- package/dist/chart/chart.config.js +4 -0
- package/dist/chart/components/chart/chart.component.d.ts +11 -0
- package/dist/chart/components/chart/chart.component.js +11 -0
- package/dist/chart/components/pane/pane.component.js +5 -1
- package/dist/chart/components/x_axis/x-axis-time-labels.drawer.js +4 -1
- package/dist/chart/components/y_axis/y-axis.component.d.ts +5 -1
- package/dist/chart/components/y_axis/y-axis.component.js +11 -5
- package/dist/chart/components/y_axis/y-axis.drawer.js +5 -3
- package/dist/chart/components/y_axis/y-axis.model.d.ts +1 -1
- package/dist/chart/drawers/chart-type-drawers/area.drawer.d.ts +2 -2
- package/dist/chart/drawers/chart-type-drawers/area.drawer.js +5 -5
- package/dist/chart/drawers/chart-type-drawers/bar.drawer.d.ts +2 -2
- package/dist/chart/drawers/chart-type-drawers/bar.drawer.js +6 -6
- package/dist/chart/drawers/chart-type-drawers/baseline.drawer.d.ts +2 -2
- package/dist/chart/drawers/chart-type-drawers/baseline.drawer.js +8 -8
- package/dist/chart/drawers/chart-type-drawers/candle.drawer.d.ts +3 -3
- package/dist/chart/drawers/chart-type-drawers/candle.drawer.js +20 -16
- package/dist/chart/drawers/chart-type-drawers/histogram.drawer.d.ts +2 -2
- package/dist/chart/drawers/chart-type-drawers/histogram.drawer.js +5 -5
- package/dist/chart/drawers/chart-type-drawers/line.drawer.d.ts +2 -2
- package/dist/chart/drawers/chart-type-drawers/line.drawer.js +5 -5
- package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.d.ts +2 -2
- package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.js +4 -3
- package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.js +2 -2
- package/dist/chart/drawers/data-series-drawers/color-candle.drawer.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/color-candle.drawer.js +4 -4
- package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.js +9 -9
- package/dist/chart/drawers/data-series-drawers/histogram.drawer.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/histogram.drawer.js +3 -3
- package/dist/chart/drawers/data-series-drawers/linear.drawer.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/linear.drawer.js +3 -3
- package/dist/chart/drawers/data-series-drawers/points.drawer.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/points.drawer.js +3 -3
- package/dist/chart/drawers/data-series-drawers/text.drawer.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/text.drawer.js +2 -2
- package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.js +16 -13
- package/dist/chart/drawers/data-series-drawers/triangle.drawer.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/triangle.drawer.js +2 -2
- package/dist/chart/drawers/data-series.drawer.d.ts +5 -5
- package/dist/chart/drawers/data-series.drawer.js +3 -3
- package/dist/chart/drawers/ht-data-series.drawer.js +2 -2
- package/dist/chart/model/scale.model.js +4 -0
- package/dist/dxchart.min.js +4 -4
- package/package.json +1 -1
|
@@ -4,18 +4,16 @@
|
|
|
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 EventBus from '../events/event-bus';
|
|
7
|
-
import { Animation } from './types/animation';
|
|
8
|
-
import { ColorAlphaAnimationConfig, ColorAlphaAnimation } from './types/color-alpha-animation';
|
|
9
|
-
import { ColorTransitionAnimationConfig, ColorTransitionAnimation } from './types/color-transition-animation';
|
|
10
|
-
import { ViewportMovementAnimationConfig, ViewportMovementAnimation } from './types/viewport-movement-animation';
|
|
11
|
-
import { ViewportModel } from '../model/scaling/viewport.model';
|
|
12
|
-
import { StringTMap } from '../utils/object.utils';
|
|
13
7
|
import { BehaviorSubject } from 'rxjs';
|
|
8
|
+
import { ViewportModel } from '../model/scaling/viewport.model';
|
|
9
|
+
import { ColorAlphaAnimation, ColorAlphaAnimationConfig } from './types/color-alpha-animation';
|
|
10
|
+
import { ColorTransitionAnimation, ColorTransitionAnimationConfig } from './types/color-transition-animation';
|
|
11
|
+
import { ViewportMovementAnimation, ViewportMovementAnimationConfig } from './types/viewport-movement-animation';
|
|
12
|
+
export declare const VIEWPORT_ANIMATION_ID = "VIEWPORT_ANIMATION";
|
|
14
13
|
export interface AnimationConfig {
|
|
15
14
|
duration: number;
|
|
16
15
|
timeLeft?: number;
|
|
17
16
|
}
|
|
18
|
-
export declare const VIEWPORT_ANIMATION_ID = "VIEWPORT_ANIMATION";
|
|
19
17
|
/**
|
|
20
18
|
* Singleton animation container for all chart animations.
|
|
21
19
|
* Does the following things:
|
|
@@ -28,10 +26,10 @@ export declare const VIEWPORT_ANIMATION_ID = "VIEWPORT_ANIMATION";
|
|
|
28
26
|
* @doc-tags chart-core,animation
|
|
29
27
|
*/
|
|
30
28
|
export declare class CanvasAnimation {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
animations: StringTMap<Animation>;
|
|
29
|
+
eventBus: EventBus;
|
|
30
|
+
animations: Record<string, any>;
|
|
34
31
|
animationInProgressSubject: BehaviorSubject<boolean>;
|
|
32
|
+
animFrameId: string;
|
|
35
33
|
constructor(eventBus: EventBus);
|
|
36
34
|
/**
|
|
37
35
|
* Starts a viewport movement animation with the given configuration and adds it to the list of animations.
|
|
@@ -41,7 +39,10 @@ export declare class CanvasAnimation {
|
|
|
41
39
|
* @param {Function} [onTickFunction] - The function to be called on each tick of the animation.
|
|
42
40
|
* @returns {ViewportMovementAnimation} The container for the created animation.
|
|
43
41
|
*/
|
|
44
|
-
startViewportMovementAnimation(viewportModel: ViewportModel, config: ViewportMovementAnimationConfig, uniqueAnimationId
|
|
42
|
+
startViewportMovementAnimation(viewportModel: ViewportModel, config: ViewportMovementAnimationConfig, uniqueAnimationId: string | undefined, onTickFunction: {
|
|
43
|
+
(): boolean;
|
|
44
|
+
(): void;
|
|
45
|
+
}): ViewportMovementAnimation;
|
|
45
46
|
/**
|
|
46
47
|
* Starts a color alpha animation with the given configuration and adds it to the list of animations.
|
|
47
48
|
* @param {string} uniqueAnimationId - A unique identifier for the animation.
|
|
@@ -50,7 +51,7 @@ export declare class CanvasAnimation {
|
|
|
50
51
|
* @param {Partial<ACAnimationConfig>} [animationConfig] - An optional configuration for the animation.
|
|
51
52
|
* @returns {ColorAlphaAnimation} - The created animation container.
|
|
52
53
|
*/
|
|
53
|
-
startColorAlphaAnimation(uniqueAnimationId: string, colorConfigs: Array<ColorAlphaAnimationConfig>, onTickFunction?: () => void, animationConfig?:
|
|
54
|
+
startColorAlphaAnimation(uniqueAnimationId: string, colorConfigs: Array<ColorAlphaAnimationConfig>, onTickFunction?: (() => void) | undefined, animationConfig?: AnimationConfig): ColorAlphaAnimation;
|
|
54
55
|
/**
|
|
55
56
|
* Starts a color transition animation with the given configurations and duration.
|
|
56
57
|
* @param {string} uniqueAnimationId - A unique identifier for the animation.
|
|
@@ -63,20 +64,20 @@ export declare class CanvasAnimation {
|
|
|
63
64
|
/**
|
|
64
65
|
* This function takes an id as a string and returns an animation container object of type T. It retrieves the animation container object from the animations object using the provided id. The @ts-ignore comment is used to ignore any TypeScript errors that may occur due to the dynamic nature of the function.
|
|
65
66
|
*/
|
|
66
|
-
getAnimation
|
|
67
|
+
getAnimation(id: string | number): any;
|
|
67
68
|
/**
|
|
68
69
|
* Returns a ColorAlphaAnimation object for the given animation ID.
|
|
69
70
|
*
|
|
70
71
|
* @param {string} id - The ID of the animation to retrieve.
|
|
71
72
|
* @returns {ColorAlphaAnimation} - The ColorAlphaAnimation object for the given ID.
|
|
72
73
|
*/
|
|
73
|
-
getColorAlphaAnimation(id: string):
|
|
74
|
+
getColorAlphaAnimation(id: string): any;
|
|
74
75
|
/**
|
|
75
76
|
* Returns a ColorTransitionAnimation object for the given id.
|
|
76
77
|
* @param {string} id - The id of the animation to retrieve.
|
|
77
78
|
* @returns {ColorTransitionAnimation} - The ColorTransitionAnimation object for the given id.
|
|
78
79
|
*/
|
|
79
|
-
getColorTransitionAnimation(id: string):
|
|
80
|
+
getColorTransitionAnimation(id: string): any;
|
|
80
81
|
/**
|
|
81
82
|
* Stops the animation with the given ID.
|
|
82
83
|
* @param {string} id - The ID of the animation to be stopped.
|
|
@@ -86,13 +87,10 @@ export declare class CanvasAnimation {
|
|
|
86
87
|
/**
|
|
87
88
|
* This method ensures that the animation interval is started. If the animation interval ID is not set, it sets it to a new interval ID using `window.setInterval()` with a callback function of `this.tick()` and a delay of 20 milliseconds.
|
|
88
89
|
*/
|
|
89
|
-
|
|
90
|
+
processAnimation(): void;
|
|
90
91
|
/**
|
|
91
92
|
* This is a private method that iterates through all the animations in the container and calls their tick method. If any animation is still in progress, it sets the allCompleted flag to false. If all animations are completed, it stops the interval. If not, it fires the draw event.
|
|
92
93
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
* Stops the interval for the animation.
|
|
96
|
-
*/
|
|
97
|
-
private stopInterval;
|
|
94
|
+
tick(): void;
|
|
95
|
+
stopInterval(): void;
|
|
98
96
|
}
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
|
+
import { BehaviorSubject } from 'rxjs';
|
|
7
|
+
import { animationFrameThrottledPrior, cancelThrottledAnimationFrame, } from '../utils/performance/request-animation-frame-throttle.utils';
|
|
8
|
+
import { uuid } from '../utils/uuid.utils';
|
|
6
9
|
import { ColorAlphaAnimation } from './types/color-alpha-animation';
|
|
7
10
|
import { ColorTransitionAnimation } from './types/color-transition-animation';
|
|
8
11
|
import { ViewportMovementAnimation } from './types/viewport-movement-animation';
|
|
9
|
-
|
|
10
|
-
const DEFAULT_ANIMATION_TIME = 10;
|
|
12
|
+
const DEFAULT_ANIMATION_TIME_MS = 400;
|
|
11
13
|
export const VIEWPORT_ANIMATION_ID = 'VIEWPORT_ANIMATION';
|
|
12
14
|
/**
|
|
13
15
|
* Singleton animation container for all chart animations.
|
|
@@ -22,9 +24,10 @@ export const VIEWPORT_ANIMATION_ID = 'VIEWPORT_ANIMATION';
|
|
|
22
24
|
*/
|
|
23
25
|
export class CanvasAnimation {
|
|
24
26
|
constructor(eventBus) {
|
|
25
|
-
this.eventBus = eventBus;
|
|
26
27
|
this.animations = {};
|
|
27
28
|
this.animationInProgressSubject = new BehaviorSubject(false);
|
|
29
|
+
this.animFrameId = `canvas_animation_${uuid()}`;
|
|
30
|
+
this.eventBus = eventBus;
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
30
33
|
* Starts a viewport movement animation with the given configuration and adds it to the list of animations.
|
|
@@ -37,7 +40,7 @@ export class CanvasAnimation {
|
|
|
37
40
|
startViewportMovementAnimation(viewportModel, config, uniqueAnimationId = VIEWPORT_ANIMATION_ID, onTickFunction) {
|
|
38
41
|
const animation = new ViewportMovementAnimation(viewportModel, config, onTickFunction);
|
|
39
42
|
this.animations[uniqueAnimationId] = animation;
|
|
40
|
-
this.
|
|
43
|
+
this.processAnimation();
|
|
41
44
|
return animation;
|
|
42
45
|
}
|
|
43
46
|
/**
|
|
@@ -49,9 +52,9 @@ export class CanvasAnimation {
|
|
|
49
52
|
* @returns {ColorAlphaAnimation} - The created animation container.
|
|
50
53
|
*/
|
|
51
54
|
startColorAlphaAnimation(uniqueAnimationId, colorConfigs, onTickFunction, animationConfig) {
|
|
52
|
-
const animation = new ColorAlphaAnimation(Object.assign(Object.assign({}, animationConfig), { duration: (animationConfig && animationConfig.duration) ||
|
|
55
|
+
const animation = new ColorAlphaAnimation(Object.assign(Object.assign({}, animationConfig), { duration: (animationConfig && animationConfig.duration) || DEFAULT_ANIMATION_TIME_MS }), colorConfigs, onTickFunction);
|
|
53
56
|
this.animations[uniqueAnimationId] = animation;
|
|
54
|
-
this.
|
|
57
|
+
this.processAnimation();
|
|
55
58
|
return animation;
|
|
56
59
|
}
|
|
57
60
|
/**
|
|
@@ -62,10 +65,10 @@ export class CanvasAnimation {
|
|
|
62
65
|
* @param {Function} [onTickFunction] - A function to be called on each tick of the animation.
|
|
63
66
|
* @returns {ColorTransitionAnimation} - The created animation container.
|
|
64
67
|
*/
|
|
65
|
-
startColorTransitionAnimation(uniqueAnimationId, colorConfigs, duration =
|
|
68
|
+
startColorTransitionAnimation(uniqueAnimationId, colorConfigs, duration = DEFAULT_ANIMATION_TIME_MS, onTickFunction) {
|
|
66
69
|
const animation = new ColorTransitionAnimation({ duration }, colorConfigs, onTickFunction);
|
|
67
70
|
this.animations[uniqueAnimationId] = animation;
|
|
68
|
-
this.
|
|
71
|
+
this.processAnimation();
|
|
69
72
|
return animation;
|
|
70
73
|
}
|
|
71
74
|
/**
|
|
@@ -100,17 +103,15 @@ export class CanvasAnimation {
|
|
|
100
103
|
forceStopAnimation(id) {
|
|
101
104
|
const animation = this.animations[id];
|
|
102
105
|
if (animation) {
|
|
103
|
-
animation.animationTimeLeft = -1;
|
|
104
106
|
animation.animationInProgress = false;
|
|
107
|
+
animation.animationStartTime = 0;
|
|
105
108
|
}
|
|
106
109
|
}
|
|
107
110
|
/**
|
|
108
111
|
* This method ensures that the animation interval is started. If the animation interval ID is not set, it sets it to a new interval ID using `window.setInterval()` with a callback function of `this.tick()` and a delay of 20 milliseconds.
|
|
109
112
|
*/
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
this.animationIntervalId = window.setInterval(() => this.tick(), 20);
|
|
113
|
-
}
|
|
113
|
+
processAnimation() {
|
|
114
|
+
animationFrameThrottledPrior(this.animFrameId, () => this.tick());
|
|
114
115
|
}
|
|
115
116
|
/**
|
|
116
117
|
* This is a private method that iterates through all the animations in the container and calls their tick method. If any animation is still in progress, it sets the allCompleted flag to false. If all animations are completed, it stops the interval. If not, it fires the draw event.
|
|
@@ -126,17 +127,16 @@ export class CanvasAnimation {
|
|
|
126
127
|
}
|
|
127
128
|
this.animationInProgressSubject.next(!allCompleted);
|
|
128
129
|
if (!allCompleted) {
|
|
129
|
-
|
|
130
|
+
queueMicrotask(() => {
|
|
131
|
+
this.processAnimation();
|
|
132
|
+
this.eventBus.fireDraw();
|
|
133
|
+
});
|
|
130
134
|
}
|
|
131
135
|
else {
|
|
132
136
|
this.stopInterval();
|
|
133
137
|
}
|
|
134
138
|
}
|
|
135
|
-
/**
|
|
136
|
-
* Stops the interval for the animation.
|
|
137
|
-
*/
|
|
138
139
|
stopInterval() {
|
|
139
|
-
|
|
140
|
-
this.animationIntervalId = undefined;
|
|
140
|
+
cancelThrottledAnimationFrame(this.animFrameId);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -4,32 +4,20 @@
|
|
|
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 { AnimationConfig } from '../canvas-animation';
|
|
7
|
-
|
|
8
|
-
tick: () => void;
|
|
9
|
-
}
|
|
7
|
+
type OnTickFunction = () => void;
|
|
10
8
|
/**
|
|
11
9
|
* Basic animation. Holds current state: inProgress, timeLeft.
|
|
12
10
|
* Additional params are useful to pass data which helps animating.
|
|
13
11
|
*/
|
|
14
|
-
export declare class Animation
|
|
15
|
-
private onTickFunction?;
|
|
12
|
+
export declare class Animation {
|
|
16
13
|
animationTime: number;
|
|
17
14
|
animationTimeLeft: number;
|
|
15
|
+
animationStartTime: number;
|
|
18
16
|
animationInProgress: boolean;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* Decrements the animation time left and executes the onTickFunction if it exists.
|
|
22
|
-
* If the animation time left reaches zero, sets the animationInProgress flag to false.
|
|
23
|
-
*/
|
|
17
|
+
onTickFunction?: OnTickFunction;
|
|
18
|
+
constructor(animationConfig: AnimationConfig, onTickFunction: OnTickFunction);
|
|
24
19
|
tick(): void;
|
|
25
|
-
/**
|
|
26
|
-
* Calculates the normalized progress of an animation.
|
|
27
|
-
* @returns {number} A value between 0 and 1 representing the progress of the animation.
|
|
28
|
-
*/
|
|
29
20
|
getProgress(): number;
|
|
30
|
-
/**
|
|
31
|
-
* Sets the animationInProgress flag to false and resets the animationTimeLeft to 0.
|
|
32
|
-
*/
|
|
33
21
|
finishAnimation(): void;
|
|
34
22
|
}
|
|
35
23
|
export {};
|
|
@@ -9,40 +9,35 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export class Animation {
|
|
11
11
|
constructor(animationConfig, onTickFunction) {
|
|
12
|
-
this.onTickFunction = onTickFunction;
|
|
13
12
|
this.animationTimeLeft = 0;
|
|
14
|
-
this.
|
|
13
|
+
this.onTickFunction = onTickFunction;
|
|
15
14
|
this.animationTime = animationConfig.duration;
|
|
16
|
-
this.
|
|
17
|
-
animationConfig.timeLeft === undefined ? animationConfig.duration : animationConfig.timeLeft;
|
|
15
|
+
this.animationStartTime = Date.now();
|
|
18
16
|
this.animationInProgress = true;
|
|
19
17
|
}
|
|
20
|
-
|
|
18
|
+
/*
|
|
21
19
|
* Decrements the animation time left and executes the onTickFunction if it exists.
|
|
22
20
|
* If the animation time left reaches zero, sets the animationInProgress flag to false.
|
|
23
21
|
*/
|
|
24
22
|
tick() {
|
|
25
|
-
|
|
23
|
+
var _a;
|
|
24
|
+
if (Date.now() > this.animationStartTime + this.animationTime) {
|
|
26
25
|
this.animationInProgress = false;
|
|
27
26
|
}
|
|
28
|
-
|
|
29
|
-
this.animationTimeLeft--;
|
|
30
|
-
}
|
|
31
|
-
this.onTickFunction && this.onTickFunction();
|
|
27
|
+
(_a = this.onTickFunction) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
32
28
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
* Calculates the normalized progress of an animation.
|
|
29
|
+
/*
|
|
30
|
+
* Gets the normalized progress of the animation.
|
|
36
31
|
* @returns {number} A value between 0 and 1 representing the progress of the animation.
|
|
37
32
|
*/
|
|
38
33
|
getProgress() {
|
|
39
|
-
return
|
|
34
|
+
return Math.min((Date.now() - this.animationStartTime) / this.animationTime, 1);
|
|
40
35
|
}
|
|
41
|
-
|
|
42
|
-
* Sets the animationInProgress flag to false and resets the
|
|
36
|
+
/*
|
|
37
|
+
* Sets the animationInProgress flag to false and resets the animationStartTime to 0.
|
|
43
38
|
*/
|
|
44
39
|
finishAnimation() {
|
|
45
40
|
this.animationInProgress = false;
|
|
46
|
-
this.
|
|
41
|
+
this.animationStartTime = 0;
|
|
47
42
|
}
|
|
48
43
|
}
|
|
@@ -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 { clamp } from '../../utils/math.utils';
|
|
6
7
|
import { Animation } from './animation';
|
|
7
8
|
import Color from 'color';
|
|
8
9
|
/**
|
|
@@ -24,19 +25,13 @@ export class ColorAlphaAnimation extends Animation {
|
|
|
24
25
|
*/
|
|
25
26
|
tick() {
|
|
26
27
|
super.tick();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
else if (config.type === 'appearing') {
|
|
36
|
-
config.currentAnimationColor = config.rgbColor.alpha(config.initialAlpha * (1 - this.animationTimeLeft / this.animationTime));
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
28
|
+
this.colorConfigs.forEach(config => {
|
|
29
|
+
if (config.initialAlpha === undefined || config.rgbColor === undefined) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const alpha = config.initialAlpha * (config.type === 'fading' ? 1 - this.getProgress() : this.getProgress());
|
|
33
|
+
config.currentAnimationColor = config.rgbColor.alpha(alpha);
|
|
34
|
+
});
|
|
40
35
|
}
|
|
41
36
|
/**
|
|
42
37
|
* Returns the color of the current animation for a given index.
|
|
@@ -51,15 +46,10 @@ export class ColorAlphaAnimation extends Animation {
|
|
|
51
46
|
* This function reverts the animation by changing the type of color configurations from 'fading' to 'appearing' and vice versa. It also ensures that the animationTimeLeft is not zero to avoid getting stuck in the middle of the animation.
|
|
52
47
|
*/
|
|
53
48
|
revert() {
|
|
54
|
-
|
|
55
|
-
this.
|
|
49
|
+
const timePassed = clamp(Date.now() - this.animationStartTime, 0, this.animationTime);
|
|
50
|
+
this.animationStartTime = Date.now() - this.animationTime + timePassed;
|
|
56
51
|
this.colorConfigs.forEach(config => {
|
|
57
|
-
|
|
58
|
-
config.type = 'appearing';
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
config.type = 'fading';
|
|
62
|
-
}
|
|
52
|
+
config.type = config.type === 'fading' ? 'appearing' : 'fading';
|
|
63
53
|
});
|
|
64
54
|
}
|
|
65
55
|
}
|
|
@@ -32,7 +32,7 @@ export declare class ViewportMovementAnimation extends Animation {
|
|
|
32
32
|
readonly zoomY: number;
|
|
33
33
|
readonly easingFn: easingFn;
|
|
34
34
|
readonly id: string;
|
|
35
|
-
constructor(viewportModel: ViewportModel, animationConfig: ViewportMovementAnimationConfig, onTickFunction
|
|
35
|
+
constructor(viewportModel: ViewportModel, animationConfig: ViewportMovementAnimationConfig, onTickFunction: () => void);
|
|
36
36
|
/**
|
|
37
37
|
* Updates the viewport model's properties based on the animation configuration and easing function. If an animation is in progress, the properties are updated based on the current progress of the animation. The updated properties include the start and end coordinates for the x and y axes, as well as the zoom level for both axes. The updated properties are then applied to the viewport model.
|
|
38
38
|
*/
|
|
@@ -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 { VIEWPORT_ANIMATION_ID } from './canvas-animation';
|
|
7
|
-
const
|
|
7
|
+
const VIEWPORT_ANIMATION_DURATION_MS = 400;
|
|
8
8
|
/**
|
|
9
9
|
* Starts the animation for chart viewport movement.
|
|
10
10
|
* @param canvasAnimation
|
|
@@ -14,7 +14,7 @@ const VIEWPORT_ANIMATION_DURATION = 20;
|
|
|
14
14
|
*/
|
|
15
15
|
export const startViewportModelAnimation = (canvasAnimation, viewportModel, state) => {
|
|
16
16
|
const animation = canvasAnimation.startViewportMovementAnimation(viewportModel, {
|
|
17
|
-
duration:
|
|
17
|
+
duration: VIEWPORT_ANIMATION_DURATION_MS,
|
|
18
18
|
targetXStart: state.xStart,
|
|
19
19
|
targetXEnd: state.xEnd,
|
|
20
20
|
targetYStart: state.yStart,
|
|
@@ -322,6 +322,13 @@ export interface ChartConfigComponentsChart {
|
|
|
322
322
|
* The maximum amount of Y axis scales on a single chart
|
|
323
323
|
*/
|
|
324
324
|
maxYAxisScalesAmount: number;
|
|
325
|
+
/**
|
|
326
|
+
* Background color will be also applied to the chart axes
|
|
327
|
+
*/
|
|
328
|
+
applyBackgroundToAxes: {
|
|
329
|
+
x: boolean;
|
|
330
|
+
y: boolean;
|
|
331
|
+
};
|
|
325
332
|
sortCandles?: (candles: Candle[]) => Candle[];
|
|
326
333
|
}
|
|
327
334
|
export interface ChartConfigComponentsEvents {
|
|
@@ -132,6 +132,17 @@ export declare class ChartComponent extends ChartBaseElement {
|
|
|
132
132
|
* @returns {void}
|
|
133
133
|
*/
|
|
134
134
|
setShowWicks(isShow: boolean): void;
|
|
135
|
+
/**
|
|
136
|
+
* Sets the options for the background color applying to the chart axes
|
|
137
|
+
* @param {Object} options - options for both axes
|
|
138
|
+
* @param {boolean} options.x - should the background color apply to the x axis
|
|
139
|
+
* @param {boolean} options.y - should the background color apply to the y axis
|
|
140
|
+
* @returns {void}
|
|
141
|
+
*/
|
|
142
|
+
setApplyBackgroundToAxes(options: {
|
|
143
|
+
x: boolean;
|
|
144
|
+
y: boolean;
|
|
145
|
+
}): void;
|
|
135
146
|
/**
|
|
136
147
|
* Used to set the main series to chart.
|
|
137
148
|
* @param series
|
|
@@ -228,6 +228,17 @@ export class ChartComponent extends ChartBaseElement {
|
|
|
228
228
|
this.config.components.chart.showWicks = isShow;
|
|
229
229
|
this.canvasModel.fireDraw();
|
|
230
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Sets the options for the background color applying to the chart axes
|
|
233
|
+
* @param {Object} options - options for both axes
|
|
234
|
+
* @param {boolean} options.x - should the background color apply to the x axis
|
|
235
|
+
* @param {boolean} options.y - should the background color apply to the y axis
|
|
236
|
+
* @returns {void}
|
|
237
|
+
*/
|
|
238
|
+
setApplyBackgroundToAxes(options) {
|
|
239
|
+
this.config.components.chart.applyBackgroundToAxes = Object.assign({}, options);
|
|
240
|
+
this.chartModel.bus.fireDraw();
|
|
241
|
+
}
|
|
231
242
|
/**
|
|
232
243
|
* Used to set the main series to chart.
|
|
233
244
|
* @param series
|
|
@@ -151,7 +151,11 @@ export class PaneComponent extends ChartBaseElement {
|
|
|
151
151
|
extentComponents.forEach(extentComponent => extentComponent.disable());
|
|
152
152
|
this.yExtentComponents = this.yExtentComponents.filter(current => !extentComponents.map(excluded => excluded.idx).includes(current.idx));
|
|
153
153
|
// re-index extents
|
|
154
|
-
this.yExtentComponents.forEach((c, idx) =>
|
|
154
|
+
this.yExtentComponents.forEach((c, idx) => {
|
|
155
|
+
c.yAxis.setExtentIdx(idx);
|
|
156
|
+
c.idx = idx;
|
|
157
|
+
c.yAxis.updateCursor();
|
|
158
|
+
});
|
|
155
159
|
this.canvasBoundsContainer.updateYAxisWidths();
|
|
156
160
|
this.yExtentComponentsChangedSubject.next();
|
|
157
161
|
}
|
|
@@ -35,7 +35,10 @@ export class XAxisTimeLabelsDrawer {
|
|
|
35
35
|
ctx.font = font;
|
|
36
36
|
ctx.fillStyle = xAxisColors.backgroundColor;
|
|
37
37
|
const bounds = this.canvasBoundsContainer.getBounds(CanvasElement.X_AXIS);
|
|
38
|
-
|
|
38
|
+
// draw axis background rect if the background color is not used
|
|
39
|
+
if (!this.config.components.chart.applyBackgroundToAxes.x) {
|
|
40
|
+
ctx.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
|
|
41
|
+
}
|
|
39
42
|
const color = this.config.colors.xAxis.labelTextColor;
|
|
40
43
|
const labels = this.labelsProvider();
|
|
41
44
|
this.drawLabels(ctx, labels, bounds, color, fontHeight, fontFamily, offsetTop + X_AXIS_MOBILE_PADDING / 2);
|
|
@@ -32,10 +32,13 @@ export declare class YAxisComponent extends ChartBaseElement {
|
|
|
32
32
|
private config;
|
|
33
33
|
private canvasModel;
|
|
34
34
|
scale: ScaleModel;
|
|
35
|
+
private canvasInputListeners;
|
|
35
36
|
private canvasBoundsContainer;
|
|
37
|
+
private chartPanComponent;
|
|
36
38
|
private cursors;
|
|
37
39
|
paneUUID: string;
|
|
38
40
|
extentIdx: number;
|
|
41
|
+
private hitTestCanvasModel;
|
|
39
42
|
private chartResizeHandler;
|
|
40
43
|
private labelsColorByChartTypeMap;
|
|
41
44
|
yAxisScaleHandler: YAxisScaleHandler;
|
|
@@ -44,6 +47,7 @@ export declare class YAxisComponent extends ChartBaseElement {
|
|
|
44
47
|
axisAlignSetSubject: Subject<YAxisAlign>;
|
|
45
48
|
readonly state: YAxisConfig;
|
|
46
49
|
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
|
+
setExtentIdx(extentIdx: number): void;
|
|
47
51
|
/**
|
|
48
52
|
* Registers default label color resolvers for different chart types.
|
|
49
53
|
* @private
|
|
@@ -53,7 +57,7 @@ export declare class YAxisComponent extends ChartBaseElement {
|
|
|
53
57
|
*/
|
|
54
58
|
private registerDefaultLabelColorResolvers;
|
|
55
59
|
protected doActivate(): void;
|
|
56
|
-
|
|
60
|
+
updateCursor(): void;
|
|
57
61
|
/**
|
|
58
62
|
* Updates labels visual appearance on canvas
|
|
59
63
|
*/
|
|
@@ -3,11 +3,6 @@
|
|
|
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
|
-
/*
|
|
7
|
-
* Copyright (C) 2019 - 2024 Devexperts Solutions IE Limited
|
|
8
|
-
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
9
|
-
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
10
|
-
*/
|
|
11
6
|
import { Subject } from 'rxjs';
|
|
12
7
|
import { CanvasElement } from '../../canvas/canvas-bounds-container';
|
|
13
8
|
import { ChartBaseElement } from '../../model/chart-base-element';
|
|
@@ -28,10 +23,13 @@ export class YAxisComponent extends ChartBaseElement {
|
|
|
28
23
|
this.config = config;
|
|
29
24
|
this.canvasModel = canvasModel;
|
|
30
25
|
this.scale = scale;
|
|
26
|
+
this.canvasInputListeners = canvasInputListeners;
|
|
31
27
|
this.canvasBoundsContainer = canvasBoundsContainer;
|
|
28
|
+
this.chartPanComponent = chartPanComponent;
|
|
32
29
|
this.cursors = cursors;
|
|
33
30
|
this.paneUUID = paneUUID;
|
|
34
31
|
this.extentIdx = extentIdx;
|
|
32
|
+
this.hitTestCanvasModel = hitTestCanvasModel;
|
|
35
33
|
this.chartResizeHandler = chartResizeHandler;
|
|
36
34
|
this.labelsColorByChartTypeMap = {};
|
|
37
35
|
this.axisTypeSetSubject = new Subject();
|
|
@@ -62,6 +60,14 @@ export class YAxisComponent extends ChartBaseElement {
|
|
|
62
60
|
this.updateCursor();
|
|
63
61
|
this.registerDefaultLabelColorResolvers();
|
|
64
62
|
}
|
|
63
|
+
setExtentIdx(extentIdx) {
|
|
64
|
+
this.extentIdx = extentIdx;
|
|
65
|
+
this.model.extentIdx = extentIdx;
|
|
66
|
+
this.yAxisScaleHandler.deactivate();
|
|
67
|
+
this.removeChildEntity(this.yAxisScaleHandler);
|
|
68
|
+
this.yAxisScaleHandler = new YAxisScaleHandler(this.eventBus, this.state, this.chartPanComponent, this.scale, this.canvasInputListeners, this.canvasBoundsContainer, this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.PANE_UUID_Y_AXIS(this.paneUUID, extentIdx)), this.hitTestCanvasModel);
|
|
69
|
+
this.addChildEntity(this.yAxisScaleHandler);
|
|
70
|
+
}
|
|
65
71
|
/**
|
|
66
72
|
* Registers default label color resolvers for different chart types.
|
|
67
73
|
* @private
|
|
@@ -30,9 +30,11 @@ export class YAxisDrawer {
|
|
|
30
30
|
const labels = yAxisComponent.model.baseLabelsModel.labels;
|
|
31
31
|
const bounds = yAxisComponent.getBounds();
|
|
32
32
|
const ctx = this.canvasModel.ctx;
|
|
33
|
-
// draw axis background rect
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
// draw axis background rect if the background color is not used
|
|
34
|
+
if (!this.fullConfig.components.chart.applyBackgroundToAxes.y) {
|
|
35
|
+
ctx.fillStyle = this.getBackgroundColor();
|
|
36
|
+
ctx.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
|
|
37
|
+
}
|
|
36
38
|
const font = getFontFromConfig(yAxisComponent.state);
|
|
37
39
|
const fontHeight = calculateSymbolHeight(font, ctx);
|
|
38
40
|
const textColor = this.getLabelTextColor();
|
|
@@ -18,7 +18,7 @@ export declare class YAxisModel extends ChartBaseElement {
|
|
|
18
18
|
private paneUUID;
|
|
19
19
|
private state;
|
|
20
20
|
private canvasBoundsContainer;
|
|
21
|
-
|
|
21
|
+
extentIdx: number;
|
|
22
22
|
labelsGenerator: NumericYAxisLabelsGenerator;
|
|
23
23
|
baseLabelsModel: YAxisBaseLabelsModel;
|
|
24
24
|
fancyLabelsModel: FancyYAxisLabelsModel;
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { ChartConfigComponentsChart } from '../../chart.config';
|
|
7
7
|
import { DataSeriesModel, VisualSeriesPoint } from '../../model/data-series.model';
|
|
8
|
-
import {
|
|
8
|
+
import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
|
|
9
9
|
export declare class AreaDrawer implements SeriesDrawer {
|
|
10
10
|
private config;
|
|
11
11
|
constructor(config: ChartConfigComponentsChart);
|
|
12
|
-
draw(ctx: CanvasRenderingContext2D, points: VisualSeriesPoint[][], model: DataSeriesModel,
|
|
12
|
+
draw(ctx: CanvasRenderingContext2D, points: VisualSeriesPoint[][], model: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
|
|
13
13
|
}
|
|
@@ -10,15 +10,15 @@ export class AreaDrawer {
|
|
|
10
10
|
constructor(config) {
|
|
11
11
|
this.config = config;
|
|
12
12
|
}
|
|
13
|
-
draw(ctx, points, model,
|
|
13
|
+
draw(ctx, points, model, hitTestDrawerConfig) {
|
|
14
14
|
if (model instanceof CandleSeriesModel) {
|
|
15
15
|
// @ts-ignore
|
|
16
16
|
const visualCandles = flat(points);
|
|
17
17
|
if (visualCandles.length === 0) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
if (
|
|
21
|
-
ctx.strokeStyle =
|
|
20
|
+
if (hitTestDrawerConfig.color) {
|
|
21
|
+
ctx.strokeStyle = hitTestDrawerConfig.color;
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
24
|
ctx.strokeStyle = model.colors.areaTheme.lineColor;
|
|
@@ -51,8 +51,8 @@ export class AreaDrawer {
|
|
|
51
51
|
ctx.lineTo(floor(firstLineX), bottomY);
|
|
52
52
|
ctx.closePath();
|
|
53
53
|
let fillColor;
|
|
54
|
-
if (
|
|
55
|
-
ctx.fillStyle =
|
|
54
|
+
if (hitTestDrawerConfig.color) {
|
|
55
|
+
ctx.fillStyle = hitTestDrawerConfig.color;
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
58
|
ctx.fillStyle =
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { ChartConfigComponentsChart } from '../../chart.config';
|
|
7
7
|
import { DataSeriesModel, VisualSeriesPoint } from '../../model/data-series.model';
|
|
8
|
-
import {
|
|
8
|
+
import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
|
|
9
9
|
export declare class BarDrawer implements SeriesDrawer {
|
|
10
10
|
private config;
|
|
11
11
|
constructor(config: ChartConfigComponentsChart);
|
|
12
12
|
private setFillStyle;
|
|
13
|
-
draw(ctx: CanvasRenderingContext2D, points: VisualSeriesPoint[][], candleSeries: DataSeriesModel,
|
|
13
|
+
draw(ctx: CanvasRenderingContext2D, points: VisualSeriesPoint[][], candleSeries: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
|
|
14
14
|
}
|