If you're looking to build a website or a cross-platform mobile app – we will be happy to help you! Send a note to clients@ui1.io and we will be in touch with you shortly.
Usage no npm install needed!
<script type="module">
import reactNativeChartKit from 'https://cdn.skypack.dev/react-native-chart-kit';
</script>
README
If you're looking to build a website or a cross-platform mobile app – we will be happy to help you! Send a note to clients@ui1.io and we will be in touch with you shortly.
To try the examples in Expo, please change main to ./node_modules/expo/AppEntry.js in package.json before starting things with expo run. You'll need to have expo-cli installed via npm install -g expo-cli.
Width of the chart, use 'Dimensions' library to get the width of your screen for responsive
height
Number
Height of the chart
chartConfig
Object
Configuration object for the chart, see example config in the beginning of this file
accessor
string
Property in the data object from which the number values are taken
bgColor
string
background color - if you want to set transparent, input transparent or none.
paddingLeft
string
left padding of the pie chart
center
array
offset x and y coordinates to position the chart
absolute
boolean
shows the values as absolute numbers
hasLegend
boolean
Defaults to true, set it to false to remove the legend
avoidFalseZero
boolean
Defaults to false, set it to true to display a "<1%" instead of a rounded value equal to "0%"
Contribution graph (heatmap)
This type of graph is often use to display a developer contribution activity. However, there many other use cases this graph is used when you need to visualize a frequency of a certain event over time.
Width of the chart, use 'Dimensions' library to get the width of your screen for responsive
height
Number
Height of the chart
gutterSize
Number
Size of the gutters between the squares in the chart
squareSize
Number
Size of the squares in the chart
horizontal
boolean
Should graph be laid out horizontally? Defaults to true
showMonthLabels
boolean
Should graph include labels for the months? Defaults to true
showOutOfRangeDays
boolean
Should graph be filled with squares, including days outside the range? Defaults to false
chartConfig
Object
Configuration object for the chart, see example config in the beginning of this file
accessor
string
Property in the data object from which the number values are taken; defaults to count
getMonthLabel
function
Function which returns the label for each month, taking month index (0 - 11) as argument
onDayPress
function
Callback invoked when the user clicks a day square on the chart; takes a value-item object
More styling
Every charts also accepts style props, which will be applied to parent svg or View component of each chart.
Abstract Chart
src/abstract-chart.js is an extendable class which can be used to create your own charts!
The following methods are available:
renderHorizontalLines(config)
Renders background horizontal lines like in the Line Chart and Bar Chart. Takes a config object with following properties:
{
// width of your chart
width: Number,
// height of your chart
height: Number,
// how many lines to render
count: Number,
// top padding from the chart top edge
paddingTop: Number
}
renderVerticalLabels(config)
Render background vertical lines. Takes a config object with following properties:
{
// data needed to calculate the number of lines to render
data: Array,
// width of your chart
width: Number,
// height of your chart
height: Number,
paddingTop: Number,
paddingRight: Number
}
renderDefs(config)
Render definitions of background and shadow gradients
{
// width of your chart
width: Number,
// height of your chart
height: Number,
// first color of background gradient
backgroundGradientFrom: String,
// first color opacity of background gradient (0 - 1.0)
backgroundGradientFromOpacity: Number,
// second color of background gradient
backgroundGradientTo: String,
// second color opacity of background gradient (0 - 1.0)
backgroundGradientToOpacity: Number,
}
Compilation
For production use, the package is automatically compiled after installation, so that you can just install it with npm and use it out-of-the-box.
To transpile TypeScript into JavaScript for development purposes, you can use either run npm run build to compile once, or npm run dev to start compilation in watch mode, which will recompile the files on change.
More information
This library is built on top of the following open-source projects: