-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSvgChartDemo.js
72 lines (68 loc) · 1.54 KB
/
SvgChartDemo.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React from 'react';
import {View, SafeAreaView} from 'react-native';
import {
AreaChart,
Grid,
YAxis,
XAxis,
LineChart,
} from 'react-native-svg-charts';
import * as shape from 'd3-shape';
class SvgChartDemo extends React.PureComponent {
render() {
const data = [
50,
10,
40,
95,
-4,
-24,
85,
91,
35,
53,
-53,
24,
50,
-20,
-80,
];
const contentInset = {top: 20, bottom: 20};
return (
<SafeAreaView>
<View style={{height: 200, flexDirection: 'row'}}>
<YAxis
data={data}
contentInset={contentInset}
svg={{
fill: 'grey',
fontSize: 10,
}}
numberOfTicks={10}
formatLabel={(value) => `${value}ºC`}
style={{position: 'absolute', bottom: 5, left: 0, top: 0}}
/>
<XAxis
data={data}
contentInset={contentInset}
svg={{
fill: 'grey',
fontSize: 10,
}}
numberOfTicks={10}
formatLabel={(value) => `${value}ºC`}
style={{position: 'absolute', bottom: 0, left: 5, right: 0}}
/>
<LineChart
style={{flex: 1, marginLeft: 16}}
data={data}
svg={{stroke: 'rgb(134, 65, 244)'}}
contentInset={contentInset}>
<Grid />
</LineChart>
</View>
</SafeAreaView>
);
}
}
export default SvgChartDemo;