Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't access this.props in load #33

Closed
nidhi-tandon opened this issue May 29, 2017 · 4 comments
Closed

Can't access this.props in load #33

nidhi-tandon opened this issue May 29, 2017 · 4 comments

Comments

@nidhi-tandon
Copy link

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.

@Infinity0106
Copy link
Contributor

Infinity0106 commented Sep 8, 2017

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

@farshidbakh
Copy link

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,

@Infinity0106
Copy link
Contributor

Infinity0106 commented Oct 27, 2017

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

@nidhi-tandon
Copy link
Author

Closing this as I have lost context of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants