- Home
- Forum
- Xamarin.Forms
- How to remove comma(,) in x-axis label?
How to remove comma(,) in x-axis label?
Please check the link below I have given the output image of my following code.
Expected Result :
I need time on the x-axis should be (5:00 Am 10:00 AM 11:00 Pm). when I set time in category axis after time comma will appear I don't know how to remove it.
Actual Result :
https://ibb.co/9G6PqQh
code:
LineChart.PrimaryAxis = new CategoryAxis()
{
CrossesAt = 0,
EnableAutoIntervalOnZooming = true,
PlotOffset = 5,
ShowMajorGridLines = false,
AxisLineStyle = new ChartLineStyle{ StrokeWidth = 0 },
MajorTickStyle=new ChartAxisTickStyle { TickSize = 0 },
LabelStyle=new ChartAxisLabelStyle {
LabelFormat = "hh:mm tt",
FontFamily = "Avenir-Medium.ttf",
FontSize = 11,
TextColor = Color.FromHex("#6D76AF") }
};
SIGN IN To post a reply.
3 Replies
HM
Hemalatha Marikumar
Syncfusion Team
December 23, 2019 06:17 AM UTC
Hi Bharath,
Greetings from Syncfusion.
Greetings from Syncfusion.
We have validated your query with provided screenshot, and we would like to let you know this is our new behavior of X- axis label rendering from Volume 3,2019 release while having the different category values on the series collection.
Until our previous release we have shown first series category values alone in axis labels, we have implemented new feature in Volume 3 release to show all the series different category values with comma.
For more details please refer below UG and release notes.
UG link : https://help.syncfusion.com/xamarin/sfchart/axis#indexed-category-axis
Release Notes : https://help.syncfusion.com/xamarin/release-notes/v17.3.0.14?type=all#sfchart-features
However, you can show first series values alone in axis labels in our latest version by invoking LabelCreated event in CategoryAxis then customizing the axis label based on your requirement as per the below code snippet.
Code Snippet [Xaml]:
|
<chart:SfChart.PrimaryAxis>
<chart:CategoryAxis LabelCreated="CategoryAxis_LabelCreated" />
</chart:SfChart.PrimaryAxis> |
Code Snippet [C#]:
|
private void CategoryAxis_LabelCreated(object sender, ChartAxisLabelEventArgs e)
{
e.LabelContent = e.LabelContent.Split(',')[0].Trim();
} |
And we have prepared a sample based on your requirement and you can download the sample from the below link.
Please let us know if need any further assistance on this.
Regards,
Hemalatha M.
BH
Bharath
December 23, 2019 07:07 AM UTC
Hi Hemalatha,
Thank you for your support issue is resolved. I have one more question for you. Please check the link below.
if you see in that image ending text of x-axis label is not showing full. How do fix this issue?
HM
Hemalatha Marikumar
Syncfusion Team
December 24, 2019 05:54 AM UTC
Hi Bharath,
Thanks for the update and we are glad to hear that solution for removing the comma on the axis label has worked.
Query: if you see in that image ending text of x-axis label is not showing full. How do fix this issue?
We would like to let you know that your requirement is to “Completely show the last axis label” then it can be achieved by setting the EdgeLabelsDrawingMode as Shift for CategoryAxis, and this property is used to position the axis label based on its size as per in below code snippet.
Code Snippet[Xaml]:
|
<chart:CategoryAxis EdgeLabelsDrawingMode="Shift" >
</chart:CategoryAxis>
|
For more details please refer below UG link.
Please let us know if need any further assistance on this.
Regards,
Hemalatha M.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
BH Bharath
- Dec 21, 2019 10:46 AM UTC
- Dec 24, 2019 05:54 AM UTC