ChartsOrg / Charts

Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.
Apache License 2.0
27.43k stars 5.97k forks source link

Support for React Native #597

Open gutenye opened 8 years ago

gutenye commented 8 years ago

I'm looking for a chart library for React Native, is there's a way to do it?


This issue is dedicated for React Native support, any info and discussions on this matter should go here

DavoCg commented 8 years ago

I'm currently trying to develop a module to use this lib in react native. I'm really new in Swift or Objective C so it's quite difficult for me.

I follow a tutorial to bind swift module to react native and it's quite easy : http://browniefed.com/blog/2015/11/28/react-native-how-to-bridge-a-swift-view/

But for this lib I don't really know where to start.

Your help is welcome :)

gutenye commented 8 years ago

I'm also new to Apple Development. I've followed your tutorial, only get importing works, but can not get chart showing. I need some help, what's missing with below code?

  LineChartView *chart = [[LineChartView alloc] init];
  chart.descriptionText = @"hello";
  chart.noDataTextDescription = @"You need to provide data for the chart.";

  NSMutableArray *xVals = [[NSMutableArray alloc] init];
  [xVals addObject:@"1"];
  [xVals addObject:@"2"];

  NSMutableArray *yVals = [[NSMutableArray alloc] init];
  [yVals addObject:[[ChartDataEntry alloc] initWithValue:1 xIndex:1]];
  [yVals addObject:[[ChartDataEntry alloc] initWithValue:2 xIndex:2]];

  LineChartDataSet *set1 = [[LineChartDataSet alloc] initWithYVals:yVals label:@"hello"];

  NSMutableArray *dataSets = [[NSMutableArray alloc] init];
  [dataSets addObject:set1];

  chart.data = [[LineChartData alloc] initWithXVals:xVals dataSets:dataSets];

  return chart; // the view is used by React Native
  // return [[UIDatePicker alloc] init]; // e.g. this works fine.

Build and run have no errors, but the app show as blank.

tannewt commented 8 years ago

Has anyone started a separate GitHub project for react native bindings to ios-charts? It'd be good to pool resources.

danielgindi commented 8 years ago

I do not use React (yet?) but we'll leave this issue for React people coming here - so you could all join forces :-)

Jpadilla1 commented 8 years ago

I've been working on this library https://github.com/Jpadilla1/react-native-ios-charts in the past few weeks that has react-native bindings to ios-charts. It currently supports Bar chart and Line chart with most of their properties. You can view the properties here https://github.com/Jpadilla1/react-native-ios-charts/blob/master/components/BarChart.js#L131-L389

gutenye commented 8 years ago

@Jpadilla1 nice work :+1:

MattyK14 commented 7 years ago

+1

wuxudong commented 7 years ago

I extended https://github.com/Jpadilla1/react-native-ios-charts. Now it support both android and iOS. You can find it here https://github.com/wuxudong/react-native-charts-wrapper

lukasa1993 commented 2 years ago

any love for this?