Skip to main content
A newer version of this page is available. .

TreeMapItemGroupInfo Struct

This class stores information about a tree map item group.

Namespace: DevExpress.XtraTreeMap

Assembly: DevExpress.XtraTreeMap.v18.1.dll

Declaration

public struct TreeMapItemGroupInfo

Remarks

This class provides information about a tree map group to the ITreeMapColorizer.GetItemColor method. This information contains a group’s nested level (TreeMapItemGroupInfo.GroupLevel), group index in the level (TreeMapItemGroupInfo.GroupIndex), minimum and maximum values in the group (TreeMapItemGroupInfo.MinValue and TreeMapItemGroupInfo.MaxValue), and current item index in the group (TreeMapItemGroupInfo.ItemIndex).

Example

To implement a custom colorizer, design a class implementing the ITreeMapColorizer interface and implement the interface ITreeMapColorizer.GetItemColor method. After that, an instance of the class can be assigned to the TreeMapControl.Colorizer property.

using DevExpress.TreeMap;
using DevExpress.XtraTreeMap;
using System;
using System.Drawing;

namespace CustomColorizerSample {
    class CustomColorizer : ITreeMapColorizer {
        Palette palette = Palette.Office2016Palette;

        public Palette Palette {
            get { return palette; }
            set {
                if(palette.Equals(value)) return;
                palette = value;
                RaiseColorizerChanged();
            }
        }

        public event ColorizerChangedEventHandler ColorizerChanged;

        public Color GetItemColor(ITreeMapItem item, TreeMapItemGroupInfo group) {
            if(item.Children.Count == 0) {
                Color itemColor = Palette[group.ItemIndex % Palette.Count];
                double itemWeight = (item.Value - group.MinValue) / (group.MaxValue - group.MinValue);
                if(Double.IsNaN(itemWeight)) itemWeight = 1;

                return Color.FromArgb(
                    (int)(itemWeight * 255),
                    itemColor.R,
                    itemColor.G,
                    itemColor.B
                );
            }
            else
                return Palette[Palette.Count - 1 - (group.GroupIndex + group.GroupLevel + group.ItemIndex) % Palette.Count];

        }

        void RaiseColorizerChanged() {
            if(ColorizerChanged == null) return;
            ColorizerChanged.Invoke(this, new ColorizerChangedEventArgs());
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the TreeMapItemGroupInfo struct.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also