private void TwinChartsCheckBox_CheckedChanged(object sender, EventArgs e) { nChartControl1.Document.RootPanel.Guidelines.Clear(); if (TwinChartsCheckBox.Checked) { // add twin guide line NTwinGuideline twinGuideLine = new NTwinGuideline(); twinGuideLine.Side = PanelSide.Left; twinGuideLine.Target1 = m_ChartFemale; twinGuideLine.Target2 = m_ChartMale; nChartControl1.Document.RootPanel.Guidelines.Add(twinGuideLine); } nChartControl1.Refresh(); }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); // header label NLabel headerLabel = nChartControl1.Labels.AddHeader("Population structure of New York for 2001"); headerLabel.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); headerLabel.ContentAlignment = ContentAlignment.MiddleCenter; headerLabel.TextStyle.FontStyle.Name = "Times New Roman"; headerLabel.TextStyle.FontStyle.Style = FontStyle.Italic; headerLabel.DockMode = PanelDockMode.Top; headerLabel.Margins = new NMarginsL(10, 10, 10, 10); // footer label NLabel footerLabel = nChartControl1.Labels.AddFooter("Population (in thousands)"); footerLabel.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); footerLabel.ContentAlignment = ContentAlignment.MiddleCenter; footerLabel.TextStyle.FontStyle.Name = "Times New Roman"; footerLabel.TextStyle.FontStyle.Style = FontStyle.Italic; footerLabel.Margins = new NMarginsL(10, 10, 10, 10); footerLabel.DockMode = PanelDockMode.Bottom; NDockPanel containerPanel = new NDockPanel(); containerPanel.DockMode = PanelDockMode.Fill; containerPanel.Margins = new NMarginsL(10, 0, 10, 0); nChartControl1.Panels.Add(containerPanel); // create male chart m_ChartMale = new NCartesianChart(); m_ChartMale.BoundsMode = BoundsMode.Stretch; m_ChartMale.ContentAlignment = ContentAlignment.MiddleCenter; m_ChartMale.DockMode = PanelDockMode.Left; m_ChartMale.Size = new NSizeL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(100, NRelativeUnit.ParentPercentage)); m_ChartMale.Margins = new NMarginsL(10, 10, 0, 10); SetupMaleChart(); containerPanel.ChildPanels.Add(m_ChartMale); // create female chart m_ChartFemale = new NCartesianChart(); m_ChartFemale.BoundsMode = BoundsMode.Stretch; m_ChartFemale.ContentAlignment = ContentAlignment.MiddleCenter; m_ChartFemale.DockMode = PanelDockMode.Left; m_ChartFemale.Size = new NSizeL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(100, NRelativeUnit.ParentPercentage)); m_ChartFemale.Margins = new NMarginsL(0, 10, 10, 10); SetupFemaleChart(); containerPanel.ChildPanels.Add(m_ChartFemale); // add twin guide line NTwinGuideline twinGuideLine = new NTwinGuideline(); twinGuideLine.Side = PanelSide.Left; twinGuideLine.Target1 = m_ChartFemale; twinGuideLine.Target2 = m_ChartMale; nChartControl1.Document.RootPanel.Guidelines.Add(twinGuideLine); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); TwinChartsCheckBox.Checked = true; }