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;
        }
Пример #3
0
        public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Polar Angle 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();

            nChartControl1.Charts.Clear();
            nChartControl1.Charts.Add(polar);
            polar.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal);
            polar.DisplayOnLegend = nChartControl1.Legends[0];
            polar.Depth           = 5;
            polar.Width           = 70.0f;
            polar.Height          = 70.0f;

            // 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);

            // 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.Polar, true);

            NScaleStripStyle strip = new NScaleStripStyle();

            strip.FillStyle  = new NColorFillStyle(Color.Beige);
            strip.Interlaced = true;
            strip.SetShowAtWall(ChartWallType.Polar, true);
            linearScale.StripStyles.Add(strip);

            // setup polar angle axis
            NAngularScaleConfigurator degreeScale = (NAngularScaleConfigurator)polar.Axis(StandardAxis.PolarAngle).ScaleConfigurator;

            degreeScale.MajorGridStyle.SetShowAtWall(ChartWallType.Polar, true);
            degreeScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0);
            degreeScale.SetPredefinedScaleStyle(PredefinedScaleStyle.Scientific);

            // add a second value axes
            NPolarAxis valueAxis = (NPolarAxis)polar.Axis(StandardAxis.Polar);

            NPolarAxis primaryAxis   = (NPolarAxis)polar.Axis(StandardAxis.PolarAngle);
            NPolarAxis secondaryAxis = ((NPolarAxisCollection)polar.Axes).AddCustomAxis(PolarAxisOrientation.Angle);

            NAngularScaleConfigurator gradScale = new NAngularScaleConfigurator();

            gradScale.AngleUnit        = NAngleUnit.Grad;
            gradScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0);
            gradScale.SetPredefinedScaleStyle(PredefinedScaleStyle.Scientific);
            secondaryAxis.ScaleConfigurator = gradScale;
            m_CustomAxisId = secondaryAxis.AxisId;

            NCrossPolarAxisAnchor secondaryAnchor = new NCrossPolarAxisAnchor(PolarAxisOrientation.Angle);

            secondaryAnchor.Crossings.Add(new NValueAxisCrossing(valueAxis, 10));

            // 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.Width = new NLength(2);
            series2.BorderStyle.Width = new NLength(2);

            DockDegreeAxisCheckBox.Checked   = true;
            DockGradAxisCheckBox.Checked     = false;
            DegreeAxisCrossValueUpDown.Value = 70;
            GradAxisCrossValueUpDown.Value   = 50;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            if (!IsPostBack)
            {
                WebExamplesUtilities.FillComboWithValues(BeginAngleDropDownList, 0, 360, 15);
                DockDegreeAxisCheckBox.Checked = true;
                DockGradAxisCheckBox.Checked   = false;
            }

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Polar Angle 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(90, NRelativeUnit.ParentPercentage), new NLength(87, NRelativeUnit.ParentPercentage));

            // 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);

            // 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);

            NScaleStripStyle strip = new NScaleStripStyle();

            strip.FillStyle  = new NColorFillStyle(Color.Beige);
            strip.Interlaced = true;
            strip.SetShowAtWall(ChartWallType.Polar, true);
            linearScale.StripStyles.Add(strip);

            // setup polar angle axis
            NAngularScaleConfigurator degreeScale = (NAngularScaleConfigurator)polarChart.Axis(StandardAxis.PolarAngle).ScaleConfigurator;

            degreeScale.MajorGridStyle.SetShowAtWall(ChartWallType.Polar, true);
            degreeScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0);
            degreeScale.SetPredefinedScaleStyle(PredefinedScaleStyle.Scientific);

            // add a second value axes
            NPolarAxis valueAxis = (NPolarAxis)polarChart.Axis(StandardAxis.Polar);

            NPolarAxis degreeAxis = (NPolarAxis)polarChart.Axis(StandardAxis.PolarAngle);
            NPolarAxis gradAxis   = ((NPolarAxisCollection)polarChart.Axes).AddCustomAxis(PolarAxisOrientation.Angle);

            NAngularScaleConfigurator gradScale = new NAngularScaleConfigurator();

            gradScale.AngleUnit        = NAngleUnit.Grad;
            gradScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0);
            gradScale.SetPredefinedScaleStyle(PredefinedScaleStyle.Scientific);
            gradAxis.ScaleConfigurator = gradScale;
            m_CustomAxisId             = gradAxis.AxisId;

            NCrossPolarAxisAnchor secondaryAnchor = new NCrossPolarAxisAnchor(PolarAxisOrientation.Angle);

            secondaryAnchor.Crossings.Add(new NValueAxisCrossing(valueAxis, 10));

            // 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(degreeAxis, Color.Red);
            ApplyColorToAxis(gradAxis, Color.Green);

            series1.BorderStyle.Width = new NLength(2);
            series2.BorderStyle.Width = new NLength(2);

            // set the begin angle
            polarChart.BeginAngle = BeginAngleDropDownList.SelectedIndex * 15;

            // configure axis docking / crossing
            if (DockDegreeAxisCheckBox.Checked)
            {
                degreeAxis.Anchor = new NDockPolarAxisAnchor();
            }
            else
            {
                degreeAxis.Anchor = new NCrossPolarAxisAnchor(PolarAxisOrientation.Angle, new NValueAxisCrossing(valueAxis, 0.0));
            }

            if (DockGradAxisCheckBox.Checked)
            {
                gradAxis.Anchor = new NDockPolarAxisAnchor();
            }
            else
            {
                gradAxis.Anchor = new NCrossPolarAxisAnchor(PolarAxisOrientation.Angle, new NValueAxisCrossing(valueAxis, 100.0));
            }
        }