@devexperts/dxcharts-lite 2.5.7 → 2.6.0
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/__tests__/chart.test.js +5 -5
- package/dist/chart/__tests__/env.js +1 -1
- package/dist/chart/bootstrap.js +2 -2
- package/dist/chart/canvas/canvas-bounds-container.js +24 -3
- package/dist/chart/chart.config.d.ts +2 -0
- package/dist/chart/chart.config.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/candle-transformer.functions.js +1 -1
- package/dist/chart/components/chart/candle.functions.d.ts +1 -1
- package/dist/chart/components/chart/candle.functions.js +3 -2
- package/dist/chart/components/chart/chart.component.d.ts +29 -8
- package/dist/chart/components/chart/chart.component.js +33 -4
- package/dist/chart/components/chart/chart.model.d.ts +42 -5
- package/dist/chart/components/chart/chart.model.js +99 -19
- package/dist/chart/components/chart/fake-candles.js +2 -0
- package/dist/chart/components/chart/fake-visual-candle.d.ts +4 -4
- package/dist/chart/components/chart/fake-visual-candle.js +4 -4
- package/dist/chart/components/pane/pane.component.js +3 -3
- package/dist/chart/components/volumes/separate-volumes.component.d.ts +1 -3
- package/dist/chart/components/volumes/separate-volumes.component.js +1 -3
- package/dist/chart/components/volumes/volumes.component.js +1 -1
- package/dist/chart/components/volumes/volumes.drawer.js +3 -3
- package/dist/chart/components/watermark/water-mark.component.d.ts +3 -12
- package/dist/chart/components/watermark/water-mark.component.js +1 -1
- package/dist/chart/components/x_axis/time/parser/time-formats-parser.functions.js +1 -1
- 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.js +2 -2
- package/dist/chart/components/x_axis/x-axis.component.js +1 -1
- package/dist/chart/components/y_axis/y-axis-scale.handler.js +3 -3
- package/dist/chart/drawers/drawing-manager.d.ts +1 -1
- package/dist/chart/drawers/drawing-manager.js +0 -1
- package/dist/chart/inputhandlers/hover-producer.component.js +8 -2
- package/dist/chart/inputhandlers/main-canvas-touch.handler.js +1 -1
- package/dist/chart/model/candle.model.d.ts +3 -0
- package/dist/chart/model/candle.model.js +7 -1
- package/dist/chart/model/data-series.model.d.ts +3 -3
- package/dist/chart/model/data-series.model.js +1 -1
- package/dist/chart/model/scale.model.js +1 -1
- package/dist/chart/model/scaling/viewport.model.d.ts +2 -1
- package/dist/chart/model/scaling/viewport.model.js +6 -1
- package/dist/chart/model/time-zone.model.js +1 -3
- package/dist/chart/utils/candles-generator-ts.utils.d.ts +1 -0
- package/dist/chart/utils/candles-generator.utils.d.ts +1 -0
- package/dist/chart/utils/candles-generator.utils.js +2 -0
- package/dist/chart/utils/string.utils.d.ts +6 -0
- package/dist/chart/utils/string.utils.js +19 -0
- package/dist/chart/utils/types.utils.d.ts +9 -0
- package/dist/chart/utils/types.utils.js +6 -0
- package/dist/dxchart.min.js +4 -4
- package/package.json +1 -1
|
@@ -3,9 +3,14 @@
|
|
|
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 { hashCode } from '../utils/string.utils';
|
|
6
7
|
// Has no specific rule, just any number to use in units calculation.
|
|
7
8
|
// 1 - because why not? Easy to debug.
|
|
8
9
|
export const BASIC_CANDLE_WIDTH = 1;
|
|
10
|
+
export const defaultSortCandles = (candles) => candles.slice().sort((a, b) => (a.timestamp === b.timestamp ? 0 : a.timestamp > b.timestamp ? 1 : -1));
|
|
11
|
+
export const generateCandleId = (timestamp, hashValue) => {
|
|
12
|
+
return `${timestamp}_${hashCode(hashValue.toString())}`;
|
|
13
|
+
};
|
|
9
14
|
/**
|
|
10
15
|
* Provides the name of candle difference
|
|
11
16
|
* @param {Number} open
|
|
@@ -45,7 +50,7 @@ export function hollowDirection(open, close) {
|
|
|
45
50
|
* @returns {Candle} A new Candle object with the same properties as the base object, with the option to modify the prices.
|
|
46
51
|
*/
|
|
47
52
|
export function copyCandle(base, idx, pricesAsClose = false) {
|
|
48
|
-
const { expansion, impVolatility, vwap, volume, timestamp } = base;
|
|
53
|
+
const { id, expansion, impVolatility, vwap, volume, timestamp } = base;
|
|
49
54
|
let hi = base.hi;
|
|
50
55
|
let lo = base.lo;
|
|
51
56
|
let open = base.open;
|
|
@@ -60,6 +65,7 @@ export function copyCandle(base, idx, pricesAsClose = false) {
|
|
|
60
65
|
_idx = idx;
|
|
61
66
|
}
|
|
62
67
|
return {
|
|
68
|
+
id,
|
|
63
69
|
hi,
|
|
64
70
|
lo,
|
|
65
71
|
open,
|
|
@@ -11,7 +11,7 @@ import { DataSeriesView } from './data-series-view';
|
|
|
11
11
|
import { DataSeriesConfig, DataSeriesPaintConfig, DataSeriesType } from './data-series.config';
|
|
12
12
|
import { HighLowWithIndex, ScaleModel } from './scale.model';
|
|
13
13
|
import { HighLowProvider } from './scaling/auto-scale.model';
|
|
14
|
-
import { Index, Unit, Viewable } from './scaling/viewport.model';
|
|
14
|
+
import { Index, Pixel, Unit, Viewable } from './scaling/viewport.model';
|
|
15
15
|
/**
|
|
16
16
|
* Properties are named in order to match VisualCandle interface
|
|
17
17
|
*/
|
|
@@ -22,11 +22,11 @@ export declare class VisualSeriesPoint {
|
|
|
22
22
|
/**
|
|
23
23
|
* returns y coordinate in pixels
|
|
24
24
|
*/
|
|
25
|
-
y(viewable: Viewable):
|
|
25
|
+
y(viewable: Viewable): Pixel;
|
|
26
26
|
/**
|
|
27
27
|
* returns x coordinate in pixels
|
|
28
28
|
*/
|
|
29
|
-
x(viewable: Viewable):
|
|
29
|
+
x(viewable: Viewable): Pixel;
|
|
30
30
|
clone(): VisualSeriesPoint;
|
|
31
31
|
}
|
|
32
32
|
export interface DataSeriesPoint {
|
|
@@ -30,7 +30,7 @@ export class VisualSeriesPoint {
|
|
|
30
30
|
* returns x coordinate in pixels
|
|
31
31
|
*/
|
|
32
32
|
x(viewable) {
|
|
33
|
-
return
|
|
33
|
+
return viewable.toX(this.centerUnit);
|
|
34
34
|
}
|
|
35
35
|
clone() {
|
|
36
36
|
return new VisualSeriesPoint(this.centerUnit, this.close);
|
|
@@ -125,7 +125,7 @@ export class ScaleModel extends ViewportModel {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
zoomXTo(state, zoomIn, forceNoAnimation) {
|
|
128
|
-
const initialStateCopy =
|
|
128
|
+
const initialStateCopy = this.export();
|
|
129
129
|
const constrainedState = this.scalePostProcessor(initialStateCopy, state);
|
|
130
130
|
this.zoomReached = this.calculateZoomReached(constrainedState.zoomX, zoomIn);
|
|
131
131
|
if (this.zoomReached.zoomIn || this.zoomReached.zoomOut) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
|
-
import { Subject } from 'rxjs';
|
|
6
|
+
import { BehaviorSubject, Subject } from 'rxjs';
|
|
7
7
|
import { ChartBaseElement } from '../chart-base-element';
|
|
8
8
|
import { ViewportMovementAnimation } from '../../animation/types/viewport-movement-animation';
|
|
9
9
|
import { Bounds } from '../bounds.model';
|
|
@@ -92,6 +92,7 @@ export declare abstract class ViewportModel extends ChartBaseElement implements
|
|
|
92
92
|
start: number;
|
|
93
93
|
end: number;
|
|
94
94
|
}>;
|
|
95
|
+
initialViewportValidSubject: BehaviorSubject<boolean>;
|
|
95
96
|
protected doActivate(): void;
|
|
96
97
|
protected doDeactivate(): void;
|
|
97
98
|
/**
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
|
-
import { Subject } from 'rxjs';
|
|
6
|
+
import { BehaviorSubject, Subject } from 'rxjs';
|
|
7
7
|
import { distinctUntilChanged, map, share } from 'rxjs/operators';
|
|
8
8
|
import { ChartBaseElement } from '../chart-base-element';
|
|
9
9
|
import { keys } from '../../utils/object.utils';
|
|
@@ -50,10 +50,15 @@ export class ViewportModel extends ChartBaseElement {
|
|
|
50
50
|
start: this.yStart,
|
|
51
51
|
end: this.yEnd,
|
|
52
52
|
})), distinctUntilChanged((p, c) => p.start === c.start && p.end === c.end), share());
|
|
53
|
+
this.initialViewportValidSubject = new BehaviorSubject(false);
|
|
53
54
|
}
|
|
54
55
|
//endregion
|
|
55
56
|
doActivate() {
|
|
56
57
|
super.doActivate();
|
|
58
|
+
this.addRxSubscription(this.changed.subscribe(() => {
|
|
59
|
+
!this.initialViewportValidSubject.getValue() &&
|
|
60
|
+
this.initialViewportValidSubject.next(this.isViewportValid());
|
|
61
|
+
}));
|
|
57
62
|
}
|
|
58
63
|
doDeactivate() {
|
|
59
64
|
super.doDeactivate();
|
|
@@ -87,9 +87,7 @@ export class TimeZoneModel {
|
|
|
87
87
|
// In JS Date object is created with local tz offset,
|
|
88
88
|
// so we have to subtract localOffset from current time
|
|
89
89
|
return time => {
|
|
90
|
-
return new Date(time +
|
|
91
|
-
getTimezoneOffset(timezone, time) +
|
|
92
|
-
new Date(time).getTimezoneOffset() * timeMultiplier);
|
|
90
|
+
return new Date(time + getTimezoneOffset(timezone, time) + new Date(time).getTimezoneOffset() * timeMultiplier);
|
|
93
91
|
};
|
|
94
92
|
}
|
|
95
93
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/* eslint-disable */
|
|
7
7
|
'use strict';
|
|
8
|
+
import { generateCandleId } from '../model/candle.model';
|
|
8
9
|
export default function generateCandlesData(config) {
|
|
9
10
|
// default generation config
|
|
10
11
|
config = config || {};
|
|
@@ -78,6 +79,7 @@ function generateRandomCandle(from, to, candleAvgSize, type) {
|
|
|
78
79
|
var high = Math.max(open, close) + Math.random() * candleAvgSize * 0.2;
|
|
79
80
|
var low = Math.min(open, close) - Math.random() * candleAvgSize * 0.2;
|
|
80
81
|
return {
|
|
82
|
+
id: generateCandleId(0, high + low + open + close),
|
|
81
83
|
hi: high,
|
|
82
84
|
lo: low,
|
|
83
85
|
open: open,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2019 - 2024 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 function hashCode(str: string): number;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2019 - 2024 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 function hashCode(str) {
|
|
7
|
+
let hash = 0;
|
|
8
|
+
if (str.length === 0) {
|
|
9
|
+
return hash;
|
|
10
|
+
}
|
|
11
|
+
for (let i = 0; i < str.length; i++) {
|
|
12
|
+
const chr = str.charCodeAt(i);
|
|
13
|
+
// eslint-disable-next-line no-bitwise
|
|
14
|
+
hash = (hash << 5) - hash + chr;
|
|
15
|
+
// eslint-disable-next-line no-bitwise
|
|
16
|
+
hash |= 0; // Convert to 32bit integer
|
|
17
|
+
}
|
|
18
|
+
return hash;
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2019 - 2024 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 type Mutable<T> = {
|
|
7
|
+
-readonly [P in keyof T]: T[P];
|
|
8
|
+
};
|
|
9
|
+
export type PartialExcept<T, K extends keyof T> = Partial<Omit<T, K>> & Pick<T, K>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2019 - 2024 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 {};
|