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. Image for the cookie policy date

[SF.Chart] Issue with Chart.PointToValue on DateTimeAxis shifted of 2 days...

Hi,

 

I'm starting to use SF.Chart. I was using traditional LineChart before.

It's basic chart  with a DateTimeAxis as PrimaryAxis and NumericalAxis as SecondaryAxis.

I want to display information on the current point  on Series.MouseMove event like below.

But the function Chart.PointToValue(..) return a wrong value. The date is shifted by 2 days..   How can I fix that..

I have attached a sample

 

Best regards,

Rodolphe

Code snippet [C#]:

void SeriesMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
     var point = e.GetPosition(this.lineChart);
     double xValue = this.lineChart.PointToValue(this.lineChart.PrimaryAxis, point);
     var date = DateTime.FromOADate(xValue);



LineChar_28a71746.zip

2 Replies

RB Rodolphe Billottet February 6, 2014 04:57 AM UTC

Hi,

 

It seems that I solved the issue with the following transformation:

             var point = e.GetPosition(this.lineChart);

            point.X = point.X - (yAxis.ActualWidth + lineChart.Margin.Left);

            double xValue = this.lineChart.PointToValue(this.lineChart.PrimaryAxis, point);

 

Can you confirm ?

 

What the point to have a method 'Chart.PointToValue' if we need to do such transformation ??

You should update the online documentation which is wrong..

http://help.syncfusion.com/ug/wpf/sfchart/default.htm#!documents/transformdatatopoint.htm

 

Regards,

Rodolphe

 



KV Karthikeyan V Syncfusion Team February 6, 2014 11:08 AM UTC

Hi Rodolphe,

Thank you for the update.

We have analysed your reported query. You can achieve your requirement with the help of below code snippet.
Code snippet [C#]:
private void SfChart_MouseMouse(object sender, MouseButtonEventArgs e)
{
SfChart SER = e.Source as SfChart;
Point pt = e.GetPosition(SER.Series[0]); // To get exact position by Chart instance as a replacement for by Series.
YPoint = (SER.PointToValue(SER.SecondaryAxis, pt));
XPoint = (SER.PointToValue(SER.PrimaryAxis, pt));
var date = DateTime.FromOADate(XPoint);
}
And the codes suggested by you is not appropriate solution for this requirement, since this solution may be fail in case of multiple axes with chart.

Query 2: Documentation issue.

Thank you for your feedback. We will modify the mentioned page in our documentation and we will update the modified details in our upcoming release.

Please let us know if you require further assistance on this.

Thanks,
Karthikeyan V.


Loader.
Live Chat Icon For mobile
Up arrow icon