private getLegendValueColor(seriesId: string, strategy: SeriesStrategies, time?: Time): string {
const indicatorId = this.id as IndicatorsIds;
if (indicatorId !== IndicatorsIds.vol || seriesId !== 'volume') {
return this.legendSeriesColors.get(seriesId) ?? strategy.getLegendColor(time) ?? '';
}
const { colors } = getThemeStore();
const mainSeries = this.mainSeriesRef.value;
const mainPoint = mainSeries?.getDataItemByTime(time) as Record<string, unknown> | null;
if (!mainPoint) {
return colors.chartCandleUp;
}
const customValues =
'customValues' in mainPoint &&
typeof mainPoint.customValues === 'object' &&
mainPoint.customValues !== null
? (mainPoint.customValues as Record<string, unknown>)
: null;
const open =
typeof mainPoint.open === 'number'
? mainPoint.open
: customValues && typeof customValues.open === 'number'
? customValues.open
: undefined;
const close =
typeof mainPoint.close === 'number'
? mainPoint.close
: customValues && typeof customValues.close === 'number'
? customValues.close
: undefined;
if (typeof open === 'number' && typeof close === 'number') {
return close >= open ? colors.chartCandleUp : colors.chartCandleDown;
}
return colors.chartCandleUp;
}