Пример #1
0
        private void ShowLowerXErrorCheckBox_Checked(object sender, System.Windows.RoutedEventArgs e)
        {
            NErrorBarSeries series = (NErrorBarSeries)m_Chart.Series[0];

            series.ShowLowerErrorX = (bool)ShowLowerXErrorCheckBox.IsChecked;
            nChartControl1.Refresh();
        }
Пример #2
0
        private void GenerateData(NErrorBarSeries series)
        {
            series.ClearDataPoints();

            NVector3DF v       = new NVector3DF();
            Random     randrom = new Random();

            for (int i = 0; i < 10; i++)
            {
                v.X = (float)(0.5 - randrom.NextDouble());
                v.Y = (float)(0.5 - randrom.NextDouble());
                v.Z = (float)(0.5 - randrom.NextDouble());

                v.Normalize(40.0f);

                series.Values.Add(v.X);
                series.XValues.Add(v.Y);
                series.ZValues.Add(v.Z);

                series.LowerErrorsX.Add(3 + 5 * randrom.NextDouble());
                series.UpperErrorsX.Add(3 + 5 * randrom.NextDouble());
                series.LowerErrorsY.Add(3 + 5 * randrom.NextDouble());
                series.UpperErrorsY.Add(3 + 5 * randrom.NextDouble());
                series.LowerErrorsZ.Add(3 + 5 * randrom.NextDouble());
                series.UpperErrorsZ.Add(3 + 5 * randrom.NextDouble());
            }
        }
Пример #3
0
        private void GenerateDataButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            NErrorBarSeries series = (NErrorBarSeries)m_Chart.Series[0];

            GenerateData(series);
            nChartControl1.Refresh();
        }
Пример #4
0
        private void ZErrorSizeScroll_ValueChanged(object sender, Nevron.UI.WinForm.Controls.ScrollBarEventArgs e)
        {
            NErrorBarSeries series = (NErrorBarSeries)m_Chart.Series[0];

            series.SizeZ = new NLength(ZErrorSizeScroll.Value / 20.0f, NRelativeUnit.ParentPercentage);
            nChartControl1.Refresh();
        }
Пример #5
0
        private void ShowLowerErrorZCheck_CheckedChanged(object sender, System.EventArgs e)
        {
            NErrorBarSeries series = (NErrorBarSeries)m_Chart.Series[0];

            series.ShowLowerErrorZ = ShowLowerErrorZCheck.Checked;
            nChartControl1.Refresh();
        }
Пример #6
0
        private void XErrorWhiskerSizeScrollBar_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs <double> e)
        {
            NErrorBarSeries series = (NErrorBarSeries)m_Chart.Series[0];

            series.SizeX = new NLength((float)XErrorWhiskerSizeScrollBar.Value * 5.0f, NRelativeUnit.ParentPercentage);

            nChartControl1.Refresh();
        }
Пример #7
0
        public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Error Bar Chart");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue);

            // remove the legend
            nChartControl1.Legends.Clear();

            // setup chart
            m_Chart = nChartControl1.Charts[0];
            m_Chart.Axis(StandardAxis.Depth).Visible = false;

            NLinearScaleConfigurator linearScale = m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;

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

            NErrorBarSeries series = (NErrorBarSeries)m_Chart.Series.Add(SeriesType.ErrorBar);

            series.DataLabelStyle.Visible  = false;
            series.BorderStyle             = new NStrokeStyle(GreyBlue);
            series.MarkerStyle.Visible     = true;
            series.MarkerStyle.AutoDepth   = false;
            series.MarkerStyle.FillStyle   = new NColorFillStyle(DarkOrange);
            series.MarkerStyle.BorderStyle = new NStrokeStyle(GreyBlue);
            series.MarkerStyle.Width       = new NLength(1.2f, NRelativeUnit.ParentPercentage);
            series.MarkerStyle.Height      = new NLength(1.2f, NRelativeUnit.ParentPercentage);
            series.MarkerStyle.Depth       = new NLength(1.2f, NRelativeUnit.ParentPercentage);

            GenerateData(series);

            // apply layout
            ConfigureStandardLayout(m_Chart, title, null);

            // init form controls
            YErrorSizeScroll.Value      = 40;
            ShowLowerErrorCheck.Checked = true;
            ShowUpperErrorCheck.Checked = true;
            RoundToTickCheck.Checked    = true;
            InflateMarginsCheck.Checked = true;
        }
Пример #8
0
        private void GenerateData(NErrorBarSeries series)
        {
            series.ClearDataPoints();

            double y = 20.0;
            double p = Random.NextDouble() * 10;

            for (int i = 0; i < 15; i++)
            {
                y = Math.Sin(p + i / 6.0) * 8 + Random.NextDouble();

                series.Values.Add(y);
                series.LowerErrorsY.Add(1 + Random.NextDouble());
                series.UpperErrorsY.Add(1 + Random.NextDouble());
            }
        }
Пример #9
0
        void GenerateData(NErrorBarSeries series)
        {
            series.ClearDataPoints();

            double y;
            double x = 50.0;

            for (int i = 0; i < 15; i++)
            {
                y  = 20 + Random.NextDouble() * 30;
                x += 2.0 + Random.NextDouble() * 2;

                series.Values.Add(y);
                series.LowerErrorsY.Add(1 + Random.NextDouble());
                series.UpperErrorsY.Add(1 + Random.NextDouble());

                series.XValues.Add(x);
                series.LowerErrorsX.Add(1 + Random.NextDouble());
                series.UpperErrorsX.Add(1 + Random.NextDouble());
            }
        }
Пример #10
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Standard Error Bar";

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

            chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);

            // add interlace stripe
            NScaleStrip stripStyle = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);

            stripStyle.Interlaced = true;
            chart.Axes[ENCartesianAxis.PrimaryY].Scale.Strips.Add(stripStyle);
            chart.Axes[ENCartesianAxis.PrimaryY].Scale.MajorGridLines.Visible = true;

            chart.Axes[ENCartesianAxis.PrimaryY].Scale.ViewRangeInflateMode  = ENScaleViewRangeInflateMode.MajorTick;
            chart.Axes[ENCartesianAxis.PrimaryY].Scale.InflateViewRangeBegin = true;
            chart.Axes[ENCartesianAxis.PrimaryY].Scale.InflateViewRangeEnd   = true;
            chart.Axes[ENCartesianAxis.PrimaryX].Scale.ViewRangeInflateMode  = ENScaleViewRangeInflateMode.MajorTick;
            chart.Axes[ENCartesianAxis.PrimaryX].Scale.InflateViewRangeBegin = true;
            chart.Axes[ENCartesianAxis.PrimaryX].Scale.InflateViewRangeEnd   = true;

            // add an error bar series
            m_ErrorBar = new NErrorBarSeries();
            chart.Series.Add(m_ErrorBar);
            m_ErrorBar.DataLabelStyle = new NDataLabelStyle(false);
            m_ErrorBar.Stroke         = new NStroke(NColor.Black);
            m_ErrorBar.UseXValues     = true;

            GenerateData();

            chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, false));

            return(chartView);
        }
Пример #11
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("XYZ Error Bar");

            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;

            // no legend
            nChartControl1.Legends.Clear();

            // setup chart
            NChart chart = nChartControl1.Charts[0];

            chart.Enable3D = true;
            chart.Depth    = 55.0f;
            chart.Width    = 55.0f;
            chart.Height   = 55.0f;
            chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted);
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft);

            // setup Y axis
            NLinearScaleConfigurator linearScaleConfigurator = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;

            linearScaleConfigurator.RoundToTickMin = RoundToTickCheck.Checked;
            linearScaleConfigurator.RoundToTickMax = RoundToTickCheck.Checked;
            linearScaleConfigurator.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
            linearScaleConfigurator.LabelStyle.TextStyle.FontStyle   = new NFontStyle("Arial", 8);

            // add interlaced 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);
            linearScaleConfigurator.StripStyles.Add(stripStyle);

            // setup X axis
            linearScaleConfigurator = new NLinearScaleConfigurator();
            linearScaleConfigurator.RoundToTickMin = RoundToTickCheck.Checked;
            linearScaleConfigurator.RoundToTickMax = RoundToTickCheck.Checked;
            linearScaleConfigurator.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
            linearScaleConfigurator.LabelStyle.TextStyle.FontStyle   = new NFontStyle("Arial", 8);
            linearScaleConfigurator.MajorGridStyle.ShowAtWalls       = new ChartWallType[] { ChartWallType.Back, ChartWallType.Floor };
            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator      = linearScaleConfigurator;

            // setup Z axis
            linearScaleConfigurator = new NLinearScaleConfigurator();
            linearScaleConfigurator.RoundToTickMin = RoundToTickCheck.Checked;
            linearScaleConfigurator.RoundToTickMax = RoundToTickCheck.Checked;
            linearScaleConfigurator.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
            linearScaleConfigurator.LabelStyle.TextStyle.FontStyle   = new NFontStyle("Arial", 8);
            linearScaleConfigurator.MajorGridStyle.ShowAtWalls       = new ChartWallType[] { ChartWallType.Left, ChartWallType.Floor };
            chart.Axis(StandardAxis.Depth).ScaleConfigurator         = linearScaleConfigurator;

            // add an error bar series
            NErrorBarSeries series = (NErrorBarSeries)chart.Series.Add(SeriesType.ErrorBar);

            series.DataLabelStyle.Visible  = false;
            series.BorderStyle             = new NStrokeStyle(GreyBlue);
            series.MarkerStyle.Visible     = true;
            series.MarkerStyle.AutoDepth   = false;
            series.MarkerStyle.FillStyle   = new NColorFillStyle(DarkOrange);
            series.MarkerStyle.BorderStyle = new NStrokeStyle(GreyBlue);
            series.MarkerStyle.Width       = new NLength(1.5f, NRelativeUnit.ParentPercentage);
            series.MarkerStyle.Height      = new NLength(1.5f, NRelativeUnit.ParentPercentage);
            series.MarkerStyle.Depth       = new NLength(1.5f, NRelativeUnit.ParentPercentage);
            series.UseXValues = true;
            series.UseZValues = true;

            GenerateData(series);

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, chart, title, null);

            if (!IsPostBack)
            {
                ShowUpperXErrorCheck.Checked = series.ShowUpperErrorX;
                ShowLowerXErrorCheck.Checked = series.ShowLowerErrorX;
                ShowUpperYErrorCheck.Checked = series.ShowUpperErrorY;
                ShowLowerYErrorCheck.Checked = series.ShowLowerErrorY;
                ShowUpperZErrorCheck.Checked = series.ShowUpperErrorZ;
                ShowLowerZErrorCheck.Checked = series.ShowLowerErrorZ;
                InflateMarginsCheck.Checked  = series.InflateMargins;
            }
            else
            {
                series.ShowUpperErrorX = ShowUpperXErrorCheck.Checked;
                series.ShowLowerErrorX = ShowLowerXErrorCheck.Checked;
                series.ShowUpperErrorY = ShowUpperYErrorCheck.Checked;
                series.ShowLowerErrorY = ShowLowerYErrorCheck.Checked;
                series.ShowUpperErrorZ = ShowUpperZErrorCheck.Checked;
                series.ShowLowerErrorZ = ShowLowerZErrorCheck.Checked;
                series.InflateMargins  = InflateMarginsCheck.Checked;
            }
        }
Пример #12
0
        /// <summary>
        /// Called to initialize the example
        /// </summary>
        /// <param name="chartControl"></param>
        public override void Create()
        {
            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("XY Error Bar");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic);
            title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue);

            // remove the legend
            nChartControl1.Legends.Clear();

            m_Chart = nChartControl1.Charts[0];

            // setup axes
            NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator();

            linearScale.MajorGridStyle.ShowAtWalls                = new ChartWallType[] { ChartWallType.Back, ChartWallType.Floor };
            linearScale.MajorGridStyle.LineStyle.Pattern          = LinePattern.Dot;
            m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale;

            linearScale = (NLinearScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
            linearScale.MajorGridStyle.ShowAtWalls       = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left };
            linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;

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

            m_Chart.Axis(StandardAxis.Depth).Visible = false;

            // add an error bar series
            NErrorBarSeries series = (NErrorBarSeries)m_Chart.Series.Add(SeriesType.ErrorBar);

            series.DataLabelStyle.Visible  = false;
            series.BorderStyle             = new NStrokeStyle(GreyBlue);
            series.MarkerStyle.Visible     = true;
            series.MarkerStyle.PointShape  = PointShape.Ellipse;
            series.MarkerStyle.AutoDepth   = false;
            series.MarkerStyle.FillStyle   = new NColorFillStyle(DarkOrange);
            series.MarkerStyle.BorderStyle = new NStrokeStyle(GreyBlue);
            series.MarkerStyle.Width       = new NLength(1.2f, NRelativeUnit.ParentPercentage);
            series.MarkerStyle.Height      = new NLength(1.2f, NRelativeUnit.ParentPercentage);
            series.MarkerStyle.Depth       = new NLength(1.2f, NRelativeUnit.ParentPercentage);
            series.ShowLowerErrorX         = true;
            series.ShowUpperErrorX         = true;
            series.UseXValues = true;

            GenerateData(series);

            // apply layout
            ConfigureStandardLayout(m_Chart, title, null);

            // init form controls
            YErrorWhiskerSizeScrollBar.Value  = series.SizeY.Value / 5.0f;
            ShowLowerYErrorCheckBox.IsChecked = series.ShowLowerErrorY;
            ShowUpperYErrorCheckBox.IsChecked = series.ShowUpperErrorY;

            XErrorWhiskerSizeScrollBar.Value  = series.SizeX.Value / 5.0f;
            ShowLowerXErrorCheckBox.IsChecked = series.ShowLowerErrorX;
            ShowUpperXErrorCheckBox.IsChecked = series.ShowUpperErrorX;


            LeftAxisRoundToTickCheckBox.IsChecked = true;
            InflateMarginsCheckBox.IsChecked      = true;
        }
Пример #13
0
        private void ChartTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            NChart chart = nChartControl1.Charts[0];

            chart.Series.Clear();
            const int numDataPoints = 50;

            switch (ChartTypeComboBox.SelectedIndex)
            {
            case 0:                     // Area
            {
                NAreaSeries area = new NAreaSeries();
                area.DataLabelStyle.Visible = false;
                area.VerticalAxisRangeMode  = AxisRangeMode.ViewRange;

                GenerateData(area, 100.0, numDataPoints, new NRange1DD(60, 140));
                chart.Series.Add(area);
                chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NValueTimelineScaleConfigurator();
            }
            break;

            case 1:                     // Bar
            {
                NBarSeries bar = new NBarSeries();
                bar.DataLabelStyle.Visible = false;
                bar.VerticalAxisRangeMode  = AxisRangeMode.ViewRange;

                GenerateData(bar, 100.0, numDataPoints, new NRange1DD(60, 140));
                chart.Series.Add(bar);
                chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NValueTimelineScaleConfigurator();
            }
            break;

            case 2:                     // Box And Whiskers
            {
                NBoxAndWhiskersSeries boxAndWhiskers = new NBoxAndWhiskersSeries();
                boxAndWhiskers.VerticalAxisRangeMode = AxisRangeMode.ViewRange;

                for (int i = 0; i < 40; i++)
                {
                    double boxLower      = 1000 + Random.NextDouble() * 200;
                    double boxUpper      = boxLower + 200 + Random.NextDouble() * 200;
                    double whiskersLower = boxLower - (20 + Random.NextDouble() * 300);
                    double whiskersUpper = boxUpper + (20 + Random.NextDouble() * 300);

                    double IQR     = (boxUpper - boxLower);
                    double median  = boxLower + IQR * 0.25 + Random.NextDouble() * IQR * 0.5;
                    double average = boxLower + IQR * 0.25 + Random.NextDouble() * IQR * 0.5;

                    boxAndWhiskers.UpperBoxValues.Add(boxUpper);
                    boxAndWhiskers.LowerBoxValues.Add(boxLower);
                    boxAndWhiskers.UpperWhiskerValues.Add(whiskersUpper);
                    boxAndWhiskers.LowerWhiskerValues.Add(whiskersLower);
                    boxAndWhiskers.MedianValues.Add(median);
                    boxAndWhiskers.AverageValues.Add(average);

                    int outliersCount = Random.Next(5);

                    NDoubleList outliers = new NDoubleList();

                    for (int k = 0; k < outliersCount; k++)
                    {
                        double dOutlier = 0;

                        if (Random.NextDouble() > 0.5)
                        {
                            dOutlier = boxUpper + IQR * 1.5 + Random.NextDouble() * 100;
                        }
                        else
                        {
                            dOutlier = boxLower - IQR * 1.5 - Random.NextDouble() * 100;
                        }

                        outliers.Add(dOutlier);
                    }

                    boxAndWhiskers.OutlierValues.Add(outliers);
                }

                chart.Series.Add(boxAndWhiskers);
                chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator();
            }
            break;

            case 3:                     // Error Bar
            {
                NErrorBarSeries errorBar = new NErrorBarSeries();
                errorBar.VerticalAxisRangeMode = AxisRangeMode.ViewRange;

                double y;
                double x = 50.0;

                for (int i = 0; i < 50; i++)
                {
                    y  = 20 + Random.NextDouble() * 30;
                    x += 2.0 + Random.NextDouble() * 2;

                    errorBar.Values.Add(y);
                    errorBar.LowerErrorsY.Add(1 + Random.NextDouble());
                    errorBar.UpperErrorsY.Add(1 + Random.NextDouble());

                    errorBar.XValues.Add(x);
                    errorBar.LowerErrorsX.Add(1 + Random.NextDouble());
                    errorBar.UpperErrorsX.Add(1 + Random.NextDouble());
                }

                chart.Series.Add(errorBar);
                chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator();
            }
            break;

            case 4:                     // "Float Bar");
            {
                NFloatBarSeries floatBar = new NFloatBarSeries();

                floatBar.VerticalAxisRangeMode = AxisRangeMode.ViewRange;

                // generate Y values
                for (int i = 0; i < 100; i++)
                {
                    double dBeginValue = Random.NextDouble() * 5;
                    double dEndValue   = dBeginValue + 2 + Random.NextDouble();
                    floatBar.Values.Add(dBeginValue);
                    floatBar.EndValues.Add(dEndValue);
                }

                // generate X values
                DateTime dt = new DateTime(2007, 5, 24, 11, 0, 0);

                for (int i = 0; i < 100; i++)
                {
                    dt = dt.AddHours(12 + Random.NextDouble() * 60);

                    floatBar.XValues.Add(dt);
                }

                chart.Series.Add(floatBar);
                chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NValueTimelineScaleConfigurator();
            }
            break;

            case 5:                     // Line
            {
                NLineSeries line = new NLineSeries();
                line.DataLabelStyle.Visible = false;
                line.VerticalAxisRangeMode  = AxisRangeMode.ViewRange;

                GenerateData(line, 100.0, numDataPoints, new NRange1DD(60, 140));
                chart.Series.Add(line);
                chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NValueTimelineScaleConfigurator();
            }
            break;

            case 6:                     // Point
            {
                NPointSeries point = new NPointSeries();
                point.DataLabelStyle.Visible = false;
                point.VerticalAxisRangeMode  = AxisRangeMode.ViewRange;
                point.Size = new NLength(5);

                GenerateData(point, 100.0, numDataPoints, new NRange1DD(60, 140));
                chart.Series.Add(point);
                chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator();
            }
            break;

            case 7:                     // Stock
            {
                // setup stock series
                NStockSeries stock = (NStockSeries)chart.Series.Add(SeriesType.Stock);
                stock.DataLabelStyle.Visible   = false;
                stock.UpFillStyle              = new NColorFillStyle(Color.White);
                stock.UpStrokeStyle.Color      = Color.Black;
                stock.DownFillStyle            = new NColorFillStyle(Color.Crimson);
                stock.DownStrokeStyle.Color    = Color.Crimson;
                stock.HighLowStrokeStyle.Color = Color.Black;
                stock.CandleWidth              = new NLength(1.2f, NRelativeUnit.ParentPercentage);
                stock.UseXValues            = true;
                stock.InflateMargins        = true;
                stock.VerticalAxisRangeMode = AxisRangeMode.ViewRange;

                // add some stock items
                GenerateOHLCData(stock, 100.0, numDataPoints, new NRange1DD(60, 140));
                FillStockDates(stock, numDataPoints);
                chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NValueTimelineScaleConfigurator();
            }
            break;
            }

            nChartControl1.Refresh();
        }
Пример #14
0
        /// <summary>
        /// Called to initialize the example
        /// </summary>
        /// <param name="chartControl"></param>
        public override void Create()
        {
            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("XYZ Error Bar");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic);
            title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue);

            // remove the legend
            nChartControl1.Legends.Clear();

            // setup chart
            m_Chart          = nChartControl1.Charts[0];
            m_Chart.Enable3D = true;
            m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted);
            m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft);
            m_Chart.BoundsMode       = BoundsMode.Fit;
            m_Chart.ContentAlignment = ContentAlignment.BottomRight;
            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;

            // setup the x axis
            NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator();

            m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale;
            linearScale.MajorGridStyle.LineStyle.Pattern          = LinePattern.Dot;
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);

            // setup the y axis
            linearScale = new NLinearScaleConfigurator();
            m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale;
            linearScale.MajorGridStyle.LineStyle.Pattern          = LinePattern.Dot;
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true);
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);

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

            // setup the z axis
            linearScale = new NLinearScaleConfigurator();
            m_Chart.Axis(StandardAxis.Depth).ScaleConfigurator = linearScale;

            linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true);

            // add an error bar series
            NErrorBarSeries series = (NErrorBarSeries)m_Chart.Series.Add(SeriesType.ErrorBar);

            series.DataLabelStyle.Visible  = false;
            series.BorderStyle             = new NStrokeStyle(GreyBlue);
            series.MarkerStyle.Visible     = true;
            series.MarkerStyle.AutoDepth   = false;
            series.MarkerStyle.FillStyle   = new NColorFillStyle(DarkOrange);
            series.MarkerStyle.BorderStyle = new NStrokeStyle(GreyBlue);
            series.MarkerStyle.Width       = new NLength(1.2f, NRelativeUnit.ParentPercentage);
            series.MarkerStyle.Height      = new NLength(1.2f, NRelativeUnit.ParentPercentage);
            series.MarkerStyle.Depth       = new NLength(1.2f, NRelativeUnit.ParentPercentage);
            series.UseXValues      = true;
            series.UseZValues      = true;
            series.ShowLowerErrorX = true;
            series.ShowLowerErrorY = true;
            series.ShowLowerErrorZ = true;
            series.ShowUpperErrorX = true;
            series.ShowUpperErrorY = true;
            series.ShowUpperErrorZ = true;

            GenerateData(series);

            nChartControl1.Controller.Tools.Add(new NPanelSelectorTool());
            nChartControl1.Controller.Tools.Add(new NTrackballTool());

            // apply layout
            ConfigureStandardLayout(m_Chart, title, null);
        }
        /// <summary>
        /// Demonstrates linear reression in two dimensions.
        /// </summary>
        void LinearRegression()
        {
            // Set up example description
            nRichDescription.Text = "A linear regression model is computed from the sample data containing random normal noise. \n\nA point is then predicted from the model with a 95% confidence interval - meaning the predicted point is expected to lie within the confidence interval 95% of the time.";

            // First read in the independent (or predictor) values. This is a matrix
            // with one column and a row for each amounts measurement.
            DoubleVector raw_data = new DoubleVector(25, 0, 1);
            DoubleMatrix measurements = new DoubleMatrix(raw_data);

            // Next, read in the responses
            // Build a linear polynomial and add noise for interest
            RandomNumberGenerator rand = new RandGenNormal(0, noiselevel_);
            Polynomial poly = new Polynomial(new DoubleVector("0, 1"));
            DoubleVector responses = poly.Evaluate(raw_data) + new DoubleVector(raw_data.Length, rand); ;

            // Construct a linear regression. If we want our regression to calculate a
            // y-intercept we must send in true for the "addIntercept" parameter (the
            // third paramameter in the constructor).
            LinearRegression regression = new LinearRegression(measurements, responses, true);
            DoubleVector residues = regression.Residuals;

            // Use the linear regression class to make a prediction according to the model
            DoubleVector xvalues = new DoubleVector("30"); // Use the model to predict the observation at 30.
            Interval pi = regression.PredictionInterval(xvalues, 0.95);

            // Build some data points along the regression line for display
            DoubleMatrix abcissae = new DoubleMatrix(new DoubleVector(raw_data));
            DoubleVector predicted_ys = regression.PredictedObservations(abcissae);

            // Build the chart
            SetupChartLayout("Linear Regression");

            NChart chart = nChartControl1.Charts[0];

            SetupChartAxes(chart);

            // Set up the line series
            NLineSeries line = new NLineSeries();
            chart.Series.Add(line);

            // tell the series to regard the X values
            line.UseXValues = true;

            // no data labels
            line.DataLabelStyle.Visible = false;

            // Set the line color
            line.BorderStyle = new NStrokeStyle(2.0f, Color.Tomato);

            // name data set
            line.Name = "Linear Regression";

            // Add the the Linear Regression line data to the line series
            line.XValues.AddRange(abcissae.DataBlock.Data);
            line.Values.AddRange(predicted_ys.DataBlock.Data);

            // Draw the raw data points
            NPointSeries point = new NPointSeries();
            chart.Series.Add(point);

            point.UseXValues = true;
            point.DataLabelStyle.Visible = false;

            // Set the point appearance properties
            point.FillStyle = new NColorFillStyle(Color.SkyBlue);
            point.BorderStyle = new NStrokeStyle(1.0f,Color.DarkGray);
            point.PointShape = PointShape.Cross;
            point.Size = new NLength(6.0f);

            // Points must fit in the chart area
            point.InflateMargins = true;

            // Name point set
            point.Name = "Observations";

            // set the point data
            point.Values.AddRange(responses.DataBlock.Data);
            point.XValues.AddRange(measurements.DataBlock.Data);

            double m = (pi.Min + pi.Max) / 2.0;

            // Display the predicted value with an error bar series
            NErrorBarSeries predicted_points = new NErrorBarSeries();
            chart.Series.Add(predicted_points);
            predicted_points.Name = "Predicted Point";
            predicted_points.UseXValues = true;
            predicted_points.InflateMargins = true;
            predicted_points.FillStyle = new NColorFillStyle(Color.Crimson);
            predicted_points.BorderStyle = new NStrokeStyle(1.0f, Color.DarkGray);
            predicted_points.DataLabelStyle.Visible = false;
            predicted_points.MarkerStyle.Visible = true;
            predicted_points.MarkerStyle.FillStyle = new NColorFillStyle(Color.Crimson);
            predicted_points.MarkerStyle.BorderStyle = new NStrokeStyle(1.0f, Color.DarkGray);
            predicted_points.MarkerStyle.PointShape = PointShape.Bar;
            predicted_points.MarkerStyle.Width = new NLength(5);
            predicted_points.MarkerStyle.Height = new NLength(5);
            predicted_points.SizeY = new NLength(5);

            // Fill the data for the predicted point
            predicted_points.XValues.AddRange(xvalues.DataBlock.Data);
            predicted_points.Values.Add(m);
            predicted_points.UpperErrorsY.Add(pi.Max - m);
            predicted_points.LowerErrorsY.Add(m - pi.Min);

            // Create a label to display the predicted value
            NLabel label = new NLabel();
            label.BoundsMode = BoundsMode.None;
            label.ContentAlignment = ContentAlignment.BottomLeft;
            label.Location = new NPointL(
                new NLength(87, NRelativeUnit.ParentPercentage),
                new NLength(3, NRelativeUnit.ParentPercentage));

            label.TextStyle.TextFormat = TextFormat.XML;
            label.TextStyle.FontStyle = new NFontStyle("Arial", 9);
            label.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Right;
            label.TextStyle.BackplaneStyle.Visible = true;
            label.TextStyle.BackplaneStyle.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(130, 255, 255, 255), Color.FromArgb(130, 233, 233, 255));
            label.TextStyle.BackplaneStyle.Shape = BackplaneShape.SmoothEdgeRectangle;
            label.TextStyle.BackplaneStyle.StandardFrameStyle.InnerBorderColor = Color.White;
            label.Text = "<font color = 'crimson'>" + m.ToString("0.###") + "</font> - predicted value with 95% confidence interval";

            chart.ChildPanels.Add(label);

            nChartControl1.Refresh();
        }
Пример #16
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Error Bar");

            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;

            // no legend
            nChartControl1.Legends.Clear();

            // setup chart
            NChart chart = nChartControl1.Charts[0];

            chart.BoundsMode = BoundsMode.Stretch;

            // add interlaced stripe
            NLinearScaleConfigurator scaleY     = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
            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);
            scaleY.StripStyles.Add(stripStyle);

            NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;

            scaleX.MajorTickMode = MajorTickMode.AutoMaxCount;

            // setup error bar series
            NErrorBarSeries series = (NErrorBarSeries)chart.Series.Add(SeriesType.ErrorBar);

            series.DataLabelStyle.Visible  = false;
            series.BorderStyle             = new NStrokeStyle(GreyBlue);
            series.MarkerStyle.Visible     = true;
            series.MarkerStyle.AutoDepth   = false;
            series.MarkerStyle.FillStyle   = new NColorFillStyle(DarkOrange);
            series.MarkerStyle.BorderStyle = new NStrokeStyle(GreyBlue);
            series.MarkerStyle.Width       = new NLength(1.5f, NRelativeUnit.ParentPercentage);
            series.MarkerStyle.Height      = new NLength(1.5f, NRelativeUnit.ParentPercentage);
            series.MarkerStyle.Depth       = new NLength(1.5f, NRelativeUnit.ParentPercentage);

            GenerateData(series);

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, chart, title, null);

            if (!IsPostBack)
            {
                ShowUpperYErrorCheck.Checked = series.ShowUpperErrorY;
                ShowLowerYErrorCheck.Checked = series.ShowLowerErrorY;
                InflateMarginsCheck.Checked  = series.InflateMargins;
                RoundToTickCheck.Checked     = true;
            }
            else
            {
                series.ShowUpperErrorY = ShowUpperYErrorCheck.Checked;
                series.ShowLowerErrorY = ShowLowerYErrorCheck.Checked;
                series.InflateMargins  = InflateMarginsCheck.Checked;

                NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
                linearScale.RoundToTickMin = RoundToTickCheck.Checked;
                linearScale.RoundToTickMax = RoundToTickCheck.Checked;
            }
        }