Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

SunburstDataAdapterBase.DataSource Property

Gets or sets the object from which the adapter retrieves data to create and group sectors, and generate sector labels.

Namespace: DevExpress.Xpf.TreeMap

Assembly: DevExpress.Xpf.TreeMap.v24.2.dll

NuGet Package: DevExpress.Wpf.TreeMap

#Declaration

public object DataSource { get; set; }

#Property Value

Type Description
Object

A source from which the adapter loads data to create Sunburst sectors.

#Example

This example loads data and creates a Sunburst chart based on a hierarchical data source. To do this, follow steps below:

<dxtm:SunburstControl>
  <dxtm:SunburstControl.DataAdapter>
      <dxtm:SunburstHierarchicalDataAdapter
              x:Name="dataAdapter"
              DataSource="{Binding}">
          <dxtm:SunburstHierarchicalDataAdapter.Mappings>
              <dxtm:SunburstDataMapping                             
                      LabelDataMember="CountryName"
                      ChildrenDataMember="CityInfos"
                      Type="{x:Type local:CountryInfo}"/>
              <dxtm:SunburstDataMapping                               
                      LabelDataMember="CityName"
                      ChildrenDataMember="SaleInfos"
                      Type="{x:Type local:CityInfo}"/>
              <dxtm:SunburstDataMapping
                      ValueDataMember="Total"
                      LabelDataMember="Category"                             
                      Type="{x:Type local:ProductInfo}"/>
          </dxtm:SunburstHierarchicalDataAdapter.Mappings>
      </dxtm:SunburstHierarchicalDataAdapter>
  </dxtm:SunburstControl.DataAdapter>
</dxtm:SunburstControl>
using System.Collections.Generic;
using System.Windows;

namespace HierarchicalSunburst {
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
            DataContext = CreateInfos();
        }
        List<CountryInfo> CreateInfos() {
            List<CountryInfo> infos = new List<CountryInfo>();
            CountryInfo germanyInfo = new CountryInfo { CountryName = "Germany" };
            CityInfo leipzigInfo = new CityInfo { CityName = "Leipzig" };
            leipzigInfo.SaleInfos.AddRange(new List<ProductInfo> {
                new ProductInfo { Category = "Beverages", Total = 2634.5 },
                new ProductInfo { Category = "Baked Goods", Total = 4523.98 },
                new ProductInfo { Category = "Grains and Cereals", Total = 913.85 },
                new ProductInfo { Category = "Milk and Dairy", Total = 4219.98 },
            });
            CityInfo berlinInfo = new CityInfo { CityName = "Berlin" };
            berlinInfo.SaleInfos.AddRange(new List<ProductInfo> {
                new ProductInfo { Category = "Frozen Foods", Total = 900 }
            });
            germanyInfo.CityInfos.AddRange(new List<CityInfo> { leipzigInfo, berlinInfo });

            CountryInfo spainInfo = new CountryInfo { CountryName = "Spain" };
            CityInfo barcelonaInfo = new CityInfo { CityName = "Barcelona" };
            barcelonaInfo.SaleInfos.AddRange(new List<ProductInfo> {
                new ProductInfo { Category = "Baked Goods", Total = 1239.2 },
                new ProductInfo { Category = "Fruits", Total = 450.41 },
                new ProductInfo { Category = "Milk and Dairy", Total = 692.5 },
            });
            CityInfo madridInfo = new CityInfo { CityName = "Madrid" };
            madridInfo.SaleInfos.AddRange(new List<ProductInfo> {
                new ProductInfo { Category = "Spices", Total = 1010.30 },
                new ProductInfo { Category = "Vegetables", Total = 2078 }
            });
            spainInfo.CityInfos.AddRange(new List<CityInfo> { barcelonaInfo, madridInfo });

            infos.AddRange(new List<CountryInfo> { germanyInfo, spainInfo });

            return infos;
        }
    }
    public class CountryInfo {
        public string CountryName { get; set; }
        public List<CityInfo> CityInfos { get; set; } = new List<CityInfo>();
    }
    public class CityInfo {
        public string CityName { get; set; }
        public List<ProductInfo> SaleInfos { get; set; } = new List<ProductInfo>();
    }
    public class ProductInfo {
        public string Category { get; set; }
        public double Total { get; set; }
    }
}

The image below shows the results:

See Also