private void UpdateAxes() { NPolarChart polarChart = nChartControl1.Charts[0] as NPolarChart; if (polarChart == null) { return; } NAxis angleAxis = polarChart.Axis(StandardAxis.PolarAngle); // configure the red axis NAxis redAxis = polarChart.Axis(StandardAxis.Polar); NPolarAxisAnchor redAnchor; RedAxisAngleUpDown.Enabled = !DockRedAxisCheckBox.Checked; if (DockRedAxisCheckBox.Checked) { redAnchor = new NDockPolarAxisAnchor(PolarAxisDockZone.Bottom); RedAxisAngleUpDown.Enabled = false; } else { NCrossPolarAxisAnchor crossAnchor = new NCrossPolarAxisAnchor(); crossAnchor.Crossings.Add(new NValueAxisCrossing(angleAxis, (float)RedAxisAngleUpDown.Value)); redAnchor = crossAnchor; } redAnchor.PaintReflection = RedAxisPaintReflectionCheckBox.Checked; redAnchor.BeginPercent = (float)RedBeginUpDown.Value; redAnchor.EndPercent = (float)RedEndUpDown.Value; redAxis.Anchor = redAnchor; // configure the green axis NAxis greenAxis = polarChart.Axis(m_CustomAxisId); NPolarAxisAnchor greenAnchor; GreenAxisAngleUpDown.Enabled = !DockGreenAxisCheckBox.Checked; if (DockGreenAxisCheckBox.Checked) { NDockPolarAxisAnchor dockAnchor = new NDockPolarAxisAnchor(PolarAxisDockZone.Left); greenAnchor = dockAnchor; } else { NCrossPolarAxisAnchor crossAnchor = new NCrossPolarAxisAnchor(); crossAnchor.Crossings.Add(new NValueAxisCrossing(angleAxis, (float)GreenAxisAngleUpDown.Value)); greenAnchor = crossAnchor; } greenAnchor.PaintReflection = GreenAxisReflectionPaintCheckBox.Checked; greenAnchor.BeginPercent = (float)GreenBeginUpDown.Value; greenAnchor.EndPercent = (float)GreenEndUpDown.Value; greenAxis.Anchor = greenAnchor; nChartControl1.Refresh(); }
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; }