I cannot get the trackball LabelPosition to update my custom annotation

Hi,

I am migrating my Xamarin.Forms project to MAUI and noticed that the XPosition property doesn't exists from the new TrackballPointInfo when it was available in ChartPointInfo from the TrackballCreated event. Will this XPosition be available soon?


4 Replies

DR Dhanaraj Rajendran Syncfusion Team August 22, 2024 07:50 AM UTC

Hi Josue,


We have reviewed your concern regarding the missing XPosition property in the TrackballPointInfo for .NET MAUI. Currently, the XPosition property is not available in the TrackballCreated event arguments. However, you can still obtain the XPosition of the trackball by using the DataItem property, which refers to your data model, in conjunction with the ValueToPoint method of the axis.


To assist you, we have prepared a sample that demonstrates how to display text annotations with the trackball using the TrackballCreated event.


Output:

Note: If you are using a Category Axis, you need to provide the segment index to retrieve the XPosition of the trackball datapoint.

If you have any further questions or require additional assistance, please don't hesitate to reach out. We're here to help.


Regards,

Dhanaraj Rajendran.


Attachment: SF_F194160_76684186.zip


JD Josue Diaz Mayorga replied to Dhanaraj Rajendran August 22, 2024 05:33 PM UTC

Hi Dhanaraj, thanks for the quick response, the example code is not working as expected with the DateTimeAxis, probably I need guidance about to get the segment index and know, if it possible to get ValueToPoint when using SplineAreaSeries with duplicated values.

I'm attaching the MainPage updated from sample project with the design of my current implementation because I'm using SplineAreaSeries instead of ColumnSeries. I just noticed that the trackball is showing dashes for the stroke, when the dashes was only setup for the line style.


Attachment: AnnotationOnTrackballPosition_4d22090.zip


DR Dhanaraj Rajendran Syncfusion Team August 23, 2024 11:32 AM UTC

Hi Josue,


We have carefully reviewed your query and the provided sample. When working with a DateTimeAxis, converting the DateTimeAxis values to OLE Automation dates (which are in double format) is necessary to get accurate positioning on the axis. Simply casting DateTime as double won’t yield the correct results. To assist you further, we’ve included a code snippet below that demonstrates this conversion:

private void OnTrackballCreated(object sender, TrackballEventArgs e)

{

    . . .

    var data = trackballInfo.DataItem as DataItem;

    textAnnotation.X1 = chart.XAxes[0].ValueToPoint(data.Date!.Value.ToOADate());

    textAnnotation.Text = data.Date.Value.ToString("MMM dd, yyyy");

    . . .

}


Output:

Additionally, we have attached the modified sample project for your reference.

Regarding the stroke dash issue you mentioned, where the marker stroke is incorrectly applying the dash pattern meant for the trackball line style, we were able to reproduce this behavior on our end. We’ll need some additional time to investigate this thoroughly. We’ll provide you with further details on or before two business days (27th August 2024).

Thank you for your understanding and patience.


Regards,

Dhanaraj Rajendran.


Attachment: AnnotationOnTrackballPosition_a3684400.zip


NT Nitheeshkumar Thangaraj Syncfusion Team August 27, 2024 12:53 PM UTC

Hi Josue,


We would like to inform you that we have discussed this issue with our development team, and they have identified it as a known issue. It was initially scheduled to be addressed in the Volume 3 main release. However, based on your request, we have included this fix earlier in our latest weekly NuGet release, version 26.2.11 which is available for download (https://www.nuget.org/).


NuGet Version: 26.2.11


Root cause:


The root cause of the issue is that the trackball elements (line, marker, and label) are drawn using the same canvas. After the trackball line is drawn with a stroke dash pattern, the canvas stroke attributes are not reset, causing the subsequent marker and label to inherit the same stroke dash pattern.


We thank you for your support and appreciate your patience. Please contact us if you require any further assistance.


Regards,

Nitheeshkumar.


Loader.
Up arrow icon