Skip to content

Commit b1249fa

Browse files
cipriancabamarkmcdowell
authored andcommitted
feat(series): provide a fillStyle factory option for the AreaSeries
1 parent 1e3b3e1 commit b1249fa

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/series/src/AreaOnlySeries.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ export interface AreaOnlySeriesProps {
2626
/**
2727
* Color, gradient, or pattern to use for fill.
2828
*/
29-
readonly fillStyle?: string;
29+
readonly fillStyle?:
30+
| string
31+
| ((context: CanvasRenderingContext2D, moreProps: any) => string | CanvasGradient | CanvasPattern);
3032
/**
3133
* Selector for data to plot.
3234
*/
@@ -71,7 +73,11 @@ export class AreaOnlySeries extends React.Component<AreaOnlySeriesProps> {
7173
}
7274

7375
if (fillStyle !== undefined) {
74-
ctx.fillStyle = fillStyle;
76+
if (typeof fillStyle === "string") {
77+
ctx.fillStyle = fillStyle;
78+
} else {
79+
ctx.fillStyle = fillStyle(ctx, moreProps);
80+
}
7581
}
7682

7783
const newBase = functor(base);

packages/series/src/AreaSeries.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export interface AreaSeriesProps {
2020
/**
2121
* Color, gradient, or pattern to use for fill.
2222
*/
23-
readonly fillStyle?: string;
23+
readonly fillStyle?:
24+
| string
25+
| ((context: CanvasRenderingContext2D, moreProps: any) => string | CanvasGradient | CanvasPattern);
2426
/**
2527
* A factory for a curve generator for the area and line.
2628
*/

0 commit comments

Comments
 (0)