Skip to content

Commit

Permalink
fix(style): style.fill has higher priority (close: #4667) (#4676)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini authored and hustcc committed May 16, 2023
1 parent 12ac82e commit 9e10168
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions __tests__/plots/static/alphabet-interval-fill.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { G2Spec } from '../../../src';

export function alphabetIntervalFill(): G2Spec {
return {
type: 'interval',
transform: [{ type: 'sortX', by: 'y', reverse: true }],
data: {
type: 'fetch',
value: 'data/alphabet.csv',
},
axis: {
y: { labelFormatter: '.0%' },
},
encode: {
x: 'letter',
y: 'frequency',
color: 'steelblue',
},
style: { fill: 'red' },
};
}
1 change: 1 addition & 0 deletions __tests__/plots/static/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,4 @@ export { population2015IntervalHOMViewLevel } from './population2015-interval-ho
export { population2015IntervalHOMMarkLevel } from './population2015-interval-hom-mark-level';
export { population2015IntervalHOMNested } from './population2015-interval-hom-nested';
export { population2015IntervalHOMMultiple } from './population2015-interval-hom-multiple';
export { alphabetIntervalFill } from './alphabet-interval-fill';
18 changes: 11 additions & 7 deletions src/shape/interval/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,17 @@ export const Color: SC<ColorOptions> = (options) => {
insetTop,
};

return select(rect(points, value, coordinate, extendedStyle))
.call(applyStyle, { ...defaults, ...rest })
.style(toOpacityKey(options), opacity)
.style(colorAttribute, color)
.style('lineWidth', lineWidth)
.style('stroke', stroke === undefined ? color : stroke)
.node();
return (
select(rect(points, value, coordinate, extendedStyle))
.call(applyStyle, defaults)
.style(colorAttribute, color)
.style(toOpacityKey(options), opacity)
.style('lineWidth', lineWidth)
.style('stroke', stroke === undefined ? color : stroke)
// shape.style has higher priority.
.call(applyStyle, rest)
.node()
);
};
};

Expand Down

0 comments on commit 9e10168

Please sign in to comment.