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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

LineSeries not displaying value

Thread ID:





151242 Feb 5,2020 02:26 AM UTC Feb 6,2020 01:13 PM UTC Xamarin.Forms 3
Tags: SfChart
dev clinicea
Asked On February 5, 2020 02:26 AM UTC

I am using a line series on a sfchart. I am binding a collection i.e. List<ChartData> to the ItemsSource. The line series appears fine when there are multiple items in the collection. But if there is only 1 item in the collection, the chart shows nothing.

How do I make a single item also show in a lineseries?


Hemalatha Marikumar [Syncfusion]
Replied On February 5, 2020 06:32 AM UTC

Hi Dev clinicea, 
Greetings from Syncfusion. 
Query: How do I make a single item also show in a lineseries? 
We would like to let you know that a line segment must require at least two data points to be plotted. If your requirement “Visibility of a single data point with LineSeries” can be achieved by using DataMarker in your sample as per the code snippet below. 
Code Snippet [XAML] MainPage 
<chart:SfChart x:Name="chart1" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"> 
            <chart:NumericalAxis RangePadding="Additional" /> 
            <chart:NumericalAxis RangePadding="Additional"/> 
        <chart:LineSeries   ItemsSource="{Binding LineData1}" 
Code Snippet [C#] [ViewModel] 
public class LineSeriesViewModel 
        public ObservableCollection<ChartModel> LineData1 { get; set; } 
        public LineSeriesViewModel() 
            LineData1 = new ObservableCollection<ChartModel> 
                new ChartModel(7, 45), 
Hemalatha M. 

dev clinicea
Replied On February 5, 2020 10:28 AM UTC

I tried it, but it still does not work :(. here is my code, screen is blank. Can you suggest what might be wrong?

            chart = new SfChart();
            chart.Title.Text = "sample title";
            chart.VerticalOptions = LayoutOptions.FillAndExpand;
            DateTimeAxis dateTimeAxis = new DateTimeAxis();
            dateTimeAxis.Title.Text = "";
            dateTimeAxis.LabelStyle.LabelFormat = "dd-MMM";
            dateTimeAxis.LabelRotationAngle = 90;
            chart.PrimaryAxis = dateTimeAxis;
            chart.PrimaryAxis.IsVisible = true;

            //Initializing secondary Axis
            NumericalAxis secondaryAxis = new NumericalAxis();
            secondaryAxis.RangePadding = NumericalPadding.Additional;
            chart.SecondaryAxis = secondaryAxis;
            chart.SecondaryAxis.IsVisible = true;

            //Initializing series
            series = new LineSeries();
            series.XBindingPath = "VitalID";
            series.YBindingPath = "VitalValueNum";

            series.DataMarker = new ChartDataMarker();
            //both showmarker and showlabel required to show a single data point
            series.DataMarker.ShowMarker = true;
            series.DataMarker.ShowLabel = true;
            series.DataMarker.LabelStyle.LabelPosition = DataMarkerLabelPosition.Outer;
            series.DataMarker.LabelStyle.TextColor = Styles.ColorBlack;    
            series.DataMarker.LabelStyle.BorderThickness = 0;
            series.DataMarker.LabelStyle.BackgroundColor = Styles.ColorWhite;
            series.EnableTooltip = true;

Attachment: Screenshot_1580898295_1274cb19.zip

Hemalatha Marikumar [Syncfusion]
Replied On February 6, 2020 01:13 PM UTC

Hi Dev clinicea, 
We have analyzed the provided code snippet and screenshot, we noticed that range of both chart axes has been changed and set based on the single data point. And also we have found that Additional RangePadding is not set for primary axis alone. So, to avoid this issue, please set RangePadding to the primary DateTimeAxis as per in below code snippet. 
chart = new SfChart() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand}; 
DateTimeAxis dateTimeAxis = new DateTimeAxis(); 
dateTimeAxis.LabelStyle.LabelFormat = "dd-MMM"; 
dateTimeAxis.LabelRotationAngle = 90; 
dateTimeAxis.RangePadding = DateTimeRangePadding.Additional; 
NumericalAxis secondaryAxis = new NumericalAxis() 
    RangePadding = NumericalPadding.Additional, 
chart.PrimaryAxis = dateTimeAxis; 
chart.SecondaryAxis = secondaryAxis; 
LineSeries lineSeries = new LineSeries() 
    ItemsSource = viewModel.DateData, 
    XBindingPath = "Date", 
    YBindingPath = "YValue", 
lineSeries.DataMarker = new ChartDataMarker() 
    ShowLabel = true, 
    ShowMarker = true, 
    UseSeriesPalette = true, 
    MarkerType = DataMarkerType.Ellipse, 
    MarkerHeight = 10, 
    MarkerWidth = 10, 
    LabelStyle = new DataMarkerLabelStyle() 
        BackgroundColor = Color.Transparent, 
        TextColor = Color.Black, 
        LabelPosition = DataMarkerLabelPosition.Auto, //This is default value 
Note: You have set the Position of DataMarker as outer, it may lead to have a chance of getting the reported issue. So, please set as Auto (default value). 
Please let us know if you need any further assistance on this. 
Hemalatha 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

Live Chat Icon For mobile
Live Chat Icon