Reputation: 57
I am trying to create a multiline chart in simple react native mobile application. I tried various libraries but the multiline chart is not working. I am new to this. Please help.
Upvotes: 1
Views: 5413
Reputation: 56
you can use "react-native-char-kit" just by providing multiple datasets, you can implement a multiline chart.
<LineChart
bezier
withHorizontalLabels={false}
withVerticalLabels={false}
data={{
labels: [' jan', ' feb', ' mar', ' apr', ' june', ' july'],
datasets: [
{
data: [10, -4, 6, -8, 80, 20],
strokeWidth: 2,
},
{
data: [5,8,6,9,8,2,-2],
strokeWidth: 2,
},
],
legend: ['car', 'bike'],
}}
width={Dimensions.get('window').width - 16}
height={200}
chartConfig={{
backgroundColor: '#1cc910',
backgroundGradientFrom: '#eff3ff',
backgroundGradientTo: '#efefef',
decimalPlaces: 2,
color: (opacity = 1) => `rgba(0, 0, 0, ${opacity})`,
style: {
borderRadius: 16,
},
}}
style={{
borderRadius: 16,
}}
/>
Upvotes: 4