We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to converts the mouse point value to primary axis (date time axis) value

Thread ID:

Created:

Updated:

Platform:

Replies:

125297 Aug 5,2016 04:13 PM UTC Aug 18,2016 12:19 PM UTC WPF 5
loading
Tags: SfChart
komatora
Asked On August 5, 2016 04:13 PM UTC

Hi,
I am using the wpf UI of Syncfusion to building a app for stock analysis and I am new for this. I want to implement the the multiple row chart with candle stick and volume only. Now I am implementing the autoscale Y when zooming Xaxis (date time axis). I use the SelectionZoomingEndEventArgs to get the selected area and converts the pixel value to chart value by PointToValue. However, the return value is not a date format. How can I get the date format? Below is my code. Thanks a lot for your assistance.
private void chart1_SelectionZoomingEnd(object sender, SelectionZoomingEndEventArgs e)
{
Point mousePointstart = new Point(e.ZoomRect.Left, e.ZoomRect.Top);
Point mousePointend = new Point(e.ZoomRect.Right, e.ZoomRect.Top);
double xValuestart = this.chart1.PointToValue(this.chart1.PrimaryAxis, mousePointstart);
double YValuestart = this.chart1.PointToValue(this.chart1.SecondaryAxis, mousePointstart);
double xValueend = this.chart1.PointToValue(this.chart1.PrimaryAxis, mousePointend);
double YValueend = this.chart1.PointToValue(this.chart1.SecondaryAxis, mousePointend);
double chartPointX = this.chart1.ValueToPoint(this.chart1.PrimaryAxis, xValuestart);
}

Devi Aruna Maharasi Murugan [Syncfusion]
Replied On August 8, 2016 09:23 AM UTC

Hi Komatora, 
  
Thanks for contacting Syncfusion Support. 
  
The PointToValue method returns the DateTimeAxis axis value as double value of OLE automation date. This value can be converted in to its equivalent date time format, by using FromOADate extension method as shown in the below code snippet.  
  
[C#] 
 
     double xStart = chart.PointToValue(chart.PrimaryAxis, mousePointStart); 
     DateTime startDate = DateTime.FromOADate(xStart); 
  
We have prepared a demo sample based on your requirement and it can be downloaded from below link, 
  
  
Regards, 
Devi 





komatora
Replied On August 9, 2016 05:11 AM UTC

Hi Devi,

Thanks for your reply and Demo. I have other question After checking your Demo, the return date value is not exactly the start and end point what I selected. The return value seems shift with a constant value. Attached please find the screen capture of the return value and selection screen.


Attachment: Selection_get_vale_ec383e38.zip

Devi Aruna Maharasi Murugan [Syncfusion]
Replied On August 10, 2016 10:06 AM UTC

Hi Komatora, 
  
Thanks for your update. 
  
In order to get the exact position of chart area, we have to reduce the SeriesClipRect value to corresponding positon as shown in the below code.  
 
[C#] 
 
     Point mousePointStart = new Point(e.ZoomRect.Left - chart.SeriesClipRect.Left,  
 
                                           e.ZoomRect.Top - chart.SeriesClipRect.Top); 
 
     Point mousePointEnd = new Point(e.ZoomRect.Right - chart.SeriesClipRect.Left,  
  
                                    e.ZoomRect.Top - chart.SeriesClipRect.Top); 
  
We have modified the demo sample and it can be downloaded from below link, 
  
  
Please refer the below link to know about the axis value to pixel value conversion, 
  
  
Regards, 
Devi 




komatora
Replied On August 17, 2016 03:46 PM UTC

Hi Devi,

Thanks for your updated samples and it is working fine.

And I want to confirm that can I change the Y axis's value when the zoom changed event is triggered? It got some error during run time. Please check the below code.

        private void chart_ZoomChanged(object sender, ZoomChangedEventArgs e)
        {


            NumericalAxis yAsix = new NumericalAxis()
            {
                Maximum = 890,
                Minimum = 820,
            };

            chart.SecondaryAxis = yAsix;


        }

Thank you


Devi Aruna Maharasi Murugan [Syncfusion]
Replied On August 18, 2016 12:19 PM UTC

Hi komatora, 
  
Thanks for your update. 
  
We would like inform you that, we are unable to change the chart axis in Zoom changed event. Since we have calculated the zooming value based on axis and we cannot modify that Axes collection in that flow.  
  
Regards, 
Devi 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;