- Home
- Forum
- Angular - EJ 2
- Bar Chart - Align xAxis label to the left
Bar Chart - Align xAxis label to the left
Hi. I'm trying to do something simple but I'm not sure if it's possible, couldn't find anything in documentation.
I need to align the labels for X Axis in Bar Chart to the left, so they start at the same place. I'll add an image as example.
Kind regards,
Gabriel
SIGN IN To post a reply.
5 Replies
1 reply marked as answer
DG
Durga Gopalakrishnan
Syncfusion Team
August 12, 2020 05:36 PM UTC
Hi Gabriel,
We have validated your reported scenario with attached sample. We suggest you trim axis labels using maximum label width to achieve your requirement. We have specified enableTrim property as true and maximumLabelWidth as 122 based on your requirement for x axis in provided sample. Please check with the below code snippet and screenshot.
Code Snippet
|
public primaryXAxis: Object = {
maximumLabelWidth: 122,
enableTrim: true
}; |
Screenshot
Sample
UG
Kindly revert us, if you have any concerns.
Regards,
Durga G
GA
Gabriel Alva
August 13, 2020 06:26 PM UTC
Hi, thank you for your answer.
I checked the code and I have two issues with it:
First, this would work only in this case since you set the value for maximumLabelWidth. It's not dynamic with any kind of value for x.
Second, is not exactly what I need. It's trimming part of the text, and I need it to be complete. Something like this:

I checked the code and I have two issues with it:
First, this would work only in this case since you set the value for maximumLabelWidth. It's not dynamic with any kind of value for x.
Second, is not exactly what I need. It's trimming part of the text, and I need it to be complete. Something like this:

Is there a way to accomplish this?
Kind regards
Kind regards
DG
Durga Gopalakrishnan
Syncfusion Team
August 15, 2020 04:59 AM UTC
Hi Gabriel,
We have validated your reported scenario. We have prepared a workaround to achieve your requirement. In chart loaded event, we have specified text anchor as start and x position as 10 pixel to display axis labels from start location. Please check with the below code snippet and sample.
Code Snippet
|
public loaded(args: ILoadedEventArgs): void {
var axisLabelEle = document.getElementById("chartcontainer").querySelectorAll('[id*="chartcontainer0_AxisLabel_"]');
for (var i = 0; i < axisLabelEle.length; i++) {
var ele = axisLabelEle[i];
if(ele){
ele.setAttribute('text-anchor', 'start');
ele.setAttribute('x', '10');
}
}
}; |
Screenshot
Sample
Kindly revert us, if you have any concerns.
Regards,
Durga G
Marked as answer
GA
Gabriel Alva
August 20, 2020 10:24 PM UTC
Hi Durga
Thank you very much, that solved our issue with the alignment of the text.
Regards,
Gabriel
SM
Srihari Muthukaruppan
Syncfusion Team
August 21, 2020 05:52 AM UTC
Hi Gabriel,
Most welcome. Kindly get in touch with us, if you requires further assistance. We are always happy in assisting you.
Thanks,
Srihari M
SIGN IN To post a reply.
- 5 Replies
- 3 Participants
- Marked answer
-
GA Gabriel Alva
- Aug 11, 2020 03:52 PM UTC
- Aug 21, 2020 05:52 AM UTC
