Beispiel #1
0
        public JcwChartStatisticsCtl()
        {
            AutoHide = true;
            Series   = new Dictionary <StatisticTypes, List <IJcwChartStatistic> > ();

            InitializeComponent();

            MinDataGridView.OnRecalculateAggregate += GridView_OnRecalculateAggregate;
            MaxDataGridView.OnRecalculateAggregate += GridView_OnRecalculateAggregate;
            AveDataGridView.OnRecalculateAggregate += GridView_OnRecalculateAggregate;

            // don't auto generate data grid view columns when binding to datasources below
            MinDataGridView.AutoGenerateColumns = false;
            MaxDataGridView.AutoGenerateColumns = false;
            AveDataGridView.AutoGenerateColumns = false;

            MinSeriesNameColumn.DataPropertyName  = "Name";
            MinSeriesValueColumn.DataPropertyName = "Value";

            MaxSeriesNameColumn.DataPropertyName  = "Name";
            MaxSeriesValueColumn.DataPropertyName = "Value";

            AveSeriesNameColumn.DataPropertyName  = "Name";
            AveSeriesValueColumn.DataPropertyName = "Value";

            MinDataGridView.AfterInitialize();
            MaxDataGridView.AfterInitialize();
            AveDataGridView.AfterInitialize();
        }
Beispiel #2
0
        public void EndLoadData()
        {
            // Populate min/max/ave lists that grid view will use as datasources.  The data will come from the series collection
            // and will include calculated aggregates of the series information as well.
            if (Series.Count > 0)
            {
                if (Series.ContainsKey(StatisticTypes.Minimum))
                {
                    List <double> vector = new List <double> ();
                    foreach (IJcwChartStatistic statistic in Series[StatisticTypes.Minimum])
                    {
                        m_minValues.Add(statistic);
                        if (statistic.IncludeInAggregate)
                        {
                            vector.Add(statistic.Value);
                        }
                    }

                    double             average          = Utilities.GetAverage(vector);
                    IJcwChartStatistic averageStatistic = new ChartStatistic()
                    {
                        Name  = "Average",
                        Value = average,
                        IncludeInAggregate    = false,
                        CanIncludeInAggregate = false
                    };
                    m_minValues.Add(averageStatistic);

                    double             stdDev          = Utilities.GetStandardDeviation(vector);
                    IJcwChartStatistic stdDevStatistic = new ChartStatistic()
                    {
                        Name  = "Standard Deviation",
                        Value = stdDev,
                        IncludeInAggregate    = false,
                        CanIncludeInAggregate = false
                    };
                    m_minValues.Add(stdDevStatistic);
                }

                if (Series.ContainsKey(StatisticTypes.Maximum))
                {
                    List <double> vector = new List <double> ();
                    foreach (IJcwChartStatistic statistic in Series[StatisticTypes.Maximum])
                    {
                        m_maxValues.Add(statistic);
                        if (statistic.IncludeInAggregate)
                        {
                            vector.Add(statistic.Value);
                        }
                    }

                    double             average          = Utilities.GetAverage(vector);
                    IJcwChartStatistic averageStatistic = new ChartStatistic()
                    {
                        Name  = "Average",
                        Value = average,
                        IncludeInAggregate    = false,
                        CanIncludeInAggregate = false
                    };
                    m_maxValues.Add(averageStatistic);

                    double             stdDev          = Utilities.GetStandardDeviation(vector);
                    IJcwChartStatistic stdDevStatistic = new ChartStatistic()
                    {
                        Name  = "Standard Deviation",
                        Value = stdDev,
                        IncludeInAggregate    = false,
                        CanIncludeInAggregate = false
                    };
                    m_maxValues.Add(stdDevStatistic);
                }

                if (Series.ContainsKey(StatisticTypes.Average))
                {
                    List <double> vector = new List <double> ();
                    foreach (IJcwChartStatistic statistic in Series[StatisticTypes.Average])
                    {
                        m_aveValues.Add(statistic);
                        if (statistic.IncludeInAggregate)
                        {
                            vector.Add(statistic.Value);
                        }
                    }

                    double             average          = Utilities.GetAverage(vector);
                    IJcwChartStatistic averageStatistic = new ChartStatistic()
                    {
                        Name  = "Average",
                        Value = average,
                        IncludeInAggregate    = false,
                        CanIncludeInAggregate = false
                    };
                    m_aveValues.Add(averageStatistic);

                    double             stdDev          = Utilities.GetStandardDeviation(vector);
                    IJcwChartStatistic stdDevStatistic = new ChartStatistic()
                    {
                        Name  = "Standard Deviation",
                        Value = stdDev,
                        IncludeInAggregate    = false,
                        CanIncludeInAggregate = false
                    };
                    m_aveValues.Add(stdDevStatistic);
                }
            }

            MinDataGridView.Refresh();
            MaxDataGridView.Refresh();
            AveDataGridView.Refresh();
        }