New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-graph-kit

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-graph-kit

Personalized graphs featuring customizable options for React Native app

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

LineChartBarChart

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

BarChartLineChart
  • 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

PropDefaultTypeDescriptionBarChartLineChart
chartData*nullChartDataTypeData to plot graphs✔️✔️
chartHeight500numberHeight of chart in BarChart✔️
showLinestruebooleanControl visibility of Y Axis Ref lines on the chart✔️✔️
lineHeight2numberHeight of horizontal grid lines in BarChart✔️
lineWidth3numberThe line width value of LineChart✔️
lineColor#DE5E69ColorValueThe line color of LineChart✔️
barWidth20numberThe width of the bars in BarChart✔️
barColor#DE5E69ColorValueThe color of the bars in BarChart✔️
barRadius0numberThe borderRadius of the bars in BarChart from top✔️
barGap50numberX Axis length covered by bars✔️
labelSize18numberThe fontsize of labels on the chart✔️✔️
labelColor#000000ColorValueThe font color of chart labels✔️✔️
labelFontFamilySystem FontColorValueThe font path that will be applied to chart labels✔️✔️
horizontalGridLineColor#D3D3D3ColorThe Ref lines color✔️✔️
yAxisMin0numberThe minimum value for the YAxis Plotting✔️✔️
yAxisMaxautonumberThe maximum value for the YAxis Plotting✔️✔️
initialDistance10numberThe initial distance of chart from the Y Axis Labels✔️✔️
xAxisLengthautonumberManual distance between x Axis Plotting✔️
verticalLabelfalsebooleanHandle rotation of X-Axis Labels✔️✔️
verticalLabelHeightautonumberDesired height of the X-Axis✔️
chartBackgroundColor#FFFFFFColorChart background color✔️✔️
xAxisLegendundefinedstringThe X Axis Legend Value✔️✔️
yAxisLegendundefinedstringThe Y Axis Legend Value✔️✔️
xLegendStylesDefaultTextStyleX Axis Legend styles✔️✔️
yLegendStylesDefaultTextStyleY Axis Legend styles✔️✔️

Tooltip Props

PropDefaultTypeDescriptionBarChartLineChart
displayTooltipfalsebooleanFlag to handle tooltip visibility✔️✔️
toolTipLabelFontSize12numberFont size✔️✔️
toolTipColor#FF0000stringTooltip color✔️✔️
toolTipDataColor#FFFFFFstringTooltip data color✔️✔️
toolTipHorizontalPadding20numberTooltip padding✔️✔️
toolTipFadeOutDuration4000numberDuration in ms to fade out tooltip✔️✔️
circularPointerColor#000000stringColor 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

Keywords

FAQs

Package last updated on 27 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc