I want to fit the chart to the parent element.

Hi,


How can I fit the chart to the parent element?

I styled the e-chart and thought it fits the parent element, but the element inside the chart sticks out.




The source is as follows.



Regards, 

Pylori.



3 Replies 1 reply marked as answer

SM Srihari Muthukaruppan Syncfusion Team November 19, 2020 04:10 PM UTC

Hi Pylori, 
 
We have analysed your query. From that, we would like to let you know that the chart is responsive with respect to the width and height of its parent element, if its zero, then it will render with its default size(600 * 450). Since while the dashboard panel resizes the height and width of the parent element seem to be zero and the chart gets rendered with the default size. Hence we suggest refreshing the chart manually after panel resize to achieve your requirement using created() and resize() event of DashboardLayout component. we have also modified the style of chart using the class name to achieve your requirement. Please find the below sample, code snippet and screenshot 
  
  
Code Snippet: 
@Html.EJS().DashboardLayout("defaultLayout").Resize("resize").Created("created").Columns(5).AllowResizing(true). 
// add your additional code here 
<script> 
 
    function created() { 
       var chart = document.getElementById("container").ej2_instances[0]; 
       chart.refresh(); 
    } 
    function resize() { 
        var chart = document.getElementById("container").ej2_instances[0]; 
        chart.refresh(); 
    } 
         
 
</script> 
<style> 
    .e-chart { 
        heightinherit !important; 
    } 
    .e-accumulationchart{ 
        heightinherit !important; 
    } 
</style> 
 
Screenshot: 
 
 
 
 
Let us know if you have any concerns. 
 
Regards, 
Srihari M  


Marked as answer

PY Pylori November 20, 2020 07:16 AM UTC

Hi,

thank you for your answer.
I tried the sample.
The behavior of the DashboardLayout component was smooth and very good.
Proceed with development using the DashboardLayout component.

Regards,
Pylori.



BS Baskaran S Syncfusion Team November 23, 2020 05:06 PM UTC

Hi Pylori, 
  
Thanks for your update. 
  
Regards, 
Baskaran S 


Loader.
Up arrow icon