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

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

Open San10694 opened this issue 6 years ago • 3 comments

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);

San10694 avatar Dec 02 '19 11:12 San10694

same issue. Any Solution ?

dinhtrumdieu avatar May 21 '20 13:05 dinhtrumdieu

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) => {

}) `

San10694 avatar May 21 '20 15:05 San10694

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

dinhtrumdieu avatar May 21 '20 18:05 dinhtrumdieu