Giter VIP home page Giter VIP logo

tayfun-kaya / react-native-graph-kit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from simformsolutionspvtltd/react-native-graph-kit

0.0 0.0 0.0 5.73 MB

Personalized graphs featuring customizable options for React Native app 📈

License: MIT License

Shell 0.15% JavaScript 6.62% Ruby 1.18% C++ 5.90% Objective-C 1.93% Java 12.63% TypeScript 67.27% Objective-C++ 3.60% CMake 0.22% Starlark 0.49%

react-native-graph-kit's Introduction

react-native-graph-kit

@shopify/react-native-skia react-native-graph-kit on npm npm downloads Android iOS MIT


React Native Graph Kit is a powerful library that is built using @shopify/react-native-skia to provide LineChart and BarChart components with interactive tooltips for your React Native applications. With this library, you can effortlessly visualize your data in a clean and intuitive manner, making it easier than ever for users to understand complex datasets.

ℹī¸ Compatibility Notice: This library is designed to work seamlessly with @shopify/react-native-skia version <=0.1.228. Make sure to use this version for optimal compatibility.

  • It also provides an example app and a detailed usage overview of both the components.
  • Both the available components are fully Android and iOS compatible.

đŸŽŦ Preview

LineChart BarChart

Quick Access

Installation | Charts | Properties | Example | License

Installation

1. Install library and @shopify/react-native-skia
npm install react-native-graph-kit @shopify/react-native-skia
--- or ---
yarn add react-native-graph-kit @shopify/react-native-skia
2. Install cocoapods in the ios project
cd ios && pod install

And you are good to begin.


Charts

BarChart LineChart
  • LineChart: Create elegant line charts to showcase trends and patterns in your data.
  • BarChart: Display data using visually appealing bar charts, making comparisons at a glance.

ChartDataType

type ChartDataType = {
  xAxis: {
    labels: string[]
  },
  yAxis: {
    datasets: number[]
  }
};

ChartDataFormat

const data = {
  xAxis: {
    labels: [
      'Alice',
      'Bob',
      'Charlie',
      'Liam',
      'Mia',
      'Nora',
      'Oliver',
      'Penelope',
      'Quinn',
      'Ryan',
      'Sophia'
    ]
  },
  yAxis: {
    datasets: [230, 75, 100, 500, 387, 655, 30, 60, 400, 500, 687]
  }
};

Usage

Basic Example
import React from 'react';
import { SafeAreaView, StyleSheet, View } from 'react-native';
import { BarChart, LineChart } from 'react-native-graph-kit';

const data = {
  xAxis: {
    labels: [
      'Alice',
      'Bob',
      'Charlie',
      'Liam',
      'Mia',
      'Nora',
      'Oliver',
      'Penelope',
      'Quinn',
      'Ryan',
      'Sophia'
    ]
  },
  yAxis: {
    datasets: [120, 350, 400, 70, 87, 655, 10, 20, 400, 70, 87]
  }
};

const App = () => (
  <SafeAreaView style={styles.screen}>
    <View style={styles.chartContainer}>
      <BarChart
        chartData={data}
        barWidth={30}
        barGap={70}
        horizontalGridLineColor={'grey'}
        chartHeight={300}
        yAxisMax={1000}
      />
    </View>
    <View style={styles.chartContainer}>
      <LineChart yAxisMax={1000} chartData={data} xAxisLength={70} initialDistance={30} />
    </View>
  </SafeAreaView>
);

const styles = StyleSheet.create({
  screen: {
    flex: 1
  },
  chartContainer: {
    flex: 1,
    borderRadius: 10,
    borderWidth: 0.5,
    borderColor: 'lightgrey',
    padding: 10,
    margin: 10,
    shadowColor: 'lightgrey',
    shadowOpacity: 1,
    backgroundColor: 'white',
    shadowOffset: {
      height: 6,
      width: 5
    }
  }
});

export default App;

Properties

Chart Props

Prop Default Type Description BarChart LineChart
chartData* null ChartDataType Data to plot graphs ✔ī¸ ✔ī¸
chartHeight 500 number Height of chart in BarChart ✔ī¸ â¤Ģ
showLines true boolean Control visibility of Y Axis Ref lines on the chart ✔ī¸ ✔ī¸
lineHeight 2 number Height of horizontal grid lines in BarChart ✔ī¸ â¤Ģ
lineWidth 3 number The line width value of LineChart â¤Ģ ✔ī¸
lineColor #DE5E69 ColorValue The line color of LineChart â¤Ģ ✔ī¸
barWidth 20 number The width of the bars in BarChart ✔ī¸ â¤Ģ
barColor #DE5E69 ColorValue The color of the bars in BarChart ✔ī¸ â¤Ģ
barRadius 0 number The borderRadius of the bars in BarChart from top ✔ī¸ â¤Ģ
barGap 50 number X Axis length covered by bars ✔ī¸ â¤Ģ
labelSize 18 number The fontsize of labels on the chart ✔ī¸ ✔ī¸
labelColor #000000 ColorValue The font color of chart labels ✔ī¸ ✔ī¸
labelFontFamily System Font ColorValue The font path that will be applied to chart labels ✔ī¸ ✔ī¸
horizontalGridLineColor #D3D3D3 Color The Ref lines color ✔ī¸ ✔ī¸
yAxisMin 0 number The minimum value for the YAxis Plotting ✔ī¸ ✔ī¸
yAxisMax auto number The maximum value for the YAxis Plotting ✔ī¸ ✔ī¸
initialDistance 10 number The initial distance of chart from the Y Axis Labels ✔ī¸ ✔ī¸
xAxisLength auto number Manual distance between x Axis Plotting â¤Ģ ✔ī¸
verticalLabel false boolean Handle rotation of X-Axis Labels ✔ī¸ ✔ī¸
verticalLabelHeight auto number Desired height of the X-Axis â¤Ģ ✔ī¸
chartBackgroundColor #FFFFFF Color Chart background color ✔ī¸ ✔ī¸
xAxisLegend undefined string The X Axis Legend Value ✔ī¸ ✔ī¸
yAxisLegend undefined string The Y Axis Legend Value ✔ī¸ ✔ī¸
xLegendStyles Default TextStyle X Axis Legend styles ✔ī¸ ✔ī¸
yLegendStyles Default TextStyle Y Axis Legend styles ✔ī¸ ✔ī¸

Tooltip Props

Prop Default Type Description BarChart LineChart
displayTooltip false boolean Flag to handle tooltip visibility ✔ī¸ ✔ī¸
toolTipLabelFontSize 12 number Font size ✔ī¸ ✔ī¸
toolTipColor #FF0000 string Tooltip color ✔ī¸ ✔ī¸
toolTipDataColor #FFFFFF string Tooltip data color ✔ī¸ ✔ī¸
toolTipHorizontalPadding 20 number Tooltip padding ✔ī¸ ✔ī¸
toolTipFadeOutDuration 4000 number Duration in ms to fade out tooltip ✔ī¸ ✔ī¸
circularPointerColor #000000 string Color of circular pointer for LineChart â¤Ģ ✔ī¸

Example

A full working example project is here Example

yarn
yarn example ios   // For ios
yarn example android   // For Android

TODO

  • Add option to enable Parametric Curve

Find this library useful? ❤ī¸

Support it by joining stargazers for this repository.⭐

Bugs / Feature requests / Feedbacks

For bugs, feature requests, and discussion please use GitHub Issues, GitHub New Feature, GitHub Feedback

🤝 How to Contribute

We'd love to have you improve this library or fix a problem đŸ’Ē Check out our Contributing Guide for ideas on contributing.

Awesome Mobile Libraries

License

react-native-graph-kit's People

Contributors

mukesh-simform avatar stavan-simform avatar virajpsimformsolutions avatar vishva-simform avatar kavin-m-simform avatar simform-solutions avatar shalu-simformsolutions avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.