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
close icon

PieChart not rendering

I am trying to make a simple pie chart in WPF using dummy data. My XAML is the following:

<Grid>
 
 
 
        <syncfusion:TabControlExt x:Name="tabControlExt" 
                              HorizontalAlignment="Stretch" 
                              VerticalAlignment="Stretch"
                              CloseButtonType="Hide"
                              IsNewButtonEnabled="False" Grid.ColumnSpan="2">
            <syncfusion:TabItemExt Name="overviewTab" Header="Overview">
                <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
  
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
            
 
                    
            
                    <syncfusion:SfChart Grid.Column="0" Grid.ColumnSpan="2" Header="Chart Header" HorizontalAlignment="Center" Margin="10" VerticalAlignment="Center">
                        <syncfusion:SfChart.PrimaryAxis>
                            <syncfusion:CategoryAxis/>
                        </syncfusion:SfChart.PrimaryAxis>
                        <syncfusion:SfChart.SecondaryAxis>
                            <syncfusion:NumericalAxis/>
                        </syncfusion:SfChart.SecondaryAxis>
                        <syncfusion:PieSeries Palette="Metro" Width="200" Height="200" ConnectorType="Bezier" PieCoefficient=".2" EnableSmartLabels="True" LabelPosition="OutsideExtended"
                                          x:Name="ClusterUserPieSeries" ShowTooltip="True" syncfusion:ChartTooltip.EnableAnimation="True"
                                          ItemsSource="{Binding Path=UserCounts}" YBindingPath="count" XBindingPath="name" Interior="Aqua">
                        </syncfusion:PieSeries>
                    </syncfusion:SfChart>
                </Grid>
            </syncfusion:TabItemExt>
            <syncfusion:TabItemExt Name="clustersTab" Header="Clusters"></syncfusion:TabItemExt>
            <syncfusion:TabItemExt Name="vmTab" Header="VMs"></syncfusion:TabItemExt>
            
 
        </syncfusion:TabControlExt>
 
 
    </Grid>

My MainWindow code is the following:

public partial class MainWindow : Window
{
    public OverviewViewModel OverviewModel;
 
    public MainWindow()
    {
        
        InitializeComponent();
        init();
    }
 
    private void init()
    {
        if(OverviewModel == null)
            OverviewModel = new OverviewViewModel();
        this.DataContext = OverviewModel;
        Debug.WriteLine(OverviewModel.UserCounts.Count);
    }
}

And inside OverViewModel class is the following:

public class OverviewViewModel
{
 
 
    public IList<OverViewTestClass> UserCounts { getset; }
 
    public OverviewViewModel()
    {
        UserCounts = new List<OverViewTestClass>();
        UserCounts.Add(new OverViewTestClass(1000"CLUSTER1"));
        UserCounts.Add(new OverViewTestClass(2000"CLUSTER2"));
    }
 
}
 
public class OverViewTestClass
{
    public int count;
    public string name;
 
    public OverViewTestClass(int count, string name)
    {
        this.count = count;
        this.name = name;
    }
}


And yet when I try to run my app, all I get is a blank grid. I've tried to find a detailed walkthrough of the piechart control and how to set it up properly but even when I followed the example (as above) I get nothing. Any ideas?

1 Reply

SA Santhiya Arulsamy Syncfusion Team December 23, 2015 12:39 PM UTC

Hi Matt,

Thanks for contacting Syncfusion support.

We can't refer the path value as variables for XBindingPath and YBindingPath properties in ChartSeries, instead of variables need to refer any defined property. We have modified the sample for your reference.Please find the sample from the following location. 

Sample:PieSeries

Please refer the below UG documentation link to make customize the chart look.

http://help.syncfusion.com/wpf/sfchart/styling-and-customization

Thanks,

Santhiya A


Loader.
Live Chat Icon For mobile
Up arrow icon