- Home
- Forum
- Xamarin.Android
- Conditional Series DataMarker
Conditional Series DataMarker
- Jun 17, 2017 08:40 AM UTC
- Jun 30, 2017 07:14 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.
SIGN IN To post a reply.
5 Replies
PS
Parthiban Sundaram
Syncfusion Team
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;
chartTop.ReloadChart();
}
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.
Regards,
Parthiban S
AK
Albert K
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.
SP
Saravana Pandian Murugan
Syncfusion Team
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.
Regards,
Saravana Pandian M.
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.
Regards,
Saravana Pandian M.
AK
Albert K
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.
SP
Saravana Pandian Murugan
Syncfusion Team
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.
Regards,
Saravana Pandian M.
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.
Regards,
Saravana Pandian M.
SIGN IN To post a reply.
- 5 Replies
- 3 Participants
-
AK Albert K
- Jun 17, 2017 08:40 AM UTC
- Jun 30, 2017 07:14 AM UTC