@devexperts/dxcharts-lite
Advanced tools
Comparing version 2.5.4 to 2.5.5
@@ -13,3 +13,3 @@ /* | ||
*/ | ||
export declare const prepareCandle: (candle: PartialCandle) => Candle; | ||
export declare const prepareCandle: (candle: PartialCandle) => Candle | undefined; | ||
/** | ||
@@ -21,1 +21,2 @@ * Adds index to candles according to their array index. | ||
export declare const deleteCandlesIndex: (candles: Array<Candle>) => void; | ||
export declare const isCandle: (value: Candle | undefined) => value is Candle; |
@@ -14,23 +14,29 @@ /* | ||
var _a; | ||
const settlementPrice = finite(candle.close, candle.open, candle.hi, candle.lo); | ||
if (!isFinite(settlementPrice)) { | ||
throw new Error('Received candle without any price'); | ||
try { | ||
const settlementPrice = finite(candle.close, candle.open, candle.hi, candle.lo); | ||
if (!isFinite(settlementPrice)) { | ||
throw new Error('Received candle without any price'); | ||
} | ||
// @ts-ignore | ||
const preparedCandleHi = finite(candle.hi, Math.max(candle.open, candle.close), settlementPrice); | ||
// @ts-ignore | ||
const preparedCandleLo = finite(candle.lo, Math.min(candle.open, candle.close), settlementPrice); | ||
const preparedCandleOpen = finite(candle.open, candle.lo, settlementPrice); | ||
const preparedCandleClose = finite(candle.close, candle.hi, settlementPrice); | ||
return { | ||
hi: preparedCandleHi, | ||
lo: preparedCandleLo, | ||
open: preparedCandleOpen, | ||
close: preparedCandleClose, | ||
timestamp: candle.timestamp, | ||
volume: (_a = candle.volume) !== null && _a !== void 0 ? _a : 0, | ||
expansion: candle.expansion, | ||
idx: candle.idx, | ||
impVolatility: candle.impVolatility, | ||
}; | ||
} | ||
// @ts-ignore | ||
const preparedCandleHi = finite(candle.hi, Math.max(candle.open, candle.close), settlementPrice); | ||
// @ts-ignore | ||
const preparedCandleLo = finite(candle.lo, Math.min(candle.open, candle.close), settlementPrice); | ||
const preparedCandleOpen = finite(candle.open, candle.lo, settlementPrice); | ||
const preparedCandleClose = finite(candle.close, candle.hi, settlementPrice); | ||
return { | ||
hi: preparedCandleHi, | ||
lo: preparedCandleLo, | ||
open: preparedCandleOpen, | ||
close: preparedCandleClose, | ||
timestamp: candle.timestamp, | ||
volume: (_a = candle.volume) !== null && _a !== void 0 ? _a : 0, | ||
expansion: candle.expansion, | ||
idx: candle.idx, | ||
impVolatility: candle.impVolatility, | ||
}; | ||
catch (e) { | ||
console.warn(e); | ||
return; | ||
} | ||
}; | ||
@@ -51,1 +57,2 @@ /** | ||
}; | ||
export const isCandle = (value) => value !== undefined; |
@@ -103,2 +103,3 @@ /* | ||
paneId: series.extentComponent.paneUUID, | ||
parentId: series.parentId, | ||
model: series, | ||
@@ -105,0 +106,0 @@ drawer: this.dataSeriesDrawer, |
@@ -23,3 +23,3 @@ /* | ||
import { calculateCandleWidth } from './candle-width-calculator.functions'; | ||
import { deleteCandlesIndex, prepareCandle, reindexCandles } from './candle.functions'; | ||
import { deleteCandlesIndex, isCandle, prepareCandle, reindexCandles } from './candle.functions'; | ||
import { ChartInstrument } from './chart.component'; | ||
@@ -166,5 +166,5 @@ import { fakeCandle } from './fake-candles'; | ||
setSecondaryCandleSeries(candles, instrument = this.mainCandleSeries.instrument, recalculateAndUpdate = true) { | ||
const prepareCandleCandles = sortCandles(candles.map(prepareCandle)); | ||
const preparedCandles = prepareCandles(candles); | ||
// set correct indexes based on main candles timestamp | ||
const reindexCandles = this.reindexCandlesBasedOnSeries(this.mainCandleSeries.dataPoints, prepareCandleCandles); | ||
const reindexCandles = this.reindexCandlesBasedOnSeries(this.mainCandleSeries.dataPoints, preparedCandles); | ||
// ensure there are no gaps in new candles | ||
@@ -203,6 +203,6 @@ const secondaryCandles = this.secondarySeriesAdjustments(this.mainCandleSeries.dataPoints, reindexCandles); | ||
this.rememberCurrentTimeframe(); | ||
const prepareCandleCandles = sortCandles(mainSeries.candles.map(prepareCandle)); | ||
const preparedCandles = prepareCandles(mainSeries.candles); | ||
this.mainCandleSeries.clearData(); | ||
reindexCandles(prepareCandleCandles); | ||
this.mainCandleSeries.dataPoints = prepareCandleCandles; | ||
reindexCandles(preparedCandles); | ||
this.mainCandleSeries.dataPoints = preparedCandles; | ||
// deactivate deleted series | ||
@@ -288,3 +288,3 @@ this.secondaryCandleSeries | ||
} | ||
const preparedCandles = sortCandles(mainSeries.candles.map(prepareCandle)); | ||
const preparedCandles = prepareCandles(mainSeries.candles); | ||
const updateResult = updateCandles(this.mainCandleSeries.dataPoints, preparedCandles); | ||
@@ -297,3 +297,3 @@ const updatedCandles = updateResult.candles; | ||
var _a, _b, _c, _d; | ||
const preparedCandles = sortCandles(series.candles.map(prepareCandle)); | ||
const preparedCandles = prepareCandles(series.candles); | ||
const updatedCandles = updateCandles((_d = (_c = this.findSecondarySeriesBySymbol((_b = (_a = series.instrument) === null || _a === void 0 ? void 0 : _a.symbol) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.dataPoints) !== null && _d !== void 0 ? _d : [], preparedCandles).candles; | ||
@@ -940,2 +940,3 @@ return this.setSecondaryCandleSeries(updatedCandles, series.instrument, false); | ||
const sortCandles = (candles) => candles.slice().sort((a, b) => (a.timestamp === b.timestamp ? 0 : a.timestamp > b.timestamp ? 1 : -1)); | ||
const prepareCandles = (candles) => sortCandles(candles.map(prepareCandle).filter(isCandle)); | ||
const findFirstNotEmptyCandle = (candles, startIdx, iterateStep) => { | ||
@@ -942,0 +943,0 @@ if (startIdx >= candles.length) { |
@@ -17,2 +17,3 @@ /* | ||
readonly model?: T; | ||
readonly parentId?: DynamicObjectId; | ||
} | ||
@@ -23,2 +24,3 @@ export declare class DynamicObjectsModel extends ChartBaseElement { | ||
private modelIdToObjectMap; | ||
private _uniqueObjects; | ||
constructor(canvasModel: CanvasModel); | ||
@@ -29,3 +31,3 @@ /** | ||
*/ | ||
private getObjectInfoById; | ||
getObjectInfoById(id: DynamicObjectId): [DynamicObject, LinkedList<DynamicObject>] | undefined; | ||
/** | ||
@@ -85,2 +87,6 @@ * @returns `DynamicObject` position in associated pane `LinkedList` | ||
/** | ||
* Getter for the unique objects, unique object is an entity which is either dynamic object itself, or its parent | ||
*/ | ||
get uniqueObjects(): Record<string, Set<DynamicObjectId>>; | ||
/** | ||
* Sets the objects | ||
@@ -87,0 +93,0 @@ * @param objects |
@@ -14,2 +14,3 @@ /* | ||
this.modelIdToObjectMap = new Map(); | ||
this._uniqueObjects = {}; | ||
this._objects = new BehaviorSubject({}); | ||
@@ -53,3 +54,3 @@ } | ||
addObject(obj) { | ||
var _a; | ||
var _a, _b; | ||
const paneId = obj.paneId; | ||
@@ -63,2 +64,6 @@ const objects = this.objects; | ||
this.modelIdToObjectMap.set(obj.id, obj); | ||
if (!this.uniqueObjects[paneId]) { | ||
this.uniqueObjects[paneId] = new Set(); | ||
} | ||
this.uniqueObjects[paneId].add((_b = obj.parentId) !== null && _b !== void 0 ? _b : obj.id); | ||
this.setDynamicObjects(objects); | ||
@@ -71,2 +76,3 @@ } | ||
removeObject(id) { | ||
var _a; | ||
const objInfo = this.getObjectInfoById(id); | ||
@@ -81,2 +87,5 @@ if (!objInfo) { | ||
this.modelIdToObjectMap.delete(id); | ||
if (this.uniqueObjects[obj.paneId]) { | ||
this.uniqueObjects[obj.paneId].delete((_a = obj.parentId) !== null && _a !== void 0 ? _a : obj.id); | ||
} | ||
if (paneList.size() === 0) { | ||
@@ -207,2 +216,8 @@ delete this.objects[obj.paneId]; | ||
/** | ||
* Getter for the unique objects, unique object is an entity which is either dynamic object itself, or its parent | ||
*/ | ||
get uniqueObjects() { | ||
return this._uniqueObjects; | ||
} | ||
/** | ||
* Sets the objects | ||
@@ -209,0 +224,0 @@ * @param objects |
@@ -50,2 +50,3 @@ /* | ||
htId: number; | ||
parentId?: string | number | undefined; | ||
name: string; | ||
@@ -75,3 +76,3 @@ highlighted: boolean; | ||
set visualPoints(points: V[][] | V[]); | ||
constructor(extentComponent: YExtentComponent, id: string, htId: number, _config?: AtLeastOne<DataSeriesConfig>); | ||
constructor(extentComponent: YExtentComponent, id: string, htId: number, parentId?: string | number | undefined, _config?: AtLeastOne<DataSeriesConfig>); | ||
protected doActivate(): void; | ||
@@ -78,0 +79,0 @@ /** |
@@ -68,3 +68,3 @@ /* | ||
} | ||
constructor(extentComponent, id, htId, _config = cloneUnsafe(DEFAULT_DATA_SERIES_CONFIG)) { | ||
constructor(extentComponent, id, htId, parentId, _config = cloneUnsafe(DEFAULT_DATA_SERIES_CONFIG)) { | ||
var _a; | ||
@@ -75,2 +75,3 @@ super(); | ||
this.htId = htId; | ||
this.parentId = parentId; | ||
this.name = ''; | ||
@@ -77,0 +78,0 @@ this.highlighted = false; |
{ | ||
"name": "@devexperts/dxcharts-lite", | ||
"version": "2.5.4", | ||
"version": "2.5.5", | ||
"description": "DXCharts Lite", | ||
@@ -5,0 +5,0 @@ "author": "Devexperts Solutions IE Limited", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1743388
31938