Skip to content
Merged
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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ Define a chart style object with following properies as such:
```js
const chartConfig = {
backgroundGradientFrom: '#1E2923',
backgroundGradientFromOpacity: 0,
backgroundGradientTo: '#08130D',
backgroundGradientToOpacity: 0.5,
color: (opacity = 1) => `rgba(26, 255, 146, ${opacity})`,
strokeWidth: 2 // optional, default 3
}
Expand All @@ -78,7 +80,9 @@ const chartConfig = {
| Property | Type | Description |
| ------------- |-------------| -----|
| backgroundGradientFrom | string | Defines the first color in the linear gradient of a chart's background |
| backgroundGradientFromOpacity | Number | Defines the first color opacity in the linear gradient of a chart's background |
| backgroundGradientTo | string | Defines the second color in the linear gradient of a chart's background |
| backgroundGradientToOpacity | Number | Defines the second color opacity in the linear gradient of a chart's background |
| color | function => string | Defines the base color function that is used to calculate colors of labels and sectors used in a chart |
| strokeWidth | Number | Defines the base stroke width in a chart |

Expand Down Expand Up @@ -373,8 +377,12 @@ Render definitions of background and shadow gradients
height: Number,
// first color of background gradient
backgroundGradientFrom: String,
// first color opacity of background gradient (0 - 1.0)
backgroundGradientFromOpacity: Number,
// second color of background gradient
backgroundGradientTo: String
backgroundGradientTo: String,
// second color opacity of background gradient (0 - 1.0)
backgroundGradientToOpacity: Number,
}
```

Expand Down
7 changes: 5 additions & 2 deletions src/abstract-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ class AbstractChart extends Component {

renderDefs = config => {
const {width, height, backgroundGradientFrom, backgroundGradientTo} = config
const fromOpacity = config.hasOwnProperty('backgroundGradientFromOpacity') ? config.backgroundGradientFromOpacity : 1.0;
const toOpacity = config.hasOwnProperty('backgroundGradientToOpacity') ? config.backgroundGradientToOpacity : 1.0;

return (
<Defs>
<LinearGradient
Expand All @@ -198,8 +201,8 @@ class AbstractChart extends Component {
x2={width}
y2={0}
>
<Stop offset="0" stopColor={backgroundGradientFrom} />
<Stop offset="1" stopColor={backgroundGradientTo} />
<Stop offset="0" stopColor={backgroundGradientFrom} stopOpacity={fromOpacity} />
<Stop offset="1" stopColor={backgroundGradientTo} stopOpacity={toOpacity} />
</LinearGradient>
<LinearGradient
id="fillShadowGradient"
Expand Down