- Home
- Forum
- Xamarin.Forms
- Move x axis without moving points
Move x axis without moving points
Hi there, Sync team!

Is it possible to move (add margin) to the labels without moving the points?
SIGN IN To post a reply.
3 Replies
1 reply marked as answer
YP
Yuvaraj Palanisamy
Syncfusion Team
January 11, 2021 07:36 AM UTC
Hi Jorge Valenzuela,
Greetings from Syncfusion.
We have achieved your requirement “To move the axis label without points” by setting of EdgeLabelDrawingMode exact Interval and IntervalType of DateTimeAxis. Please find the following code snippet for your reference.
Code Snippet:
[Xaml]
|
<chart:SfChart.PrimaryAxis>
<local:ChartAxisExt x:Name="XAxis"
EdgeLabelsDrawingMode="Shift"
EdgeLabelsVisibilityMode="AlwaysVisible">
<chart:DateTimeAxis.LabelStyle >
<chart:ChartAxisLabelStyle LabelFormat="hh:mm tt">
</chart:ChartAxisLabelStyle>
</chart:DateTimeAxis.LabelStyle>
</local:ChartAxisExt>
</chart:SfChart.PrimaryAxis> |
[C#]
|
private void ChartControl_SeriesRendered(object sender, EventArgs e)
{
var min = (ChartControl.PrimaryAxis as DateTimeAxis).VisibleMinimum;
var max = (ChartControl.PrimaryAxis as DateTimeAxis).VisibleMaximum;
var range = max - min;
var visibleLabelRange = range / 3; //Label count (4 - 1)= 3
DateTime baseDate = new DateTime(1899, 12, 30);
var intervalRange = min + visibleLabelRange;
var intervalDate = baseDate.AddDays(intervalRange);
var minimumDate = baseDate.AddDays(min);
var d = intervalDate.Subtract(minimumDate);
XAxis.Interval = (d.Minutes * 60) + d.Seconds;
XAxis.IntervalType = DateTimeIntervalType.Seconds;
} |
Also, we have attached the sample, please find the sample from the below link.
Output:
Regards,
Yuvaraj.
Marked as answer
JV
Jorge Valenzuela
January 11, 2021 10:49 AM UTC
Thank you very much, that worked for me :)
YP
Yuvaraj Palanisamy
Syncfusion Team
January 11, 2021 01:40 PM UTC
Hi Jorge Valenzuela,
Thanks for your update.
Regards,
Yuvaraj
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
- Marked answer
-
JV Jorge Valenzuela
- Jan 8, 2021 09:11 PM UTC
- Jan 11, 2021 01:40 PM UTC