@devexperts/dxcharts-lite 2.7.23 → 2.7.24
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/components/chart/candle.functions.js +1 -0
- package/dist/chart/components/volumes/volumes.drawer.js +17 -3
- package/dist/chart/components/volumes/volumes.model.js +3 -1
- package/dist/chart/model/candle.model.d.ts +1 -0
- package/dist/chart/model/candle.model.js +2 -1
- package/dist/chart/utils/types.utils.d.ts +6 -0
- package/dist/dxchart.min.js +4 -4
- package/package.json +1 -1
|
@@ -86,14 +86,20 @@ export class VolumesDrawer {
|
|
|
86
86
|
if (volumeMax === 0) {
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
+
const viewportModel = this.getViewportModel();
|
|
90
|
+
if (!viewportModel.isViewportValid()) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
89
93
|
const candles = flat(this.chartModel.mainCandleSeries
|
|
90
94
|
// TODO volumes drawer should be a part of data series drawer
|
|
91
95
|
.getSeriesInViewport(this.chartModel.scale.xStart - 1, this.chartModel.scale.xEnd + 1));
|
|
92
|
-
const viewportModel = this.getViewportModel();
|
|
93
96
|
candles.forEach((vCandle, idx) => {
|
|
94
97
|
if (vCandle.candle.volume) {
|
|
95
98
|
const bounds = viewportModel.getBounds();
|
|
96
99
|
const fullVHeight = bounds.height;
|
|
100
|
+
if (fullVHeight <= 0) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
97
103
|
const nextX = candles[idx + 1] !== undefined
|
|
98
104
|
? floorToDPR(viewportModel.toX(candles[idx + 1].startUnit))
|
|
99
105
|
: undefined;
|
|
@@ -105,8 +111,16 @@ export class VolumesDrawer {
|
|
|
105
111
|
this.drawVolume(canvasModel, vCandle, x, y, width, height);
|
|
106
112
|
}
|
|
107
113
|
else {
|
|
108
|
-
const
|
|
109
|
-
|
|
114
|
+
const volumeHeightDivisor = fullVHeight / OVERLAY_VOLUME_TOTAL_HEIGHT_DIVISOR;
|
|
115
|
+
if (volumeHeightDivisor <= 0) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const zoomY = volumeMax / volumeHeightDivisor;
|
|
119
|
+
if (!isFinite(zoomY) || zoomY <= 0) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const calculatedHeight = Math.max(ceilToDPR(unitToPixels(vCandle.candle.volume, zoomY)), 2);
|
|
123
|
+
const height = Math.min(calculatedHeight, fullVHeight);
|
|
110
124
|
const y = floorToDPR(bounds.y + fullVHeight - height);
|
|
111
125
|
this.drawVolume(canvasModel, vCandle, x, y, width, height);
|
|
112
126
|
}
|
|
@@ -50,6 +50,8 @@ export class VolumesModel extends ChartBaseElement {
|
|
|
50
50
|
*/
|
|
51
51
|
updateVolumeMax() {
|
|
52
52
|
var _a;
|
|
53
|
-
|
|
53
|
+
// Use the same parameters as in drawer to ensure volumeMax is calculated from the same candles that will be drawn
|
|
54
|
+
const candles = this.chartComponent.chartModel.mainCandleSeries.getSeriesInViewport(this.scale.xStart - 1, this.scale.xEnd + 1);
|
|
55
|
+
this.volumeMax.next((_a = firstOf(volumeMaxMinFn(candles.flat()))) !== null && _a !== void 0 ? _a : 0);
|
|
54
56
|
}
|
|
55
57
|
}
|
|
@@ -50,7 +50,7 @@ export function hollowDirection(open, close) {
|
|
|
50
50
|
* @returns {Candle} A new Candle object with the same properties as the base object, with the option to modify the prices.
|
|
51
51
|
*/
|
|
52
52
|
export function copyCandle(base, idx, pricesAsClose = false) {
|
|
53
|
-
const { id, expansion, impVolatility, vwap, typicalPrice, volume, timestamp } = base;
|
|
53
|
+
const { id, expansion, impVolatility, openInterest, vwap, typicalPrice, volume, timestamp } = base;
|
|
54
54
|
let hi = base.hi;
|
|
55
55
|
let lo = base.lo;
|
|
56
56
|
let open = base.open;
|
|
@@ -75,6 +75,7 @@ export function copyCandle(base, idx, pricesAsClose = false) {
|
|
|
75
75
|
expansion,
|
|
76
76
|
idx: _idx,
|
|
77
77
|
impVolatility,
|
|
78
|
+
openInterest,
|
|
78
79
|
vwap,
|
|
79
80
|
typicalPrice,
|
|
80
81
|
};
|
|
@@ -7,3 +7,9 @@ export type Mutable<T> = {
|
|
|
7
7
|
-readonly [P in keyof T]: T[P];
|
|
8
8
|
};
|
|
9
9
|
export type PartialExcept<T, K extends keyof T> = Partial<Omit<T, K>> & Pick<T, K>;
|
|
10
|
+
export type RequiredKeys<T> = {
|
|
11
|
+
[K in keyof T]-?: undefined extends T[K] ? never : K;
|
|
12
|
+
}[keyof T];
|
|
13
|
+
export type OptionalKeys<T> = {
|
|
14
|
+
[K in keyof T]-?: undefined extends T[K] ? K : never;
|
|
15
|
+
}[keyof T];
|