From 022d5a7be2002b423db00906a8cb1a353cc80217 Mon Sep 17 00:00:00 2001 From: e109033 Date: Thu, 25 Jan 2024 14:51:29 +0000 Subject: [PATCH] fix(#1205,#1482): added value to custom colors --- .../ngx-charts/src/lib/bar-chart/series-vertical.component.ts | 2 +- projects/swimlane/ngx-charts/src/lib/common/color.helper.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/swimlane/ngx-charts/src/lib/bar-chart/series-vertical.component.ts b/projects/swimlane/ngx-charts/src/lib/bar-chart/series-vertical.component.ts index 6ddce3baf..b0426e3a6 100644 --- a/projects/swimlane/ngx-charts/src/lib/bar-chart/series-vertical.component.ts +++ b/projects/swimlane/ngx-charts/src/lib/bar-chart/series-vertical.component.ts @@ -240,7 +240,7 @@ export class SeriesVerticalComponent implements OnChanges { } if (this.colors.scaleType === ScaleType.Ordinal) { - bar.color = this.colors.getColor(label); + bar.color = this.colors.getColor(value, label); } else { if (this.type === BarChartType.Standard) { bar.color = this.colors.getColor(value); diff --git a/projects/swimlane/ngx-charts/src/lib/common/color.helper.ts b/projects/swimlane/ngx-charts/src/lib/common/color.helper.ts index f1aec711f..5385b3ebd 100644 --- a/projects/swimlane/ngx-charts/src/lib/common/color.helper.ts +++ b/projects/swimlane/ngx-charts/src/lib/common/color.helper.ts @@ -75,7 +75,7 @@ export class ColorHelper { return colorScale; } - getColor(value: StringOrNumberOrDate): string { + getColor(value: StringOrNumberOrDate, label?: StringOrNumberOrDate): string { if (value === undefined || value === null) { throw new Error('Value can not be null'); } @@ -87,7 +87,7 @@ export class ColorHelper { return this.scale(valueScale(value as number)); } else { if (typeof this.customColors === 'function') { - return this.customColors(value); + return this.customColors(value, label); } const formattedValue = value.toString();