How to make chart responsive when sidebar hide and unhide

How to make chart responsive when side bar hide and unhide?
i use reactjs typescript



5 Replies 1 reply marked as answer

SB Swetha Babu Syncfusion Team January 21, 2022 03:23 PM UTC

Hi asep,

Greetings from Syncfision. 

We can achieve your requirement by calling the refresh method while closing and opening the sidebar menu.  Please find the below code snippet for the same

<AccumulationChartComponent  id='acccharts' ref={chart => this.accchartInstance = chart}></AccumulationChartComponent>
<ChartComponent id='charts' ref={chart => this.chartInstance = chart}> </ChartComponent> 
//close the sidebar 
    closeClick() { 
        this.chartInstance.refresh(); 
        this.accchartInstance.refresh(); 
    } 
    //open the sidebar 
    openClick() { 
        this.chartInstance.refresh(); 
         this.accchartInstance.refresh(); 
    } 


Kindly revert us if you have any concerns.

Thanks, 
Swetha


Marked as answer

AS asep replied to Swetha Babu January 28, 2022 04:30 AM UTC

its work for me, thank you so much



DG Durga Gopalakrishnan Syncfusion Team January 31, 2022 12:19 PM UTC

Hi Asep,


Most welcome. Please get back to us if you need any further assistance. We are always happy in assisting you.


Regards,

Durga G



CN Chedva Neuman replied to Swetha Babu July 17, 2022 03:47 AM UTC

Hi,

I have similar issue,

how i did it in react hooks?


thanks!



DG Durga Gopalakrishnan Syncfusion Team July 18, 2022 12:51 PM UTC

Hi Chedva,
We suggest you to follow below snippet to re-render the chart and accumulation chart using refresh method while working with react hooks. 
<AccumulationChartComponent  id='acccharts'></AccumulationChartComponent>
<ChartComponent id='charts'> </ChartComponent>
  //close the sidebar
    closeClick() {
       var chartObj = document.getElementById("charts").ej2_instances[0];
       var accObj = document.getElementById("acccharts").ej2_instances[0];
       chartObj.refresh();
       accObj.refresh();
    }
    //open the sidebar
   openClick() {     
        var chartObj = document.getElementById("charts").ej2_instances[0];
        //...
       chartObj.refresh();
       //.....
   }
Please let us know if you have any concerns.
Regards,
Durga Gopalakrishnan.

Loader.
Up arrow icon