TradingPal / react-native-highcharts

📈 Add Highcharts charts to react-native app for IOS and Android
https://github.com/TradingPal/react-native-highcharts
256 stars 158 forks source link

type is invalid #49

Closed mobitinker closed 6 years ago

mobitinker commented 6 years ago

HI,

Much appreciation for what you've created since it will make my life easy on my project!

I'm probably missing something obvious in trying run a simple example but...

At display of my chart per your readme.md example I get this warning:

ExceptionsManager.js:73 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in.
Check your code at AVDaypart.js:115

My code to make the chart is below:

  myChart () {
    var Highcharts='Highcharts';
    var conf={
        chart: {
            type: 'spline',
            animation: Highcharts.svg, // don't animate in old IE
            marginRight: 10,
            events: {
                load: function () {

                    // set up the updating of the chart each second
                    var series = this.series[0];
                    setInterval(function () {
                        var x = (new Date()).getTime(), // current time
                            y = Math.random();
                        series.addPoint([x, y], true, true);
                    }, 1000);
                }
            }
        },
        title: {
            text: 'Live random data'
        },
        xAxis: {
            type: 'datetime',
            tickPixelInterval: 150
        },
        yAxis: {
            title: {
                text: 'Value'
            },
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        tooltip: {
            formatter: function () {
                return '<b>' + this.series.name + '</b><br/>' +
                    Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) + '<br/>' +
                    Highcharts.numberFormat(this.y, 2);
            }
        },
        legend: {
            enabled: false
        },
        exporting: {
            enabled: false
        },
        series: [{
            name: 'Random data',
            data: (function () {
                // generate an array of random data
                var data = [],
                    time = (new Date()).getTime(),
                    i;

                for (i = -19; i <= 0; i += 1) {
                    data.push({
                        x: time + i * 1000,
                        y: Math.random()
                    });
                }
                return data;
            }())
        }]
    };

    return (
      <ChartView style={{height:300}} conf={conf}></ChartView> <--- line 115
    );

    //return (<Text style={styles.whiteText}>junk</Text>);
}

render () {
    return (
      <View style={{flex: 1}}>
        {this.myChart()}
      </View>
    )
  }
}
mobitinker commented 6 years ago

There's a typo in the example. This line:

  <ChartView style={{height:300}} conf={conf}></ChartView> 

should be:

  <ChartView style={{height:300}} config={conf}></ChartView>