How to: Bind a Treemap Dashboard Item to Data in Code

The following example demonstrates how to bind a Treemap dashboard item to data in code.

using DevExpress.DashboardCommon;
using DevExpress.XtraEditors;

namespace DashboardViewer_Treemap {
    public partial class Form1 : XtraForm {
        public Form1() {

            Dashboard dashboard = new Dashboard();

            DashboardExtractDataSource dataSource = new DashboardExtractDataSource();
            dataSource.FileName = @"..\..\Data\SalesDataExtract.dat";

            TreemapDashboardItem treeMap = new TreemapDashboardItem();
            treeMap.DataSource = dataSource;
            treeMap.Values.Add(new Measure("Sales"));            
            treeMap.Arguments.Add(new Dimension { DataMember = "Product Category", GroupChildValues = true });
            treeMap.Arguments.Add(new Dimension("Product Sub-Category"));
            treeMap.LayoutAlgorithm = DashboardTreemapLayoutAlgorithm.Striped;

            dashboardViewer1.Dashboard = dashboard;