Skip to content

Commit

Permalink
Merge pull request #1238 from VisActor/fix/color-legend-handler-color
Browse files Browse the repository at this point in the history
fix: color legend handler cannot customize fill color
  • Loading branch information
xile611 authored Jun 3, 2024
2 parents 2dbe2d4 + 98f00c7 commit 724b0d4
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/vrender-components/src/legend/color/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class ColorContinuousLegend extends LegendBase<ColorLegendAttributes> {
},
handlerSize: 10,
handlerStyle: {
fill: null as any,
lineWidth: 4,
stroke: '#fff',
outerBorder: {
Expand Down Expand Up @@ -220,12 +221,20 @@ export class ColorContinuousLegend extends LegendBase<ColorLegendAttributes> {
const { layout = 'horizontal', colors, railWidth, railHeight } = this.attribute as ColorLegendAttributes;
const { startHandler, endHandler, track } = this._slider;
const { startValue, endValue, startPos, endPos } = this._slider.currentValue;

// 计算颜色
const startHandlerColor = this._colorScale.scale(startValue);
const endHandlerColor = this._colorScale.scale(endValue);
startHandler?.setAttribute('fill', startHandlerColor);
endHandler?.setAttribute('fill', endHandlerColor);
if (startHandler) {
if (!startHandler.attribute.fill) {
const startHandlerColor = this._colorScale.scale(startValue);
startHandler.setAttribute('fill', startHandlerColor);
}
}

if (endHandler) {
if (!endHandler.attribute.fill) {
const endHandlerColor = this._colorScale.scale(endValue);
endHandler.setAttribute('fill', endHandlerColor);
}
}

const isHorizontal = layout === 'horizontal';
const railLen = isHorizontal ? railWidth : railHeight;
Expand Down

0 comments on commit 724b0d4

Please sign in to comment.