react-native-highcharts icon indicating copy to clipboard operation
react-native-highcharts copied to clipboard

Can't access this.props in load

Open nidhi-tandon opened this issue 7 years ago • 3 comments

render(){
            let conf={
                chart: {
                    type: 'spline',
                    animation: Highcharts.svg, // don't animate in old IE
                    marginRight: 10,
                    events: {
                        load:function(){
                            var series = this.series[0];
                            setInterval(() =>{
                                var x = new Date().getTime() // current time
                                y = this.props.y
                                series.addPoint([x,y], true, true);
                            }, 900);
                        }
                    }
                },
                title: {
                    text: 'Live random data'
                }
}
}

Cant access this.props.y in load function and I cant even access constructor variable. Thanks for the help in advance.

nidhi-tandon avatar May 29 '17 12:05 nidhi-tandon

try something like this

render(){
            let self=this;
            let conf={
                chart: {
                    type: 'spline',
                    animation: Highcharts.svg, // don't animate in old IE
                    marginRight: 10,
                    events: {
                        load:function(){
                            var series = this.series[0];
                            setInterval(() =>{
                                var x = new Date().getTime() // current time
                                y = self.props.y
                                series.addPoint([x,y], true, true);
                            }, 900);
                        }
                    }
                },
                title: {
                    text: 'Live random data'
                }
}
}

let me know if this worked for you, and thanks in advance for using the component

Infinity0106 avatar Sep 08 '17 01:09 Infinity0106

Hello Nidhi-tandon,

Any update on this issue? Because I am trying to do the similar thing. I would appreciate if you post your solution to this forum. I tried the suggested solution above and it didn't work for me. Please let us know. Thanks,

farshidbakh avatar Sep 28 '17 18:09 farshidbakh

I dont know how to solve it but what happens is that the complete object is parsed inside the html then concatenated, so the text would be literal not connecting the variables because in the html cant find the variable self.props.y, try passing it as a string maybe

Infinity0106 avatar Oct 27 '17 13:10 Infinity0106

Closing this as I have lost context of this issue.

nidhi-tandon avatar Mar 21 '23 03:03 nidhi-tandon