Is it possible to display only one or multiple DataMarker based ShowMarker ?

            <chart:SfChart x:Name="chart">

                <chart:SfChart.Series>

                    <chart:LineSeries

                            ItemsSource ="{Binding ChartPoints}" XBindingPath="DateTime"

                            YBindingPath="Value" EnableTooltip="True" StrokeWidth="5">

                        <chart:LineSeries.DataMarker>

                            <chart:ChartDataMarker

                                MarkerColor="Red"

                                ShowMarker="{Binding IsMarkerVisible}" //// -----This part its not working.

                                ShowLabel="False"

                                MarkerWidth="20"

                                MarkerHeight="20"

                                MarkerType="Diamond" />

                        </chart:LineSeries.DataMarker>

                 </chart:LineSeries>

 </chart:SfChart.Series>

</chart:SfChart>


3 Replies

YP Yuvaraj Palanisamy Syncfusion Team April 19, 2022 01:04 PM UTC

Hi Sujeet Kumar,


We have achieved your requiremnt “Want to show DataMarker symbol based on IsMarkerVisible model property” with the help of DataMarkerLabelCreated event. Please find the code example below.


CodeSnippet:

<chart:LineSeries ItemsSource="{Binding Data1}"

                      XBindingPath="XValue"

                      YBindingPath="YValue"

                      DataMarkerLabelCreated="LineSeries_DataMarkerLabelCreated">

    <chart:LineSeries.DataMarker>

        <chart:ChartDataMarker ShowLabel="False"

                               ShowMarker="True"

                               MarkerHeight="10"

                               MarkerWidth="10"

                               MarkerType="Pentagon"

                               MarkerColor="Red"/>

 

    </chart:LineSeries.DataMarker>

</chart:LineSeries>

void LineSeries_DataMarkerLabelCreated(System.Object sender, Syncfusion.SfChart.XForms.ChartDataMarkerLabelCreatedEventArgs e)

{

    var data = e.DataMarkerLabel.Data as Model;

    if(!data.IsMarkerVisible)

    {

        e.DataMarkerLabel.MarkerColor = Color.Transparent;

    }

}


We have attached the sample for your reference. Please find the sample from the below attachment.


Output:


For more details, please refer the below link

https://www.syncfusion.com/kb/11979/how-to-show-different-data-marker-symbols-based-on-condition-in-xamarin-forms-charts


https://www.syncfusion.com/kb/10922/how-to-add-a-custom-data-marker-in-xamarin-forms-chart


Please let us know if you have any further assistance.


Regards,

Yuvaraj.


Attachment: ChartSample_DataMarker_aab54958.zip


SK sujeet kumar replied to Yuvaraj Palanisamy April 19, 2022 01:51 PM UTC

Thanks for your quick reply,

But here is the problem let us say I have 500K data1 items, Now only 2 items i need to show Data marked on chart.

So as per the above solution, it will trigger 500K times to check each condition, Then this will be the problem for performance.



DD Devakumar Dhanapoosanam Syncfusion Team April 20, 2022 02:15 PM UTC

Hi Sujeet Kumar,


We can show one or multiple marker shapes for larger data points without affecting performance using below solution


Solution 1: Annotation


Using Annotation instead of DataMarker based on your requirement for one or multiple data point values and add all annotation in the ChartAnnotations collection.


Please refer the below link for more details

https://help.syncfusion.com/xamarin/charts/chartannotation#shape-annotation

https://help.syncfusion.com/xamarin/charts/chartannotation#ellipse-annotation

https://help.syncfusion.com/xamarin/charts/chartannotation#positioning-the-annotation


Solution 2: ScatterSeries


We can achieve your requirement by adding collection of data with one or multiple data points as per your requirement and adding one additional ScatterSeries or FastScatterSeries. We can set the data collection for scatter series ItemsSource property instead of adding DataMarker for huge data points.


https://help.syncfusion.com/xamarin/charts/charttypes#scatter-chart

https://help.syncfusion.com/xamarin/charts/charttypes#fast-scatter-chart


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


Regards,

Devakumar D


Loader.
Up arrow icon