TradingPal / react-native-highcharts

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

Can't access external variables inside events.load method and I want to access all the highchart apis outside the scope, please help #115

Open San10694 opened 4 years ago

San10694 commented 4 years ago

I want to access all the high chart APIs outside the scope, I tried ref={'chart' } but didn't help, I am getting all the props via ref but not other functions

for the example, how to use below statements outside of the scope like in componentDidMount() ( ie. this.series[0] is not available outside the scope) var series = this.series[0]; setInterval(function () { var x = (new Date()).getTime(), // current time y = Math.random(); series.addPoint([x, y], true, true); }, 1000);

dinhtrumdieu commented 4 years ago

same issue. Any Solution ?

San10694 commented 4 years ago

use WebView from react-native, insert data in the webview like this <WebView style={{ height: 200, }} ref={'highCharts'} source={{ html:<your highchart string > }} />

and for accessing functions use this

this.refs.highCharts.postMessage(JSON.stringify(data))

and for listening data use this inside your highchart string

` document.addEventListener("message", (event) => {

}) `

dinhtrumdieu commented 4 years ago

use WebView from react-native, insert data in the webview like this <WebView style={{ height: 200, }} ref={'highCharts'} source={{ html:<your highchart string > }} />

and for accessing functions use this

this.refs.highCharts.postMessage(JSON.stringify(data))

and for listening data use this inside your highchart string

` document.addEventListener("message", (event) => {

}) `

It would be great if you could show an example for use series.addPoint() . I'm stuck this issues