Treemap nothing show up

T

treeman

I copied the example

Compile is successful .net 2003

but i press button , nothing to show

but the example has box show up, why ? where 's wrong?



using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.Research.CommunityTechnologies.Treemap;
using System.Xml;

namespace treemap
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private
Microsoft.Research.CommunityTechnologies.Treemap.TreemapControl
treemapControl1;
private System.Windows.Forms.Button build_button;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
InitializeComponent();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.treemapControl1 = new
Microsoft.Research.CommunityTechnologies.Treemap.TreemapControl();
this.build_button = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// treemapControl1
//
this.treemapControl1.BorderColor =
System.Drawing.SystemColors.WindowFrame;
this.treemapControl1.DiscreteNegativeColors = 20;
this.treemapControl1.DiscretePositiveColors = 20;
this.treemapControl1.FontFamily = "Arial";
this.treemapControl1.FontSolidColor = System.Drawing.Color.Black;
this.treemapControl1.IsZoomable = false;
this.treemapControl1.Location = new System.Drawing.Point(88, 9);
this.treemapControl1.MaxColor = System.Drawing.Color.Green;
this.treemapControl1.MaxColorMetric = 100F;
this.treemapControl1.MinColor = System.Drawing.Color.Red;
this.treemapControl1.MinColorMetric = -100F;
this.treemapControl1.Name = "treemapControl1";
this.treemapControl1.NodeLevelsWithText =
Microsoft.Research.CommunityTechnologies.Treemap.NodeLevelsWithText.All;
this.treemapControl1.NodesXml = "<?xml version=\"1.0\"
encoding=\"utf-16\"?><Nodes xmlns:xsd=\"http://www.w3.org/2001/X" +
"MLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
EmptySizeMetric=" +
"\"0\" />";
this.treemapControl1.PaddingDecrementPerLevelPx = 1;
this.treemapControl1.PaddingPx = 5;
this.treemapControl1.PenWidthDecrementPerLevelPx = 1;
this.treemapControl1.PenWidthPx = 3;
this.treemapControl1.ShowToolTips = true;
this.treemapControl1.Size = new System.Drawing.Size(656, 554);
this.treemapControl1.TabIndex = 0;
//
// build_button
//
this.build_button.Location = new System.Drawing.Point(16, 24);
this.build_button.Name = "build_button";
this.build_button.Size = new System.Drawing.Size(64, 24);
this.build_button.TabIndex = 1;
this.build_button.Text = "Build";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 15);
this.ClientSize = new System.Drawing.Size(760, 614);
this.Controls.Add(this.build_button);
this.Controls.Add(this.treemapControl1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());

}
void BuildTreemap(TreemapControl tmcMap)
{
Nodes oNodes, oChildNodes, oGrandChildNodes;
Node oNode, oChildNode, oGrandChildNode;
oNodes = tmcMap.Nodes;

// Add a top-level node to the collection.
oNode = oNodes.Add("Europe", 25F, 100F);

// Add child nodes to this node.
oChildNodes = oNode.Nodes;
oChildNode = oChildNodes.Add("England", 50F, 2.5F);
oChildNode = oChildNodes.Add("Ireland", 50F, -34.5F);

// Add another top-level node.
oNode = oNodes.Add("Americas", 50F, -40.1F);

// Add child nodes to the this new node.
oChildNodes = oNode.Nodes;
oChildNode = oChildNodes.Add("Canada", 20F, 200F);
oChildNode = oChildNodes.Add("USA", 100F, 0F);

// Add a child node to one of the children
oGrandChildNodes = oChildNode.Nodes;
oGrandChildNode = oGrandChildNodes.Add("California", 60F, 0F);
oGrandChildNode = oGrandChildNodes.Add("Texas", 30F, 0F);

// Draw it
//tmcMap.Draw();

}
private void build_button_Click(object sender, System.EventArgs e)
{
BuildTreemap(treemapControl1);
}
}
}
 
F

Frans Bouma [C# MVP]

You create the nodes, but you should first add a root node to the
three, then add the nodes you add to oNodes to that node's Nodes.

FB
I copied the example

Compile is successful .net 2003

but i press button , nothing to show

but the example has box show up, why ? where 's wrong?



using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.Research.CommunityTechnologies.Treemap;
using System.Xml;

namespace treemap
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private
Microsoft.Research.CommunityTechnologies.Treemap.TreemapControl
treemapControl1;
private System.Windows.Forms.Button build_button;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
InitializeComponent();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.treemapControl1 = new
Microsoft.Research.CommunityTechnologies.Treemap.TreemapControl();
this.build_button = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// treemapControl1
//
this.treemapControl1.BorderColor =
System.Drawing.SystemColors.WindowFrame;
this.treemapControl1.DiscreteNegativeColors = 20;
this.treemapControl1.DiscretePositiveColors = 20;
this.treemapControl1.FontFamily = "Arial";
this.treemapControl1.FontSolidColor = System.Drawing.Color.Black;
this.treemapControl1.IsZoomable = false;
this.treemapControl1.Location = new System.Drawing.Point(88, 9);
this.treemapControl1.MaxColor = System.Drawing.Color.Green;
this.treemapControl1.MaxColorMetric = 100F;
this.treemapControl1.MinColor = System.Drawing.Color.Red;
this.treemapControl1.MinColorMetric = -100F;
this.treemapControl1.Name = "treemapControl1";
this.treemapControl1.NodeLevelsWithText =
Microsoft.Research.CommunityTechnologies.Treemap.NodeLevelsWithText.Al
l; this.treemapControl1.NodesXml = "<?xml version=\"1.0\"
encoding=\"utf-16\"?><Nodes xmlns:xsd=\"http://www.w3.org/2001/X" +
"MLSchema\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
EmptySizeMetric=" + "\"0\" />";
this.treemapControl1.PaddingDecrementPerLevelPx = 1;
this.treemapControl1.PaddingPx = 5;
this.treemapControl1.PenWidthDecrementPerLevelPx = 1;
this.treemapControl1.PenWidthPx = 3;
this.treemapControl1.ShowToolTips = true;
this.treemapControl1.Size = new System.Drawing.Size(656, 554);
this.treemapControl1.TabIndex = 0;
//
// build_button
//
this.build_button.Location = new System.Drawing.Point(16, 24);
this.build_button.Name = "build_button";
this.build_button.Size = new System.Drawing.Size(64, 24);
this.build_button.TabIndex = 1;
this.build_button.Text = "Build";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 15);
this.ClientSize = new System.Drawing.Size(760, 614);
this.Controls.Add(this.build_button);
this.Controls.Add(this.treemapControl1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());

}
void BuildTreemap(TreemapControl tmcMap)
{
Nodes oNodes, oChildNodes, oGrandChildNodes;
Node oNode, oChildNode, oGrandChildNode;
oNodes = tmcMap.Nodes;

// Add a top-level node to the collection.
oNode = oNodes.Add("Europe", 25F, 100F);

// Add child nodes to this node.
oChildNodes = oNode.Nodes;
oChildNode = oChildNodes.Add("England", 50F, 2.5F);
oChildNode = oChildNodes.Add("Ireland", 50F, -34.5F);

// Add another top-level node.
oNode = oNodes.Add("Americas", 50F, -40.1F);

// Add child nodes to the this new node.
oChildNodes = oNode.Nodes;
oChildNode = oChildNodes.Add("Canada", 20F, 200F);
oChildNode = oChildNodes.Add("USA", 100F, 0F);

// Add a child node to one of the children
oGrandChildNodes = oChildNode.Nodes;
oGrandChildNode = oGrandChildNodes.Add("California", 60F, 0F);
oGrandChildNode = oGrandChildNodes.Add("Texas", 30F, 0F);

// Draw it
//tmcMap.Draw();

}
private void build_button_Click(object sender, System.EventArgs e)
{
BuildTreemap(treemapControl1);
}
}
}



--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 
Top