Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/HelperTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
12 changes: 6 additions & 6 deletions src/line-chart/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ class LineChart extends AbstractChart<LineChartProps, LineChartState> {
return (dataset.color || this.props.chartConfig.color)(opacity);
};

getShadowColor = (dataset: Dataset, opacity: number) => {
return (dataset.shadowColor || dataset.color || this.props.chartConfig.color)(opacity);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like it should default to url(#fillShadowGradient..., to make this change backwards compatible

};

getStrokeWidth = (dataset: Dataset) => {
return dataset.strokeWidth || this.props.chartConfig.strokeWidth || 3;
};
Expand Down Expand Up @@ -584,9 +588,7 @@ class LineChart extends AbstractChart<LineChartProps, LineChartState> {
(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}
/>
);
Expand Down Expand Up @@ -761,9 +763,7 @@ class LineChart extends AbstractChart<LineChartProps, LineChartState> {
<Path
key={index}
d={d}
fill={`url(#fillShadowGradient${
useColorFromDataset ? `_${index}` : ""
})`}
fill={this.getShadowColor(dataset, 0.2)}
strokeWidth={0}
/>
);
Expand Down