diff --git a/src/chart/chart.config.ts b/src/chart/chart.config.ts index 74b45b08..7d15d2b9 100644 --- a/src/chart/chart.config.ts +++ b/src/chart/chart.config.ts @@ -510,6 +510,8 @@ export const getDefaultConfig = (): FullChartConfig => ({ boxNegative: 'rgba(217,44,64,1)', boxPositive: 'rgba(77,153,83,1)', boxSelected: 'rgba(255,255,255,1)', + labelTextNegative: 'rgba(217,44,64,1)', + labelTextPositive: 'rgba(77,153,83,1)', }, countdownToBarClose: { textNegative: 'rgba(255,255,255,1)', @@ -1408,6 +1410,8 @@ export interface YAxisLastPriceLabelColorConfig { textSelected: string; textNegative: string; textPositive: string; + labelTextPositive: string; + labelTextNegative: string; } export interface YAxisBidAskLabelColorConfig { diff --git a/src/chart/components/y_axis/label-color.functions.ts b/src/chart/components/y_axis/label-color.functions.ts index 35f894d0..cb1f9212 100644 --- a/src/chart/components/y_axis/label-color.functions.ts +++ b/src/chart/components/y_axis/label-color.functions.ts @@ -8,6 +8,17 @@ import { FullChartColors, YAxisLabelsColors } from '../../chart.config'; export const DEFAULT_LABEL_COLOR = '#FF00FF'; +export const getPlainLabelTextColor = (lastPriceMovement: PriceMovement, colors: YAxisLabelsColors): string => { + if (lastPriceMovement === 'down') { + return colors.lastPrice.labelTextNegative; + } else if (lastPriceMovement === 'up') { + return colors.lastPrice.labelTextPositive; + } else if (lastPriceMovement === 'none') { + return colors.lastPrice.labelTextPositive; + } else { + return colors.lastPrice.labelTextPositive; + } +}; export const getPrimaryLabelTextColor = (lastPriceMovement: PriceMovement, colors: YAxisLabelsColors): string => { if (lastPriceMovement === 'down') { return colors.lastPrice.textNegative; diff --git a/src/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.ts b/src/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.ts index c2773cbd..60f822da 100644 --- a/src/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.ts +++ b/src/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.ts @@ -77,7 +77,12 @@ export class DataSeriesYAxisLabelsProvider implements YAxisLabelsProvider { const config = this.series.config; const paintConfig = config.paintConfig[0] ?? DEFAULT_DATA_SERIES_PAINT_CONFIG; const bgColor = paintConfig.color; - const textColor = getLabelTextColorByBackgroundColor(bgColor, 'white', 'black'); + + const textColor = getLabelTextColorByBackgroundColor( + bgColor, + paintConfig.lightTextColor ?? 'white', + paintConfig.darkTextColor ?? 'black ', + ); return { textColor, bgColor, diff --git a/src/chart/components/y_axis/price_labels/last-candle-labels.provider.ts b/src/chart/components/y_axis/price_labels/last-candle-labels.provider.ts index cbd244c7..c5dc730c 100644 --- a/src/chart/components/y_axis/price_labels/last-candle-labels.provider.ts +++ b/src/chart/components/y_axis/price_labels/last-candle-labels.provider.ts @@ -7,7 +7,7 @@ import { FullChartConfig, YAxisConfig } from '../../../chart.config'; import { CandleSeriesModel } from '../../../model/candle-series.model'; import { DataSeriesType } from '../../../model/data-series.config'; import { ChartModel, LastCandleLabelHandler } from '../../chart/chart.model'; -import { getPrimaryLabelTextColor } from '../label-color.functions'; +import { getPlainLabelTextColor, getPrimaryLabelTextColor } from '../label-color.functions'; import { YAxisLabelDrawConfig } from '../y-axis-labels.drawer'; import { LabelGroup, VisualYAxisLabel, YAxisLabelsProvider } from './y-axis-labels.model'; import { lastOf } from '../../../utils/array.utils'; @@ -30,9 +30,11 @@ export class LastCandleLabelsProvider implements YAxisLabelsProvider { public getUnorderedLabels(): LabelGroup[] { const collectedLabels: LabelGroup[] = []; const visible = this.yAxisConfig.labels.settings.lastPrice.mode !== 'none'; + if (visible) { // main candle series const yAxisVisualLabel = this.getYAxisVisualLabel(this.chartModel.mainCandleSeries); + const mainCandleSeriesVisualLabel: VisualYAxisLabel | null = yAxisVisualLabel ? { ...yAxisVisualLabel, @@ -105,13 +107,18 @@ export class LastCandleLabelsProvider implements YAxisLabelsProvider { */ private getLabelDrawConfig(series: CandleSeriesModel, primary: boolean): YAxisLabelDrawConfig { const colors = series.colors.labels; + const isPlain = this.fullConfig.components.yAxis.labels.settings['lastPrice'].type === 'plain'; const getLabelBoxColor = this.resolveLabelColorFn(series.config.type); const { rectLabelTextColor, rectLabelInvertedTextColor } = this.chartModel.config.colors.yAxis; let boxColor = '#FFFFFF'; let textColor = '#FFFFFF'; if (colors) { boxColor = getLabelBoxColor(series.lastPriceMovement, series.colors); - textColor = primary ? getPrimaryLabelTextColor(series.lastPriceMovement, colors) : rectLabelTextColor; + textColor = isPlain + ? getPlainLabelTextColor(series.lastPriceMovement, colors) + : primary + ? getPrimaryLabelTextColor(series.lastPriceMovement, colors) + : rectLabelTextColor; } return { bgColor: boxColor, diff --git a/src/chart/model/data-series.config.ts b/src/chart/model/data-series.config.ts index 0f8cec74..cc522d62 100644 --- a/src/chart/model/data-series.config.ts +++ b/src/chart/model/data-series.config.ts @@ -42,6 +42,8 @@ export interface DataSeriesPaintConfig { color: string; lineWidth: number; hoveredLineWidth: number; + lightTextColor?: string; + darkTextColor?: string; //add this for TREND_HISTOGRAM study type // this way not add breaking change aditionalColor?: string;