protected void Page_Load(object sender, System.EventArgs e) { nChartControl1.AjaxToolsFactoryType = "NCustomToolFactory"; if (nChartControl1.RequiresInitialization) { NCustomToolsData.NData data = NCustomToolsData.Read(); nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Charts.Clear(); // display the female population chart NCartesianChart fChart = new NCartesianChart(); fChart.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalRight); fChart.Margins = new NMarginsL(9, 0, 0, 0); fChart.Location = new NPointL( new NLength(0, NRelativeUnit.ParentPercentage), new NLength(0, NRelativeUnit.ParentPercentage)); fChart.Size = new NSizeL( new NLength(54.21f, NRelativeUnit.ParentPercentage), new NLength(100, NRelativeUnit.ParentPercentage)); nChartControl1.Charts.Add(fChart); InitializeChartData(fChart, data.TotalFemaleData, true, Color.Pink); NAxis axisX = fChart.Axis(StandardAxis.PrimaryX); NLinearScaleConfigurator scaleX = axisX.ScaleConfigurator as NLinearScaleConfigurator; scaleX.CustomLabelsLevelOffset = new NLength(4); int nRowCount = data.TotalMaleData.Rows.Count; for (int i = 0; i < nRowCount; i++) { NCustomToolsData.NPopulationDataEntry en = data.TotalMaleData.Rows[i]; double begin = en.AgeRange.Start; double end = en.AgeRange.End + 1; scaleX.CustomLabels.Add(new NCustomValueLabel((begin + end) / 2, en.AgeRange.Title)); } // display the male population chart NCartesianChart mChart = new NCartesianChart(); mChart.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft); mChart.Margins = new NMarginsL(0, 0, 9, 0); mChart.Location = new NPointL( new NLength(55.5f, NRelativeUnit.ParentPercentage), new NLength(0, NRelativeUnit.ParentPercentage)); mChart.Size = new NSizeL( new NLength(44.8f, NRelativeUnit.ParentPercentage), new NLength(100, NRelativeUnit.ParentPercentage)); nChartControl1.Charts.Add(mChart); InitializeChartData(mChart, data.TotalMaleData, false, Color.SkyBlue); } }
private void SetupMaleChart() { // chart setup m_ChartMale.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalRight); // setup Y axis NAxis axisY = m_ChartMale.Axis(StandardAxis.PrimaryY); axisY.ScaleConfigurator.InnerMajorTickStyle.Visible = false; // add labels to the male chart X axis NAxis axisX = m_ChartMale.Axis(StandardAxis.PrimaryX); NOrdinalScaleConfigurator scaleX = axisX.ScaleConfigurator as NOrdinalScaleConfigurator; scaleX.MajorTickMode = MajorTickMode.CustomStep; scaleX.LabelFitModes = new LabelFitMode[] { LabelFitMode.AutoScale }; scaleX.AutoLabels = false; scaleX.Labels.AddRange(AgeLabels); // populate the male chart m_barM = (NBarSeries)m_ChartMale.Series.Add(SeriesType.Bar); m_barM.BorderStyle.Color = GreyBlue; m_barM.DataLabelStyle.Format = "<value>"; m_barM.DataLabelStyle.VertAlign = VertAlign.Center; m_barM.DataLabelStyle.TextStyle.FontStyle = new NFontStyle("Arial", 7); m_barM.Values.Add(200); // 0 - 4 m_barM.Values.Add(210); // 5 - 9 m_barM.Values.Add(205); // 10 - 14 m_barM.Values.Add(225); // 15 - 19 m_barM.Values.Add(250); // 20 - 24 m_barM.Values.Add(290); // 25 - 29 m_barM.Values.Add(340); // 30 - 34 m_barM.Values.Add(340); // 35 - 39 m_barM.Values.Add(370); // 40 - 44 m_barM.Values.Add(310); // 45 - 49 m_barM.Values.Add(260); // 50 - 54 m_barM.Values.Add(180); // 55 - 59 m_barM.Values.Add(120); // 60 - 64 m_barM.Values.Add(115); // 65 - 69 m_barM.Values.Add(100); // 70 - 74 m_barM.Values.Add(50); // 75 - 79 m_barM.Values.Add(35); // 80 + }
private void SetupFemaleChart() { // female chart setup m_ChartFemale.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft); // setup Y axis NAxis axisY = m_ChartFemale.Axis(StandardAxis.PrimaryY); axisY.ScaleConfigurator.InnerMajorTickStyle.Visible = false; axisY.Anchor = new NDockAxisAnchor(AxisDockZone.FrontRight, false, 0, 100); // add manual labels to the female chart NOrdinalScaleConfigurator ordinalScale = m_ChartFemale.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.MajorTickMode = MajorTickMode.CustomStep; ordinalScale.CustomStep = 1; // populate the female chart m_barF = (NBarSeries)m_ChartFemale.Series.Add(SeriesType.Bar); m_barF.BorderStyle.Color = DarkOrange; m_barF.DataLabelStyle.Format = "<value>"; m_barF.DataLabelStyle.VertAlign = VertAlign.Center; m_barF.DataLabelStyle.TextStyle.FontStyle = new NFontStyle("Arial", 7); m_barF.Values.Add(210); // 0 - 4 m_barF.Values.Add(215); // 5 - 9 m_barF.Values.Add(219); // 10 - 14 m_barF.Values.Add(225); // 15 - 19 m_barF.Values.Add(245); // 20 - 24 m_barF.Values.Add(289); // 25 - 29 m_barF.Values.Add(355); // 30 - 34 m_barF.Values.Add(355); // 35 - 39 m_barF.Values.Add(380); // 40 - 44 m_barF.Values.Add(320); // 45 - 49 m_barF.Values.Add(250); // 50 - 54 m_barF.Values.Add(190); // 55 - 59 m_barF.Values.Add(112); // 60 - 64 m_barF.Values.Add(110); // 65 - 69 m_barF.Values.Add(90); // 70 - 74 m_barF.Values.Add(55); // 75 - 79 m_barF.Values.Add(45); // 80 + }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = new NLabel("Gantt Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); // no legend nChartControl1.Legends.Clear(); // configure the chart NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; chart.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft); chart.Axis(StandardAxis.Depth).Visible = false; // setup the value axis NRangeTimelineScaleConfigurator dateTimeScale = new NRangeTimelineScaleConfigurator(); dateTimeScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; // add interlaced stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; stripStyle.Interlaced = true; dateTimeScale.StripStyles.Add(stripStyle); chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = dateTimeScale; chart.Axis(StandardAxis.PrimaryY).Anchor = new NDockAxisAnchor(AxisDockZone.FrontRight, true, 0, 100); // fill data DateTime start = DateTime.Now; DateTime end = start + new TimeSpan(10, 0, 0, 0); TaskCollection tasks = new TaskCollection(); tasks.Add(new Task("Write Proposal", new DateTime(2001, 4, 1), new DateTime(2001, 4, 5), new uint[] { 1, 2 })); tasks.Add(new Task("Obtain Approval", new DateTime(2001, 4, 12), new DateTime(2001, 9, 4), new uint[] { 9 })); tasks.Add(new Task("Requirements Analysis", new DateTime(2001, 4, 9), new DateTime(2001, 5, 5), new uint[] { 3 })); tasks.Add(new Task("Design Phase", new DateTime(2001, 5, 6), new DateTime(2001, 5, 30), new uint[] { 4 })); tasks.Add(new Task("Design Signoff", new DateTime(2001, 6, 2), new DateTime(2001, 6, 2), new uint[] { 5 })); tasks.Add(new Task("Alpha Implementation", new DateTime(2001, 6, 3), new DateTime(2001, 7, 31), new uint[] { 6 })); tasks.Add(new Task("Design Review", new DateTime(2001, 8, 1), new DateTime(2001, 8, 8), new uint[] { 7 })); tasks.Add(new Task("Revised Design Signoff", new DateTime(2001, 8, 10), new DateTime(2001, 8, 10), new uint[] { 8 })); tasks.Add(new Task("Beta Implementation", new DateTime(2001, 8, 12), new DateTime(2001, 9, 12), new uint[] { 9 })); tasks.Add(new Task("Testing", new DateTime(2001, 9, 13), new DateTime(2001, 10, 31), new uint[] { 10 })); tasks.Add(new Task("Final Implementation", new DateTime(2001, 11, 1), new DateTime(2001, 11, 15), new uint[] { 11 })); tasks.Add(new Task("Signoff", new DateTime(2001, 11, 28), new DateTime(2001, 11, 30), new uint[] { 12 })); tasks.ConfigureChart(chart); // apply layout ConfigureStandardLayout(chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NFloatBarDragPointTool()); // init form controls ShowGanttConnectorLinesCheckBox.Checked = true; }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Float Bar Connector Lines"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // no legend nChartControl1.Legends.Clear(); // configure the chart NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; chart.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft); chart.Axis(StandardAxis.Depth).Visible = false; // setup the value axis NRangeTimelineScaleConfigurator dateTimeScale = new NRangeTimelineScaleConfigurator(); dateTimeScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; // add interlaced stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; stripStyle.Interlaced = true; dateTimeScale.StripStyles.Add(stripStyle); chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = dateTimeScale; chart.Axis(StandardAxis.PrimaryY).Anchor = new NDockAxisAnchor(AxisDockZone.FrontRight, true, 0, 100); // fill data DateTime start = DateTime.Now; DateTime end = start + new TimeSpan(10, 0, 0, 0); TaskCollection tasks = new TaskCollection(); tasks.Add(new Task("Write Proposal", new DateTime(2001, 4, 1), new DateTime(2001, 4, 5), new uint[] { 1, 2 })); tasks.Add(new Task("Obtain Approval", new DateTime(2001, 4, 12), new DateTime(2001, 9, 4), new uint[] { 9 })); tasks.Add(new Task("Requirements Analysis", new DateTime(2001, 4, 9), new DateTime(2001, 5, 5), new uint[] { 3 })); tasks.Add(new Task("Design Phase", new DateTime(2001, 5, 6), new DateTime(2001, 5, 30), new uint[] { 4 })); tasks.Add(new Task("Design Signoff", new DateTime(2001, 6, 2), new DateTime(2001, 6, 2), new uint[] { 5 })); tasks.Add(new Task("Alpha Implementation", new DateTime(2001, 6, 3), new DateTime(2001, 7, 31), new uint[] { 6 })); tasks.Add(new Task("Design Review", new DateTime(2001, 8, 1), new DateTime(2001, 8, 8), new uint[] { 7 })); tasks.Add(new Task("Revised Design Signoff", new DateTime(2001, 8, 10), new DateTime(2001, 8, 10), new uint[] { 8 })); tasks.Add(new Task("Beta Implementation", new DateTime(2001, 8, 12), new DateTime(2001, 9, 12), new uint[] { 9 })); tasks.Add(new Task("Testing", new DateTime(2001, 9, 13), new DateTime(2001, 10, 31), new uint[] { 10 })); tasks.Add(new Task("Final Implementation", new DateTime(2001, 11, 1), new DateTime(2001, 11, 15), new uint[] { 11 })); tasks.Add(new Task("Signoff", new DateTime(2001, 11, 28), new DateTime(2001, 11, 30), new uint[] { 12 })); tasks.ConfigureChart(chart); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); NFloatBarSeries floatBar = (NFloatBarSeries)nChartControl1.Charts[0].Series[0]; floatBar.ShowGanttConnectorLines = ShowGanttConnectorLinesCheckBox.Checked; }
NDocument CreateDocument(NSize chartSize, NCustomToolsData.NData data, int populationDataId, int dataPointId) { NDocument document = new NDocument(); document.RootPanel.Charts.Clear(); // set a chart title string sex; string total; if (populationDataId == data.TotalFemaleData.Id) { sex = "Female"; total = string.Format("{0:0,#} +/-{1:0,#}", data.TotalFemaleData.Rows[dataPointId].Value, data.TotalFemaleData.Rows[dataPointId].Error); } else { sex = "Male"; total = string.Format("{0:0,#} +/-{1:0,#}", data.TotalMaleData.Rows[dataPointId].Value, data.TotalMaleData.Rows[dataPointId].Error); } NLabel header = document.RootPanel.Labels.AddHeader(string.Format("{0}, {1}, Population Data per Race<br/><font size='9pt'>Total of All Races: {2}</font>", sex, data.AgeRanges[dataPointId].Title, total)); header.TextStyle.TextFormat = TextFormat.XML; header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 13, FontStyle.Italic); header.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Left; header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL( new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage)); // add the chart NCartesianChart chart = new NCartesianChart(); document.RootPanel.Charts.Add(chart); chart.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft); chart.Margins = new NMarginsL(9, 40, 9, 9); chart.Location = new NPointL( new NLength(0, NRelativeUnit.ParentPercentage), new NLength(0, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(100, NRelativeUnit.ParentPercentage), new NLength(100, NRelativeUnit.ParentPercentage)); chart.Width = chartSize.Width + 180; chart.Height = chartSize.Height; NLinearScaleConfigurator scaleY = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; scaleY.LabelValueFormatter = new NNumericValueFormatter("0,,.#M"); NOrdinalScaleConfigurator scaleX = new NOrdinalScaleConfigurator(); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; scaleX.AutoLabels = false; scaleX.MajorTickMode = MajorTickMode.CustomTicks; scaleX.CustomLabelFitModes = new LabelFitMode[] { LabelFitMode.AutoScale }; scaleX.CustomLabelsLevelOffset = new NLength(4); NBarSeries barSeries = chart.Series.Add(SeriesType.Bar) as NBarSeries; barSeries.DataLabelStyle.Visible = false; int length = data.Races.Count; for (int i = 0; i < length; i++) { NCustomToolsData.NRace race = data.Races[i]; double value; if (populationDataId == race.MaleData.Id) { value = race.MaleData.Rows[dataPointId].Value; } else { value = race.FemaleData.Rows[dataPointId].Value; } barSeries.Values.Add(value); NCustomValueLabel vl = new NCustomValueLabel(i, race.Title); vl.Style.ContentAlignment = ContentAlignment.MiddleRight; scaleX.CustomLabels.Add(vl); } return(document); }