Exemple #1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel title = new NLabel("Data Distribution");

            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
            title.ContentAlignment           = ContentAlignment.BottomCenter;
            title.Margins  = new NMarginsL(5, 5, 5, 5);
            title.DockMode = PanelDockMode.Top;
            title.Location = new NPointL(
                new NLength(50, NRelativeUnit.ParentPercentage),
                new NLength(2, NRelativeUnit.ParentPercentage));

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

            // create box and whiskers chart
            NChart boxChart = new NCartesianChart();

            boxChart.Margins    = new NMarginsL(5, 0, 5, 5);
            boxChart.BoundsMode = BoundsMode.Stretch;
            boxChart.DockMode   = PanelDockMode.Right;
            boxChart.Size       = new NSizeL(new NLength(20, NRelativeUnit.ParentPercentage), new NLength(100, NRelativeUnit.ParentPercentage));

            // create point chart
            NChart pointChart = new NCartesianChart();

            pointChart.Margins    = new NMarginsL(5, 0, 0, 5);
            pointChart.BoundsMode = BoundsMode.Stretch;
            pointChart.DockMode   = PanelDockMode.Fill;

            // create a guide line to align the chart bottoms
            NSideGuideline bottomChartGuideline = new NSideGuideline(PanelSide.Bottom);

            nChartControl1.Document.RootPanel.Guidelines.Add(bottomChartGuideline);
            bottomChartGuideline.Targets.Add(pointChart);
            bottomChartGuideline.Targets.Add(boxChart);

            // arrange panels
            nChartControl1.Panels.Add(title);
            nChartControl1.Panels.Add(boxChart);
            nChartControl1.Panels.Add(pointChart);

            SetupCharts(pointChart, boxChart);

            bool showAverage  = ShowAverageCheckBox.Checked;
            bool showOutliers = ShowOutliersCheckBox.Checked;

            NPointSeries          pointSeries = (NPointSeries)pointChart.Series[0];
            NBoxAndWhiskersSeries boxSeries   = (NBoxAndWhiskersSeries)boxChart.Series[0];

            NBoxAndWhiskersDataPoint bwdp = new NBoxAndWhiskersDataPoint(pointSeries.Values, showAverage, showOutliers);

            boxSeries.ClearDataPoints();
            boxSeries.AddDataPoint(bwdp);
        }
Exemple #2
0
        private void GenerateData(NBoxAndWhiskersSeries series, int nCount)
        {
            series.ClearDataPoints();

            DateTime dt     = new DateTime(2005, 5, 24, 11, 0, 0);
            Random   random = new Random();

            for (int i = 0; i < nCount; 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;

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

                // generate date time value
                dt = dt.AddHours(12 + Random.NextDouble() * 60);
                series.XValues.Add(dt.ToOADate());

                // generate outlier values
                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);
                }

                series.OutlierValues.Add(outliers);
            }
        }
Exemple #3
0
        void UpdateBoxAndWhiskers()
        {
            NChart pointChart = nChartControl1.Charts[0];
            NChart boxChart   = nChartControl1.Charts[1];

            NPointSeries          pointSeries = (NPointSeries)pointChart.Series[0];
            NBoxAndWhiskersSeries boxSeries   = (NBoxAndWhiskersSeries)boxChart.Series[0];

            bool showAverage  = ShowAverageCheck.Checked;
            bool showOutliers = ShowOutliersCheck.Checked;

            NBoxAndWhiskersDataPoint bwdp = new NBoxAndWhiskersDataPoint(pointSeries.Values, showAverage, showOutliers);

            boxSeries.ClearDataPoints();
            boxSeries.AddDataPoint(bwdp);
        }
        private void GenerateData(NBoxAndWhiskersSeries series, int nCount)
        {
            series.ClearDataPoints();

            for (int i = 0; i < nCount; 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;

                series.UpperBoxValues.Add(boxUpper);
                series.LowerBoxValues.Add(boxLower);
                series.UpperWhiskerValues.Add(whiskersUpper);
                series.LowerWhiskerValues.Add(whiskersLower);
                series.MedianValues.Add(median);
                series.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);
                }

                series.OutlierValues.Add(outliers);
            }
        }