Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreatePolarChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Polar Area";

            // configure chart
            m_Chart = (NPolarChart)chartView.Surface.Charts[0];

            m_Chart.SetPredefinedPolarAxes(ENPredefinedPolarAxes.AngleValue);

            // setup polar axis
            NLinearScale linearScale = (NLinearScale)m_Chart.Axes[ENPolarAxis.PrimaryValue].Scale;

            linearScale.ViewRangeInflateMode  = ENScaleViewRangeInflateMode.MajorTick;
            linearScale.InflateViewRangeBegin = true;
            linearScale.InflateViewRangeEnd   = true;
            linearScale.MajorGridLines.Stroke = new NStroke(1, NColor.Black);

            NScaleStrip strip = new NScaleStrip();

            strip.Fill       = new NColorFill(NColor.FromColor(NColor.Beige, 0.5f));
            strip.Interlaced = true;
            linearScale.Strips.Add(strip);

            // setup polar angle axis
            NAngularScale angularScale = (NAngularScale)m_Chart.Axes[ENPolarAxis.PrimaryAngle].Scale;

            strip            = new NScaleStrip();
            strip.Fill       = new NColorFill(NColor.FromRGBA(192, 192, 192, 125));
            strip.Interlaced = true;
            angularScale.Strips.Add(strip);

            // polar area series 1
            NPolarAreaSeries series1 = new NPolarAreaSeries();

            m_Chart.Series.Add(series1);
            series1.Name           = "Theoretical";
            series1.DataLabelStyle = new NDataLabelStyle(false);
            GenerateData(series1, 100, 15.0);

            // polar area series 2
            NPolarAreaSeries series2 = new NPolarAreaSeries();

            m_Chart.Series.Add(series2);
            series2.Name           = "Experimental";
            series2.DataLabelStyle = new NDataLabelStyle(false);
            GenerateData(series2, 100, 10.0);

            // apply style sheet
            chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, false));

            return(chartView);
        }
Example #2
0
        private void GenerateData(NPolarAreaSeries series, int count, double scale)
        {
            series.DataPoints.Clear();

            double angleStep = 2 * Math.PI / count;
            Random random    = new Random();

            for (int i = 0; i < count; i++)
            {
                double angle = i * angleStep;
                double c1    = 1.0 * Math.Sin(angle * 3);
                double c2    = 0.3 * Math.Sin(angle * 1.5);
                double c3    = 0.05 * Math.Cos(angle * 26);
                double c4    = 0.05 * (0.5 - random.NextDouble());
                double value = scale * (Math.Abs(c1 + c2 + c3) + c4);

                if (value < 0)
                {
                    value = 0;
                }

                series.DataPoints.Add(new NPolarAreaDataPoint(angle * 180 / Math.PI, value));
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WebExamplesUtilities.FillComboWithValues(BeginAngleDropDownList, 0, 360, 15);
                AngleStepDropDownList.Items.Add("15");
                AngleStepDropDownList.Items.Add("30");
                AngleStepDropDownList.Items.Add("45");
                AngleStepDropDownList.Items.Add("90");
                AngleStepDropDownList.SelectedIndex = 0;
            }

            // disable frame
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Polar Area");

            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
            title.TextStyle.FillStyle        = new NColorFillStyle(Color.FromArgb(60, 90, 108));
            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.DisplayOnLegend  = nChartControl1.Legends[0];
            polarChart.DisplayAxesOnTop = true;
            polarChart.Location         = new NPointL(new NLength(5, NRelativeUnit.ParentPercentage), new NLength(5, NRelativeUnit.ParentPercentage));
            polarChart.Size             = new NSizeL(new NLength(90, NRelativeUnit.ParentPercentage), new NLength(90, 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);
            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);

            // polar area series 1
            NPolarAreaSeries series1 = new NPolarAreaSeries();

            polarChart.Series.Add(series1);
            series1.Name = "Theoretical";
            series1.DataLabelStyle.Visible = false;
            GenerateData(series1, 100, 15.0);

            // polar area series 2
            NPolarAreaSeries series2 = new NPolarAreaSeries();

            polarChart.Series.Add(series2);
            series2.Name = "Experimental";
            series2.DataLabelStyle.Visible = false;
            GenerateData(series2, 100, 10.0);

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);

            styleSheet.Apply(nChartControl1.Document);

            // apply settings
            polarChart.BeginAngle = BeginAngleDropDownList.SelectedIndex * 15.0f;

            NAngularScaleConfigurator angleScale = polarChart.Axis(StandardAxis.PolarAngle).ScaleConfigurator as NAngularScaleConfigurator;

            angleScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0);

            switch (AngleStepDropDownList.SelectedIndex)
            {
            case 0:
                angleScale.MajorTickMode = MajorTickMode.CustomStep;
                angleScale.CustomStep    = new NAngle(15, NAngleUnit.Degree);
                break;

            case 1:
                angleScale.MajorTickMode = MajorTickMode.CustomStep;
                angleScale.CustomStep    = new NAngle(30, NAngleUnit.Degree);
                break;

            case 2:
                angleScale.MajorTickMode = MajorTickMode.CustomStep;
                angleScale.CustomStep    = new NAngle(45, NAngleUnit.Degree);
                break;

            case 3:
                angleScale.MajorTickMode = MajorTickMode.CustomStep;
                angleScale.CustomStep    = new NAngle(90, NAngleUnit.Degree);
                break;
            }
        }
Example #4
0
        public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Polar Area");

            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.Charts.Clear();
            nChartControl1.Charts.Add(chart);
            chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal);
            chart.DisplayOnLegend = nChartControl1.Legends[0];
            chart.Width           = 70.0f;
            chart.Height          = 70.0f;
            chart.Depth           = 5;

            // setup polar axis
            NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)chart.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.FromArgb(125, Color.Beige));
            strip.Interlaced = true;
            strip.SetShowAtWall(ChartWallType.Polar, true);
            linearScale.StripStyles.Add(strip);

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

            angularScale.MajorGridStyle.SetShowAtWall(ChartWallType.Polar, true);
            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);

            // polar area series 1
            NPolarAreaSeries series1 = new NPolarAreaSeries();

            chart.Series.Add(series1);
            series1.Name = "Theoretical";
            series1.DataLabelStyle.Visible = false;
            GenerateData(series1, 100, 15.0);

            // polar area series 2
            NPolarAreaSeries series2 = new NPolarAreaSeries();

            chart.Series.Add(series2);
            series2.Name = "Experimental";
            series2.DataLabelStyle.Visible = false;
            GenerateData(series2, 100, 10.0);

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);

            styleSheet.Apply(nChartControl1.Document);

            // init form controls
            AngleStepCombo.Items.Add("15");
            AngleStepCombo.Items.Add("30");
            AngleStepCombo.Items.Add("45");
            AngleStepCombo.Items.Add("90");
            AngleStepCombo.SelectedIndex = 0;
        }