forked from JesperLekland/react-native-svg-charts-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
decorator.js
48 lines (40 loc) · 1.23 KB
/
decorator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React from 'react'
import { AreaChart, Grid } from 'react-native-svg-charts'
import { Circle, Path } from 'react-native-svg'
class DecoratorExample extends React.PureComponent {
render() {
const data = [ 50, 10, 40, 95, -4, -24, 85, 91, 35, 53, -53, 24, 50, -20, -80 ]
const Decorator = ({ x, y, data }) => {
return data.map((value, index) => (
<Circle
key={ index }
cx={ x(index) }
cy={ y(value) }
r={ 4 }
stroke={ 'rgb(134, 65, 244)' }
fill={ 'white' }
/>
))
}
const Line = ({ line }) => (
<Path
d={ line }
stroke={ 'rgba(134, 65, 244)' }
fill={ 'none' }
/>
)
return (
<AreaChart
style={{ height: 200 }}
data={ data }
svg={{ fill: 'rgba(134, 65, 244, 0.2)' }}
contentInset={{ top: 20, bottom: 30 }}
>
<Grid/>
<Line/>
<Decorator/>
</AreaChart>
)
}
}
export default DecoratorExample