Giter Club home page Giter Club logo

react-native-chartjs's Introduction

抱歉最近没有时间维护此组件,给大家带来的不便敬请谅解。 Sorry for no time to maintain the component in time.

react-native-chartjs

用法: 将表格的参数作为chartConfiguration传入 示例代码:

import React, {
  Component
} from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View
} from 'react-native';

import Chart from 'react-native-chartjs';
const chartConfiguration = {
    type: 'bar',
    data: {
      labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
      datasets: [{
        label: '# of Votes',
        data: [12, 19, 3, 5, 2, 3],
        backgroundColor: [
          'rgba(255, 99, 132, 0.2)',
          'rgba(54, 162, 235, 0.2)',
          'rgba(255, 206, 86, 0.2)',
          'rgba(75, 192, 192, 0.2)',
          'rgba(153, 102, 255, 0.2)',
          'rgba(255, 159, 64, 0.2)'
        ],
        borderColor: [
          'rgba(255,99,132,1)',
          'rgba(54, 162, 235, 1)',
          'rgba(255, 206, 86, 1)',
          'rgba(75, 192, 192, 1)',
          'rgba(153, 102, 255, 1)',
          'rgba(255, 159, 64, 1)'
        ],
        borderWidth: 1
      }]
    },
    options: {
      maintainAspectRatio : false,
      scales: {
        yAxes: [{
          ticks: {
            beginAtZero: true
          }
        }]
      }
    }
  
}; 
export default class App extends Component < {} > {
  constructor(props) {
    super(props);
  
    this.state = {
      chartConfiguration : chartConfiguration
    };
  }
  render() {
    
    return ( 
      <View style = {{ flex : 1 }}>    
          <Chart chartConfiguration = {
            this.state.chartConfiguration
          }
	   defaultFontSize={20}/>  
      </View> 
    );
  }
}

react-native-chartjs's People

Contributors

kbourchbane avatar moon-009 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

react-native-chartjs's Issues

Android warning with Expo

Hi,

I get error while develop with Expo, the screenshot as below,

Encountered an error loading page, Object {
"canGoBack": false,
"canGoForward": false,
"code": -1,
"description": "net::ERR_FILE_NOT_FOUND",
"loading": false,
"target": 173,
"title": "",
"url": "file:///android_asset/dist/index.html",
}

  • node_modules/expo/build/environment/muteWarnings.fx.js:18:23 in warn
  • ... 20 more stack frames from framework internals

image

Thanks

Problem in production

Everything works in debugging versions on both platforms.
But in release versions on IOS and Android nothing shows.

iOS warning scalesPageToFit

There is a warning on iOS devices connected to the scalesPageToFit(proprety is not supported when useWebKite = true).

The line
scalesPageToFit={Platform.OS === 'ios' ? false : true}

should be replaced by
scalesPageToFit={Platform.OS === 'ios' ? undefined : true}

Undefined in place of "false" is a better practice.

Thank you.

Update Real-Time Line Chart Dynamically

I'm trying to get my chart to update dynamically as new data comes. I have already updated the values, but the graph does not update the change in data dynamically. What is the equivalent function of the React function chart.update() for react-native to enable the graph to update?

`import {Chart,LineChart,BarChart,PieChart,ProgressChart,ContributionGraph} from 'react-native-chart-kit'
import React, { Component } from 'react';
import { View, Text, StyleSheet, ImageBackground, Icon, FlatList, Button, TextInput, Dimensions } from 'react-native';
import CheckBox from 'react-native-check-box'

export default class FocusScreen extends React.Component {
constructor(props) {
super(props);
this.state = {
isChecked: false,
}
this.dates =['January', 'February', 'March', 'April', 'May', 'June']
this.values = [20, 30,40,50,60,70]
this.shouldRedraw = true
this.chart = new LineChart();
}

componentDidMount(){
this.timer = setInterval(()=> this.returnLabels(), 1000)
this.timer = setInterval(()=> this.returnData(), 1000)
}

updateShouldRedraw = () => {
this.shouldRedraw = true;
}

returnLabels = () => {
this.dates.push(parseInt(Math.random()*100).toString())
console.log(this.dates)
return this.dates
}

returnData = () => {
this.values.push(parseInt(Math.random()*100))
console.log(this.values)
return this.values
}

render() {
return (



Bezier Line Chart

<LineChart

        data={{
          labels: this.returnLabels(),
          datasets: [{
            data: this.returnData()
          }]
        }}
        redraw
        width={Dimensions.get('window').width /2} // from react-native
        height={400}
        yAxisLabel={'$'}
        chartConfig={{
          backgroundColor: '#e26a00',
          backgroundGradientFrom: '#fb8c00',
          backgroundGradientTo: '#ffa726',
          decimalPlaces: 2, // optional, defaults to 2dp
          color: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
          style: {
            borderRadius: 16
          }
        }}
        bezier
        style={{
          marginVertical: 8,
          borderRadius: 16
        }}
      />
    </View>
  </View>
);

}
}

const styles = StyleSheet.create({
container: {
flex: 1,

alignItems: 'center',
width: '100%',
height: '100%',

},
imageBackground: {
height: '100%',
width: '100%',
},
wrapper: {
borderWidth: 3,
borderColor: 'green',
flex: 1,
margin: '10%',
marginTop: '20%',
height: 40,
justifyContent: 'flex-end',
alignItems: 'stretch',

},

leftText: {
fontSize: 28,
}
})`

iOS: Error evaluating injectedJavaScript

I've been checking on this error and im not able to fix it, the error is:

"Error evaluating injectedJavaScript: This is possibly due to an unsupported return type. Try adding true to the end of your injectedJavaScript string. Error Domain=WKErrorDomain Code=4 "A JavaScript exception ocurred"
UserInfo ={WKJavaScriptExceptionLineNumber=0, WKJavaScriptExceptionMessage=, WKJavaScriptExceptionColumnNumber=0, NSLocalizedDescription=A JavaScript exception occurred}

I've been checking inside the library and everything is working perfectly, even in Android, it's working correctly.

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.