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

Display message "No data". Can I it?

Thread ID:





148940 Nov 8,2019 10:04 AM UTC Nov 11,2019 11:18 AM UTC UWP 1
Tags: SfChart
Gianfranco Percopo
Asked On November 8, 2019 10:08 AM UTC

When I create a chart and there is no data to display how do I get a "No data to display" message directly in the chart without having to create a custom solution? Thank you

Hemalatha Marikumar [Syncfusion]
Replied On November 11, 2019 11:18 AM UTC

Hi Gianfranco, 
Greetings from Syncfusion. 
We would like to let you know that currently there is no direct property to achieve your requirement, but you can achieve this using the TextAnnotation and set its X1 and Y1 properties using the SeriesClipRect in SizeChanged event. 
You can set the text as what you want if the data count is less than zero otherwise set as null to hide the text annotation when you populate the data. Please refer to the code below. 
Code snippet[XAML]: 
<syncfusion:SfChart SizeChanged="Chart_SizeChanged" x:Name="chart" > 
    <syncfusion:CategoryAxis Visibility="{Binding AxisVisibility}"/> 
    <syncfusion:NumericalAxis Visibility="{Binding AxisVisibility}"/> 
.  .  . 
    <syncfusion:TextAnnotation x:Name="textAnnotation" Text="{Binding AnnotationText}" CoordinateUnit="Pixel" FontStyle="Normal" FontSize="20"/> 
Code snippet[C#]: 
private void Chart_SizeChanged(object sender, SizeChangedEventArgs e) 
    var rect = (sender as SfChart).SeriesClipRect; 
    textAnnotation.X1 = rect.Width / 2; 
    textAnnotation.Y1 = rect.Height / 2; 
Code snippet[C#]: 
public class ViewModel 
    public ViewModel() 
        Data = new ObservableCollection<Person>();   
        if (Data.Count <= 0) 
            AnnotationText = "No data to display"; 
            AxisVisibility = Visibility.Collapsed; 
            IsVisible = false; 
            AnnotationText = null; 
            AxisVisibility= Visibility.Visible; 
            IsVisible = true; 
Please get back to us if you have any questions 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