Skip to content

Commit

Permalink
feat(series): provide a fillStyle factory option for the AreaSeries
Browse files Browse the repository at this point in the history
  • Loading branch information
cipriancaba authored and markmcdowell committed May 21, 2021
1 parent 1e3b3e1 commit b1249fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions packages/series/src/AreaOnlySeries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export interface AreaOnlySeriesProps {
/**
* Color, gradient, or pattern to use for fill.
*/
readonly fillStyle?: string;
readonly fillStyle?:
| string
| ((context: CanvasRenderingContext2D, moreProps: any) => string | CanvasGradient | CanvasPattern);
/**
* Selector for data to plot.
*/
Expand Down Expand Up @@ -71,7 +73,11 @@ export class AreaOnlySeries extends React.Component<AreaOnlySeriesProps> {
}

if (fillStyle !== undefined) {
ctx.fillStyle = fillStyle;
if (typeof fillStyle === "string") {
ctx.fillStyle = fillStyle;
} else {
ctx.fillStyle = fillStyle(ctx, moreProps);
}
}

const newBase = functor(base);
Expand Down
4 changes: 3 additions & 1 deletion packages/series/src/AreaSeries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export interface AreaSeriesProps {
/**
* Color, gradient, or pattern to use for fill.
*/
readonly fillStyle?: string;
readonly fillStyle?:
| string
| ((context: CanvasRenderingContext2D, moreProps: any) => string | CanvasGradient | CanvasPattern);
/**
* A factory for a curve generator for the area and line.
*/
Expand Down

0 comments on commit b1249fa

Please sign in to comment.