Sfchart DateTimeCategoryAxis VisibleRange value convertion

Hi,

I would like to clarify the value type of Visible Range in DateTimeCategoryAxis . It cannot return a correct datetime value of the visible range in my code, when I use FromOAdate function to convert it to a date time value. Actually I want to use it to write a function to auto-scale the y-axis after zooming. Could you let me know what is the meaning of the value of Visible Range in DateTimeCategoryAxis.

Thanks


19 Replies

DS Durgadevi Selvaraj Syncfusion Team December 16, 2017 01:30 PM UTC

Hi Komatora, 
  
Thanks for contacting Syncfusion Support. 
  
DateTimeCategoryAxis plots the data based on the data point index and not based on the actual value of the data. That is the reason why you are getting the indexes instead of date value in minimum and maximum. However, you can achieve this requirement by getting the respective date value by index. Please refer the below code, 
Code Snippet[C#] 
  private void SfChart_ZoomChanged(object sender, Syncfusion.UI.Xaml.Charts.ZoomChangedEventArgs e) 
  { 
            if (e.Axis is DateTimeCategoryAxis) 
            { 
                 var axis = e.Axis as DateTimeCategoryAxis; 
                int startIndex =(int) axis.VisibleRange.Start; 
                int endIndex = (int)axis.VisibleRange.End; 
  
                DateTime visibleStartDate = (view.Collection as ObservableCollection<Model>)[startIndex].XValue; 
                DateTime visibleEndDate = (view.Collection as ObservableCollection<Model>)[endIndex].XValue;             
     }             
  } 
Please find the reference sample from below link, 

  
If your requirement is different from the above solution then please revert us with more information about your requirement. So that, it would be more helpful for us to provide a solution as sooner. 
  
Regards, 
Durgadevi S 



KO komatora December 16, 2017 04:23 PM UTC

Hi Durgadevi,

Thank you for your information and code, it is very clear. And I can get the correct date time value from visible range start and end value by your code.

 thanks and Regards,


DS Durgadevi Selvaraj Syncfusion Team December 18, 2017 05:38 AM UTC

Hi Komatora, 
 
We glad to know that your problem has been resolved. 
 
Please let us know if you required any further assistance on this. 
 
Regards, 
Durgadevi S 



KO komatora December 19, 2017 06:27 AM UTC

Hi Durgadevi ,

How can I get the Selected range's members from RangeNavigator ValueChanged event. Please check the below code. The members in Object "items"  has properties - max, min and date.
I want to find the maximum number and minimum number of  the properties - max and min respectively. Because i making  the auto scale Y axis in sfchart after changing the selected range of RangeNavigator.

        private void RangeNavigator_ValueChanged(object sender, EventArgs e)
        {
            var items = (sender as SfDateTimeRangeNavigator).SelectedData as ObservableCollection<object>;
        }

Thanks for your help.
  



DS Durgadevi Selvaraj Syncfusion Team December 19, 2017 10:41 AM UTC

Hi Komatora, 

We have analyzed your requirement and we guess that your requirement is to get the value of view range start and end of range navigator. If so, you can achieve this using ViewRangeStart and ViewRangeEnd property of SfDateTimeRangeNavigator. Please refer the below code, 

Code Snippet[C#] 

private void RangeNavigator_ValueChanged(object sender, EventArgs e) 
{ 
            SfDateTimeRangeNavigator rangeNavigator = sender as SfDateTimeRangeNavigator; 
            var viewRangeStartDate = rangeNavigator.ViewRangeStart; 
 
            var vieeRangeEndDate = rangeNavigator.ViewRangeEnd; 
             
} 

Please find the reference sample from below link, 

Also, you can refer our UG Documentation link to know more about SfDateTimeRangeNavigator properties, 

Please let us know if you have any concerns on the above solution. 

Regards,  
Durgadevi S 



KO komatora December 19, 2017 04:43 PM UTC

Hi Durgadevi

Thanks for your sample. I am using the DatetimeCatagory as X-axis in the sfchart. And the data is in minutes, not daily. I found the same issue if i change the data interval to minutes and DatetimeCatagory as X-axis in your sample (please find the attached). The return of the viewrangestart and viewrangestart is not the correct datetime value after changing the selected range of Rangenavigator. 





Attachment: RangeNavigtor_datetimecatagory_8e8ba88d.zip


DS Durgadevi Selvaraj Syncfusion Team December 20, 2017 01:43 PM UTC

Hi Komatora, 
 
Thanks for the update. 
 
We have analyzed the given sample and you have set ViewRangeStart  and ViewRangeEnd with wrong date time value so you are unable to  change the view ranges properly. 
 
However, we have resolved this problem by setting proper date time value to the ViewRangeStart and ViewRangeEnd property of range navigator as like in the below code, 
 
Code Snippet [XAML] 
   <chart:SfDateTimeRangeNavigator 
                ItemsSource="{Binding StockPriceDetails}" 
                ValueChanged="RangeNavigator_ValueChanged" 
//you need to set minimum date value to ViewRangeStart and Maximum value to ViewRangeEnd 
                ViewRangeStart="2012/1/1 12:00am"                     ViewRangeEnd="2012/1/1 11:00pm" 
                XBindingPath="Date"> 
 
Please find the below screenshots, 
1.ViewRangeStart and ViewRangeEnd value after changing the ranges. 
 
 
2.Output screenshot  
 
 
Please find the modified sample from below link, 
Please let us know any concerns. 
Regards,  
Durgadevi S 



KO komatora December 22, 2017 03:47 PM UTC

Hi Durgadevi 

Thank you very much for your information, but I have another issue on the date value of rangenavigator and chart visible range. Attached please find the code and screen capture of the app. The datetime label of rangenavigator and chart x-axis is not match. Could you advise how to solve it?

Thanks and regards,
Andrew

Attachment: Candlestick_testing_8d4f31b.zip


DS Durgadevi Selvaraj Syncfusion Team December 27, 2017 03:51 AM UTC

 
You can resolve this problem by setting RangePadding as None to the range navigator as like in the below code, 
 
Code Snippet[XAML] 
 
<chart:SfDateTimeRangeNavigator 
                RangePadding="None" 
                ItemsSource="{Binding StockPriceDetails}" 
                ValueChanged="RangeNavigator_ValueChanged" 
                ViewRangeEnd="2017/11/14 11:00pm" 
                ViewRangeStart="2017/11/13 12:00am" 
                XBindingPath="date"/> 
 
Please find the output screenshot, 
 
 
Regards,  
Durgadevi S 



KO komatora December 27, 2017 04:29 PM UTC

Hi Durgadevi,

Thank you for your solution, it help to solved the start and end datetime value mismatch issue, however it still have mismatch issue if move the selected range to other dates after adding the new setting.

Attached pls find the screen capture.

Regards,
Andrew

Attachment: candlestick01_71417e42.zip


DS Durgadevi Selvaraj Syncfusion Team January 2, 2018 04:11 PM UTC

Hi Martin, 
Thanks for contacting Syncfusion Support. 
It is possible to keep the minimum as less than 60 minutes from now and maximum as greater than 5 minutes from now until user zoom and pan the Chart. But, we need to specify the minimum and maximum to restrict the panning at each direction instead of infinitive. So, could you please let us know the purpose of panning at each direction whether it contains data or you would like to show the empty Chart. 
Regards, 
Durgadevi S 



KO komatora replied to Durgadevi Selvaraj January 3, 2018 09:03 AM UTC

Hi Martin, 
Thanks for contacting Syncfusion Support. 
It is possible to keep the minimum as less than 60 minutes from now and maximum as greater than 5 minutes from now until user zoom and pan the Chart. But, we need to specify the minimum and maximum to restrict the panning at each direction instead of infinitive. So, could you please let us know the purpose of panning at each direction whether it contains data or you would like to show the empty Chart. 
Regards, 
Durgadevi S 


Hi Durgadevi,

You may replied to a wrong person.

I copied my question as below for your reference.

*******************************************************

komatora
Replied On December 27, 2017 11:29 AM

Hi Durgadevi,

Thank you for your solution, it help to solved the start and end datetime value mismatch issue, however it still have mismatch issue if move the selected range to other dates after adding the new setting.

Attached pls find the screen capture.

Regards,
Andrew

Attachment: candlestick01_71417e42.zip
************************************************************

Pls kindly check.

Regards,
Andrew,


DS Durgadevi Selvaraj Syncfusion Team January 5, 2018 03:56 AM UTC

Sorry for the inconvenience. 
We would like to inform you that the behavior of DateTimeCategoryAxis will plot the data at the index of actual data point and not based on the data point value. But, range navigator interval and range is calculated based on the minimum and maximum of the data collection and it will not consider the missing points at intermediate level. So, we suggest you to use DateTimeAxis instead of DateTimeCategoryAxis or else you can try to achieve this requirement by collapsing the built-in range navigator label and show the PrimaryAxis label of Chart which is plotted inside the range navigator.  
 
Regards,  
Durgadevi S 



KO komatora January 5, 2018 02:57 PM UTC

Hi Durgadevi

Thank you for your information. Since my data has three trading periods(two breaks) in a trading day. But I checked your DateTimeAxis can only set one set of Open&Close value. Could you advise is there any option to set more than one set of Open&Close value in DateTimeAxis?

Thanks 
Andrew

 


DS Durgadevi Selvaraj Syncfusion Team January 8, 2018 02:10 PM UTC

Hi Komatora, 
 
We have tried to understand your requirement but unable to get it clearly. DateTimeAxis plots the data at provided x value of your model. For example, if you provide three different data at 9 AM, 1 PM and 6 PM for a day, it plots the series with respective open & close values exactly at the given time. Also, we request you to provide us some more information about your exact requirement. So that, it would be really helpful for us to provide a solution sooner. 
 
Regards,  
Durgadevi S 



KO komatora January 8, 2018 03:38 PM UTC

Hi Durgadevi,

Attached please find the data sample for your reference.

<chart:DateTimeAxis
                    Name="axis1"
                    AxisLineStyle="{StaticResource AxisStyle}"
                    OpenTime="09"
                    CloseTime="16"
                    EnableBusinessHours="True"
...........>

I changed the Axis type to DateTimeAxis and enable the BusinessHours to remove the gap in candlestick chart. However in my data the business periods are as below:

Period 1: 9:35 to 12:00

Period 2: 13:05 to 16:00

and some data has the period 3: 17:00 to 01:00

I want to show the candlestick data continuously without any gaps in the chart.

Thank and regards,
Andrew

      

Attachment: Candlestick_testing2_3cd285ed.zip


DS Durgadevi Selvaraj Syncfusion Team January 9, 2018 01:11 PM UTC

Hi Komatora, 
 
As informer earlier, we can’t get the same value between chart and range navigator even though setting chart with Business hours for date time axis since the range navigator will not consider the missing point at the intermediate level.  
 
Also, we recommend you to use chart as direct content to the range navigator in order to get same value between chart and range navigator. 
 
Please find the reference output screenshot below, 
   
We have modified the provided sample based on the above solution and it can be downloaded from below link, 
 
Regards,  
Durgadevi S 



KO komatora January 9, 2018 03:21 PM UTC

Hi Durgadevi,

Thank you very much for your advise.

Best regards,
Andrew




DS Durgadevi Selvaraj Syncfusion Team January 10, 2018 05:18 AM UTC

Hi Komatora, 
Thanks for the update. 
  
Please let us know if you required any further assistance on this. 
Regards, 
Durgadevi S 


Loader.
Up arrow icon