Skip to content

Commit

Permalink
fix(series): BarSeries should have opacity
Browse files Browse the repository at this point in the history
This is specified through the strokeStyle now instead.
  • Loading branch information
markmcdowell committed Aug 28, 2020
1 parent 27f410a commit 7d6e414
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
8 changes: 2 additions & 6 deletions packages/series/src/BarSeries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ export interface BarSeriesProps {
| CanvasGradient
| CanvasPattern
| ((data: any) => string | CanvasGradient | CanvasPattern);
readonly opacity?: number;
readonly stroke?: boolean;
readonly strokeStyle?: string | CanvasGradient | CanvasPattern;
readonly swapScales?: boolean;
readonly width?: number | ((props: { widthRatio: number }, moreProps: any) => number);
Expand All @@ -44,9 +42,7 @@ export class BarSeries extends React.Component<BarSeriesProps> {
yScale: ScaleContinuousNumeric<number, number> /* , d*/,
) => head(yScale.range()),
clip: true,
direction: "up",
fillStyle: "rgba(70, 130, 180, 0.5)",
stroke: false,
swapScales: false,
width: plotDataLengthBarWidth,
widthRatio: 0.8,
Expand All @@ -73,7 +69,7 @@ export class BarSeries extends React.Component<BarSeriesProps> {
} else {
const bars = this.getBars(moreProps);

const { stroke, strokeStyle } = this.props;
const { strokeStyle } = this.props;

const nest = group(bars, (d: any) => d.fillStyle);

Expand All @@ -90,7 +86,7 @@ export class BarSeries extends React.Component<BarSeriesProps> {
ctx.fillRect(d.x - 0.5, d.y, 1, d.height);
} else {
ctx.fillRect(d.x + 0.5, d.y + 0.5, d.width, d.height);
if (stroke) {
if (strokeStyle !== undefined) {
ctx.strokeRect(d.x, d.y, d.width, d.height);
}
}
Expand Down
4 changes: 0 additions & 4 deletions packages/series/src/MACDSeries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { StraightLine } from "./StraightLine";
export interface MACDSeriesProps {
readonly className?: string;
readonly clip?: boolean;
readonly divergenceStroke?: boolean;
readonly fillStyle?: {
divergence: string | CanvasGradient | CanvasPattern;
};
Expand All @@ -30,7 +29,6 @@ export class MACDSeries extends React.Component<MACDSeriesProps> {
public static defaultProps = {
className: "react-financial-charts-macd-series",
clip: true,
divergenceStroke: false,
fillStyle: {
divergence: "rgba(70, 130, 180, 0.6)",
},
Expand All @@ -48,7 +46,6 @@ export class MACDSeries extends React.Component<MACDSeriesProps> {
className,
clip,
fillStyle = MACDSeries.defaultProps.fillStyle,
divergenceStroke,
strokeStyle = MACDSeries.defaultProps.strokeStyle,
widthRatio,
width,
Expand All @@ -60,7 +57,6 @@ export class MACDSeries extends React.Component<MACDSeriesProps> {
baseAt={this.yAccessorForDivergenceBase}
width={width}
widthRatio={widthRatio}
stroke={divergenceStroke}
fillStyle={fillStyle.divergence}
clip={clip}
yAccessor={this.yAccessorForDivergence}
Expand Down
4 changes: 3 additions & 1 deletion packages/series/src/StackedBarSeries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ export const drawOnCanvas2 = (props: { stroke?: boolean }, ctx: CanvasRenderingC

nest.forEach((values, key) => {
if (head(values).width > 1) {
ctx.strokeStyle = key;
if (key !== undefined) {
ctx.strokeStyle = key;
}
}
ctx.fillStyle = key;

Expand Down

0 comments on commit 7d6e414

Please sign in to comment.