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

Conditional Series DataMarker

Thread ID:





131047 Jun 17,2017 08:40 AM UTC Jun 30,2017 07:14 AM UTC Xamarin.Android 5
Tags: SfDateTimeRangeNavigator
Albert K
Asked On June 17, 2017 08:40 AM UTC

I have a SfChart and a SfDateTimeRangeNavigator and both share the same data source (200 data points across a 24 hour range).  The SfChart host a line series.  

If i enable the datamarker on the line series with the rangeNavigator selected for 24hrs period then the whole chart is cluttered with the datamarker.  

Is it possible to conditionally enable the datamarker when the range selected holds less than 10 datapoints? .

Thank you.   

Parthiban Sundaram [Syncfusion]
Replied On June 20, 2017 04:19 AM UTC

Hi Albert, 
Thanks for using Syncfusion products. 
We have achieved your requirement using Range Navigator RangeChanged Event and Chart DataMarkerLabelCreated Event in MainActivity.cs. Please find the below code snippet for your reference. 
Code Snippet: 
RangeChanged Event: 
  private void sfRangeNavigator_RangeChanged(object sender, SfDateTimeRangeNavigator.RangeChangedEventArgs e) 
            start = e.P0; 
            end = e.P1; 
DataMarkerLabelCreated Event: 
        private void Series_DataMarkerLabelCreated(object sender, ChartSeries.DataMarkerLabelCreatedEventArgs e) 
            Date labelDate = new Date(); 
            ChartSeries series = sender as ChartSeries; 
            ObservableArrayList dataSource = series.DataSource as ObservableArrayList; 
            if(dataSource != null) 
                labelDate = (dataSource.Get(e.P0.Index) asChartDataPoint).GetX() as Date; 
            if(start != null && end!= null  ) 
                if (!((labelDate.After(start)|| labelDate.Equals(start)) && (labelDate.Before(end) || labelDate.Equals(end)))) 
                    e.P0.Label = "";                
Please let us know, if you need further assistance on this. 
Parthiban S 

Albert K
Replied On June 20, 2017 06:00 AM UTC

Hi,We are close to getting there?  As I have tested,  the DataMarker Label is only rendered when the line series is created.  Is to possible to render the DataMarker Label as we zoom into the line chart?.   What I want to achieve is that when the chart is zoomed out/default there will be lots of data point so I would not want to display the datalabel.  Once the user zooms in to the chart at a point where there are 20 points to be shown, then the DataMarker Label is shown.  Hope that this can be done.Thank you.

Saravana Pandian Murugan [Syncfusion]
Replied On June 21, 2017 02:20 PM UTC

Hi Albert,

We have achieved your requirement by using RangeChanged Event. In this event, we have calculated the ZoomFactor manually with the help of ViewRangeStart, ViewRangeEnd, Minimum, Maximum values of RangeNavigator. We have modified the sample which can be downloaded from the below location.

The value of ZoomFactor can vary between 0 to 1. You can change the condition depends on the range for which you want to show the data markers.

Sample: http://www.syncfusion.com/downloads/support/forum/131047/ze/RangeSelection_DataMarker1889135725

Please check the sample and let us know if you need further assistance on this.

Saravana Pandian M.

Albert K
Replied On June 29, 2017 09:25 AM UTC

Thank you for the example.  I would like to know, is it possible to get a count of data points that is displayed in the visible range of the chart?.   Thank you.

Saravana Pandian Murugan [Syncfusion]
Replied On June 30, 2017 07:14 AM UTC

Hi Albert,

We have achieved your requirement in RangeChanged event. In this event, you can get the data points count by using XValues and ViewRangeStart, ViewRangeEnd of RangeNavigator. Please download the sample from the following location.

Sample: http://www.syncfusion.com/downloads/support/forum/131047/ze/RangeSelection_DataMarker-1629262920

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

Saravana Pandian M.


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

This page will automatically be redirected to the 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