TradingPal / react-native-highcharts

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

How to pass a parameter to Load() function on events in chart part of the config? #48

Open farshidbakh opened 6 years ago

farshidbakh commented 6 years ago

Hello All,

Based on a passed parameter I need to take different action in the load function in events. How do I do that? It seems I cannot access any passed parameter in the load function. Has anyone done this before?

Thanks, Farshid

Here is my code , events is part of the config.chart that is being passed to ChartView.

I would greatly appreciate your help.

type:this.props.chartType, animation: Highcharts.svg, // don't animate in old IE marginRight: 10, shadow:true, zoomType:"xy", pinchType:"xy", spacingTop: 10, panning:true, events: {

                load: function() {

                     if(passParamterHereToChartView == false) {
                        for (var i = 0; i < this.series.length; i++) {
                            if (i == 0) {
                                var series = this.series[i];
                                if (series != null) {
                                        series.show();
                                }
                            } else {
                                var series = this.series[i];
                                if (series != null) {
                                    series.hide();
                                }
                            }
                        }
                     }

                }
            }
Infinity0106 commented 6 years ago

I see the problem that this.series.length I belive is in you react native scrip, but the complete object of config will be parsed o string so it will not take the values instead it will take the name of the variable