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

Wrong value is displayed (CrosshairBehavior)

I using DateTimeCategoryAxis

Selecting across the label gives me the correct value, for example 12:20


I get the wrong value if I select between ticks, for example 1675852200000



1 Reply

LA Lavanya Anaimuthu Syncfusion Team February 9, 2023 12:16 PM UTC

Hi Bar Ilan,


Double value is displayed instead of date time values while selecting the crosshair in between the labels. You can resolve the issue by converting the double value to its equivalent date-time value using the onCrosshairPositionChanging callback as per the below code snippet.


 

SfCartesianChart(

        onCrosshairPositionChanging: (crosshairArgs) {

          if (crosshairArgs.axisName == 'primaryXAxis') {

            String crosshairValue = crosshairArgs.value.toString();

            if (crosshairValue.length > 5) {

              int value = int.parse(crosshairValue);

              crosshairArgs.text = DateFormat.Hm() // Change the date format based on your requirement.

                  .format(DateTime.fromMillisecondsSinceEpoch(value));

            }

          }

        },

…..

}


Regards,

Lavanya A.


Loader.
Up arrow icon