public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); nChartControl1.Controller.Tools.Add(new NTooltipTool()); // set a chart title NLabel title = new NLabel("Tree Map"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); title.DockMode = PanelDockMode.Top; nChartControl1.Panels.Add(title); m_TreeMap = new NTreeMapChart(); nChartControl1.Panels.Add(m_TreeMap); m_TreeMap.DockMode = PanelDockMode.Fill; XmlDocument document = LoadData(); foreach (XmlElement industry in document.DocumentElement) { NGroupTreeMapNode treeMapSeries = new NGroupTreeMapNode(); treeMapSeries.StrokeStyle = new NStrokeStyle(4, Color.Black); treeMapSeries.Padding = new NMarginsL(2.0f); m_TreeMap.RootTreeMapNode.ChildNodes.Add(treeMapSeries); treeMapSeries.Label = industry.Attributes["Name"].Value; treeMapSeries.InteractivityStyle = new NInteractivityStyle(treeMapSeries.Label); foreach (XmlElement company in industry.ChildNodes) { double value = double.Parse(company.Attributes["Size"].Value); double change = double.Parse(company.Attributes["Change"].Value); string label = company.Attributes["Name"].Value; NValueTreeMapNode node = new NValueTreeMapNode(value, change, label); node.InteractivityStyle = new NInteractivityStyle(label); // node.FillStyle = new NColorFillStyle(Color.Green); treeMapSeries.ChildNodes.Add(node); } } VerticalFillModeComboBox.FillFromEnum(typeof(TreeMapVerticalFillMode)); VerticalFillModeComboBox.SelectedIndex = (int)TreeMapVerticalFillMode.Default; HorizontalFillModeComboBox.FillFromEnum(typeof(TreeMapHorizontalFillMode)); HorizontalFillModeComboBox.SelectedIndex = (int)TreeMapVerticalFillMode.Default; ColorFillModeComboBox.Items.Add("Custom"); ColorFillModeComboBox.Items.Add("Common Palette"); ColorFillModeComboBox.Items.Add("Group Palette"); ColorFillModeComboBox.SelectedIndex = 1; }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); nChartControl1.Controller.Tools.Add(new NTooltipTool()); // set a chart title NLabel title = new NLabel("Tree Map - Drill Down"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); title.DockMode = PanelDockMode.Top; nChartControl1.Panels.Add(title); m_TreeMap = new NTreeMapChart(); nChartControl1.Panels.Add(m_TreeMap); m_TreeMap.DockMode = PanelDockMode.Fill; m_OrgRootNode = m_TreeMap.RootTreeMapNode; XmlDocument document = LoadData(); foreach (XmlElement industry in document.DocumentElement) { NGroupTreeMapNode groupNode = new NGroupTreeMapNode(); groupNode.StrokeStyle = new NStrokeStyle(1.0f, Color.Green); groupNode.Padding = new NMarginsL(2.0f); m_TreeMap.RootTreeMapNode.ChildNodes.Add(groupNode); groupNode.Label = industry.Attributes["Name"].Value; groupNode.InteractivityStyle = new NInteractivityStyle(groupNode.Label); foreach (XmlElement company in industry.ChildNodes) { double value = double.Parse(company.Attributes["Size"].Value); double change = double.Parse(company.Attributes["Change"].Value); string label = company.Attributes["Name"].Value; NValueTreeMapNode valueNode = new NValueTreeMapNode(value, change, label); valueNode.InteractivityStyle = new NInteractivityStyle(label); groupNode.ChildNodes.Add(valueNode); } } nChartControl1.MouseClick += new MouseEventHandler(nChartControl1_MouseClick); }
/// <summary> /// /// </summary> /// <returns></returns> protected override NWidget CreateExampleContent() { NChartView chartView = CreateTreeMapView(); // configure title chartView.Surface.Titles[0].Text = "TreeMap Legend"; NTreeMapChart treeMap = (NTreeMapChart)chartView.Surface.Charts[0]; // Get the country list XML stream Stream stream = NResources.Instance.GetResourceStream("RSTR_TreeMapDataSmall_xml"); // Load an xml document from the stream NXmlDocument xmlDocument = NXmlDocument.LoadFromStream(stream); m_RootTreeMapNode = new NGroupTreeMapNode(); NThreeColorPalette palette = new NThreeColorPalette(); palette.OriginColor = NColor.White; palette.BeginColor = NColor.Red; palette.EndColor = NColor.Green; m_RootTreeMapNode.Label = "Tree Map - Industry by Sector"; m_RootTreeMapNode.Palette = palette; m_RootTreeMapNode.LegendView = new NGroupTreeMapNodeLegendView(); treeMap.RootTreeMapNode = m_RootTreeMapNode; NXmlElement rootElement = (NXmlElement)xmlDocument.GetChildAt(0); for (int i = 0; i < rootElement.ChildrenCount; i++) { NXmlElement industry = (NXmlElement)rootElement.GetChildAt(i); NGroupTreeMapNode treeMapSeries = new NGroupTreeMapNode(); treeMapSeries.BorderThickness = new NMargins(4.0); treeMapSeries.Border = NBorder.CreateFilledBorder(NColor.Black); treeMapSeries.Padding = new NMargins(2.0); m_RootTreeMapNode.ChildNodes.Add(treeMapSeries); treeMapSeries.Label = industry.GetAttributeValue("Name"); treeMapSeries.Tooltip = new NTooltip(treeMapSeries.Label); for (int j = 0; j < industry.ChildrenCount; j++) { NXmlElement company = (NXmlElement)industry.GetChildAt(j); double value = Double.Parse(company.GetAttributeValue("Size"), CultureInfo.InvariantCulture); double change = Double.Parse(company.GetAttributeValue("Change"), CultureInfo.InvariantCulture); string label = company.GetAttributeValue("Name"); NValueTreeMapNode node = new NValueTreeMapNode(value, change, label); node.Format = "<label> <change_percent>"; node.ChangeValueType = ENChangeValueType.Percentage; node.Tooltip = new NTooltip(label); treeMapSeries.ChildNodes.Add(node); } } return(chartView); }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); nChartControl1.Controller.Tools.Add(new NTooltipTool()); nChartControl1.Document.RootPanel.Margins = new NMarginsL(10); // set a chart title NLabel title = new NLabel("Tree Map - Legend Options"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); title.DockMode = PanelDockMode.Top; nChartControl1.Panels.Add(title); NLegend legend = new NLegend(); legend.DockMode = PanelDockMode.Right; nChartControl1.Panels.Add(legend); m_TreeMap = new NTreeMapChart(); nChartControl1.Panels.Add(m_TreeMap); m_TreeMap.DockMode = PanelDockMode.Fill; m_TreeMap.RootTreeMapNode.Legend.DisplayOnLegend = legend; XmlDocument document = LoadData(); m_TreeMap.RootTreeMapNode.Label = "Tree Map by Industry Sector"; m_TreeMap.RootTreeMapNode.Format = ""; m_TreeMap.RootTreeMapNode.LegendFormat = "<label>"; foreach (XmlElement industry in document.DocumentElement) { NGroupTreeMapNode groupNode = new NGroupTreeMapNode(); groupNode.Padding = new NMarginsL(2.0f); m_TreeMap.RootTreeMapNode.ChildNodes.Add(groupNode); groupNode.Label = industry.Attributes["Name"].Value; groupNode.LabelTextStyle = new NTextStyle(); groupNode.LabelTextStyle.FillStyle = new NColorFillStyle(Color.White); groupNode.FillStyle = new NColorFillStyle(Color.Black); groupNode.StrokeStyle = new NStrokeStyle(1, Color.Black); groupNode.InteractivityStyle = new NInteractivityStyle(groupNode.Label); foreach (XmlElement sector in industry.ChildNodes) { double value = double.Parse(sector.Attributes["Size"].Value); double change = double.Parse(sector.Attributes["Change"].Value); string label = sector.Attributes["Name"].Value; NValueTreeMapNode valueNode = new NValueTreeMapNode(value, change, label); valueNode.InteractivityStyle = new NInteractivityStyle(label); valueNode.StrokeStyle = new NStrokeStyle(1, Color.Black); valueNode.LabelTextStyle = new NTextStyle(); valueNode.LabelTextStyle.FillStyle = new NColorFillStyle(Color.Black); groupNode.ChildNodes.Add(valueNode); } } LegendModeComboBox.FillFromEnum(typeof(TreeMapNodeLegendMode)); LegendModeComboBox.SelectedIndex = (int)TreeMapNodeLegendMode.GroupAndChildNodes; PaletteLegendModeComboBox.FillFromEnum(typeof(PaletteLegendMode)); PaletteLegendModeComboBox.Enabled = false; PaletteLegendModeComboBox.SelectedIndex = (int)PaletteLegendMode.GradientAxis; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { WebExamplesUtilities.FillComboWithEnumNames(VerticalFillModeDropDownList, typeof(TreeMapVerticalFillMode)); VerticalFillModeDropDownList.SelectedIndex = (int)TreeMapVerticalFillMode.Default; WebExamplesUtilities.FillComboWithEnumNames(HorizontalFillModeDropDownList, typeof(TreeMapHorizontalFillMode)); HorizontalFillModeDropDownList.SelectedIndex = (int)TreeMapVerticalFillMode.Default; ColorModeDropDownList.Items.Add("Custom"); ColorModeDropDownList.Items.Add("Common Palette"); ColorModeDropDownList.Items.Add("Group Palette"); ColorModeDropDownList.SelectedIndex = 1; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = new NLabel("Tree Map"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.DockMode = PanelDockMode.Top; nChartControl1.Panels.Add(title); NTreeMapChart treeMap = new NTreeMapChart(); nChartControl1.Panels.Add(treeMap); treeMap.DockMode = PanelDockMode.Fill; XmlDocument document = LoadData(); foreach (XmlElement industry in document.DocumentElement) { NGroupTreeMapNode treeMapSeries = new NGroupTreeMapNode(); treeMapSeries.StrokeStyle = new NStrokeStyle(4, Color.Black); treeMapSeries.Padding = new NMarginsL(2.0f); treeMap.RootTreeMapNode.ChildNodes.Add(treeMapSeries); treeMapSeries.Label = industry.Attributes["Name"].Value; treeMapSeries.InteractivityStyle = new NInteractivityStyle(treeMapSeries.Label); foreach (XmlElement company in industry.ChildNodes) { double value = double.Parse(company.Attributes["Size"].Value); double change = double.Parse(company.Attributes["Change"].Value); string label = company.Attributes["Name"].Value; NValueTreeMapNode node = new NValueTreeMapNode(value, change, label); node.InteractivityStyle = new NInteractivityStyle(label); // node.FillStyle = new NColorFillStyle(Color.Green); treeMapSeries.ChildNodes.Add(node); } } nChartControl1.Controller.Tools.Add(new NTooltipTool()); // apply layout ApplyLayoutTemplate(0, nChartControl1, treeMap, title, null); // update from from controls treeMap.RootTreeMapNode.HorizontalFillMode = (TreeMapHorizontalFillMode)HorizontalFillModeDropDownList.SelectedIndex; treeMap.RootTreeMapNode.VerticalFillMode = (TreeMapVerticalFillMode)VerticalFillModeDropDownList.SelectedIndex; switch (ColorModeDropDownList.SelectedIndex) { case 0: { // custom color filling -> assign colors to each group (child nodes will inherit that fill) NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Bright); int industryIndex = 0; foreach (NGroupTreeMapNode industryTreeMapNode in treeMap.RootTreeMapNode.ChildNodes) { foreach (NTreeMapNode companyTreeMapNode in industryTreeMapNode.ChildNodes) { companyTreeMapNode.FillStyle = new NColorFillStyle(palette.SeriesColors[(industryIndex) % palette.SeriesColors.Count]); } industryIndex++; } } break; case 1: { // palette filling -> remove all fill styles assigned to nodes foreach (NGroupTreeMapNode industryTreeMapNode in treeMap.RootTreeMapNode.ChildNodes) { industryTreeMapNode.Palette = null; foreach (NTreeMapNode companyTreeMapNode in industryTreeMapNode.ChildNodes) { companyTreeMapNode.FillStyle = null; } } } break; case 2: { // palette filling -> remove all fill styles assigned to nodes foreach (NGroupTreeMapNode industryTreeMapNode in treeMap.RootTreeMapNode.ChildNodes) { NPalette palette = new NPalette(); palette.Mode = PaletteMode.AutoMinMaxColor; industryTreeMapNode.Palette = palette; foreach (NTreeMapNode companyTreeMapNode in industryTreeMapNode.ChildNodes) { companyTreeMapNode.FillStyle = null; } } } break; } }