react-native-highcharts
react-native-highcharts copied to clipboard
Can't access this.props in load
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.
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
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,
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
Closing this as I have lost context of this issue.