public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Horizontal Bar Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // setup the chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterRight); chart.Width = 40; chart.Height = 65; chart.Axis(StandardAxis.PrimaryY).Anchor = new NDockAxisAnchor(AxisDockZone.FrontRight, true, 0, 100); chart.Axis(StandardAxis.Depth).Visible = false; // add interlace stripe to the Y axis NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.StripStyles.Add(stripStyle); // add a bar series NBarSeries b1 = (NBarSeries)chart.Series.Add(SeriesType.Bar); b1.MultiBarMode = MultiBarMode.Series; b1.Name = "Bar 1"; b1.DataLabelStyle.Format = "<value>"; b1.Legend.Mode = SeriesLegendMode.DataPoints; b1.Values.AddRange(new double[] { 10, 27, 43, 71, 89, 93 }); // apply layout ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); // init form controls StyleCombo.FillFromEnum(typeof(BarShape)); StyleCombo.SelectedIndex = 0; }
private void SetupFemaleChart() { // female chart setup m_ChartFemale.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft); m_ChartFemale.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalHorizontalLeft); // 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 NAxis axisX = m_ChartFemale.Axis(StandardAxis.PrimaryX); NOrdinalScaleConfigurator scaleX = axisX.ScaleConfigurator as NOrdinalScaleConfigurator; scaleX.Invert = true; scaleX.InnerMajorTickStyle.Visible = false; scaleX.MajorTickMode = MajorTickMode.AutoMaxCount; scaleX.LabelFitModes = new LabelFitMode[] { LabelFitMode.AutoScale }; scaleX.AutoLabels = false; scaleX.Labels.AddRange(AgeLabels); // populate the female chart m_barF = (NBarSeries)m_ChartFemale.Series.Add(SeriesType.Bar); m_barF.FillStyle = new NGradientFillStyle(BeautifulRed, Color.White); m_barF.BorderStyle.Color = BeautifulRed; 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 + }
private void SetupMaleChart() { // chart setup m_ChartMale.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalRight); m_ChartMale.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalHorizontalRight); // 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.InnerMajorTickStyle.Visible = false; scaleX.MajorTickMode = MajorTickMode.AutoMaxCount; 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.FillStyle = new NGradientFillStyle(Blue, Color.White); m_barM.BorderStyle.Color = Blue; 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 + }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Horizontal Bar Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // no legend nChartControl1.Legends.Clear(); // setup chart nChart = nChartControl1.Charts[0]; nChart.Enable3D = true; nChart.Height = 70; nChart.Width = 55; nChart.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft); nChart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterRight); nChart.Axis(StandardAxis.Depth).Visible = false; // add interlace stripe to the Y axis NLinearScaleConfigurator linearScale = nChart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left }; linearScale.StripStyles.Add(stripStyle); // add a bar series NBarSeries b1 = (NBarSeries)nChart.Series.Add(SeriesType.Bar); b1.MultiBarMode = MultiBarMode.Series; b1.Name = "Bar 1"; b1.DataLabelStyle.Format = "<value>"; b1.Values.AddRange(new double[] { 10, 27, 43, 71, 89, 93 }); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); // apply layout ApplyLayoutTemplate(0, nChartControl1, nChart, title, null); // init form controls if (IsPostBack) { NBarSeries bar = (NBarSeries)nChart.Series[0]; bar.BarShape = (BarShape)BarShapeDropDownList.SelectedIndex; if (PositiveDataCheckBox.Checked == true) { PositiveDataButton_Click(null, null); } else { PositiveAndNegativeDataButton_Click(null, null); } } else { WebExamplesUtilities.FillComboWithEnumValues(BarShapeDropDownList, typeof(BarShape)); BarShapeDropDownList.SelectedIndex = 0; } }