Skip to content

Commit

Permalink
Configure active Bar brightness factor (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
pzipoy authored and amcdnl committed Dec 7, 2019
1 parent fc0a317 commit 2d2d5d5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/BarChart/BarSeries/Bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export type BarProps = {
*/
active: boolean;

/**
* Chroma brightness factor to brighten the active bar. See
* https://gka.github.io/chroma.js/#color-brighten for more info.
*/
activeBrightness?: number;

/**
* D3 scale for X Axis. Set internally by `BarChart`.
*/
Expand Down Expand Up @@ -198,6 +204,7 @@ interface BarState {

export class Bar extends Component<BarProps, BarState> {
static defaultProps: Partial<BarProps> = {
activeBrightness: 0.5,
rounded: true,
rx: 0,
ry: 0,
Expand Down Expand Up @@ -565,6 +572,7 @@ export class Bar extends Component<BarProps, BarState> {

render() {
const {
activeBrightness,
id,
gradient,
data,
Expand All @@ -585,10 +593,12 @@ export class Bar extends Component<BarProps, BarState> {
const active = tooltip ? this.state.active : this.props.active;
const stroke = color(data, barIndex);
const coords = this.getCoords(data);
const currentColorShade = active ? chroma(stroke).brighten(0.5) : stroke;
const currentColorShade = active
? chroma(stroke).brighten(activeBrightness)
: stroke;
const rangeLineColor = (rangeLines && rangeLines.props.color) || stroke;
const rangeLineColorShade = active
? chroma(rangeLineColor).brighten(0.5)
? chroma(rangeLineColor).brighten(activeBrightness)
: rangeLineColor;
const index = groupIndex !== undefined ? groupIndex : barIndex;
const isVertical = this.getIsVertical();
Expand Down

0 comments on commit 2d2d5d5

Please sign in to comment.