@devexperts/dxcharts-lite
Version:
37 lines (36 loc) • 1.66 kB
JavaScript
/*
* Copyright (C) 2019 - 2025 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 { MainCandleSeriesModel } from './main-candle-series.model';
export class CompareSeriesHoverProducerPart {
constructor(chartModel) {
this.chartModel = chartModel;
}
/**
* Returns an array of objects containing information about the series of candles at a specific x-coordinate.
* @param {BaseHover} hover - The hover object containing the x-coordinate.
* @returns {CompareSeriesHover[]} An array of objects containing the instrument symbol, price and id of each series of candles.
*/
getData(hover) {
if (this.chartModel.candleSeries.length === 1 &&
this.chartModel.candleSeries[0] instanceof MainCandleSeriesModel) {
return;
}
const { x } = hover;
const candle = this.chartModel.candleFromX(x);
const idx = candle.idx || 0;
const compareSeriesHover = this.chartModel.candleSeries.map(series => {
const candleSecondary = series.dataPoints[idx];
const priceToShow = this.chartModel.pane.regularFormatter(candleSecondary === null || candleSecondary === void 0 ? void 0 : candleSecondary.close);
return {
instrument: series.instrument.symbol,
price: priceToShow,
id: series.id,
htId: series.htId,
};
});
return compareSeriesHover;
}
}