Getting start and end (date) from the PrimaryAxis?
Hi Syncfusion Support!
Is there any change to get and set the start (from) and end (to) value (for example date) for a zoomed PrimaryAxis of a SfChart? We are using so far ZoomPosition and ZoomFactor to have an experience for panning and zooming into our data. Of course, if we change start and end value of a SfChart the ZoomPosition and ZoomFactor have to recalculate to show the new "range" of data.
Thank you!
regards,
Sascha
SIGN IN To post a reply.
3 Replies
MK
Muneesh Kumar G
Syncfusion Team
February 20, 2019 10:51 AM UTC
Hi Sascha,
Greetings from Syncfusion.
We have analyzed your requirement and you can achieve this by getting calculated range in ActualRangeChanged event in axis and setting required range in event arguments as per the below code snippet.
Code snippet
|
<chart:SfChart.PrimaryAxis>
<chart:CategoryAxis ActualRangeChanged="CategoryAxis_ActualRangeChanged"/>
</chart:SfChart.PrimaryAxis> |
|
private void CategoryAxis_ActualRangeChanged(object sender, ActualRangeChangedEventArgs e)
{
double min = (double)e.ActualMinimum;
double max = (double)e.ActualMaximum;
e.ActualMinimum = min + 1;
e.ActualMaximum = max - 1;
} |
Hope this helps you.
Regards,
Muneesh Kumar G.
SA
Sascha
February 20, 2019 12:19 PM UTC
Hi Syncfusion Support!


and 
Thank you for your answer!
Regrettably, we do not get the required data.
Here two screenshots to explain our requirements in more detail.
This is our SfChart without any zooming or panning.
Now we are zooming & panning into the data.
From your code we only get the start and end date from the "whole chart series range". Here some log when the event is firing:
CategoryAxis_ActualRangeChanged - 20.02.2019 12:15:41 - 20.02.2019 12:59:59
CategoryAxis_ActualRangeChanged - 20.02.2019 12:15:41 - 20.02.2019 12:59:59
CategoryAxis_ActualRangeChanged - 20.02.2019 12:15:41 - 20.02.2019 12:59:59
Done with: Console.WriteLine($"CategoryAxis_ActualRangeChanged - {(DateTime)e.ActualMinimum} - {(DateTime)e.ActualMaximum}");
This meets exactly the dates from the first example.
But we need
If we have any chance to get these "dates"? It is not necessary that an event is firing.
And, of course, we have to set these values for some important user experience! Perhaps a way to "recalculate" ZoomPosition and Factor?
Thank you very much!
regards,
Sascha
MK
Muneesh Kumar G
Syncfusion Team
February 21, 2019 11:36 AM UTC
Hi Sascha,
Thanks for your update.
We have analyzed your requirement and you can achieve this by getting VisibleRange in axis and converting range values in to DateTime as per the below code snippet.
Code snippet
|
private void DateTimeAxis_ActualRangeChanged(object sender, ActualRangeChangedEventArgs e)
{
var range = xAxis.VisibleRange;
if (!double.IsNaN(range.Start) && !double.IsNaN(range.End))
{
DateTime min = DateTime.FromOADate(range.Start);
DateTime max = DateTime.FromOADate(range.End);
}
} |
|
<chart:SfChart.PrimaryAxis>
<chart:DateTimeAxis x:Name="xAxis" ActualRangeChanged="DateTimeAxis_ActualRangeChanged"/>
</chart:SfChart.PrimaryAxis> |
We have prepared a sample based on this, please find the sample from the following location.
Hope it helps you.
Regards,
Muneesh Kumar G.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
SA Sascha
- Feb 19, 2019 11:06 AM UTC
- Feb 21, 2019 11:36 AM UTC