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

Unable to update chart data using functional components #66

Open
mati23 opened this issue Oct 4, 2020 · 1 comment
Open

Unable to update chart data using functional components #66

mati23 opened this issue Oct 4, 2020 · 1 comment

Comments

@mati23
Copy link

mati23 commented Oct 4, 2020

I'm using the new React Native functional components with hooks but I'm not able to update the data of the chart using the
this.chart.setOption(option); on a state change event. I tried do a console log inside the additionalCode parameter but the this object is undefined. I don't know how to reference the echart object using RN Hooks, can someone help me out?

    `const option = { 
    title: {
        show:false,
        text: 'Gráfico Radar'
    },
    tooltip: {},
    legend: {
    orient: 'horizontal',
    position:'bottom',
    left: 0,
    bottom:0,
    type:'scroll',             
    pageButtonPosition:'end', 
    data: chartColumnNameArray,
    },
    radar: {
        radius:'70%',
        name: {
            textStyle: {
                color: '#fff',
                backgroundColor: '#999',
                borderRadius: 3,
                padding: [3, 5]
            }
        },
        indicator: chartValueArray.map((item, index)=>{
        return {name:chartColumnNameArray[index].toUpperCase().substring(0,5).concat('.'), max:maxValue}
        })
    },
    series: [{
        name: 'TEST',
        type: 'radar',          
        data: radarChartData <------------------- //when this state changes I would setOptions and reload chart
    }]
    };

    <View style={{display:  visibleChart==="radarchart"?"flex":"none", width:'100%', height:'60%'}} >                     
             <ECharts option={option} additionalCode={React.useEffect(()=>{this.chart.setOption(option)},[radarChartData])}/>                                                              
     </View>
@rravithejareddy
Copy link

rravithejareddy commented Nov 1, 2022

As shown in the below complex example you need to send additionalCode as String and then use onData for callback.

link

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

2 participants