Set width/min width of axis labels to align multiple charts vertically

Is there a possibility to set something like a width or min width on the y axis labels ? What I want to achieve is that the chart areas of different charts get aligned vertically. Problem is that my charts have different text length of the labels and I found no possibility to align the size of the labels.



5 Replies 1 reply marked as answer

DG Durga Gopalakrishnan Syncfusion Team April 26, 2021 10:22 AM UTC

Hi Michael, 
  
Greetings from Syncfusion. 
  
You can use maximumLabelWidth property to customize the width of axis labels. This will trim labels when axis label width exceeds the provided width. We have specified label width for below chart to achieve your requirement.  
  
Code Snippet :  
  
public primaryYAxis: Object = { 
       maximumLabelWidth: 21, 
       enableTrim: true 
} 
  
Screenshot :  
  
 
  
  
  
  
Kindly revert us if you have any concerns. 
  
Regards, 
Durga G

Marked as answer

MI Michael April 26, 2021 03:23 PM UTC

Thanks for your answer.

Is it possible to align without trimming the labels?


DG Durga Gopalakrishnan Syncfusion Team April 27, 2021 10:42 AM UTC

Hi Michael, 
  
We suggest you to use margin left property to align the chart area left space. In the sample, we have specified margin for first chart alone. We have modified sample and attached for your reference.  
  
Code Snippet : 
  
<ejs-chart [margin]='margin'> 
</ejs-chart> 
public margin: Object = { 
      left : 20 
}; 
  
Screenshot : 
  
 
  
  
  
Kindly revert us if you have any concerns. 
  
Regards, 
Durga G


GW Gary Wilkins September 27, 2021 12:25 PM UTC

Hi,

We are also facing the exact same problem with multiple charts not left-aligning. Unfortunately the suggested solution of adding a set margin to individual charts will not work in our case as the data is dynamic and therefore the Y axis values can and do range from say 0.01 to a few 10,000s.


Is there any way to dynamically calculate the necessary margin based upon the 'maximum' length of the labels displayed on the Y axis ?




DG Durga Gopalakrishnan Syncfusion Team September 28, 2021 03:22 PM UTC

Hi Gary, 

As of now, you can align axis lines of all charts using maximumLabelWidth or margin property only, we don’t have other options to achieve your requirement. You can specify highest maximum label width for all charts, so that axis labels won’t be trimmed and axis lines will be aligned on same position. Please let us know if you have any concerns. 

Regards, 
Durga G

Loader.
Up arrow icon