1.1.1 • Published 2 years ago

react-native-build-charts v1.1.1

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

react-native-build-charts

Getting started

Before using react-native-build-charts, you need to install react-native-svg

$ npm install react-native-svg --save

$ npm install react-native-build-charts --save

Mostly automatic installation

$ react-native link react-native-build-charts

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-build-charts and add RNReactNativeBuildCharts.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNReactNativeBuildCharts.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.reactlibrary.RNReactNativeBuildChartsPackage; to the imports at the top of the file
  • Add new RNReactNativeBuildChartsPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include 'react-native-build-charts'
    project('react-native-build-charts').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-build-charts/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-build-charts')

Windows

Read it! :D

  1. In Visual Studio add the RNReactNativeBuildCharts.sln in node_modules/react-native-build-charts/windows/RNReactNativeBuildCharts.sln folder to their solution, reference from their app.
  2. Open up your MainPage.cs app
  • Add using React.Native.Build.Charts.RNReactNativeBuildCharts; to the usings at the top of the file
  • Add new RNReactNativeBuildChartsPackage() to the List<IReactPackage> returned by the Packages method

Usage

Creating a Bar chart

import {BarChart} from 'react-native-build-charts';

<BarChart width={1000} height={600} data={[
      {
        x: 10,
        y: [10,20,30,40,50]
      },
      {
        x: 20,
        y: [10,20,30,40,50]
      },
      {
        x: 30,
        y: [10,20,30,40,50]
      }
    ]} range={3}/>
PropsData TypeDescription
widthnumberThe width of the chart
heightnumberThe height of the chart
range (optional)numberThe range of the y-axis
data{ x: any, y : Number[] }The data of the chart

Alt Text

Creating a Pie chart

import { PieChart } from 'react-native-build-charts';

<PieChart size={450} data={[
      {
        x: 10,
        y: 10
      },
      {
        x: 20, 
        y: 20
      },
      {
        x: 30,
        y: 30
      }
    ]}/>
PropsData TypeDescription
sizenumberThe size of the chart
data{ x: any, y : Number }The data of the chart

Alt Text

Creating a Line chart

import { LineChart } from 'react-native-build-charts';

<LineChart width={1000} height={575} data={
      [
        {
        x:10,
        y:10
        },
        {
          x: 20,
          y: 20
        },
        {
          x: 30,
          y:30
        },
        {
          x: 40,
          y: 40
        },
        {
          x: 50,
          y: 50
        }
      ]
    }/>
PropsData TypeDescription
widthnumberThe width of the chart
heightnumberThe height of the chart
range (optional)numberThe range of the y-axis
data{ x: any, y : number }The data of the chart
colorstringThe color of the line

Alt Text

1.1.1

2 years ago

1.1.0

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago