This repository has been archived by the owner on Jan 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
LineChartScreen.js
146 lines (133 loc) · 3.42 KB
/
LineChartScreen.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import React from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import reactAddonsUpdate from 'react-addons-update';
import {LineChart} from 'react-native-mp-android-chart';
class LineChartScreen extends React.Component {
constructor() {
super();
this.state = {
data: {},
legend: {
enabled: true,
textColor: 'blue',
textSize: 12,
position: 'BELOW_CHART_RIGHT',
form: 'SQUARE',
formSize: 14,
xEntrySpace: 10,
yEntrySpace: 5,
formToTextSpace: 5,
wordWrapEnabled: true,
maxSizePercent: 0.5,
fontFamily: 'monospace',
fontStyle: 1,
custom: {
colors: ['red', 'blue', 'green'],
labels: ['Company X', 'Company Y', 'Company Dashed']
}
},
marker: {
enabled: true,
type: 'oval',
backgroundTint: 'teal'
}
};
}
componentDidMount() {
this.setState(
reactAddonsUpdate(this.state, {
data: {
$set: {
datasets: [{
yValues: [100, 110, 105, 115],
label: 'Company X',
config: {
lineWidth: 2,
drawCircles: false,
drawCubic: true,
highlightColor: 'red',
color: 'red',
drawFilled: true,
fillColor: 'red',
fillAlpha: 60,
dashedLine: {
lineLength: 20,
spaceLength: 20
}
}
}, {
yValues: [90, 130, 100, 105],
label: 'Company Y',
config: {
lineWidth: 1,
drawCubic: true,
drawCubicIntensity: 0.4,
circleRadius: 5,
drawHighlightIndicators: false,
color: 'blue',
drawFilled: true,
fillColor: 'blue',
fillAlpha: 45,
circleColor: 'blue'
}
}, {
yValues: [110, 105, 115, 110],
label: 'Company Dashed',
config: {
color: 'green',
drawFilled: true,
drawCubic: true,
fillColor: 'green',
fillAlpha: 50
}
}],
xValues: ['Q1', 'Q2', 'Q3', 'Q4']
}
}
})
);
}
render() {
return (
<View style={styles.container}>
<LineChart
style={styles.chart}
data={this.state.data}
description={{text: ''}}
legend={this.state.legend}
marker={this.state.marker}
drawGridBackground={false}
borderColor={'teal'}
borderWidth={1}
drawBorders={true}
touchEnabled={true}
dragEnabled={true}
scaleEnabled={true}
scaleXEnabled={true}
scaleYEnabled={true}
pinchZoom={true}
doubleTapToZoomEnabled={true}
dragDecelerationEnabled={true}
dragDecelerationFrictionCoef={0.99}
keepPositionOnRotation={false}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#F5FCFF'
},
chart: {
flex: 1
}
});
AppRegistry.registerComponent('LineChartScreen', () => LineChartScreen);
export default LineChartScreen;