Custom DataMarker FastLineSeries

Hi
I tried to create a Custom DataMarker in c# code according to the syncfusion documetation
      var series = new FastLineSeries();
...
series.DataMarker = new ChartDataMarker();
series.DataMarker.ShowLabel = true;
series.DataMarker.LabelStyle.LabelPosition = DataMarkerLabelPosition.Outer;

DataTemplate dataMarkerTemplate = new DataTemplate(() =>
{
StackLayout stack = new StackLayout();
stack.Orientation = StackOrientation.Horizontal;
Label label = new Label();
label.SetBinding(Label.TextProperty, "Value");
label.FontSize = 15;
label.VerticalOptions = LayoutOptions.Center;
//Image image = new Image();
//image.Source = "Down.jpg";
//image.WidthRequest = 30;
//image.HeightRequest = 30;
stack.Children.Add(label);
//stack.Children.Add(image);
return stack;
});

series.DataMarker.LabelTemplate = dataMarkerTemplate;

chart.Series.Add(series);

As soon as I add the code line series.DataMarker.LabelTemplate = dataMarkerTemplate;
markers aren't Shown anymore, when I remove everything is ok
What is wrong with my code?
Environment:
Visual Studio 2017
Syncfusioan SfChart 16.3.0.21
Xamarin.Forms 3.1.0.697729
.net Standard 2.0.3
Thanks Gunter

1 Reply

GR Geetha Rajendran Syncfusion Team October 3, 2018 01:05 PM UTC

Hi Günter,

Greetings from Syncfusion, the BindingContext of template is the corresponding underlying model that is provided in the items source of chart series. So Please bind the Model class properties to the Label. We have prepared a simple sample and it can be downloaded from the below link. Please refer the UG link for more details.

Sample : http://www.syncfusion.com/downloads/support/forum/140167/ze/140167_sample-262872484.zip

UG link - https://help.syncfusion.com/xamarin/sfchart/datamarker#label-template

Regards,
Geetha R.


Loader.
Up arrow icon