public void PlotHistogram(IEnumerable ys, string seriesName = null, string histogramName = null)
        {
            if (!CheckDataType(ys))
            {
                throw new NotSupportedException("The provided Y values type is not supported. " + SupportedTypes);
            }

            seriesName    = String.IsNullOrEmpty(seriesName) ? "Data" : seriesName;
            histogramName = String.IsNullOrEmpty(histogramName) ? "Histogram" : histogramName;

            var series = new Series(seriesName);

            foreach (var value in ys)
            {
                series.Points.AddY(value);
            }

            var ch = InitChart();

            ch.Series.Add(series);

            var hist = new HistogramChartHelper();

            hist.CreateHistogram(ch, seriesName, histogramName);
            Plot(ch);
        }
        private void UpdateChartSettings()
        {
            if (!this.loadingData)
            {
                // Create a histogram series
                HistogramChartHelper histogramHelper = new HistogramChartHelper();
                histogramHelper.SegmentIntervalNumber       = int.Parse(comboBoxIntervalNumber.Text);
                histogramHelper.ShowPercentOnSecondaryYAxis = checkBoxShowPercents.Checked;
                // NOTE: Interval width may be specified instead of interval number
                //histogramHelper.SegmentIntervalWidth = 15;
                histogramHelper.CreateHistogram(chart1, "RawData", "Histogram");

                // Set same X axis scale and interval in the single axis data distribution
                // chart area as in the histogram chart area.
                chart1.ChartAreas["Default"].AxisX.Minimum  = chart1.ChartAreas["HistogramArea"].AxisX.Minimum;
                chart1.ChartAreas["Default"].AxisX.Maximum  = chart1.ChartAreas["HistogramArea"].AxisX.Maximum;
                chart1.ChartAreas["Default"].AxisX.Interval = chart1.ChartAreas["HistogramArea"].AxisX.Interval;
            }
        }
Beispiel #3
0
        public void UpdateGraph()
        {
            if (rawData != null)
            {
                List <double> values = new List <double>();
                decimal       total  = 0;

                chart1.Series["RawData"].Points.Clear();
                chart1.Series["DataDistribution"].Points.Clear();
                for (int i = 0; i < rawData.Count; i++)
                {
                    chart1.Series["RawData"].Points.AddY(rawData[i].Time);
                }
                foreach (DataPoint dataPoint in chart1.Series["RawData"].Points)
                {
                    chart1.Series["DataDistribution"].Points.AddXY(dataPoint.YValues[0], 1);
                    values.Add(dataPoint.YValues[0]);
                    total += (decimal)dataPoint.YValues[0];
                }
                HistogramChartHelper histogramHelper = new HistogramChartHelper();

                // Specify number of segment intervals
                histogramHelper.SegmentIntervalNumber = (int)spinIntervals.Value;

                //don't show percentage values on right
                histogramHelper.ShowPercentOnSecondaryYAxis = false;

                // Create histogram series
                histogramHelper.CreateHistogram(chart1, "RawData", "Histogram");
                // Set same X axis scale and interval in the single axis data distribution
                // chart area as in the histogram chart area.
                chart1.ChartAreas["Default"].AxisX.Minimum  = chart1.ChartAreas["HistogramArea"].AxisX.Minimum;
                chart1.ChartAreas["Default"].AxisX.Maximum  = chart1.ChartAreas["HistogramArea"].AxisX.Maximum;
                chart1.ChartAreas["Default"].AxisX.Interval = chart1.ChartAreas["HistogramArea"].AxisX.Interval;

                txtStdDev.Text = StandardDeviation(values).ToString("0.0000");
                txtAve.Text    = (total / values.Count).ToString("0.0000");
            }
        }
Beispiel #4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Populate chart with random data
            Random rand = new Random();

            for (int index = 1; index < 70; index++)
            {
                int    maxValue = (int)Math.Pow(rand.Next(100, 1000) / 100.0, 2.0);
                double newVal   = 100 + rand.Next(0, (int)maxValue);
                Chart1.Series["RawData"].Points.AddY(newVal);
                newVal = 100 + rand.Next(-(int)maxValue, 0);
                Chart1.Series["RawData"].Points.AddY(newVal);
            }

            // Populate single axis data distribution series. Show Y value of the
            // data series as X value and set all Y values to 1.
            foreach (DataPoint dataPoint in Chart1.Series["RawData"].Points)
            {
                Chart1.Series["DataDistribution"].Points.AddXY(dataPoint.YValues[0], 1);
            }

            // Create a histogram series
            HistogramChartHelper histogramHelper = new HistogramChartHelper();

            histogramHelper.SegmentIntervalNumber       = int.Parse(CollectedPercentage.SelectedItem.Text);
            histogramHelper.ShowPercentOnSecondaryYAxis = checkBoxPercent.Checked;
            // NOTE: Interval width may be specified instead of interval number
            //histogramHelper.SegmentIntervalWidth = 15;
            histogramHelper.CreateHistogram(Chart1, "RawData", "Histogram");

            // Set same X axis scale and interval in the single axis data distribution
            // chart area as in the histogram chart area.
            Chart1.ChartAreas["ChartArea1"].AxisX.Minimum  = Chart1.ChartAreas["HistogramArea"].AxisX.Minimum;
            Chart1.ChartAreas["ChartArea1"].AxisX.Maximum  = Chart1.ChartAreas["HistogramArea"].AxisX.Maximum;
            Chart1.ChartAreas["ChartArea1"].AxisX.Interval = Chart1.ChartAreas["HistogramArea"].AxisX.Interval;
        }
Beispiel #5
0
        public void GetMonteCarloChart(Chart chart1, List <double> values)
        {
            // Add series and set chart type
            chart1.Series.Add("RawData");
            chart1.Series.Add("Histogram");
            chart1.Series.Add("DataDistribution");

            chart1.ChartAreas.Add("HistogramArea");

            chart1.Series["RawData"].XValueType = ChartValueType.Double;
            chart1.Series["RawData"].ChartType  = SeriesChartType.Point;
            chart1.Series["RawData"].Enabled    = true;

            chart1.Series["DataDistribution"].XValueType = ChartValueType.Double;
            chart1.Series["DataDistribution"].ChartType  = SeriesChartType.Point;

            chart1.Series["Histogram"].YValueType        = ChartValueType.Double;
            chart1.Series["Histogram"].ChartType         = SeriesChartType.Column;
            chart1.Series["Histogram"].BorderWidth       = 1;
            chart1.Series["Histogram"].ChartArea         = "HistogramArea";
            chart1.Series["Histogram"].Color             = Color.YellowGreen;
            chart1.Series["Histogram"].BorderColor       = Color.Black;
            chart1.Series["Histogram"].BackGradientStyle = GradientStyle.DiagonalLeft;
            chart1.ChartAreas["HistogramArea"].AxisX.LabelStyle.Format = "#,###";

            chart1.ChartAreas[0].Position.X      = 0;
            chart1.ChartAreas[0].Position.Y      = 0;
            chart1.ChartAreas[0].Position.Width  = 0;
            chart1.ChartAreas[0].Position.Height = 0;
            chart1.ChartAreas[0].Visible         = true;

            List <double> myValues = values;

            foreach (double value in myValues)
            {
                chart1.Series["RawData"].Points.AddY(value);
            }


            foreach (DataPoint dataPoint in chart1.Series["RawData"].Points)
            {
                chart1.Series["DataDistribution"].Points.AddXY(dataPoint.YValues[0], 1);
            }

            // Create a histogram series
            var histogramHelper = new HistogramChartHelper
            {
                ShowPercentOnSecondaryYAxis = true,
                SegmentIntervalNumber       = 12
            };

            histogramHelper.CreateHistogram(chart1, "RawData", "Histogram");

            // Set same X axis scale and interval in the single axis data distribution
            // chart area as in the histogram chart area.
            chart1.ChartAreas[0].AxisX.Minimum  = 0;
            chart1.ChartAreas[0].AxisX.Maximum  = 0;
            chart1.ChartAreas[0].AxisX.Interval = 0;
            chart1.ChartAreas["HistogramArea"].AxisX2.MinorTickMark.Enabled = true;
            chart1.ChartAreas[0].Visible = true;
            chart1.ChartAreas["HistogramArea"].AxisX.LabelStyle.Enabled = true;
            chart1.Series["Histogram"].SmartLabelStyle.Enabled          = true;
            chart1.Legends[0].Enabled = true;
        }
Beispiel #6
0
        public void PlotHistogram(IEnumerable ys, string seriesName = null, string histogramName = null)
        {
            if (!CheckDataType(ys))
                throw new NotSupportedException("The provided Y values type is not supported. "+SupportedTypes);

            seriesName = String.IsNullOrEmpty(seriesName) ? "Data" : seriesName;
            histogramName = String.IsNullOrEmpty(histogramName) ? "Histogram" : histogramName;

            var series = new Series(seriesName);
            foreach (var value in ys)
                series.Points.AddY(value);

            var ch = InitChart();
            ch.Series.Add(series);

            var hist = new HistogramChartHelper();
            hist.CreateHistogram(ch, seriesName, histogramName);
            Plot(ch);
        }