npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-chart2

v0.1.0

Published

react-native-chart2 is a simple module for adding line charts, area charts, or bar charts to your React Native app.

Downloads

4

Readme

react-native-chart2

react-native-chart2 is a simple module for adding line charts, area charts, or bar charts to your React Native app.

Features

  1. Define chart components in Javascript file and see rendered charts using Core Graphics and CALayer
  2. Supports line charts with options to show data points, line fill, customized color, customized labels, etc...
  3. Supports bar charts
  4. Supports multiple charts in one view
  5. Show animation when populating the chart

Getting Started

  1. npm install react-native-chart2 --save
  2. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  3. Go to node_modulesreact-native-chart2 and add RNChart.xcodeproj
  4. In XCode, in the project navigator, select your project. Add libRNChart.a to your project's Build PhasesLink Binary With Libraries
  5. Click RNChart.xcodeproj in the project navigator and go the Build Settings tab. Make sure 'All' is toggled on (instead of 'Basic'). Look for Header Search Paths and make sure it contains both $(SRCROOT)/../react-native/React and $(SRCROOT)/../../React - mark both as recursive.
  6. Run your project (Cmd+R)

Usage

var React = require('react-native');
var RNChart = require('react-native-chart2');

var {
    StyleSheet, View, Component,
} = React;

var styles = StyleSheet.create({
    container: {
        flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: 'white',
    },
    chart: {
        position: 'absolute', top: 16, left: 4, bottom: 4,right: 16
    }
});

var chartData = [
    {
        name:'BarChart',
        type:'bar',
        color:'purple',
        widthPercent:0.6,
        data:[
            30, 1, 1, 2, 3, 5, 21, 13, 21, 34, 55, 30
        ]
    },
    {
        name:'LineChart',
        color:'gray',
        lineWidth:2,
        showDataPoint:false,
        data:[
            10, 12, 14, 25, 31, 52, 41, 31, 52, 66, 22, 11
        ]
    }
];

var xLabels = ['0','1','2','3','4','5','6','7','8','9','10','11'];

class SimpleChart extends Component {
    render() {
        return (
            <View style={styles.container}>
                <RNChart style={styles.chart}
                    chartData={chartData}
                    verticalGridStep={5}
                    xLabels={xLabels}/>
            </View>
        );
    }
}

Properties

All properties are optional otherwise noted

General

  • chartData (Dictionary) - : one nested block produces one type of chart

    • data - (NumberArray) - Y axis values / Required
    • name - (String) - name of the plot
    • type - (String) - "line" or "bar" / Default: "line"
    • fillColor - (color) - Line chart only: area fill color / If not specified, the line will not be filled
    • lineWidth - (CGFloat) - Line chart only: line width / Default: 1.0
    • widthPercent - (CGFloat) - Bar chart only: [0 - 1.0], 0.1 means very skinny, 1.0 means bars touch each other / Default: 0.5
    • showDataPoint - (BOOL) - show or hide the data points / Default: false
    • dataPointColor - (color) - outline color of the data point / Default: blue
    • dataPointFillColor - (color) - fill color of the data point / Default: blue
    • dataPointRadius - (CGFloat) - the circel radius of the data point / Default: 1.0
  • xLabels (StringArray) - array of all X axis label strings. This determines the X-axis grid as well. Need to match the number of input data in chartData / Required

  • animationDuration (CGFloat) - duration of the animation in seconds / Default: 0.3

  • showGrid (BOOL) - show or hide grid / Default: true

  • verticalGridStep (int) - number of Y axis grids / Default: 3

  • gridColor (color) - color of the grid / Default: lightgray

  • gridLineWidth (CGFloat) - width of the grid line / Default: 0.5

  • showAxis (BOOL) - show or hide axis / Default: true

  • showXAxisLabels (BOOL) - show or hide axis labels for the X axis / Default: true

  • showYAxisLabels (BOOL) - show or hide axis labels for the Y axis / Default: true

  • axisLineWidth (CGFloat) - width of the axis line / Default: 1

  • labelFontSize (CGFloat) - font size of axis labels / Default: 10

  • labelTextColor (color) - text color of axis labels / Default: gray

Known Issues / TODO

  • Sample code cleanup
  • Needs touch support
  • Needs legend
  • Stack Bar Chart
  • Multi Line Chart
  • Scatter/Bubble chart
  • Pie chart