Skip to content

Instantly share code, notes, and snippets.

@mohit-kaushik
Last active July 29, 2020 13:01
Show Gist options
  • Select an option

  • Save mohit-kaushik/d1140d596e0de5284ec136136ef6faa0 to your computer and use it in GitHub Desktop.

Select an option

Save mohit-kaushik/d1140d596e0de5284ec136136ef6faa0 to your computer and use it in GitHub Desktop.
import React from 'react'
import { View, Text, Dimensions } from 'react-native'
import { LineChart } from 'react-native-chart-kit'
const Charts = () => {
return (
<View>
<LineChart
data={{
labels: ["January", "February", "March", "April", "May", "June"],
datasets: [
{
data: [
Math.random() * 100,
Math.random() * 100,
Math.random() * 100,
Math.random() * 100,
Math.random() * 100,
Math.random() * 100
]
}
]
}}
width={Dimensions.get("window").width}
height={250}
yAxisLabel="$"
yAxisSuffix="k"
yAxisInterval={1}
chartConfig={{
backgroundColor: "white",
backgroundGradientFrom: "#fbfbfb",
backgroundGradientTo: "#fbfbfb",
decimalPlaces: 2, // optional, defaults to 2dp
color: (opacity = 1) => `rgba(0, 0, 0, ${opacity})`,
labelColor: (opacity = 1) => `rgba(0, 0, 0, ${opacity})`,
style: {
borderRadius: 0
},
propsForDots: {
r: "6",
strokeWidth: "2",
stroke: "#fbfbfb"
}
}}
bezier
style={{
marginVertical: 8,
borderRadius: 6
}}
/>
</View>
)
}
export default Charts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment