Пример #1
0
        //---------------------------------------------

        #region Constructor
        public DataHistogramView()
        {
            InitializeComponent();

            m_histogram       = new Histogram();
            m_graphBars       = new ZedGraph.BarItem(String.Empty);
            m_graphBars.Color = Color.DarkBlue;
            zedGraphControl1.GraphPane.Title.FontSpec.IsBold            = true;
            zedGraphControl1.GraphPane.Title.FontSpec.Size              = 32f;
            zedGraphControl1.GraphPane.Title.IsVisible                  = true;
            zedGraphControl1.GraphPane.XAxis.Type                       = AxisType.Text;
            zedGraphControl1.GraphPane.XAxis.Title.IsVisible            = false;
            zedGraphControl1.GraphPane.XAxis.MinSpace                   = 0;
            zedGraphControl1.GraphPane.XAxis.MajorGrid.IsVisible        = false;
            zedGraphControl1.GraphPane.XAxis.MinorGrid.IsVisible        = false;
            zedGraphControl1.GraphPane.XAxis.MajorTic.IsBetweenLabels   = true;
            zedGraphControl1.GraphPane.XAxis.MajorTic.IsInside          = false;
            zedGraphControl1.GraphPane.XAxis.MajorTic.IsOpposite        = false;
            zedGraphControl1.GraphPane.XAxis.MinorTic.IsAllTics         = false;
            zedGraphControl1.GraphPane.XAxis.Scale.FontSpec.IsBold      = true;
            zedGraphControl1.GraphPane.XAxis.Scale.FontSpec.IsAntiAlias = true;
            zedGraphControl1.GraphPane.YAxis.MinorTic.IsAllTics         = false;
            zedGraphControl1.GraphPane.YAxis.MajorTic.IsOpposite        = false;
            zedGraphControl1.GraphPane.YAxis.Title.Text                 = "Frequency";
            zedGraphControl1.GraphPane.YAxis.Title.FontSpec.Size        = 24f;
            zedGraphControl1.GraphPane.YAxis.Title.FontSpec.IsBold      = true;
            zedGraphControl1.GraphPane.Border.IsVisible                 = false;
            zedGraphControl1.GraphPane.BarSettings.MinBarGap            = 0;
            zedGraphControl1.GraphPane.BarSettings.MinClusterGap        = 0;
            zedGraphControl1.GraphPane.CurveList.Add(m_graphBars);
        }
Пример #2
0
 public static double Entropy(params int[] values)
 {
     Visualizations.Histogram histogram;
     histogram = new Visualizations.Histogram();
     histogram.Compute(values, 1.0);
     return(Visualizations.Histogram.Measures.Entropy(histogram.Values));
 }
Пример #3
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)
            {
                if (m_dataMember != null && m_dataMember.Length > 0)
                {
                    m_samples = new SampleVector(((DataTable)m_dataSource).Columns[m_displayMember]);
                }
                else
                {
                    m_samples = new SampleVector(((DataTable)m_dataSource).Columns[0]);
                }
            }
            else if (m_dataSource is SampleVector)
            {
                m_samples = m_dataSource as SampleVector;
            }
            else if (m_dataSource is IListSource)
            {
                m_samples = new SampleVector((IListSource)m_dataSource);
            }
            else
            {
                // invalid data source
            }

            zedGraphControl1.GraphPane.Title.Text = m_samples.Name;
            this.m_histogram.Compute(m_samples, Histogram.SelectionRule.Scotts);

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

            this.trackBar1.Value = m_histogram.Count;
        }
Пример #4
0
 internal HistogramBin(Histogram histogram, int index)
 {
     this.m_index     = index;
     this.m_histogram = histogram;
 }