From 24c01c1349fec8ca6bd605b44b9ebbf0f032218e Mon Sep 17 00:00:00 2001 From: ChepteaCatalin Date: Sun, 12 Feb 2023 18:37:46 +0200 Subject: [PATCH] fix(legend): inherit legend rich text color from legend's options. close #18196 --- src/component/legend/LegendView.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/component/legend/LegendView.ts b/src/component/legend/LegendView.ts index 5b4a342599..9af5ffb664 100644 --- a/src/component/legend/LegendView.ts +++ b/src/component/legend/LegendView.ts @@ -413,16 +413,18 @@ class LegendView extends ComponentView { content = formatter(name); } - const inactiveColor = legendItemModel.get('inactiveColor'); + const textColor = isSelected + ? textStyleModel.getTextColor() : legendItemModel.get('inactiveColor'); + itemGroup.add(new graphic.Text({ style: createTextStyle(textStyleModel, { text: content, x: textX, y: itemHeight / 2, - fill: isSelected ? textStyleModel.getTextColor() : inactiveColor, + fill: textColor, align: textAlign, verticalAlign: 'middle' - }) + }, {inheritColor: textColor}) })); // Add a invisible rect to increase the area of mouse hover