private void toolTipController1_BeforeShow(object sender, ToolTipControllerShowEventArgs e)
        {
            TreeMapItem item = e.SelectedObject as TreeMapItem;

            if (item == null)
            {
                return;
            }
            if (item.IsGroup)
            {
                return;
            }

            SuperToolTip superTip = new SuperToolTip {
                AllowHtmlText = DefaultBoolean.True
            };

            superTip.Items.Add(new ToolTipTitleItem {
                Text = String.Format("{0} statistics", item.Label)
            });
            superTip.Items.Add(new ToolTipSeparatorItem());
            superTip.Items.Add(new ToolTipItem {
                Text = String.Format("<b>GDP (2014):</b> {0:C1} trillions", item.Value)
            });
            e.SuperTip = superTip;
        }
Exemple #2
0
            public void MakeTreeMap(string parentPath, Rect parentRect, long parentTotalSize)
            {
                var nCurDepth    = parentPath.Where(c => c == MainWindow.PathSep).Count(); // count the # of "\"
                var querySubDirs = from subPath in _mainWindow._DataDict.Keys
                                   where subPath.StartsWith(parentPath) &&
                                   _mainWindow._DataDict[subPath].Depth == nCurDepth + 1            // we want those 1 level deeper
                                   orderby _mainWindow._DataDict[subPath].Size descending
                                   select subPath;

                long nRunTot = 0;

                foreach (var subDir in querySubDirs)
                {
                    var  curSize = _mainWindow._DataDict[subDir].Size;
                    Rect newRectStruct;
                    if (nCurDepth % 2 == _EvenOdd) // even or odd?
                    {
                        newRectStruct = new Rect(
                            parentRect.Left + parentRect.Width * nRunTot / parentTotalSize,
                            parentRect.Top,
                            parentRect.Width * curSize / parentTotalSize,
                            parentRect.Height
                            );
                    }
                    else
                    {
                        newRectStruct = new Rect(
                            parentRect.Left,
                            parentRect.Top + parentRect.Height * nRunTot / parentTotalSize,
                            parentRect.Width,
                            parentRect.Height * curSize / parentTotalSize
                            );
                    }
                    nRunTot += curSize;
                    var data        = _mainWindow._DataDict[subDir];
                    var rectMapItem = new TreeMapItem(
                        subDir,
                        string.Format("{0} Files ={1:n0} Size ={2:n0} Index = {3:n0} ({4:n0},{5:n0})",
                                      subDir, data.NumFiles, curSize, data.Index, newRectStruct.Width, newRectStruct.Height),
                        newRectStruct,
                        nCurDepth,
                        this
                        );
                    this.Children.Add(rectMapItem);
                    if (newRectStruct.Width > 5 && newRectStruct.Height > 5)
                    { // if it's big enough to drill down, figure out the next level down.
                        var newq = from k in _mainWindow._DataDict.Keys
                                   where k.StartsWith(subDir) && k.LastIndexOf("*") < 0 &&
                                   _mainWindow._DataDict[k].Depth >= nCurDepth + 1
                                   orderby _mainWindow._DataDict[k].Size descending
                                   select k;
                        var newParent = newq.FirstOrDefault();
                        if (!string.IsNullOrEmpty(newParent))
                        {
                            MakeTreeMap(newParent, newRectStruct, curSize); //recur
                        }
                    }
                }
            }
Exemple #3
0
 public void AddChild(TreeMapItem item)
 {
     if (Children == null)
     {
         Children = new List <TreeMapItem> ();
     }
     Children.Add(item);
 }
        void ConfigureTreeMapDataAdapter()
        {
            TreeMapItemStorage storage = new TreeMapItemStorage();

            treeMap.DataAdapter = storage;

            TreeMapItem americasGroup = new TreeMapItem {
                Label = "Americas"
            };

            americasGroup.Children.Add(new TreeMapItem {
                Label = "United States", Value = 17.968
            });
            americasGroup.Children.Add(new TreeMapItem {
                Label = "Brazil", Value = 1.8
            });
            americasGroup.Children.Add(new TreeMapItem {
                Label = "Canada", Value = 1.573
            });
            storage.Items.Add(americasGroup);

            TreeMapItem europeGroup = new TreeMapItem {
                Label = "Europe"
            };

            europeGroup.Children.Add(new TreeMapItem {
                Label = "Germany", Value = 3.371
            });
            europeGroup.Children.Add(new TreeMapItem {
                Label = "United Kingdom", Value = 2.865
            });
            europeGroup.Children.Add(new TreeMapItem {
                Label = "France", Value = 2.423
            });
            europeGroup.Children.Add(new TreeMapItem {
                Label = "Italy", Value = 1.819
            });
            storage.Items.Add(europeGroup);

            TreeMapItem asiaGroup = new TreeMapItem {
                Label = "Asia"
            };

            asiaGroup.Children.Add(new TreeMapItem {
                Label = "China", Value = 11.385
            });
            asiaGroup.Children.Add(new TreeMapItem {
                Label = "Japan", Value = 4.116
            });
            asiaGroup.Children.Add(new TreeMapItem {
                Label = "India", Value = 2.183
            });
            storage.Items.Add(asiaGroup);
        }
        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]);
            }
        }
        private void PopulateTagTreemapData()
        {
            TagTreemapData.Clear();

            var treeMapItems = new List <TreeMapItem>();

            var mainTreemapItem = new TreeMapItem()
            {
                Name = "Tag Labels Map", Value = TagLabelsData.Sum(t => t.Count)
            };

            foreach (var item in TagLabelsData)
            {
                treeMapItems.Add(new TreeMapItem()
                {
                    Name = item.LabelInfo, Value = item.Count
                });
            }
            mainTreemapItem.Items = treeMapItems;
            TagTreemapData.Add(mainTreemapItem);
        }
Exemple #7
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);
        }
 public void AddChild(TreeMapItem item)
 {
     if (Children == null)
         Children = new List<TreeMapItem> ();
     Children.Add (item);
 }
        void UpdateBgImage()
        {
            m_bgImage = null;

            if (TextColumn < 0 || WeightColumn < 0)
                return;

            m_bgImage = new Cairo.ImageSurface (Format.Rgb24, Allocation.Width, this.Allocation.Height);

            using (var c = new Cairo.Context (m_bgImage))
            {
                // Paint the default background (linear gradient)
                var g = new Cairo.LinearGradient (0, 0, 1, this.Allocation.Height);
                g.AddColorStop (0.2, CairoExtensions.GdkColorToCairoColor (m_Background));
                g.AddColorStop (0.9, CairoExtensions.GdkColorToCairoColor (this.Style.Background (Gtk.StateType.Normal)));
                c.Rectangle (0, 0, this.Allocation.Width, this.Allocation.Height);
                c.Pattern = g;
                c.Paint ();
                g.Dispose ();

                Gtk.TreeIter iter;

                List<TreeMapItem> rootItems = new List<TreeMapItem> ();

                if (m_Model.GetIterFirst (out iter)) {
                    do {
                        var item = new TreeMapItem (m_Model, ref iter, true, m_TextColumn, m_WeightColumn);
                        rootItems.Add (item);
                    } while (m_Model.IterNext (ref iter));

                    double t = 0.0;

                    rootItems.ForEach (delegate (TreeMapItem i) {
                        t += Math.Abs (i.Weight);
                    });

                    double x = 0, y = 0, w = this.Allocation.Width, h = this.Allocation.Height;
                    double myx = 0, myy = 0, myw = 0, myh = 0;

                    rootItems.ForEach (delegate (TreeMapItem i) {
                        var ratio = Math.Abs (i.Weight) / t;
                        myx = x;
                        myy = y;
                        myw = w * ratio;
                        myh = h;
                        x += myw;

                        i.SetArea (myx, myy, myw, myh);
                        i.Render (c, m_Background);
                    });

                    // clear right away to lower refs
                    if (this.m_rootItems != null)
                        this.m_rootItems.Clear ();

                    this.m_rootItems = rootItems;
                }
            }
        }
Exemple #10
0
        void UpdateBgImage()
        {
            m_bgImage = null;

            if (TextColumn < 0 || WeightColumn < 0)
            {
                return;
            }

            m_bgImage = new Cairo.ImageSurface(Format.Rgb24, Allocation.Width, this.Allocation.Height);

            using (var c = new Cairo.Context(m_bgImage))
            {
                // Paint the default background (linear gradient)
                var g = new Cairo.LinearGradient(0, 0, 1, this.Allocation.Height);
                g.AddColorStop(0.2, CairoExtensions.GdkColorToCairoColor(m_Background));
                g.AddColorStop(0.9, CairoExtensions.GdkColorToCairoColor(this.Style.Background(Gtk.StateType.Normal)));
                c.Rectangle(0, 0, this.Allocation.Width, this.Allocation.Height);
                c.Pattern = g;
                c.Paint();
                g.Dispose();

                Gtk.TreeIter iter;

                List <TreeMapItem> rootItems = new List <TreeMapItem> ();

                if (m_Model.GetIterFirst(out iter))
                {
                    do
                    {
                        var item = new TreeMapItem(m_Model, ref iter, true, m_TextColumn, m_WeightColumn);
                        rootItems.Add(item);
                    } while (m_Model.IterNext(ref iter));

                    double t = 0.0;

                    rootItems.ForEach(delegate(TreeMapItem i) {
                        t += Math.Abs(i.Weight);
                    });

                    double x = 0, y = 0, w = this.Allocation.Width, h = this.Allocation.Height;
                    double myx = 0, myy = 0, myw = 0, myh = 0;

                    rootItems.ForEach(delegate(TreeMapItem i) {
                        var ratio = Math.Abs(i.Weight) / t;
                        myx       = x;
                        myy       = y;
                        myw       = w * ratio;
                        myh       = h;
                        x        += myw;

                        i.SetArea(myx, myy, myw, myh);
                        i.Render(c, m_Background);
                    });

                    // clear right away to lower refs
                    if (this.m_rootItems != null)
                    {
                        this.m_rootItems.Clear();
                    }

                    this.m_rootItems = rootItems;
                }
            }
        }