public override Color?GetItemColor(TreeMapItem item, TreeMapItemGroupInfo group)
        {
            if (item.Children.Count == 0)
            {
                Color  itemColor  = Palette[group.ItemIndex % Palette.Count];
                Color  groupColor = Palette[group.GroupIndex % Palette.Count];
                double proportion = (item.Value - group.MinValue) /
                                    (group.MaxValue - group.MinValue);

                return(new Color {
                    A = 255,
                    R = (byte)(proportion * itemColor.R + (1 - proportion) * groupColor.R),
                    G = (byte)(proportion * itemColor.G + (1 - proportion) * groupColor.G),
                    B = (byte)(proportion * itemColor.B + (1 - proportion) * groupColor.B)
                });
            }
            else
            {
                return(Palette[Palette.Count - 1 - group.GroupLevel % Palette.Count]);
            }
        }
        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]);
            }
        }
예제 #3
0
        public override Color?GetItemColor(TreeMapItem item, TreeMapItemGroupInfo group)
        {
            if (group.GroupLevel == 1)
            {
                return(Colors.White);
            }
            if (group.GroupLevel == 2)
            {
                double delta = group.MaxValue - group.MinValue;
                double coef  = 1 - (group.MaxValue - item.Value) / delta;
                switch (((OlympicMedals)item.Tag).MedalType)
                {
                case "Gold": return(MixColors(goldColors, coef));

                case "Silver": return(MixColors(silverColors, coef));

                case "Bronze": return(MixColors(bronzeColors, coef));

                default:
                    break;
                }
            }
            return(null);
        }