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

SunburstFlatDataAdapter Class

Loads data from data sources with the flat structure to a Sunburst chart.

Namespace: DevExpress.Xpf.TreeMap

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

NuGet Package: DevExpress.Wpf.TreeMap

#Declaration

public class SunburstFlatDataAdapter :
    SunburstDataAdapterBase,
    IFlatDataAdapter

#Remarks

Follow the steps below to load data from flat databases to a Sunburst chart:

using System;
using System.Collections.Generic;
using System.IO;
using System.Windows;
using System.Xml;
using System.Xml.Linq;

namespace SunburstSample {
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
            DataContext = LoadDataFromXML();
        }
        List<ChemicalElement> LoadDataFromXML() {
            XDocument document = XDocument.Load(@"D:\ChemicalElements.xml");
            List<ChemicalElement> infos = new List<ChemicalElement>();
            if (document != null) {
                foreach (XElement element in document.Element("ArrayOfElement").Elements()) {
                    ChemicalElement chemicalElement = new ChemicalElement();
                    chemicalElement.Name = element.Element("Name").Value;
                    chemicalElement.AtomicMass = element.Element("AtomicMass").Value;
                    chemicalElement.AtomicNumber = element.Element("AtomicNumber").Value;
                    chemicalElement.Density = element.Element("Density").Value;
                    chemicalElement.MeltingPoint = element.Element("MeltingPoint").Value;
                    chemicalElement.BoilingPoint = element.Element("BoilingPoint").Value;
                    chemicalElement.Block = element.Element("Block").Value;
                    chemicalElement.Family = element.Element("Family").Value;
                    chemicalElement.Symbol = element.Element("Symbol").Value;
                    infos.Add(chemicalElement);
                }
            }
            return infos;
        }
    }
    public static class DataLoader {
        static Stream GetStream(string fileName) {
            Uri uri = GetResourceUri(fileName);
            return Application.GetResourceStream(uri).Stream;
        }
        public static Uri GetResourceUri(string fileName) {
            return new Uri(fileName, UriKind.RelativeOrAbsolute);
        }
        public static XDocument LoadXDocumentFromResources(string fileName) {
            try {
                return XDocument.Load(GetStream(fileName));
            }
            catch {
                return null;
            }
        }
    }
    public class ChemicalElement {
        public string AtomicNumber { get; set; }
        public string AtomicMass { get; set; }
        public string Density { get; set; }
        public string MeltingPoint { get; set; }
        public string BoilingPoint { get; set; }
        public string Name { get; set; }
        public string Block { get; set; }
        public string Family { get; set; }
        public string Symbol { get; set; }
        public int Value { get { return 1; } }
    }
}

The data structure looks as follows:

Show structure
<?xml version="1.0"?>
<ArrayOfElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Element>
    <FakeValue>1</FakeValue>
    <AtomicNumber>1</AtomicNumber>
    <Group>1</Group>
    <Period>1</Period>
    <Symbol>H</Symbol>
    <Name>Hydrogen</Name>
    <AtomicMass>1.008</AtomicMass>
    <Density>0.00008988</Density>
    <MeltingPoint>14.01</MeltingPoint>
    <BoilingPoint>20.28</BoilingPoint>
    <Family>Nonmetal</Family>
    <DiscoveryPeriod>Middle Ages–​1799</DiscoveryPeriod>
    <Block>S-block</Block>
  </Element>
  <!--...-->
</ArrayOfElement>  

The following image shows the results:

See Also