Histogram control.

The control displays histograms represented with integer arrays, where each array's element keeps occurrence number of the corresponding element.

Sample usage:

// create array with histogram values int[] histogramValues = new int[] { 3, 8, 53, 57, 79, 69, ... }; // set values to histogram control histogram.Values = histogramValues;

Sample control's look:

Inheritance: System.Windows.Forms.Control
Exemplo n.º 1
0
 /// <summary>
 ///   Displays a histogram.
 /// </summary>
 ///
 /// <param name="histogram">The histogram to show.</param>
 ///
 public static HistogramBox Show(Histogram histogram)
 {
     return(show(histogram));
 }
Exemplo n.º 2
0
        private void onDataBind()
        {
            samples = null;

            if (dataSource == null)
            {
                return;
            }

            Histogram source = dataSource as Histogram;

            if (source == null)
            {
                if (histogram == null)
                {
                    histogram = new Histogram();
                }

                if (dataSource is DataSet)
                {
                    // throw new NotSupportedException();
                }
                else if (dataSource is DataTable)
                {
                    DataTable table = dataSource as DataTable;

                    if (dataMember != null && dataMember.Length > 0)
                    {
                        if (table.Columns.Contains(dataMember))
                        {
                            DataColumn column = table.Columns[dataMember];
                            samples = Matrix.ToArray(column);
                        }
                        else
                        {
                            samples = new double[0];
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                else if (dataSource is double[])
                {
                    samples = dataSource as double[];
                }
                else if (dataSource is IListSource)
                {
                    // throw new NotSupportedException();
                }
                else
                {
                    return; // invalid data source
                }

                if (binWidth != null)
                {
                    this.histogram.Compute(samples, binWidth.Value);
                }
                else if (numberOfBins != null)
                {
                    this.histogram.Compute(samples, numberOfBins.Value);
                }
                else
                {
                    this.histogram.Compute(samples);
                }
            }
            else
            {
                this.histogram = source;
            }

            this.UpdateTrackbar();
            this.UpdateGraph();

            if (histogram.Bins.Count > 0 &&
                histogram.Bins.Count < trackBar.Maximum)
            {
                trackBar.Value = histogram.Bins.Count;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 ///   Displays a histogram.
 /// </summary>
 ///
 /// <param name="title">The title for the histogram window.</param>
 /// <param name="histogram">The histogram to show.</param>
 ///
 public static HistogramBox Show(Histogram histogram, string title = "Histogram")
 {
     return(show(title, histogram.Values.ToDouble()));
 }
Exemplo n.º 4
0
        //---------------------------------------------

        #region Private Members
        private void OnDataBind()
        {
            if (m_dataSource == null)
            {
                return;
            }

            if (m_histogram == null)
            {
                m_histogram = new Histogram();
            }

            if (m_dataSource is DataSet)
            {
                if (m_dataMember != null && m_dataMember.Length > 0)
                {
                    if (m_displayMember != null && m_displayMember.Length > 0)
                    {
                        //m_samples = new SampleVector(((DataSet)m_dataSource).Tables[m_dataMember].Columns[m_displayMember]);
                    }
                    else
                    {
                        //  m_samples = new SampleVector(((DataSet)m_dataSource).Tables[m_dataMember].Columns[0]);
                    }
                }
                else
                {
                    //m_samples = new SampleVector(((DataSet)m_dataSource).Tables[0].Columns[0]);
                }
            }
            else if (m_dataSource is DataTable)
            {
                DataTable table = m_dataSource as DataTable;

                if (m_dataMember != null && m_dataMember.Length > 0)
                {
                    //m_samples = new SampleVector(((DataTable)m_dataSource).Columns[m_displayMember]);

                    DataColumn column = table.Columns[m_dataMember];
                    m_samples = Matrix.ToArray(column);
                }
                else
                {
                    return;
                    //m_samples = new SampleVector(((DataTable)m_dataSource).Columns[0]);
                }
            }
            else if (m_dataSource is double[])
            {
                m_samples = m_dataSource as double[];
            }
            else if (m_dataSource is IListSource)
            {
                //m_samples = new SampleVector((IListSource)m_dataSource);
            }
            else
            {
                return;
                // invalid data source
            }

            zedGraphControl1.GraphPane.Title.Text = m_histogram.Title;
            this.m_histogram.Compute(m_samples);

            this.UpdateTrackbar();
            this.UpdateGraph();

            this.trackBar1.Value = m_histogram.Count;
        }
Exemplo n.º 5
0
 /// <summary>
 ///   Displays a histogram.
 /// </summary>
 ///
 /// <param name="histogram">The histogram to show.</param>
 ///
 public static HistogramBox Show(Histogram histogram)
 {
     return(show(histogram.Title, histogram.Values.ToDouble()));
 }