diff --git a/src/HelperTypes.ts b/src/HelperTypes.ts index 6bec6e4d..dd480e0f 100644 --- a/src/HelperTypes.ts +++ b/src/HelperTypes.ts @@ -11,6 +11,9 @@ export interface Dataset { /** A function returning array of the colors of the stroke given an input opacity value for each data value. */ colors?: Array<(opacity: number) => string>; + /** A function returning the color of the shadow given an input opacity value. */ + shadowColor?:(opacity: number) => string; + /** The width of the stroke. Defaults to 2. */ strokeWidth?: number; diff --git a/src/line-chart/LineChart.tsx b/src/line-chart/LineChart.tsx index 3b7a5a90..9383dc9d 100644 --- a/src/line-chart/LineChart.tsx +++ b/src/line-chart/LineChart.tsx @@ -231,6 +231,10 @@ class LineChart extends AbstractChart { return (dataset.color || this.props.chartConfig.color)(opacity); }; + getShadowColor = (dataset: Dataset, opacity: number) => { + return (dataset.shadowColor || dataset.color || this.props.chartConfig.color)(opacity); + }; + getStrokeWidth = (dataset: Dataset) => { return dataset.strokeWidth || this.props.chartConfig.strokeWidth || 3; }; @@ -584,9 +588,7 @@ class LineChart extends AbstractChart { (dataset.data.length - 1)},${(height / 4) * 3 + paddingTop} ${paddingRight},${(height / 4) * 3 + paddingTop}` } - fill={`url(#fillShadowGradient${ - useColorFromDataset ? `_${index}` : "" - })`} + fill={this.getShadowColor(dataset, 0.2)} strokeWidth={0} /> ); @@ -761,9 +763,7 @@ class LineChart extends AbstractChart { );