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

Binding pivot chart using datatable

Pl provide sample code to bind pivot chart to datatable.

1 Reply

NM Nanthini Mahalingam Syncfusion Team January 18, 2023 06:52 AM UTC

Hi Kumar,

Thank you for reaching out to us. We have analyzed your query and found that we can bind a data table to the ItemSource of the pivot chart is possible by inheriting DataView. The following code snippet demonstrates how to inherit the DataView class, which connects the view to its corresponding DataTable, to bind the data table to the pivot chart.

  pivotChart1.ItemSource = ProductSalesObjectsDataView.GetDataTable();

The sample file also includes a DataTable collection view code snippet that demonstrates how to create the DataTable and add the data to it.

public class ProductSalesObjectsDataView : DataView


        public static DataView GetDataTable()


            DataTable dataTable = new DataTable("ProductSalesObjectsDataView");

            PropertyDescriptorCollection propertyDescriptorCollection = TypeDescriptor.GetProperties(typeof(ProductSales));


            foreach (PropertyDescriptor propertyDescriptor in propertyDescriptorCollection)


                dataTable.Columns.Add(new DataColumn(propertyDescriptor.Name, propertyDescriptor.PropertyType));



            ProductSalesCollection productSalesObjectCollection = ProductSales.GetSalesData();


            foreach (ProductSales businessObject in productSalesObjectCollection)


                DataRow dataRow = dataTable.NewRow();

                foreach (PropertyDescriptor propertyDescriptor in propertyDescriptorCollection)


                    dataRow[propertyDescriptor.Name] = propertyDescriptor.GetValue(businessObject);





            return dataTable.DefaultView;




Please refer to the following documentation for more information on data binding the pivot chart.



Please let me know if you have any further assistance. We are here to help.


Nanthini Mahalingam.

Attachment: SF180015_ac300eb1.zip

Live Chat Icon For mobile
Up arrow icon