private void CalcFunction() { NDataSeriesDouble ds = m_FuncCalculator.Calculate(); if (ds == null) { return; } m_Chart.Axis(StandardAxis.PrimaryY).ConstLines.Clear(); m_Line.Visible = false; if (m_GroupingCombo.SelectedIndex == 0) { // add a constline if there is no grouping NAxisConstLine cl = m_Chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(); cl.StrokeStyle.Width = new NLength(2, NGraphicsUnit.Pixel); cl.StrokeStyle.Color = Color.Red; cl.Value = (double)ds.GetValueForIndex(0); } else { m_Line.Visible = true; m_Line.Values = ds; m_Line.Values.ValueFormatter = new NNumericValueFormatter("0.00"); } nChartControl1.Refresh(); }
private void BottomIncludeInAxisRangeCheck_CheckedChanged(object sender, EventArgs e) { NAxisConstLine cl = (NAxisConstLine)m_Chart.Axis(StandardAxis.PrimaryX).ConstLines[0]; cl.IncludeInAxisRange = BottomIncludeInAxisRangeCheck.Checked; nChartControl1.Refresh(); }
private void LeftValue_Scroll(object sender, Nevron.UI.WinForm.Controls.ScrollBarEventArgs e) { NAxisConstLine cl = (NAxisConstLine)m_Chart.Axis(StandardAxis.PrimaryY).ConstLines[0]; cl.Value = LeftValue.Value; nChartControl1.Refresh(); }
private void XZPlaneValueNumericUpDown_ValueChanged(object sender, System.EventArgs e) { NAxisConstLine xzPlane = (NAxisConstLine)(m_Chart.Axis(StandardAxis.PrimaryY).ConstLines[0]); xzPlane.Value = (double)(XZPlaneValueNumericUpDown.Value); nChartControl1.Refresh(); }
private void BottomTitleTextBox_TextChanged(object sender, EventArgs e) { NAxisConstLine cl = (NAxisConstLine)m_Chart.Axis(StandardAxis.PrimaryX).ConstLines[0]; cl.Text = BottomTitleTextBox.Text; nChartControl1.Refresh(); }
private void BottomTitleAlignmentCombo_SelectedIndexChanged(object sender, EventArgs e) { NAxisConstLine cl = (NAxisConstLine)m_Chart.Axis(StandardAxis.PrimaryX).ConstLines[0]; cl.TextAlignment = (ContentAlignment)Enum.Parse(typeof(ContentAlignment), BottomTitleAlignmentCombo.SelectedItem.ToString()); nChartControl1.Refresh(); }
public bool ContainLine(NAxisConstLine line) { if (line == null) { return(false); } return(this._line1 == line || this._line2 == line); }
private void SetConstline() { NAxis axis = m_Chart.Axis(StandardAxis.PrimaryY); // add a constline if necessary if (axis.ConstLines.Count == 0) { axis.ConstLines.Add(); } // the line series won't be used m_Line.Visible = false; // calc the sum of the elements NDataSeriesDouble ds = m_FuncCalculator.Calculate(); // add a new constline NAxisConstLine cl = (NAxisConstLine)axis.ConstLines[0]; cl.StrokeStyle.Width = new NLength(2, NGraphicsUnit.Pixel); cl.StrokeStyle.Color = Color.Red; cl.Value = (double)ds.GetValueForIndex(0); m_LabelSum.Text = cl.Value.ToString(); // set proper scale for the axis, so that it includes the constline if (cl.Value >= 0) { // if the sum is positive - compare it to the largest value m_FuncCalculator.Expression = "MAX(values)"; ds = m_FuncCalculator.Calculate(); double dMax = (double)ds.GetValueForIndex(0); if (cl.Value > dMax) { dMax = cl.Value; } axis.View = new NRangeAxisView(new NRange1DD(0, dMax), false, true); } else { // if the sum is negative - compare it to the smallest value m_FuncCalculator.Expression = "MIN(values)"; ds = m_FuncCalculator.Calculate(); double dMin = (double)ds.GetValueForIndex(0); if (cl.Value < dMin) { dMin = cl.Value; } axis.View = new NRangeAxisView(new NRange1DD(dMin, 0), true, false); } }
private void CalculateFunction() { NAxisConstLine cl = (NAxisConstLine)m_Chart.Axis(StandardAxis.PrimaryY).ConstLines[0]; NDataSeriesDouble ds = m_FuncCalculator.Calculate(); cl.Value = (double)ds.GetValueForIndex(0); m_LabelResult.Text = cl.Value.ToString(); }
private void LeftPropsButton_Click(object sender, System.EventArgs e) { NAxisConstLine cl = (NAxisConstLine)m_Chart.Axis(StandardAxis.PrimaryY).ConstLines[0]; NStrokeStyle strokeStyleResult; if (NStrokeStyleTypeEditor.Edit(cl.StrokeStyle, out strokeStyleResult)) { cl.StrokeStyle = strokeStyleResult; nChartControl1.Refresh(); } }
private void BottomEndScroll_Scroll(object sender, Nevron.UI.WinForm.Controls.ScrollBarEventArgs e) { NAxisConstLine cl = (NAxisConstLine)m_Chart.Axis(StandardAxis.PrimaryX).ConstLines[0]; if (cl.ReferenceRanges.Count > 0) { NReferenceAxisRange refAxisRange = (NReferenceAxisRange)cl.ReferenceRanges[0]; refAxisRange.EndValue = BottomEndScroll.Value; nChartControl1.Refresh(); } }
private void LeftFillFillStyleButton_Click(object sender, System.EventArgs e) { NAxisConstLine cl = (NAxisConstLine)m_Chart.Axis(StandardAxis.PrimaryY).ConstLines[0]; NFillStyle fillStyleResult; if (NFillStyleTypeEditor.Edit(cl.FillStyle, out fillStyleResult)) { cl.FillStyle = fillStyleResult; nChartControl1.Refresh(); } }
private void BottomAxisTextStyleButton_Click(object sender, EventArgs e) { NAxisConstLine cl = (NAxisConstLine)m_Chart.Axis(StandardAxis.PrimaryX).ConstLines[0]; NTextStyle textStyle; if (NTextStyleTypeEditor.Edit(cl.TextStyle, out textStyle)) { cl.TextStyle = textStyle; nChartControl1.Refresh(); } }
public MySelectRange(NChart chart, double begin, double end, Color c) { this._chart = chart; this._end = Math.Max(begin, end); this._begin = Math.Min(begin, end); this._LineColor = c; this._line1 = chart.Axis(StandardAxis.PrimaryX).ConstLines.Add(); this._line1.StrokeStyle.Color = this._LineColor; this._line1.StrokeStyle.Width = new NLength(1.5f); this._line1.FillStyle = new NColorFillStyle(new NArgbColor(125, this._LineColor)); this._line1.Text = "点击鼠标左键进行拖动"; this._line1.Value = this._begin; this._line2 = chart.Axis(StandardAxis.PrimaryX).ConstLines.Add(); this._line2.StrokeStyle.Color = this._LineColor; this._line2.StrokeStyle.Width = new NLength(1.5f); this._line2.FillStyle = new NColorFillStyle(new NArgbColor(125, this._LineColor)); this._line2.Text = "点击鼠标左键进行拖动"; this._line2.Value = this._end; // configure the first vertical section _section = new NScaleSectionStyle(); _section.Range = new NRange1DD(begin, end); _section.SetShowAtWall(ChartWallType.Back, true); _section.SetShowAtWall(ChartWallType.Left, true); _section.RangeFillStyle = new NColorFillStyle(_LineColor); _section.MajorGridStrokeStyle = new NStrokeStyle(_LineColor); _section.MajorTickStrokeStyle = new NStrokeStyle(Color.DarkBlue); _section.MinorTickStrokeStyle = new NStrokeStyle(1, _LineColor, LinePattern.Dot, 0, 2); _standardScale = (NStandardScaleConfigurator)_chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; _standardScale.Sections.Add(_section); //labelStyle = new NTextStyle(); //labelStyle.FillStyle = new NGradientFillStyle(Color.Blue, Color.DarkBlue); //labelStyle.FontStyle.Style = FontStyle.Bold; //m_FirstVerticalSection.LabelTextStyle = labelStyle; this._line1.ValueChanged += new EventHandler(_line_ValueChanged); this._line2.ValueChanged += new EventHandler(_line_ValueChanged); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Count, Standard Deviation, RMS"); 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)); // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; m_Chart.Location = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); m_Chart.Size = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage)); // add a constline to diplay the function result NAxisConstLine cl = m_Chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(); cl.StrokeStyle.Width = new NLength(2, NGraphicsUnit.Pixel); cl.StrokeStyle.Color = Color.Red; cl.Value = 0; // add the bar series m_Bar = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); m_Bar.Name = "Bar1"; m_Bar.Values.Name = "values"; m_Bar.Values.ValueFormatter = new NNumericValueFormatter("0.00"); m_Bar.MultiBarMode = MultiBarMode.Series; m_Bar.DataLabelStyle.Visible = false; m_Bar.Legend.Mode = SeriesLegendMode.DataPoints; m_Bar.BarShape = BarShape.Cylinder; m_Bar.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); m_Bar.FillStyle = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant1, Color.DarkSeaGreen, Color.DarkGreen); m_Bar.Values.FillRandomRange(Random, 10, 0, 20); // add argument m_FuncCalculator.Arguments.Add(m_Bar.Values); // form controls m_FunctionCombo.Items.Add("Count"); m_FunctionCombo.Items.Add("Standard Deviation"); m_FunctionCombo.Items.Add("Root Mean Square"); m_FunctionCombo.SelectedIndex = 0; }
private void LeftStyleCombo_SelectedIndexChanged(object sender, System.EventArgs e) { NAxisConstLine cl = (NAxisConstLine)m_Chart.Axis(StandardAxis.PrimaryY).ConstLines[0]; switch (LeftStyleCombo.SelectedIndex) { case 0: cl.Mode = ConstLineMode.Line; LeftFillFillStyleButton.Enabled = false; break; case 1: cl.Mode = ConstLineMode.Plane; LeftFillFillStyleButton.Enabled = true; break; } nChartControl1.Refresh(); }
private void UpdateReferenceAxisRanges() { NAxisConstLine cl = (NAxisConstLine)m_Chart.Axis(StandardAxis.PrimaryY).ConstLines[0]; cl.ReferenceRanges.Clear(); if (UseBeginEndXCheck.Checked) { NAxis axisX = m_Chart.Axis(StandardAxis.PrimaryX); double refBeginValue = BeginXScroll.Value; double refEndValue = EndXScroll.Value; cl.ReferenceRanges.Add(new NReferenceAxisRange(axisX, refBeginValue, refEndValue)); BeginXScroll.Enabled = true; EndXScroll.Enabled = true; } else { BeginXScroll.Enabled = false; EndXScroll.Enabled = false; } if (UseBeginEndZCheck.Checked) { NAxis axisZ = m_Chart.Axis(StandardAxis.Depth); double refBeginValue = BeginZScroll.Value; double refEndValue = EndZScroll.Value; cl.ReferenceRanges.Add(new NReferenceAxisRange(axisZ, refBeginValue, refEndValue)); BeginZScroll.Enabled = true; EndZScroll.Enabled = true; } else { BeginZScroll.Enabled = false; EndZScroll.Enabled = false; } }
private void CreatePointAtPlaneComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { NAxisConstLine xyPlane = (NAxisConstLine)(m_Chart.Axis(StandardAxis.Depth).ConstLines[0]); NAxisConstLine xzPlane = (NAxisConstLine)(m_Chart.Axis(StandardAxis.PrimaryY).ConstLines[0]); if (CreatePointAtPlaneComboBox.SelectedIndex == 0) { xzPlane.FillStyle = new NColorFillStyle(Color.FromArgb(125, 255, 0, 0)); xyPlane.FillStyle = new NColorFillStyle(Color.FromArgb(125, 0, 0, 255)); XZPlaneValueNumericUpDown.Enabled = true; XYPlaneValueNumericUpDown.Enabled = false; } else { xzPlane.FillStyle = new NColorFillStyle(Color.FromArgb(125, 0, 0, 255)); xyPlane.FillStyle = new NColorFillStyle(Color.FromArgb(125, 255, 0, 0)); XZPlaneValueNumericUpDown.Enabled = false; XYPlaneValueNumericUpDown.Enabled = true; } nChartControl1.Refresh(); }
private void LeftUseBeginEndCheck_CheckedChanged(object sender, EventArgs e) { NAxisConstLine cl = (NAxisConstLine)m_Chart.Axis(StandardAxis.PrimaryY).ConstLines[0]; if (LeftUseBeginEndCheck.Checked) { NAxis referenceAxis = m_Chart.Axis(StandardAxis.PrimaryX); double refBeginValue = LeftBeginScroll.Value; double refEndValue = LeftEndScroll.Value; cl.ReferenceRanges.Add(new NReferenceAxisRange(referenceAxis, refBeginValue, refEndValue)); LeftBeginScroll.Enabled = true; LeftEndScroll.Enabled = true; } else { cl.ReferenceRanges.Clear(); LeftBeginScroll.Enabled = false; LeftEndScroll.Enabled = false; } nChartControl1.Refresh(); }
public override void Initialize() { base.Initialize(); // Enable GPU acceleration nChartControl1.Settings.RenderSurface = RenderSurface.Window; nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Surface Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(Color.Gray); // setup chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 60.0f; chart.Depth = 60.0f; chart.Height = 25.0f; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft); // setup axes NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); ordinalScale.DisplayDataPointsBetweenTicks = false; ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); ordinalScale.DisplayDataPointsBetweenTicks = false; chart.Axis(StandardAxis.SecondaryY).Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, false, 100.0f, 100.0f); chart.Axis(StandardAxis.SecondaryY).Visible = false; m_ContourLineSeries = new NLineSeries(); chart.Series.Add(m_ContourLineSeries); m_ContourLineSeries.UseXValues = true; m_ContourLineSeries.UseZValues = true; m_ContourLineSeries.BorderStyle.Width = new NLength(2); m_ContourLineSeries.BorderStyle.Color = Color.Red; m_ContourLineSeries.DataLabelStyle.Visible = false; m_ContourLineSeries.DisplayOnAxis((int)StandardAxis.PrimaryY, false); m_ContourLineSeries.DisplayOnAxis((int)StandardAxis.SecondaryY, true); m_ContourLineSeries.Legend.Mode = SeriesLegendMode.None; m_CrossSectionPlane = new NAxisConstLine(); m_CrossSectionPlane.Mode = ConstLineMode.Plane; m_CrossSectionPlane.FillStyle = new NColorFillStyle(Color.FromArgb(25, Color.Blue)); chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(m_CrossSectionPlane); // add the surface series NGridSurfaceSeries surface = (NGridSurfaceSeries)chart.Series.Add(SeriesType.GridSurface); surface.Name = "Surface"; surface.Legend.Mode = SeriesLegendMode.SeriesLogic; surface.PositionValue = 10.0; surface.Data.SetGridSize(31, 32); surface.SyncPaletteWithAxisScale = false; surface.PaletteSteps = 8; surface.ValueFormatter.FormatSpecifier = "0.00"; surface.FillStyle = new NColorFillStyle(Color.YellowGreen); surface.Isolines.Add(new NSurfaceIsoline(10, new NStrokeStyle(2.0f, Color.Blue))); surface.FrameColorMode = SurfaceFrameColorMode.Uniform; FillData(surface); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); PlaneValueNumericUpDown.Value = 10; }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Polar Value Axis Position"); 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 chart NPolarChart polar = new NPolarChart(); polar.InnerRadius = new NLength(20); nChartControl1.Charts.Clear(); nChartControl1.Charts.Add(polar); polar.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); polar.DisplayOnLegend = nChartControl1.Legends[0]; // setup polar axis NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)polar.Axis(StandardAxis.Polar).ScaleConfigurator; linearScale.RoundToTickMax = true; linearScale.RoundToTickMin = true; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); // setup polar angle axis NAngularScaleConfigurator angularScale = (NAngularScaleConfigurator)polar.Axis(StandardAxis.PolarAngle).ScaleConfigurator; angularScale.MajorGridStyle.SetShowAtWall(ChartWallType.Polar, true); angularScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0); NScaleStripStyle strip = new NScaleStripStyle(); strip.FillStyle = new NColorFillStyle(Color.FromArgb(125, 192, 192, 192)); strip.Interlaced = true; strip.SetShowAtWall(ChartWallType.Polar, true); angularScale.StripStyles.Add(strip); // add a const line NAxisConstLine line = polar.Axis(StandardAxis.Polar).ConstLines.Add(); line.Value = 50; line.StrokeStyle.Color = Color.SlateBlue; line.StrokeStyle.Width = new NLength(1, NGraphicsUnit.Pixel); // create a polar line series NPolarLineSeries series1 = new NPolarLineSeries(); polar.Series.Add(series1); series1.Name = "Series 1"; series1.CloseContour = true; series1.DataLabelStyle.Visible = false; series1.MarkerStyle.Visible = false; series1.MarkerStyle.Width = new NLength(1, NRelativeUnit.ParentPercentage); series1.MarkerStyle.Height = new NLength(1, NRelativeUnit.ParentPercentage); Curve1(series1, 50); // create a polar line series NPolarLineSeries series2 = new NPolarLineSeries(); polar.Series.Add(series2); series2.Name = "Series 2"; series2.CloseContour = true; series2.DataLabelStyle.Visible = false; series2.MarkerStyle.Visible = false; series2.MarkerStyle.Width = new NLength(1, NRelativeUnit.ParentPercentage); series2.MarkerStyle.Height = new NLength(1, NRelativeUnit.ParentPercentage); Curve2(series2, 100); // add a second value axes NPolarAxis primaryAxis = (NPolarAxis)polar.Axis(StandardAxis.Polar); NPolarAxis secondaryAxis = ((NPolarAxisCollection)polar.Axes).AddCustomAxis(PolarAxisOrientation.Value); m_CustomAxisId = secondaryAxis.AxisId; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // color code the axes and series after the stylesheet is applied ApplyColorToAxis(primaryAxis, Color.Red); ApplyColorToAxis(secondaryAxis, Color.Green); series1.BorderStyle.Color = Color.DarkRed; series1.BorderStyle.Width = new NLength(2); series2.BorderStyle.Color = Color.DarkGreen; series2.BorderStyle.Width = new NLength(2); series2.DisplayOnAxis(StandardAxis.Polar, false); series2.DisplayOnAxis(m_CustomAxisId, true); // init form controls RadianAngleStepComboBox.Items.Add("15"); RadianAngleStepComboBox.Items.Add("30"); RadianAngleStepComboBox.Items.Add("45"); RadianAngleStepComboBox.Items.Add("90"); RadianAngleStepComboBox.SelectedIndex = 0; RedAxisAngleUpDown.Value = (decimal)0; RedBeginUpDown.Value = (decimal)0; RedEndUpDown.Value = (decimal)100; GreenAxisAngleUpDown.Value = (decimal)90; GreenBeginUpDown.Value = (decimal)0; GreenEndUpDown.Value = (decimal)100; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // fill the combo WebExamplesUtilities.FillComboWithValues(XValueDropDownList, 10, 90, 10); WebExamplesUtilities.FillComboWithValues(YValueDropDownList, 10, 90, 10); } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Intersect Line With X/Y Value"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; NChart chart = nChartControl1.Charts[0]; // 2D line chart chart.BoundsMode = BoundsMode.Stretch; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = GetScaleConfigurator(); chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = GetScaleConfigurator(); chart.Axis(StandardAxis.Depth).Visible = false; NAxisCollection axes = chart.Axes; // add point series NPointSeries point = (NPointSeries)chart.Series.Add(SeriesType.Point); point.UseXValues = true; point.FillStyle = new NColorFillStyle(Color.Red); point.DataLabelStyle.Visible = false; point.Size = new NLength(2); NLineSeries line = new NLineSeries(); chart.Series.Add(line); line.Name = "Point 1"; line.FillStyle = new NColorFillStyle(Color.Red); line.BorderStyle.Color = Color.Pink; line.DataLabelStyle.Visible = false; line.UseXValues = true; line.InflateMargins = true; // fill with data Random rand = new Random(); double radius = 0; double angle = 0; int dataPointCount = 1000; double rStep = 50.0 / dataPointCount; double aStep = 10.0; for (int i = 0; i < dataPointCount; i++) { double y = Math.Sin(angle * 0.0174533f) * radius; double x = Math.Cos(angle * 0.0174533f) * radius; line.XValues.Add(50.0 + x); line.Values.Add(50.0 + y); radius += rStep; angle += aStep; } point.XValues.Clear(); point.Values.Clear(); NAxisConstLine horizontalAxisCursor = new NAxisConstLine(); NAxisConstLine verticalAxisCursor = new NAxisConstLine(); chart.Axis(StandardAxis.PrimaryX).ConstLines.Add(horizontalAxisCursor); chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(verticalAxisCursor); double xValue = (XValueDropDownList.SelectedIndex + 1) * 10; double yValue = (YValueDropDownList.SelectedIndex + 1) * 10; horizontalAxisCursor.Value = xValue; List <double> intersections = line.IntersectWithXValue(xValue); for (int i = 0; i < intersections.Count; i++) { point.XValues.Add(xValue); point.Values.Add(intersections[i]); } verticalAxisCursor.Value = yValue; intersections = line.IntersectWithYValue(yValue); for (int i = 0; i < intersections.Count; i++) { point.XValues.Add(intersections[i]); point.Values.Add(yValue); } // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
protected void Page_Load(object sender, EventArgs e) { // disable frame nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Axis Const Lines"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; // configure the chart margins chart.BoundsMode = BoundsMode.Fit; chart.Location = new NPointL( new NLength(10, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(80, NRelativeUnit.ParentPercentage), new NLength(78, NRelativeUnit.ParentPercentage)); // set projection and lighting chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); // disable the depth axis chart.Axis(StandardAxis.Depth).Visible = false; NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; // add interlace stripe 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); // switch the X axis to linear as well chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator(); // Create a point series NPointSeries pnt = (NPointSeries)chart.Series.Add(SeriesType.Point); pnt.InflateMargins = true; pnt.UseXValues = true; pnt.Name = "Series 1"; pnt.DataLabelStyle.Format = "<value>"; // Add some data pnt.Values.Add(31); pnt.Values.Add(67); pnt.Values.Add(12); pnt.Values.Add(84); pnt.Values.Add(90); pnt.XValues.Add(10); pnt.XValues.Add(36); pnt.XValues.Add(52); pnt.XValues.Add(62); pnt.XValues.Add(88); // Add a constline for the left axis NAxisConstLine cl1 = chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(); cl1.StrokeStyle.Color = Color.SlateGray; cl1.FillStyle = new NColorFillStyle(Color.FromArgb(60, Color.SlateGray)); cl1.Value = 90; // Add a constline for the bottom axis NAxisConstLine cl2 = chart.Axis(StandardAxis.PrimaryX).ConstLines.Add(); cl2.StrokeStyle.Color = Color.LightSkyBlue; cl2.FillStyle = new NColorFillStyle(Color.FromArgb(60, Color.LightSkyBlue)); cl2.Value = 40; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); if (!IsPostBack) { // init the form controls WebExamplesUtilities.FillComboWithValues(LAValueDropDownList, 0, 100, 10); LAStyleDropDownList.Items.Add("Line"); LAStyleDropDownList.Items.Add("Plane"); LAStyleDropDownList.SelectedIndex = 1; WebExamplesUtilities.FillComboWithValues(LABeginValueDropDownList, 0, 100, 10); WebExamplesUtilities.FillComboWithValues(LAEndValueDropDownList, 0, 100, 10); WebExamplesUtilities.FillComboWithValues(BAValueDropDownList, 0, 100, 10); BAStyleDropDownList.Items.Add("Line"); BAStyleDropDownList.Items.Add("Plane"); BAStyleDropDownList.SelectedIndex = 1; WebExamplesUtilities.FillComboWithValues(BABeginValueDropDownList, 0, 100, 10); WebExamplesUtilities.FillComboWithValues(BAEndValueDropDownList, 0, 100, 10); LAValueDropDownList.SelectedIndex = (int)(cl1.Value / 10); BAValueDropDownList.SelectedIndex = (int)(cl2.Value / 10); LABeginValueDropDownList.SelectedIndex = 0; LAEndValueDropDownList.SelectedIndex = 10; BABeginValueDropDownList.SelectedIndex = 0; BAEndValueDropDownList.SelectedIndex = 10; LABeginValueDropDownList.Enabled = false; LAEndValueDropDownList.Enabled = false; BABeginValueDropDownList.Enabled = false; BAEndValueDropDownList.Enabled = false; } NAxisConstLine leftAxisConstLine = chart.Axis(StandardAxis.PrimaryY).ConstLines[0]; leftAxisConstLine.Value = (LAValueDropDownList.SelectedIndex * 10); switch (LAStyleDropDownList.SelectedIndex) { case 0: leftAxisConstLine.Mode = ConstLineMode.Line; break; case 1: leftAxisConstLine.Mode = ConstLineMode.Plane; break; } NAxisConstLine cl = chart.Axis(StandardAxis.PrimaryY).ConstLines[0]; if (LAUseBeginEndValueCheckBox.Checked) { NAxis referenceAxis = chart.Axis(StandardAxis.PrimaryX); double refBeginValue = Convert.ToDouble(LABeginValueDropDownList.SelectedIndex) * 10; double refEndValue = Convert.ToDouble(LAEndValueDropDownList.SelectedIndex) * 10; cl.ReferenceRanges.Add(new NReferenceAxisRange(referenceAxis, refBeginValue, refEndValue)); LABeginValueDropDownList.Enabled = true; LAEndValueDropDownList.Enabled = true; } else { cl.ReferenceRanges.Clear(); LABeginValueDropDownList.Enabled = false; LAEndValueDropDownList.Enabled = false; } // bottom axis NAxisConstLine bottomAxisConstline = chart.Axis(StandardAxis.PrimaryX).ConstLines[0]; bottomAxisConstline.Value = (BAValueDropDownList.SelectedIndex * 10); switch (BAStyleDropDownList.SelectedIndex) { case 0: bottomAxisConstline.Mode = ConstLineMode.Line; break; case 1: bottomAxisConstline.Mode = ConstLineMode.Plane; break; } cl = chart.Axis(StandardAxis.PrimaryX).ConstLines[0]; if (BAUseBeginEndValueCheckBox.Checked) { NAxis referenceAxis = chart.Axis(StandardAxis.PrimaryY); double refBeginValue = Convert.ToDouble(BABeginValueDropDownList.SelectedIndex) * 10; double refEndValue = Convert.ToDouble(BAEndValueDropDownList.SelectedIndex) * 10; cl.ReferenceRanges.Add(new NReferenceAxisRange(referenceAxis, refBeginValue, refEndValue)); BABeginValueDropDownList.Enabled = true; BAEndValueDropDownList.Enabled = true; } else { cl.ReferenceRanges.Clear(); BABeginValueDropDownList.Enabled = false; BAEndValueDropDownList.Enabled = false; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // form controls FunctionDropDownList.Items.Add("Count"); FunctionDropDownList.Items.Add("Standard Deviation"); FunctionDropDownList.Items.Add("Root Mean Square"); FunctionDropDownList.SelectedIndex = 0; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // add header NLabel header = nChartControl1.Labels.AddHeader("Functions"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // align the legend NLegend legend = nChartControl1.Legends[0]; legend.Location = new NPointL(legend.Location.X, new NLength(15, NRelativeUnit.ParentPercentage)); legend.Data.MarkSize = new NSizeL(5, 5); nFuncCalculator = new NFunctionCalculator(); nChart = nChartControl1.Charts[0]; nChart.Enable3D = true; nChart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); nChart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); nChart.BoundsMode = BoundsMode.Stretch; nChart.Location = new NPointL( new NLength(10, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); nChart.Size = new NSizeL( new NLength(70, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage)); nChart.Axis(StandardAxis.Depth).Visible = false; nChart.Wall(ChartWallType.Left).Visible = false; nChart.Wall(ChartWallType.Floor).Visible = false; // setup X axis NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)nChart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; ordinalScale.DisplayDataPointsBetweenTicks = false; // add a constline to diplay the function result NAxisConstLine cl = nChart.Axis(StandardAxis.PrimaryY).ConstLines.Add(); cl.StrokeStyle.Width = new NLength(2, NGraphicsUnit.Pixel); cl.StrokeStyle.Color = Color.Red; cl.Value = 0; // add the bar series nBar = (NBarSeries)nChart.Series.Add(SeriesType.Bar); nBar.Name = "Bar1"; nBar.Values.Name = "values"; nBar.Values.ValueFormatter = new NNumericValueFormatter("0.00"); nBar.MultiBarMode = MultiBarMode.Series; nBar.DataLabelStyle.Visible = false; nBar.Legend.Mode = SeriesLegendMode.DataPoints; nBar.BarShape = BarShape.Cylinder; nBar.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); nBar.FillStyle = new NColorFillStyle(Color.DarkSeaGreen); nBar.Values.FillRandomRange(Random, 10, 0, 20); nBar.Legend.TextStyle = new NTextStyle(new NFontStyle("Arial", 7)); // add argument nFuncCalculator.Arguments.Add(nBar.Values); nBar.Values.FillRandomRange(Random, 10, 0, 20); BuildExpression(); CalculateFunction(); }
public override void Initialize() { base.Initialize(); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Converting from viewport to scale coordinates"); 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)); // no legend nChartControl1.Legends.Clear(); // configure a free xyz point chart m_Chart = nChartControl1.Charts[0]; m_Chart.Enable3D = true; m_Chart.BoundsMode = BoundsMode.Fit; m_Chart.Location = new NPointL(new NLength(8, NRelativeUnit.ParentPercentage), new NLength(8, NRelativeUnit.ParentPercentage)); m_Chart.Size = new NSizeL(new NLength(84, NRelativeUnit.ParentPercentage), new NLength(84, NRelativeUnit.ParentPercentage)); m_Chart.Depth = 55.0f; m_Chart.Width = 55.0f; m_Chart.Height = 55.0f; m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); // configure x axis to scale in numeric linear mode NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; // configure y axis to scale in numeric linear mode linearScale = new NLinearScaleConfigurator(); m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; // configure depth axis to scale in numeric linear mode linearScale = new NLinearScaleConfigurator(); m_Chart.Axis(StandardAxis.Depth).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; nChartControl1.Controller.Selection.Clear(); nChartControl1.Controller.Selection.Add(m_Chart); m_Point = (NPointSeries)m_Chart.Series.Add(SeriesType.Point); m_Point.Name = "Point Series"; m_Point.DataLabelStyle.Visible = false; m_Point.Legend.Mode = SeriesLegendMode.DataPoints; m_Point.Legend.Format = "<label>"; m_Point.PointShape = PointShape.Sphere; m_Point.FillStyle = new NColorFillStyle(Color.Red); m_Point.UseXValues = true; m_Point.UseZValues = true; // limit the axes to show the range [0, 100] m_Chart.Axis(StandardAxis.PrimaryX).View = new NRangeAxisView(new NRange1DD(0, 100)); m_Chart.Axis(StandardAxis.PrimaryY).View = new NRangeAxisView(new NRange1DD(0, 100)); m_Chart.Axis(StandardAxis.Depth).View = new NRangeAxisView(new NRange1DD(0, 100)); // create the point creation planes NAxisConstLine xzPlane = new NAxisConstLine(); xzPlane.Mode = ConstLineMode.Plane; xzPlane.FillStyle = new NColorFillStyle(Color.FromArgb(125, 255, 0, 0)); xzPlane.Value = 0; m_Chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(xzPlane); NAxisConstLine xyPlane = new NAxisConstLine(); xyPlane.Mode = ConstLineMode.Plane; xyPlane.FillStyle = new NColorFillStyle(Color.FromArgb(125, 0, 0, 255)); xyPlane.Value = 0; m_Chart.Axis(StandardAxis.Depth).ConstLines.Add(xyPlane); // init form controls CreatePointAtPlaneComboBox.Items.Add("XZ plane"); CreatePointAtPlaneComboBox.Items.Add("XY plane"); CreatePointAtPlaneComboBox.SelectedIndex = 0; MouseModeComboBox.Items.Add("Create Point"); MouseModeComboBox.Items.Add("Trackball"); MouseModeComboBox.Items.Add("Zoom"); MouseModeComboBox.Items.Add("Offset"); MouseModeComboBox.SelectedIndex = 0; XYPlaneValueNumericUpDown.Value = (decimal)50; XZPlaneValueNumericUpDown.Value = (decimal)50; // register for the mouse down event nChartControl1.MouseDown += new System.Windows.Forms.MouseEventHandler(OnChartMouseDown); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Axis Const Lines"); 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)); // no legend nChartControl1.Legends.Clear(); // setup chart m_Chart = nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; // configure the x scale NLinearScaleConfigurator xScale = new NLinearScaleConfigurator(); xScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = xScale; // configure the y scale NLinearScaleConfigurator yScale = new NLinearScaleConfigurator(); NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); stripStyle.Interlaced = true; yScale.StripStyles.Add(stripStyle); yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = yScale; // Create a point series NPointSeries pnt = (NPointSeries)m_Chart.Series.Add(SeriesType.Point); pnt.InflateMargins = true; pnt.UseXValues = true; pnt.Name = "Series 1"; pnt.DataLabelStyle.Visible = false; // Add some data pnt.Values.Add(31); pnt.Values.Add(67); pnt.Values.Add(12); pnt.Values.Add(84); pnt.Values.Add(90); pnt.XValues.Add(5); pnt.XValues.Add(36); pnt.XValues.Add(51); pnt.XValues.Add(76); pnt.XValues.Add(93); // Add a constline for the left axis NAxisConstLine cl1 = m_Chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(); cl1.StrokeStyle.Color = Color.SteelBlue; cl1.StrokeStyle.Width = new NLength(1.5f); cl1.FillStyle = new NColorFillStyle(new NArgbColor(125, Color.SteelBlue)); cl1.Value = 40; // Add a constline for the bottom axis NAxisConstLine cl2 = m_Chart.Axis(StandardAxis.PrimaryX).ConstLines.Add(); cl2.StrokeStyle.Color = Color.SteelBlue; cl2.StrokeStyle.Width = new NLength(1.5f); cl2.FillStyle = new NColorFillStyle(new NArgbColor(125, Color.SteelBlue)); cl2.Value = 60; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // init form controls LeftValue.Value = (int)cl1.Value; BottomValue.Value = (int)cl2.Value; LeftBeginScroll.Value = 10; LeftEndScroll.Value = 80; BottomBeginScroll.Value = 10; BottomEndScroll.Value = 80; LeftBeginScroll.Enabled = false; LeftEndScroll.Enabled = false; BottomBeginScroll.Enabled = false; BottomEndScroll.Enabled = false; nChartControl1.Refresh(); }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Real Time Polar"); 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 chart NPolarChart chart = new NPolarChart(); nChartControl1.Panels.Add(chart); chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); chart.InnerRadius = new NLength(10, NGraphicsUnit.Point); chart.Width = 70.0f; chart.Height = 70.0f; Color gridColor = Color.Green; NPolarAxis polarAngleAxis = (NPolarAxis)chart.Axis(StandardAxis.PolarAngle); NAngularScaleConfigurator angleScale = (NAngularScaleConfigurator)polarAngleAxis.ScaleConfigurator; angleScale.MajorGridStyle.SetShowAtWall(ChartWallType.Polar, true); angleScale.MajorGridStyle.LineStyle.Color = gridColor; angleScale.OuterMajorTickStyle.LineStyle.Color = gridColor; angleScale.InnerMajorTickStyle.LineStyle.Color = gridColor; angleScale.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(gridColor); angleScale.RulerStyle.BorderStyle.Color = gridColor; angleScale.LabelFitModes = new LabelFitMode[0]; m_RadarRay = new NAxisConstLine[10]; for (int i = 0; i < m_RadarRay.Length; i++) { m_RadarRay[i] = new NAxisConstLine(); m_RadarRay[i].StrokeStyle.Color = Color.FromArgb((byte)((1.0 - ((float)i / m_RadarRay.Length)) * 255), gridColor); polarAngleAxis.ConstLines.Add(m_RadarRay[i]); } // setup polar axis NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)chart.Axis(StandardAxis.Polar).ScaleConfigurator; linearScale.RoundToTickMax = true; linearScale.RoundToTickMin = true; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.AutoLabels = false; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Polar, true); linearScale.MajorGridStyle.LineStyle.Color = gridColor; linearScale.InnerMajorTickStyle.Width = new NLength(0); linearScale.OuterMajorTickStyle.Width = new NLength(0); linearScale.RulerStyle.BorderStyle.Width = new NLength(0); // create three polar point series m_PolarSeries = new NPolarPointSeries(); m_PolarSeries.Name = "Polar"; m_PolarSeries.BorderStyle.Width = new NLength(0); m_PolarSeries.PointShape = PointShape.Bar; m_PolarSeries.Size = new NLength(4, NGraphicsUnit.Point); m_PolarSeries.Angles.ValueFormatter = new NNumericValueFormatter("0.00"); m_PolarSeries.DataLabelStyle.Visible = false; m_PolarSeries.DataLabelStyle.Format = "<value> - <angle_in_degrees>"; // change the storage type to array to increase performance m_PolarSeries.FillStyles.StorageType = IndexedStorageType.Array; Random rand = new Random(); for (int i = 0; i < 360; i++) { m_PolarSeries.Values.Add(rand.Next(100)); m_PolarSeries.Angles.Add(i); m_PolarSeries.FillStyles[i] = new NColorFillStyle(Color.FromArgb(0, Color.Green)); } // add the series to the chart chart.Series.Add(m_PolarSeries); ConfigureStandardLayout(chart, title, null); UseHardwareAccelerationCheckBox.Checked = true; StartTimer(); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Axis Const Lines"); 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)); // no legend nChartControl1.Legends.Clear(); // setup chart m_Chart = nChartControl1.Charts[0]; m_Chart.Enable3D = true; // configure the axes m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator(); m_Chart.Axis(StandardAxis.Depth).ScaleConfigurator = new NLinearScaleConfigurator(); NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); // add interlaced stripe to the Y axis NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); stripStyle.Interlaced = true; linearScale.StripStyles.Add(stripStyle); m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale; // apply predefined lighting and projection m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); // apply 1:1:1 aspect m_Chart.Depth = 70; m_Chart.Width = 70; m_Chart.Height = 70; m_Chart.BoundsMode = BoundsMode.Fit; // Create a point series NPointSeries pnt = (NPointSeries)m_Chart.Series.Add(SeriesType.Point); pnt.InflateMargins = true; pnt.UseXValues = true; pnt.UseZValues = true; pnt.Name = "Series 1"; pnt.DataLabelStyle.Visible = false; // Add some data pnt.Values.Add(31); pnt.Values.Add(67); pnt.Values.Add(12); pnt.Values.Add(84); pnt.Values.Add(90); pnt.XValues.Add(5); pnt.XValues.Add(27); pnt.XValues.Add(49); pnt.XValues.Add(78); pnt.XValues.Add(93); pnt.ZValues.Add(9); pnt.ZValues.Add(57); pnt.ZValues.Add(89); pnt.ZValues.Add(31); pnt.ZValues.Add(49); // Add a constline for the left axis NAxisConstLine constLine = m_Chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(); constLine.StrokeStyle.Color = Color.Blue; constLine.FillStyle = new NColorFillStyle(new NArgbColor(125, Color.SteelBlue)); constLine.Value = 50.0; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // init form controls LeftStyleCombo.SelectedIndex = (int)ConstLineMode.Plane; LeftValue.Value = (int)constLine.Value; BeginXScroll.Value = 10; EndXScroll.Value = 80; BeginXScroll.Enabled = false; EndXScroll.Enabled = false; BeginZScroll.Value = 10; EndZScroll.Value = 80; BeginZScroll.Enabled = false; EndZScroll.Enabled = false; nChartControl1.Refresh(); }
/// <summary> /// Builds the attribute chart /// </summary> /// <param name="attributes">statistics for an attribute chart</param> private void BuildChart(IAttributeChartStats stats) { int nppoints = stats.Statistic.Length; double xstart = stats.TimeStart; double xincrement = stats.TimeSampleInterval; this.nControlChart.Panels.Clear(); // // Set up chart title. // NLabel title = new NLabel(); this.nControlChart.Panels.Add(title); title.Dock = DockStyle.Top; title.Padding = new NMarginsL(5, 8, 5, 4); title.Text = stats.ChartTitle; title.TextStyle.FontStyle = new NFontStyle("Verdana", 12, FontStyle.Bold | FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(Color.FromArgb(68, 90, 108)); // // Set up the chart // NChart chart = new NCartesianChart(); this.nControlChart.Charts.Add(chart); chart.BoundsMode = BoundsMode.Stretch; chart.Dock = DockStyle.Fill; chart.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant2, Color.White, Color.FromArgb(233, 233, 255)); chart.Padding = new NMarginsL( new NLength(6, NRelativeUnit.ParentPercentage), new NLength(6, NRelativeUnit.ParentPercentage), new NLength(6, NRelativeUnit.ParentPercentage), new NLength(6, NRelativeUnit.ParentPercentage)); SetupChartAxes(chart, stats); // // First set up a point series for the outliers so it's on-top in z-order. // NPointSeries outlierPoints = new NPointSeries(); chart.Series.Add(outlierPoints); // Name the series outlierPoints.Name = "Control Limit Violations"; // Tell the series to regard the X values outlierPoints.UseXValues = true; // Points must fit in the chart area outlierPoints.InflateMargins = true; // No data labels outlierPoints.DataLabelStyle.Visible = false; // Set the point appearance properties outlierPoints.FillStyle = new NColorFillStyle(Color.Red); outlierPoints.BorderStyle = new NStrokeStyle(1.0f, Color.Black); outlierPoints.PointShape = PointShape.Cross; outlierPoints.Size = new NLength(6.0f); // Add the statistic for (int i = 0; i < nppoints; i++) { double statValue = stats.Statistic[i]; // Do not display a marker if the point is an outlier if ((statValue > stats.UCL[i]) || (statValue < stats.LCL[i])) { outlierPoints.XValues.Add(xstart + xincrement * i); outlierPoints.Values.Add(statValue); } } // // Set up the statistic line series // NLineSeries line = new NLineSeries(); chart.Series.Add(line); line.Name = "Statistic"; line.UseXValues = true; line.InflateMargins = true; line.DataLabelStyle.Visible = false; line.BorderStyle = new NStrokeStyle(1.6f, Color.Tomato); // Set up the marker style for the regular points line.MarkerStyle.Visible = true; line.MarkerStyle.FillStyle = new NColorFillStyle(Color.SkyBlue); line.MarkerStyle.BorderStyle = new NStrokeStyle(1.0f, Color.Tomato); line.MarkerStyle.PointShape = PointShape.Sphere; line.MarkerStyle.Width = new NLength(4.0f); line.MarkerStyle.Height = new NLength(4.0f); // Add the statistic for (int i = 0; i < nppoints; i++) { line.XValues.Add(xstart + xincrement * i); double statValue = stats.Statistic[i]; // Do not display a marker if the point is an outlier if ((statValue > stats.UCL[i]) || (statValue < stats.LCL[i])) { NMarkerStyle outlierMarker = new NMarkerStyle(); outlierMarker.Visible = false; line.MarkerStyles[i] = outlierMarker; } } line.Values.AddRange(stats.Statistic.DataBlock.Data); // // Set up the UCL and LCL lines // if (stats.ConstControlLimits) { bool showLCL = (stats.LCL.Length > 0); bool showUCL = (stats.UCL.Length > 0); if (showLCL) { double lclValue = stats.LCL[0]; // Set up the LCL const line NAxisConstLine lcl = new NAxisConstLine(); lcl.StrokeStyle = new NStrokeStyle(1.0f, Color.Gray, LinePattern.Dash); lcl.Value = lclValue; lcl.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(lcl); // Show LCL label SetValueLabel(chart, lclValue, "LCL", true); } if (showUCL) { double uclValue = stats.UCL[0]; // Set up the UCL const line NAxisConstLine ucl = new NAxisConstLine(); ucl.Value = uclValue; ucl.StrokeStyle = new NStrokeStyle(1.0f, Color.Gray, LinePattern.Dash); ucl.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(ucl); // Show UCL label SetValueLabel(chart, uclValue, "UCL", true); } // Ensure that the UCL and LCL values are visible NRange1DD clRange = new NRange1DD(); if (showLCL && showUCL) { clRange.Begin = stats.LCL[0]; clRange.End = stats.UCL[0]; } else if (showLCL) { clRange.End = clRange.Begin = stats.LCL[0]; } else if (showUCL) { clRange.End = clRange.Begin = stats.UCL[0]; } clRange.Inflate(0.5); chart.Axis(StandardAxis.PrimaryY).UpdateScale(); chart.Axis(StandardAxis.PrimaryY).SynchronizeScaleWithConfigurator = false; // custom tick inflator NCustomRangeInflator inflator = new NCustomRangeInflator(new NRange1DD[] { clRange }); inflator.InflateBegin = true; inflator.InflateEnd = true; chart.Axis(StandardAxis.PrimaryY).Scale.ContentRangeInflators.Add(inflator); } else { // Set up the UCL line series AddStepLineSeries(chart, "UCL", stats.UCL, xstart, xincrement); // Set up the LCL line series AddStepLineSeries(chart, "LCL", stats.LCL, xstart, xincrement); // Show UCL label if (stats.UCL.Length > 0) { int lastIndexUCL = stats.UCL.Length - 1; SetValueLabel(chart, stats.UCL[lastIndexUCL], "UCL", false); } // Show LCL label if (stats.LCL.Length > 0) { int lastIndexLCL = stats.LCL.Length - 1; SetValueLabel(chart, stats.LCL[lastIndexLCL], "LCL", false); } } // // Set up the center line // NAxisConstLine cl1 = new NAxisConstLine(); cl1.StrokeStyle = new NStrokeStyle(1.0f, Color.DodgerBlue, LinePattern.Dot); cl1.Value = stats.CenterLine; cl1.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(cl1); // Show CL label SetValueLabel(chart, stats.CenterLine, "CL", true); }
private void GenerateDateLabels(int nTotalDays) { // the chart starts with the first monday of june 2003 DateTime dt = new DateTime(2003, 6, 2); TimeSpan daySpan = new TimeSpan(1, 0, 0, 0); NFontStyle labelFont = new NFontStyle("Arial", 9, FontStyle.Bold); NAxis axisX1 = m_Chart.Axis(StandardAxis.PrimaryX); NLinearScaleConfigurator linearScale = axisX1.ScaleConfigurator as NLinearScaleConfigurator; int nCurCategory = 0; m_Chart.ChildPanels.Clear(); for (int i = 0; i < nTotalDays; i++) { // add a custom label for the first work day of the month if ((dt.Day == 1) || ((dt.DayOfWeek == DayOfWeek.Monday) && (dt.Day == 2 || dt.Day == 3))) { NRectangularCallout callout = new NRectangularCallout(); callout.Anchor = new NAxisValueAnchor(axisX1, AxisValueAnchorMode.Clamp, nCurCategory); callout.Orientation = 270; callout.TextStyle.FontStyle = labelFont; callout.Text = dt.ToString("MMM yyyy"); callout.StrokeStyle.Color = Color.DarkSeaGreen; callout.StrokeStyle.Pattern = LinePattern.Dot; callout.ArrowBasePercent = 0; callout.UseAutomaticSize = true; m_Chart.ChildPanels.Add(callout); NAxisConstLine cl = axisX1.ConstLines.Add(); cl.Value = nCurCategory; cl.StrokeStyle.Color = Color.DarkSeaGreen; } if (dt.DayOfWeek == DayOfWeek.Monday) { if ((dt.Day == 1) || (dt.Day == 2) || (dt.Day == 3)) { linearScale.Labels.Add(""); nCurCategory++; } else { linearScale.Labels.Add(dt.Day.ToString()); nCurCategory++; } } else if (dt.DayOfWeek == DayOfWeek.Saturday) { } else if (dt.DayOfWeek == DayOfWeek.Sunday) { } else { nCurCategory++; } dt += daySpan; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WebExamplesUtilities.FillComboWithValues(BeginAngleDropDownList, 0, 360, 15); DockRedAxisCheckBox.Checked = false; PaintReflectionOfRedAxisCheckBox.Checked = false; DockGreenAxisCheckBox.Checked = true; PaintReflectionOfGreenAxisCheckBox.Checked = true; } // nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Polar Value Axis Position"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.ContentAlignment = ContentAlignment.BottomRight; title.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // setup chart NPolarChart polarChart = new NPolarChart(); nChartControl1.Charts.Clear(); nChartControl1.Charts.Add(polarChart); polarChart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); polarChart.DisplayOnLegend = nChartControl1.Legends[0]; polarChart.Location = new NPointL(new NLength(5, NRelativeUnit.ParentPercentage), new NLength(10, NRelativeUnit.ParentPercentage)); polarChart.Size = new NSizeL(new NLength(95, NRelativeUnit.ParentPercentage), new NLength(87, NRelativeUnit.ParentPercentage));; // setup polar axis NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)polarChart.Axis(StandardAxis.Polar).ScaleConfigurator; linearScale.RoundToTickMax = true; linearScale.RoundToTickMin = true; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Polar, true); // setup polar angle axis NAngularScaleConfigurator angularScale = (NAngularScaleConfigurator)polarChart.Axis(StandardAxis.PolarAngle).ScaleConfigurator; angularScale.MajorGridStyle.SetShowAtWall(ChartWallType.Polar, true); angularScale.MinTickDistance = new NLength(50); angularScale.LabelStyle.TextStyle.FontStyle.EmSize = new NLength(8); NScaleStripStyle strip = new NScaleStripStyle(); strip.FillStyle = new NColorFillStyle(Color.FromArgb(64, 192, 192, 192)); strip.Interlaced = true; strip.SetShowAtWall(ChartWallType.Polar, true); angularScale.StripStyles.Add(strip); // add a const line NAxisConstLine line = polarChart.Axis(StandardAxis.Polar).ConstLines.Add(); line.Value = 50; line.StrokeStyle.Color = Color.SlateBlue; line.StrokeStyle.Width = new NLength(1, NGraphicsUnit.Pixel); // create a polar line series NPolarLineSeries series1 = new NPolarLineSeries(); polarChart.Series.Add(series1); series1.Name = "Series 1"; series1.CloseContour = true; series1.DataLabelStyle.Visible = false; series1.MarkerStyle.Visible = false; series1.MarkerStyle.Width = new NLength(1, NRelativeUnit.ParentPercentage); series1.MarkerStyle.Height = new NLength(1, NRelativeUnit.ParentPercentage); Curve1(series1, 50); // create a polar line series NPolarLineSeries series2 = new NPolarLineSeries(); polarChart.Series.Add(series2); series2.Name = "Series 2"; series2.CloseContour = true; series2.DataLabelStyle.Visible = false; series2.MarkerStyle.Visible = false; series2.MarkerStyle.Width = new NLength(1, NRelativeUnit.ParentPercentage); series2.MarkerStyle.Height = new NLength(1, NRelativeUnit.ParentPercentage); Curve2(series2, 100); // add a second value axes NPolarAxis primaryAxis = (NPolarAxis)polarChart.Axis(StandardAxis.Polar); NPolarAxis secondaryAxis = ((NPolarAxisCollection)polarChart.Axes).AddCustomAxis(PolarAxisOrientation.Value); m_CustomAxisId = secondaryAxis.AxisId; NCrossPolarAxisAnchor secondaryAnchor = secondaryAxis.Anchor as NCrossPolarAxisAnchor; secondaryAnchor.Crossings.Clear(); secondaryAnchor.Crossings.Add(new NValueAxisCrossing(primaryAxis, 90)); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // color code the axes and series after the stylesheet is applied ApplyColorToAxis(primaryAxis, Color.Red); ApplyColorToAxis(secondaryAxis, Color.Green); series1.BorderStyle.Color = Color.DarkRed; series1.BorderStyle.Width = new NLength(2); series2.BorderStyle.Color = Color.DarkGreen; series2.BorderStyle.Width = new NLength(2); series2.DisplayOnAxis(StandardAxis.Polar, false); series2.DisplayOnAxis(m_CustomAxisId, true); // apply the polar orientation polarChart.BeginAngle = BeginAngleDropDownList.SelectedIndex * 15; // set angle of axis labels NAxis angleAxis = polarChart.Axis(StandardAxis.PolarAngle); NStandardScaleConfigurator scale = (NStandardScaleConfigurator)angleAxis.ScaleConfigurator; scale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0); // configure the red axis NAxis redAxis = polarChart.Axis(StandardAxis.Polar); NPolarAxisAnchor redAnchor; if (DockRedAxisCheckBox.Checked) { redAnchor = new NDockPolarAxisAnchor(PolarAxisDockZone.Bottom); } else { NCrossPolarAxisAnchor crossAnchor = new NCrossPolarAxisAnchor(); crossAnchor.Crossings.Add(new NValueAxisCrossing(angleAxis, 0)); redAnchor = crossAnchor; } redAnchor.PaintReflection = PaintReflectionOfRedAxisCheckBox.Checked; redAxis.Anchor = redAnchor; // configure the green axis NAxis greenAxis = polarChart.Axis(m_CustomAxisId); NPolarAxisAnchor greenAnchor; if (DockGreenAxisCheckBox.Checked) { NDockPolarAxisAnchor dockAnchor = new NDockPolarAxisAnchor(PolarAxisDockZone.Left); greenAnchor = dockAnchor; } else { NCrossPolarAxisAnchor crossAnchor = new NCrossPolarAxisAnchor(); crossAnchor.Crossings.Add(new NValueAxisCrossing(angleAxis, 90)); greenAnchor = crossAnchor; } greenAnchor.PaintReflection = PaintReflectionOfGreenAxisCheckBox.Checked; greenAxis.Anchor = greenAnchor; }