Example #1
0
        private FilterStruct createFilter()
        {
            DropDownList comparative = comparatives[Filter == null?(int)filterComparatives[filterNames.SelectedIndex]:(int)Filter.Type];
            ValueType    type        = (ValueType)Enum.Parse(typeof(ValueType), comparative.ID.Split('_')[1]);
            string       value       = string.Empty;

            if (type == ValueType.DateTime)
            {
                value = FilterValueDateTime.Value == null ? null : ((DateTime)FilterValueDateTime.Value).ToBinary().ToString();
            }
            else if (type == ValueType.ContainerGroup)
            {
                value = FilterValueContainerGroup.Text;
            }
            else if (comparative.SelectedValue == "inlist")
            {
                value = FilterValueStringList.Text;
            }
            else
            {
                value = FilterValueString.Text;
            }
            FilterStruct newFilterStruct = new FilterStruct(filterNames.SelectedValue, filterNames.SelectedItem.Text, type, comparative.SelectedValue, value, FilterValueStringListDelimiter.Text.Length > 0 ? FilterValueStringListDelimiter.SelectedValue : null);

            newFilterStruct.ContainerGroupPath = HiddenContainerGroupIds.Value;
            return(newFilterStruct);
        }
Example #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 public ColorFilterMenuItem(ImageComponent component, FilterStruct f)
 {
     this.filterStruct   = f;
     this.imageComponent = component;
     this.Text           = f.filter.Name;
     this.Click         += ColorFilterMenuItem_Click;
 }
Example #3
0
 public SubscriptionTarget()
 {
     Params = new JObject();
     Filter = new FilterStruct();
     //Since = null;
     //Until = null;
 }
Example #4
0
        private void AddFilter(String property, FilterItem value, Button button)
        {
            var descriptor = TypeDescriptor.GetProperties(ListItemType)[property];
            var filter     = new FilterStruct(descriptor, button, value);

            currentFilters[property] = filter;
        }
        public void AddNewFilter()
        {
            FilterStruct s = new FilterStruct(columns[0].ColumnId, FilterStruct.FilterMode.NOT_CONTAINS, " ");

            filters.Add(s);
            filtersList.AddView(MakeNewFilterItem(filters.Count - 1, s.ColumnId, s.Condition, s.Mode), filtersList.ChildCount - 1);
        }
Example #6
0
        /// <summary>
        /// Handles the selection change event from the filter popup
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SelectionChangedHandler(object sender, SelectionChangedEventArgs e)
        {
            // obtain the term to filter for
            ListView   filterListView = (ListView)sender;
            FilterItem filterItem     = (FilterItem)filterListView.SelectedItem;

            // navigate up to the header to obtain the filter property name
            GridViewColumnHeader header = (GridViewColumnHeader)Helpers.FindElementOfTypeUp(filterListView, typeof(GridViewColumnHeader));

            SortableGridViewColumn column = (SortableGridViewColumn)header.Column;
            String currentFilterProperty  = column.SortPropertyName;

            if (!column.CanBeFiltered)
            {
                FilterStruct filter = (FilterStruct)currentFilters[currentFilterProperty];
                filter.Button.Visibility = System.Windows.Visibility.Hidden;

                return;
            }
            if (filterItem == null)
            {
                return;
            }

            // determine whether to clear the filter for this column
            if (filterItem.ItemView.Equals("[clear]"))
            {
                if (currentFilters.ContainsKey(currentFilterProperty))
                {
                    FilterStruct filter = (FilterStruct)currentFilters[currentFilterProperty];
                    filter.Button.ContentTemplate = (DataTemplate)dictionary["filterButtonInactiveTemplate"];
                    if (FilterButtonInactiveStyle != null)
                    {
                        filter.Button.Style = FilterButtonInactiveStyle;
                    }
                    currentFilters.Remove(currentFilterProperty);
                }

                ApplyCurrentFilters();
            }
            else
            {
                // find the button and apply the active style
                Button button = (Button)Helpers.FindVisualElement(header, "filterButton");
                button.ContentTemplate = (DataTemplate)dictionary["filterButtonActiveTemplate"];

                if (FilterButtonActiveStyle != null)
                {
                    button.Style = FilterButtonActiveStyle;
                }

                AddFilter(currentFilterProperty, filterItem, button);
                ApplyCurrentFilters();
            }

            // navigate up to the popup and close it
            Popup popup = (Popup)Helpers.FindElementOfTypeUp(filterListView, typeof(Popup));

            popup.IsOpen = false;
        }
Example #7
0
        /// <summary>
        /// Handles the button click on the ok button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            Button   btnOk          = (Button)sender;
            ListView filterListView = (ListView)btnOk.Tag;

            // navigate up to the header to obtain the filter property name
            GridViewColumnHeader header = (GridViewColumnHeader)UIHelpers.FindElementOfTypeUp(filterListView, typeof(GridViewColumnHeader));

            SortableGridViewColumn column = (SortableGridViewColumn)header.Column;
            String currentFilterProperty  = column.SortPropertyName;

            var items = new List <FilterItem>();

            foreach (object o in filterListView.Items)
            {
                var item = (FilterItem)o;

                if (item.IsChecked)
                {
                    items.Add(item);
                }
            }

            if (items.Exists(i => i.ItemView.Equals("Clear")))
            {
                if (currentFilters.ContainsKey(currentFilterProperty))
                {
                    FilterStruct filter = (FilterStruct)currentFilters[currentFilterProperty];
                    filter.button.ContentTemplate = (DataTemplate)dictionary["filterButtonInactiveTemplate"];
                    if (FilterButtonInactiveStyle != null)
                    {
                        filter.button.Style = FilterButtonInactiveStyle;
                    }
                    currentFilters.Remove(currentFilterProperty);
                }

                ApplyCurrentFilters();
            }
            else
            {
                // find the button and apply the active style
                Button button = (Button)UIHelpers.FindVisualElement(header, "filterButton");
                button.ContentTemplate = (DataTemplate)dictionary["filterButtonActiveTemplate"];

                if (FilterButtonActiveStyle != null)
                {
                    button.Style = FilterButtonActiveStyle;
                }

                AddFilters(currentFilterProperty, items.ToArray(), button);
                ApplyCurrentFilters();
            }
            // navigate up to the popup and close it
            Popup popup = (Popup)UIHelpers.FindElementOfTypeUp(filterListView, typeof(Popup));

            popup.IsOpen = false;
        }
            public bool OnMenuItemClick(IMenuItem item)
            {
                FilterStruct s = parent.filters[(int)parent.updated.Tag];

                s.Mode = (FilterStruct.FilterMode)item.ItemId;

                ((TextView)parent.updated).Text = item.TitleFormatted.ToString();
                return(true);
            }
Example #9
0
        private void SetCurrentColorFilter(int i)
        {
            FilterStruct f = this.colorFilters[i];

            this.tbBtn_Color_Filter.ImageIndex  = f.index;
            this.tbBtn_Color_Filter.Text        = f.filter.Name;
            this.tbBtn_Color_Filter.ToolTipText = f.filter.Description;
            this.currentColorFilter             = i;
        }
Example #10
0
        private double GetAggregateValue(System.Data.DataTable sourceTable, FilterStruct filter)
        {
            AggregateStruct statStruct = GetStatistics(sourceTable, filter);

            double dependentVal;

            switch (_aggregateFunction.ToUpperInvariant())
            {
            case SilverlightStatics.AVG:
                dependentVal = statStruct.Average;
                break;

            case SilverlightStatics.COUNT:
                dependentVal = statStruct.Observations;
                break;

            case SilverlightStatics.MAX:
                if (statStruct.Maximun is double)
                {
                    dependentVal = (double)statStruct.Maximun;
                }
                else
                {
                    dependentVal = (int)statStruct.Maximun;
                }
                break;

            case SilverlightStatics.MIN:
                if (statStruct.Minimum is double)
                {
                    dependentVal = (double)statStruct.Minimum;
                }
                else
                {
                    dependentVal = (int)statStruct.Minimum;
                }
                break;

            case SilverlightStatics.PERCENT:
                dependentVal = (double)statStruct.Percent;
                break;

            case SilverlightStatics.SUM:
                dependentVal = (double)statStruct.Sum;
                break;

            case SilverlightStatics.SUMPCT:
                dependentVal = (double)statStruct.SumPercent;
                break;

            default:
                dependentVal = statStruct.Sum;
                break;
            }
            return(dependentVal);
        }
            public bool OnMenuItemClick(IMenuItem item)
            {
                FilterStruct s        = parent.filters[(int)parent.updated.Tag];
                int          colIndex = parent.columns.FindIndex(C => C.ColumnId == s.ColumnId);

                s.ColumnId = parent.columns[item.ItemId].ColumnId;

                ((TextView)parent.updated).Text = item.TitleFormatted.ToString();
                return(true);
            }
        public ConvolutionLayer(FilterStruct filterStruct, INonlinearity func)
        {
            Function = func;
            fs       = filterStruct;
            Filters  = new NNValue[fs.FilterCount];

            for (int i = 0; i < fs.FilterCount; i++)
            {
                Filters[i] = new NNValue(fs.FilterH, fs.FilterW);
            }
        }
Example #13
0
        private bool IsPropertyFiltered(String property)
        {
            foreach (String filterProperty in currentFilters.Keys)
            {
                FilterStruct filter = (FilterStruct)currentFilters[filterProperty];
                if (filter.property == property)
                {
                    return(true);
                }
            }

            return(false);
        }
        public ConvolutionLayer(INonlinearity func, int count, int h = 3, int w = 3)
        {
            Filters = new NNValue[count];

            for (int i = 0; i < count; i++)
            {
                Filters[i] = new NNValue(h, w);
            }

            Function = func;
            fs       = new FilterStruct()
            {
                FilterW = w, FilterCount = count, FilterH = h
            };
        }
        void Init(Shape inputShape, FilterStruct filterStruct, INonlinearity func, Random rnd)
        {
            InputShape = inputShape;
            fs         = filterStruct;
            int outputH = inputShape.H - filterStruct.FilterH + 1 + _padY,
                outputW = inputShape.W - filterStruct.FilterW + 1 + _padX;


            OutputShape = new Shape(outputH, outputW, filterStruct.FilterCount);

            double initParamsStdDev = 1.0 / Math.Sqrt(OutputShape.Len);


            int d = InputShape.D;

            Function = func;
            Filters  = new NNValue[filterStruct.FilterCount];

            for (int i = 0; i < filterStruct.FilterCount; i++)
            {
                Filters[i] = NNValue.Random(filterStruct.FilterH, filterStruct.FilterW, d, initParamsStdDev, rnd);
            }
        }
        public void RemoveSort(int index)
        {
            FilterStruct removed = filters[index];

            filtersList.RemoveViewAt(index);
            filters.RemoveAt(index);

            for (int i = index; i < filtersList.ChildCount - 1; ++i)
            {
                View updated = filtersList.GetChildAt(i);

                TextView columnButton = updated.FindViewById <TextView>(Resource.Id.ViewFilterColumn);
                columnButton.Tag = i;

                TextView sortTypeButton = updated.FindViewById <TextView>(Resource.Id.ViewFilterType);
                sortTypeButton.Tag = i;

                TextView sortStringButton = updated.FindViewById <TextView>(Resource.Id.ViewFilterPredicate);
                sortStringButton.Tag = i;

                View removeButton = updated.FindViewById(Resource.Id.ViewFilterRemove);
                removeButton.Tag = i;
            }
        }
Example #17
0
        public void Execute()
        {
            _regressionTable = new DataTable();
            _regressionTable.Columns.Add("SeriesName", typeof(string));
            _regressionTable.Columns.Add("Predictor", typeof(object));
            _regressionTable.Columns.Add("Response", typeof(double));

            Dictionary<string, string> config = Context.SetProperties;
            StringBuilder HTMLString = new StringBuilder();

            System.Data.DataTable sourceTable = BuildTempContextTable();
            cDataSetHelper dsHelper = new cDataSetHelper();

            Dictionary<string, string> args = new Dictionary<string, string>();

            string strataVarValue = string.Empty;
            string objectElement = string.Empty;

            SilverlightMarkup silverlight = new SilverlightMarkup();

            DataTable Strata_ValueList;

            if (string.IsNullOrEmpty(_strataVar))
            {
                Strata_ValueList = sourceTable.Clone();
                Strata_ValueList.Rows.Add(Strata_ValueList.NewRow());
            }
            else
            {
                Strata_ValueList = dsHelper.SelectDistinct("", sourceTable, _strataVar);
            }

            FilterStruct filter = new FilterStruct();
            filter.strataVarName = _strataVar;

            _independentValueTypesSame = true;
            if(_independentVariableArray.Length > 1)
            {
                for(int i = 0; (i + 1) < _independentVariableArray.Length ; i++)
                {
                    if (sourceTable.Columns[_independentVariableArray[i]].DataType != sourceTable.Columns[_independentVariableArray[i+1]].DataType )
                    {
                        _independentValueTypesSame = false;
                        break;
                    }
                }
            }

            _independentValuesAllBool = true;
            for (int i = 0; i < _independentVariableArray.Length; i++)
            {
                string indepVar = _independentVariableArray[i];

                if (sourceTable.Columns.Contains(indepVar))
                {
                    if (sourceTable.Columns[indepVar].DataType.Name != "Byte")
                    {
                        _independentValuesAllBool = false;
                        break;
                    }
                }
                else
                {
                    return;
                }
            }

            foreach (DataRow strataRow in Strata_ValueList.Rows)
            {
                if (string.IsNullOrEmpty(_strataVar) || strataRow[_strataVar] == DBNull.Value)
                {
                    filter.strataVarValue = "null";
                }
                else
                {
                    filter.strataVarValue = strataRow[_strataVar].ToString();
                }

                if (_graphType == SilverlightStatics.Scatter)
                {
                    if (_independentVariableArray.Length < 2)
                    {
                        throw new Exception("Scatter graphs must contain two (2) main variables.");
                    }

                    string categoryName = string.Empty;
                    Dictionary<object, double> indDepValuePairCollection = new Dictionary<object, double>();

                    List<string> StrataVarNameList = new List<string>();
                    List<string> StrataVarValueList = new List<string>();

                    string regressor = _independentVariableArray[0];
                    string regressand = _independentVariableArray[1];

                    StrataVarNameList.Add(filter.strataVarName);
                    StrataVarValueList.Add(filter.strataVarValue);

                    DataTable table = new DataTable();
                    table.Columns.Add(new DataColumn(sourceTable.Columns[regressor].ColumnName, sourceTable.Columns[regressor].DataType));
                    table.Columns.Add(new DataColumn(sourceTable.Columns[regressand].ColumnName, sourceTable.Columns[regressand].DataType));

                    foreach (DataRow row in sourceTable.Rows)
                    {
                        table.Rows.Add(row[regressor], row[regressand]);
                    }

                    foreach (DataRow row in table.Rows)
                    {
                        if (row[regressor] != DBNull.Value)
                        {
                            string seriesName = string.Empty;
                            object independentValue = new object();

                            if (_independentValuesAllBool)
                            {
                                independentValue = regressor;
                                byte value = (byte)(row[regressor]);
                            }
                            else
                            {
                                independentValue = GetValue(regressor, row, config);
                            }

                            seriesName = string.Format("{0} x {1}", sourceTable.Columns[regressor].ColumnName, sourceTable.Columns[regressand].ColumnName);

                            if (string.IsNullOrEmpty(_weightVar))
                            {
                                double dependentVal;

                                if (double.TryParse(row[regressand].ToString(), out dependentVal))
                                {
                                    _regressionTable.Rows.Add(seriesName, independentValue, dependentVal);
                                }
                            }
                            else
                            {
                                filter.independentVarValue = row[regressor];
                                filter.independentVarName = regressor;
                                filter.weightVarName = _weightVar;
                                double dependentVal = GetAggregateValue(sourceTable, filter);

                                _regressionTable.Rows.Add(seriesName, independentValue, dependentVal);
                            }
                        }
                    }
                }
                else if (sourceTable.Columns.Contains(_graphCrossTab))
                {
                    string categoryName = string.Empty;
                    Dictionary<object, double> indDepValuePairCollection = new Dictionary<object, double>();

                    List<string> StrataVarNameList = new List<string>();
                    List<string> StrataVarValueList = new List<string>();

                    foreach (string independentVariableName in _independentVariableArray)
                    {
                        StrataVarNameList.Add(filter.strataVarName);
                        StrataVarValueList.Add(filter.strataVarValue);

                        DataTable workingTable = cWorkingTable.CreateWorkingTable(
                            independentVariableName,
                            _graphCrossTab,
                            config,
                            sourceTable,
                            StrataVarNameList,
                            StrataVarValueList,
                            _weightVar);

                        foreach (DataColumn crossTabCandidate in workingTable.Columns)
                        {
                            if (crossTabCandidate.ColumnName != "__Values__" && crossTabCandidate.ColumnName != "__Count__")
                            {
                                Type crossTabDataType = sourceTable.Columns[_graphCrossTab].DataType;

                                string crossTabValue = crossTabCandidate.ColumnName;

                                if (crossTabDataType.Name == "Byte")
                                {
                                    if (crossTabCandidate.ColumnName == "0")
                                    {
                                        crossTabValue = config["RepresentationOfNo"];
                                    }
                                    else if (crossTabCandidate.ColumnName == "1")
                                    {
                                        crossTabValue = config["RepresentationOfYes"];
                                    }
                                }

                                string seriesName = string.Format("{0}={1}", _graphCrossTab, crossTabValue);

                                foreach (DataRow row in workingTable.Rows)
                                {
                                    double dependentVal;

                                    if (double.TryParse(row[crossTabCandidate.ColumnName].ToString(), out dependentVal))
                                    {
                                        if (row["__Values__"] != DBNull.Value)
                                        {
                                            string independentVariableTypeName = string.Empty;

                                            if (sourceTable.Columns.Contains(independentVariableName))
                                            {
                                                independentVariableTypeName = sourceTable.Columns[independentVariableName].DataType.Name;
                                            }

                                            categoryName = BuildCategoryName(independentVariableName, independentVariableTypeName, row, config);

                                            object independentValue = row["__Values__"];

                                            if (string.IsNullOrEmpty(_weightVar))
                                            {
                                                if (double.TryParse(row[crossTabCandidate.ColumnName].ToString(), out dependentVal))
                                                {
                                                    _regressionTable.Rows.Add(seriesName, independentValue, dependentVal);
                                                }
                                            }
                                            else
                                            {
                                                object independentVariableValue = row["__Values__"];

                                                bool isValue = false;

                                                if (independentVariableValue != null)
                                                {
                                                    isValue = true;

                                                    if (independentVariableValue is string)
                                                    {
                                                        string candidate = ((string)independentVariableValue).Trim();
                                                        isValue = candidate != string.Empty;
                                                    }
                                                }

                                                if (isValue)
                                                {
                                                    filter.crossTabName = _graphCrossTab;
                                                    filter.crossTabValue = crossTabCandidate.ColumnName;
                                                    filter.independentVarName = independentVariableName;
                                                    filter.independentVarValue = independentVariableValue;
                                                    filter.weightVarName = _weightVar;
                                                    dependentVal = GetAggregateValue(sourceTable, filter);
                                                    _regressionTable.Rows.Add(seriesName, independentValue, dependentVal);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else if (_graphType == "EPICURVE" && _graphIntervalUnits != "")
                {
                    string categoryName = string.Empty;
                    Dictionary<object, double> indDepValuePairCollection = new Dictionary<object, double>();

                    List<string> StrataVarNameList = new List<string>();
                    List<string> StrataVarValueList = new List<string>();

                    foreach (string independentVariable in _independentVariableArray)
                    {
                        StrataVarNameList.Add(filter.strataVarName);
                        StrataVarValueList.Add(filter.strataVarValue);

                        DataTable workingTable = cWorkingTable.CreateWorkingTable(
                            independentVariable,
                            "",
                            config,
                            sourceTable,
                            StrataVarNameList,
                            StrataVarValueList,
                            _weightVar);

                        DateTime intervalStart = DateTime.MinValue;
                        DateTime intervalEnd = DateTime.MinValue;
                        DateTime dateTimeValue = DateTime.MinValue;
                        intervalStart = _graphStartFrom;

                        double givenInterval = 1;
                        int days = 0, hours = 0, minutes = 0, seconds = 0;
                        TimeSpan period = new TimeSpan(days, hours, minutes, seconds);

                        if (_graphInterval != "")
                        {
                            double.TryParse(_graphInterval, out givenInterval);
                        }

                        if (_graphIntervalUnits == "")
                        {
                            _graphIntervalUnits = "Hours";
                        }

                        foreach (DataRow row in workingTable.Rows)
                        {
                            if (row["__Values__"] != DBNull.Value)
                            {
                                dateTimeValue = (DateTime)row["__Values__"];

                                //if (intervalStart == DateTime.MinValue)
                                //{
                                //    intervalStart = dateTimeValue;
                                //    _graphStartFrom = dateTimeValue;
                                //}

                                while ( dateTimeValue >= intervalEnd)
                                {
                                    if (intervalEnd != DateTime.MinValue)
                                    {
                                        intervalStart = intervalEnd;
                                    }

                                    switch (_graphIntervalUnits)
                                    {
                                        case "Years":
                                            intervalEnd = intervalStart.AddYears((int)givenInterval);
                                            break;
                                        case "Quarters":
                                            intervalEnd = intervalStart.AddDays(givenInterval * 365.25 / 4.0);
                                            break;
                                        case "Weeks":
                                            intervalEnd = intervalStart.AddDays(givenInterval * 7);
                                            break;
                                        case "Days":
                                            intervalEnd = intervalStart.AddDays(givenInterval);
                                            break;
                                        case "Hours":
                                            intervalEnd = intervalStart.AddHours(givenInterval);
                                            break;
                                        case "Minutes":
                                            intervalEnd = intervalStart.AddMinutes(givenInterval);
                                            break;
                                        case "Seconds":
                                            intervalEnd = intervalStart.AddSeconds(givenInterval);
                                            break;
                                    }
                                }

                                string seriesName = string.Empty;
                                object independentValue = new object();

                                independentValue = BuildIndependentValue(independentVariable, row, config);

                                if (string.IsNullOrEmpty(seriesName))
                                {
                                    seriesName = SilverlightStatics.COUNT;

                                    if (_independentVariableArray.Length > 1)
                                    {
                                        seriesName = independentVariable;
                                    }

                                    if(string.IsNullOrEmpty(_aggregateFunction) == false)
                                    {
                                        seriesName = _aggregateFunction;
                                    }
                                }

                                if (string.IsNullOrEmpty(_weightVar))
                                {
                                    double dependentVal;

                                    if (double.TryParse(row["__Count__"].ToString(), out dependentVal))
                                    {
                                        if ((dateTimeValue >= intervalStart) && (dateTimeValue < intervalEnd))
                                        {
                                            string expression = "Predictor = #" + intervalStart.ToString() + "#";
                                            DataRow[] foundRows = _regressionTable.Select(expression);

                                            if (foundRows.Length == 0)
                                            {
                                                _regressionTable.Rows.Add(seriesName, intervalStart, dependentVal);
                                            }
                                            else
                                            {
                                                foundRows[0]["Response"] = (double)foundRows[0]["Response"] + dependentVal;
                                                _regressionTable.AcceptChanges();
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    filter.independentVarValue = row["__Values__"];
                                    filter.independentVarName = independentVariable;
                                    filter.weightVarName = _weightVar;
                                    double dependentVal = GetAggregateValue(sourceTable, filter);
                                    _regressionTable.Rows.Add(seriesName, independentValue, dependentVal);
                                }
                            }
                        }
                    }
                }
                else
                {
                    string categoryName = string.Empty;
                    Dictionary<object, double> indDepValuePairCollection = new Dictionary<object, double>();

                    List<string> StrataVarNameList = new List<string>();
                    List<string> StrataVarValueList = new List<string>();

                    foreach (string independentVariable in _independentVariableArray)
                    {
                        StrataVarNameList.Add(filter.strataVarName);
                        StrataVarValueList.Add(filter.strataVarValue);

                        DataTable workingTable = cWorkingTable.CreateWorkingTable(
                            independentVariable,
                            "",
                            config,
                            sourceTable,
                            StrataVarNameList,
                            StrataVarValueList,
                            _weightVar);

                        foreach (DataRow row in workingTable.Rows)
                        {
                            if (row["__Values__"] != DBNull.Value)
                            {
                                string seriesName = string.Empty;
                                object independentValue = new object();

                                if (!_independentValueTypesSame || _graphType == SilverlightStatics.Pie )
                                {
                                    independentValue = BuildIndependentValue(independentVariable, row, config);
                                }
                                else if (_independentValuesAllBool)
                                {
                                    independentValue = independentVariable;
                                    byte value = (byte)(row["__Values__"]);

                                    seriesName = row["__Values__"].ToString();

                                    if (value == 0)
                                    {
                                        seriesName = config["RepresentationOfNo"];
                                    }
                                    else if (value == 1)
                                    {
                                        seriesName = config["RepresentationOfYes"];
                                    }
                                }
                                else
                                {
                                    independentValue = BuildIndependentValue(independentVariable, row, config);
                                }

                                if (string.IsNullOrEmpty(seriesName))
                                {
                                    seriesName = SilverlightStatics.COUNT;

                                    if (_independentVariableArray.Length > 1)
                                    {
                                        seriesName = independentVariable;
                                    }

                                    if(string.IsNullOrEmpty(_aggregateFunction) == false)
                                    {
                                        seriesName = _aggregateFunction;
                                    }
                                }

                                if (string.IsNullOrEmpty(_weightVar))
                                {
                                    //
                                    if (independentValue.ToString().ToUpper() == "TRUE")
                                    {
                                        independentValue = config["RepresentationOfYes"];
                                    }
                                    if (independentValue.ToString().ToUpper() == "FALSE")
                                    {

                                        independentValue = config["RepresentationOfNo"];
                                    }
                                    //
                                    double dependentVal;

                                    if (double.TryParse(row["__Count__"].ToString(), out dependentVal))
                                    {
                                        if ((_graphType == "EPICURVE" && independentValue is DateTime && ((DateTime)independentValue) <= _graphStartFrom) == false)
                                        {
                                            _regressionTable.Rows.Add(seriesName, independentValue, dependentVal);
                                        }
                                    }
                                }
                                else
                                {
                                    //
                                    if (independentValue.ToString().ToUpper() == "TRUE")
                                    {
                                        independentValue = config["RepresentationOfYes"];
                                    }
                                    if (independentValue.ToString().ToUpper() == "FALSE")
                                    {

                                        independentValue = config["RepresentationOfNo"];
                                    }
                                    //
                                    filter.independentVarValue = row["__Values__"];
                                    filter.independentVarName = independentVariable;
                                    filter.weightVarName = _weightVar;
                                    double dependentVal = GetAggregateValue(sourceTable, filter);
                                    _regressionTable.Rows.Add(seriesName, independentValue, dependentVal);
                                }
                            }
                        }
                    }
                }

                string graphTitle = _graphTitle;

                if (sourceTable.Columns.Contains(filter.strataVarName))
                {
                    Type _strataVarDataType = sourceTable.Columns[filter.strataVarName].DataType;
                    string strataVarText = filter.strataVarValue;

                    strataVarText = GetPrintValue(filter.strataVarName, _strataVarDataType.Name, filter.strataVarValue, config);

                    if (string.IsNullOrEmpty(_strataVar) == false)
                    {
                        graphTitle = string.Format("{0} {1}={2}", _graphTitle, filter.strataVarName, strataVarText);
                    }
                }

                DataView view = new DataView(_regressionTable);
                DataTable distinctValues = new DataTable();
                distinctValues = view.ToTable(true, "SeriesName");

                bool hideLegend = false;

                if (distinctValues.Rows.Count == 1 && distinctValues.Rows[0][0].ToString() == "COUNT")
                {
                    hideLegend = true;
                }

                objectElement = objectElement
                    + silverlight.Graph
                    (
                        _graphType,
                        graphTitle,
                        _graphIndependentAxisLabel,
                        _graphDependentAxisLabel,
                        "",
                        "",
                        _graphInterval,
                        _graphIntervalUnits,
                        _graphStartFrom,
                        _regressionTable,
                        hideLegend
                    );

                _regressionTable.Rows.Clear();
            }

            string data = string.Empty;

            if (objectElement != "")
            {
                data = objectElement + @"<hr/>";
            }
            else
            {
                data = SharedStrings.UNABLE_CREATE_GRAPH;
            }

            args.Add("COMMANDNAME", CommandNames.GRAPH);
            args.Add("DATA", data);
            args.Add("COMMANDTEXT", _commandText.Trim());
            Context.Display(args);
        }
Example #18
0
 public SubscriptionTarget() {
     Params = new JObject();
     Filter = new FilterStruct();
     //Since = null;
     //Until = null;
 }
Example #19
0
            // Вывод отфильтрованного списка элементов
            static public void PrintFilteredCars(List <Car> Cars, FilterStruct Filter)

            /*
             *  Параметры:
             *      Cars    - список авто для фильтрации
             *      Filter  - фильтра по которому происходит фильтрация
             */
            {
                // Если фильтр сброшен
                if (!Filter.ChangedValues())
                {
                    // Выводим входной список
                    PrintCars(Cars);
                    return;
                }

                // Регулярные выражения
                Regex regex_mark         = null;
                Regex regex_manufacturer = null;
                // Результат поиска по регулярному выражению
                MatchCollection matches;
                // Результирующий список
                List <Car> result = new List <Car>();

                // Фильтруем входной список
                foreach (Car El in Cars)
                {
                    // Марка
                    if (!EMPTY_VALUES.Contains(Filter.mark))
                    {
                        // Регулярное выражения на основе введенного поля фильтра
                        regex_mark = new Regex(Filter.mark);
                        // Содержится ли подстрока
                        // "ud" содержится в "Audi"
                        matches = regex_mark.Matches(El.mark);
                        if (matches.Count == 0)
                        {
                            continue;
                        }
                    }

                    // Производитель
                    if (!EMPTY_VALUES.Contains(Filter.manufacturer))
                    {
                        // Регулярное выражения на основе введенного поля фильтра
                        regex_manufacturer = new Regex(Filter.manufacturer);
                        // Ищем совпадения в строке
                        matches = regex_manufacturer.Matches(El.manufacturer);
                        if (matches.Count == 0)
                        {
                            continue;
                        }
                    }

                    // Тип авто
                    if (!EMPTY_VALUES.Contains(Filter.type))
                    {
                        // Ищем совпаднеия в строке
                        if (Filter.type.Length > 0 & El.type != Filter.type)
                        {
                            continue;
                        }
                    }

                    // Дата производства
                    if (!EMPTY_VALUES.Contains(Filter.since_date_of_manufacture))
                    {
                        // Дата производства раньше минимальной даты(даты С) - то пропускаем
                        if (El.date_of_manufacture < DateTime.Parse(Filter.since_date_of_manufacture))
                        {
                            continue;
                        }
                    }
                    if (!EMPTY_VALUES.Contains(Filter.till_date_of_manufacture))
                    {
                        // Дата производства позже максимальной даты(даты С) - то пропускаем
                        if (El.date_of_manufacture > DateTime.Parse(Filter.till_date_of_manufacture))
                        {
                            continue;
                        }
                    }

                    // Дата регистрации
                    if (!EMPTY_VALUES.Contains(Filter.since_date_of_registration))
                    {
                        // Дата регистрации раньше минимальной даты(даты С) - то пропускаем
                        if (El.date_of_registration < DateTime.Parse(Filter.since_date_of_registration))
                        {
                            continue;
                        }
                    }
                    if (!EMPTY_VALUES.Contains(Filter.till_date_of_registration))
                    {
                        // Дата регистрации позже максимальной даты(даты С) - то пропускаем
                        if (El.date_of_registration > DateTime.Parse(Filter.till_date_of_registration))
                        {
                            continue;
                        }
                    }

                    // Если мы тут, то все поля удовлетворяют
                    result.Add(El);
                }

                // Выводим отфильтрованный список
                PrintCars(result);
            }
Example #20
0
        private double GetAggregateValue(System.Data.DataTable sourceTable, FilterStruct filter)
        {
            AggregateStruct statStruct = GetStatistics(sourceTable, filter);

            double dependentVal;

            switch (_aggregateFunction.ToUpper())
            {
                case SilverlightStatics.AVG:
                    dependentVal = statStruct.Average;
                    break;
                case SilverlightStatics.COUNT:
                    dependentVal = statStruct.Observations;
                    break;
                case SilverlightStatics.MAX:
                    if (statStruct.Maximun is double)
                    {
                        dependentVal = (double)statStruct.Maximun;
                    }
                    else
                    {
                        dependentVal = (int)statStruct.Maximun;
                    }
                    break;
                case SilverlightStatics.MIN:
                    if (statStruct.Minimum is double)
                    {
                        dependentVal = (double)statStruct.Minimum;
                    }
                    else
                    {
                        dependentVal = (int)statStruct.Minimum;
                    }
                    break;
                case SilverlightStatics.PERCENT:
                    dependentVal = (double)statStruct.Percent;
                    break;
                case SilverlightStatics.SUM:
                    dependentVal = (double)statStruct.Sum;
                    break;
                case SilverlightStatics.SUMPCT:
                    dependentVal = (double)statStruct.SumPercent;
                    break;
                default:
                    dependentVal = statStruct.Sum;
                    break;
            }
            return dependentVal;
        }
Example #21
0
        public static AggregateStruct GetStatistics(DataTable sourceTable, FilterStruct filter)
        {
            AggregateStruct result;

            result.Observations = 0;
            result.Sum          = 0;
            result.Average      = 0;
            result.Variance     = 0;
            result.Std_Dev      = 0;
            result.Minimum      = 0;
            result.Median_25    = 0;
            result.Median       = 0;
            result.Median_75    = 0;
            result.Maximun      = 0;
            result.Percent      = 0;
            result.SumPercent   = 0;

            DataRow[] filteredRows;

            string indCompare = string.Empty;

            if (filter.independentVarValue is string || filter.independentVarValue is DateTime)
            {
                filter.independentVarValue = "'" + filter.independentVarValue + "'";
            }

            string filterSelect = string.Format("{0} = {1}", filter.independentVarName, filter.independentVarValue);

            if (filter.crossTabValue is string || filter.crossTabValue is DateTime)
            {
                filter.crossTabValue = "'" + filter.crossTabValue + "'";
            }

            if (string.IsNullOrEmpty(filter.crossTabName) == false)
            {
                filterSelect = string.Format("{0} AND {1} = {2}", filterSelect, filter.crossTabName, filter.crossTabValue);
            }

            if (string.IsNullOrEmpty(filter.strataVarName) == false)
            {
                double value;
                if (Double.TryParse(filter.strataVarValue, out value))
                {
                    filterSelect = string.Format("{0} AND [{1}] = {2}", filterSelect, filter.strataVarName, filter.strataVarValue);
                }
                else
                {
                    filterSelect = string.Format("{0} AND [{1}] = '{2}'", filterSelect, filter.strataVarName, filter.strataVarValue);
                }
            }

            filteredRows = sourceTable.Select(filterSelect);

            int rowCount = sourceTable.Rows.Count;

            if (filteredRows.Length < 1)
            {
                return(result);
            }

            double observations         = 0;
            double sum                  = 0;
            string independentVarString = "";
            string weightVarString      = "";

            foreach (System.Data.DataRow row in sourceTable.Rows)
            {
                double fromParse;
                independentVarString = row[filter.independentVarName].ToString();
                weightVarString      = row[filter.weightVarName].ToString();

                if (independentVarString != "" && weightVarString != "")
                {
                    double.TryParse(row[filter.weightVarName].ToString(), out fromParse);
                    sum += fromParse;
                    observations++;
                }
            }

            int i = 0;

            foreach (System.Data.DataRow row in filteredRows)
            {
                double weightValue;

                string candidate = row[filter.weightVarName].ToString();
                result.Observations += 1;

                if (double.TryParse(candidate, out weightValue))
                {
                    result.Sum += weightValue;

                    if (i == 0)
                    {
                        result.Maximun = result.Minimum = weightValue;
                    }
                    else
                    {
                        int compare = ((IComparable)weightValue).CompareTo(result.Maximun);
                        if (compare > 0)
                        {
                            result.Maximun = weightValue;
                        }

                        compare = ((IComparable)weightValue).CompareTo(result.Minimum);
                        if (compare < 0)
                        {
                            result.Minimum = weightValue;
                        }
                    }
                    i++;
                }
            }

            result.Average = result.Sum / result.Observations;
            result.Std_Dev = Math.Sqrt(result.Variance);

            result.Percent    = (result.Observations / observations) * 100;
            result.SumPercent = (result.Sum / sum) * 100;

            return(result);
        }
Example #22
0
        public static AggregateStruct GetStatistics(DataTable sourceTable, FilterStruct filter)
        {
            AggregateStruct result;

            result.Observations = 0;
            result.Sum = 0;
            result.Average = 0;
            result.Variance = 0;
            result.Std_Dev = 0;
            result.Minimum = 0;
            result.Median_25 = 0;
            result.Median = 0;
            result.Median_75 = 0;
            result.Maximun = 0;
            result.Percent = 0;
            result.SumPercent = 0;

            DataRow[] filteredRows;

            string indCompare = string.Empty;

            if (filter.independentVarValue is string || filter.independentVarValue is DateTime)
            {
                filter.independentVarValue = "'" + filter.independentVarValue + "'";
            }

            string filterSelect = string.Format("{0} = {1}", filter.independentVarName, filter.independentVarValue);

            if (filter.crossTabValue is string || filter.crossTabValue is DateTime)
            {
                filter.crossTabValue = "'" + filter.crossTabValue + "'";
            }

            if (string.IsNullOrEmpty(filter.crossTabName) == false)
            {
                filterSelect = string.Format("{0} AND {1} = {2}", filterSelect, filter.crossTabName, filter.crossTabValue);
            }

            if (string.IsNullOrEmpty(filter.strataVarName) == false)
            {
                filterSelect = string.Format("{0} AND {1} = {2}", filterSelect, filter.strataVarName, filter.strataVarValue);
            }

            filteredRows = sourceTable.Select(filterSelect);

            int rowCount = sourceTable.Rows.Count;

            if (filteredRows.Length < 1) return result;

            double observations = 0;
            double sum = 0;
            string independentVarString = "";
            string weightVarString = "";

            foreach (System.Data.DataRow row in sourceTable.Rows)
            {
                double fromParse;
                independentVarString = row[filter.independentVarName].ToString();
                weightVarString = row[filter.weightVarName].ToString();

                if (independentVarString != "" && weightVarString != "")
                {
                    double.TryParse(row[filter.weightVarName].ToString(), out fromParse);
                    sum += fromParse;
                    observations++;
                }
            }

            int i = 0;
            foreach (System.Data.DataRow row in filteredRows)
            {
                double weightValue;

                string candidate = row[filter.weightVarName].ToString();
                result.Observations += 1;

                if (double.TryParse(candidate, out weightValue))
                {
                    result.Sum += weightValue;

                    if (i == 0)
                    {
                        result.Maximun = result.Minimum = weightValue;
                    }
                    else
                    {
                        int compare = ((IComparable)weightValue).CompareTo(result.Maximun);
                        if (compare > 0)
                        {
                            result.Maximun = weightValue;
                        }

                        compare = ((IComparable)weightValue).CompareTo(result.Minimum);
                        if (compare < 0)
                        {
                            result.Minimum = weightValue;
                        }
                    }
                    i++;
                }
            }

            result.Average = result.Sum / result.Observations;
            result.Std_Dev = Math.Sqrt(result.Variance);

            result.Percent = (result.Observations / observations) * 100;
            result.SumPercent = (result.Sum / sum) * 100;

            return result;
        }
Example #23
0
        public void Execute()
        {
            _regressionTable = new DataTable();
            _regressionTable.Columns.Add("SeriesName", typeof(string));
            _regressionTable.Columns.Add("Predictor", typeof(object));
            _regressionTable.Columns.Add("Response", typeof(double));

            Dictionary <string, string> config = Context.SetProperties;
            StringBuilder HTMLString           = new StringBuilder();

            System.Data.DataTable sourceTable = BuildTempContextTable();
            cDataSetHelper        dsHelper    = new cDataSetHelper();

            Dictionary <string, string> args = new Dictionary <string, string>();

            string strataVarValue = string.Empty;
            string objectElement  = string.Empty;

            SilverlightMarkup silverlight = new SilverlightMarkup();

            DataTable Strata_ValueList;

            if (string.IsNullOrEmpty(_strataVar))
            {
                Strata_ValueList = sourceTable.Clone();
                Strata_ValueList.Rows.Add(Strata_ValueList.NewRow());
            }
            else
            {
                Strata_ValueList = dsHelper.SelectDistinct("", sourceTable, _strataVar);
            }

            FilterStruct filter = new FilterStruct();

            filter.strataVarName = _strataVar;

            _independentValueTypesSame = true;
            if (_independentVariableArray.Length > 1)
            {
                for (int i = 0; (i + 1) < _independentVariableArray.Length; i++)
                {
                    if (sourceTable.Columns[_independentVariableArray[i]].DataType != sourceTable.Columns[_independentVariableArray[i + 1]].DataType)
                    {
                        _independentValueTypesSame = false;
                        break;
                    }
                }
            }

            _independentValuesAllBool = true;
            for (int i = 0; i < _independentVariableArray.Length; i++)
            {
                string indepVar = _independentVariableArray[i];

                if (sourceTable.Columns.Contains(indepVar))
                {
                    if (sourceTable.Columns[indepVar].DataType.Name != "Byte")
                    {
                        _independentValuesAllBool = false;
                        break;
                    }
                }
                else
                {
                    return;
                }
            }

            foreach (DataRow strataRow in Strata_ValueList.Rows)
            {
                if (string.IsNullOrEmpty(_strataVar) || strataRow[_strataVar] == DBNull.Value)
                {
                    filter.strataVarValue = "null";
                }
                else
                {
                    filter.strataVarValue = strataRow[_strataVar].ToString();
                }

                if (_graphType == SilverlightStatics.Scatter)
                {
                    if (_independentVariableArray.Length < 2)
                    {
                        throw new Exception("Scatter graphs must contain two (2) main variables.");
                    }

                    string categoryName = string.Empty;
                    Dictionary <object, double> indDepValuePairCollection = new Dictionary <object, double>();

                    List <string> StrataVarNameList  = new List <string>();
                    List <string> StrataVarValueList = new List <string>();

                    string regressor  = _independentVariableArray[0];
                    string regressand = _independentVariableArray[1];

                    StrataVarNameList.Add(filter.strataVarName);
                    StrataVarValueList.Add(filter.strataVarValue);

                    DataTable table = new DataTable();
                    table.Columns.Add(new DataColumn(sourceTable.Columns[regressor].ColumnName, sourceTable.Columns[regressor].DataType));
                    table.Columns.Add(new DataColumn(sourceTable.Columns[regressand].ColumnName, sourceTable.Columns[regressand].DataType));

                    foreach (DataRow row in sourceTable.Rows)
                    {
                        table.Rows.Add(row[regressor], row[regressand]);
                    }

                    foreach (DataRow row in table.Rows)
                    {
                        if (row[regressor] != DBNull.Value)
                        {
                            string seriesName       = string.Empty;
                            object independentValue = new object();

                            if (_independentValuesAllBool)
                            {
                                independentValue = regressor;
                                byte value = (byte)(row[regressor]);
                            }
                            else
                            {
                                independentValue = GetValue(regressor, row, config);
                            }

                            seriesName = string.Format("{0} x {1}", sourceTable.Columns[regressor].ColumnName, sourceTable.Columns[regressand].ColumnName);

                            if (string.IsNullOrEmpty(_weightVar))
                            {
                                double dependentVal;

                                if (double.TryParse(row[regressand].ToString(), out dependentVal))
                                {
                                    _regressionTable.Rows.Add(seriesName, independentValue, dependentVal);
                                }
                            }
                            else
                            {
                                filter.independentVarValue = row[regressor];
                                filter.independentVarName  = regressor;
                                filter.weightVarName       = _weightVar;
                                double dependentVal = GetAggregateValue(sourceTable, filter);

                                _regressionTable.Rows.Add(seriesName, independentValue, dependentVal);
                            }
                        }
                    }
                }
                else if (sourceTable.Columns.Contains(_graphCrossTab))
                {
                    string categoryName = string.Empty;
                    Dictionary <object, double> indDepValuePairCollection = new Dictionary <object, double>();

                    List <string> StrataVarNameList  = new List <string>();
                    List <string> StrataVarValueList = new List <string>();

                    foreach (string independentVariableName in _independentVariableArray)
                    {
                        StrataVarNameList.Add(filter.strataVarName);
                        StrataVarValueList.Add(filter.strataVarValue);

                        DataTable workingTable = cWorkingTable.CreateWorkingTable(
                            independentVariableName,
                            _graphCrossTab,
                            config,
                            sourceTable,
                            StrataVarNameList,
                            StrataVarValueList,
                            _weightVar);

                        foreach (DataColumn crossTabCandidate in workingTable.Columns)
                        {
                            if (crossTabCandidate.ColumnName != "__Values__" && crossTabCandidate.ColumnName != "__Count__")
                            {
                                Type crossTabDataType = sourceTable.Columns[_graphCrossTab].DataType;

                                string crossTabValue = crossTabCandidate.ColumnName;

                                if (crossTabDataType.Name == "Byte")
                                {
                                    if (crossTabCandidate.ColumnName == "0")
                                    {
                                        crossTabValue = config["RepresentationOfNo"];
                                    }
                                    else if (crossTabCandidate.ColumnName == "1")
                                    {
                                        crossTabValue = config["RepresentationOfYes"];
                                    }
                                }

                                string seriesName = string.Format("{0}={1}", _graphCrossTab, crossTabValue);

                                foreach (DataRow row in workingTable.Rows)
                                {
                                    double dependentVal;

                                    if (double.TryParse(row[crossTabCandidate.ColumnName].ToString(), out dependentVal))
                                    {
                                        if (row["__Values__"] != DBNull.Value)
                                        {
                                            string independentVariableTypeName = string.Empty;

                                            if (sourceTable.Columns.Contains(independentVariableName))
                                            {
                                                independentVariableTypeName = sourceTable.Columns[independentVariableName].DataType.Name;
                                            }

                                            categoryName = BuildCategoryName(independentVariableName, independentVariableTypeName, row, config);

                                            object independentValue = row["__Values__"];

                                            if (string.IsNullOrEmpty(_weightVar))
                                            {
                                                if (double.TryParse(row[crossTabCandidate.ColumnName].ToString(), out dependentVal))
                                                {
                                                    _regressionTable.Rows.Add(seriesName, independentValue, dependentVal);
                                                }
                                            }
                                            else
                                            {
                                                object independentVariableValue = row["__Values__"];

                                                bool isValue = false;

                                                if (independentVariableValue != null)
                                                {
                                                    isValue = true;

                                                    if (independentVariableValue is string)
                                                    {
                                                        string candidate = ((string)independentVariableValue).Trim();
                                                        isValue = candidate != string.Empty;
                                                    }
                                                }

                                                if (isValue)
                                                {
                                                    filter.crossTabName        = _graphCrossTab;
                                                    filter.crossTabValue       = crossTabCandidate.ColumnName;
                                                    filter.independentVarName  = independentVariableName;
                                                    filter.independentVarValue = independentVariableValue;
                                                    filter.weightVarName       = _weightVar;
                                                    dependentVal = GetAggregateValue(sourceTable, filter);
                                                    _regressionTable.Rows.Add(seriesName, independentValue, dependentVal);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else if (_graphType == "EPICURVE" && _graphIntervalUnits != "")
                {
                    string categoryName = string.Empty;
                    Dictionary <object, double> indDepValuePairCollection = new Dictionary <object, double>();

                    List <string> StrataVarNameList  = new List <string>();
                    List <string> StrataVarValueList = new List <string>();

                    foreach (string independentVariable in _independentVariableArray)
                    {
                        StrataVarNameList.Add(filter.strataVarName);
                        StrataVarValueList.Add(filter.strataVarValue);

                        DataTable workingTable = cWorkingTable.CreateWorkingTable(
                            independentVariable,
                            "",
                            config,
                            sourceTable,
                            StrataVarNameList,
                            StrataVarValueList,
                            _weightVar);

                        DateTime intervalStart = DateTime.MinValue;
                        DateTime intervalEnd   = DateTime.MinValue;
                        DateTime dateTimeValue = DateTime.MinValue;
                        intervalStart = _graphStartFrom;

                        double   givenInterval = 1;
                        int      days = 0, hours = 0, minutes = 0, seconds = 0;
                        TimeSpan period = new TimeSpan(days, hours, minutes, seconds);

                        if (_graphInterval != "")
                        {
                            double.TryParse(_graphInterval, out givenInterval);
                        }

                        if (_graphIntervalUnits == "")
                        {
                            _graphIntervalUnits = "Hours";
                        }

                        foreach (DataRow row in workingTable.Rows)
                        {
                            if (row["__Values__"] != DBNull.Value)
                            {
                                dateTimeValue = (DateTime)row["__Values__"];

                                //if (intervalStart == DateTime.MinValue)
                                //{
                                //    intervalStart = dateTimeValue;
                                //    _graphStartFrom = dateTimeValue;
                                //}

                                while (dateTimeValue >= intervalEnd)
                                {
                                    if (intervalEnd != DateTime.MinValue)
                                    {
                                        intervalStart = intervalEnd;
                                    }

                                    switch (_graphIntervalUnits)
                                    {
                                    case "Years":
                                        intervalEnd = intervalStart.AddYears((int)givenInterval);
                                        break;

                                    case "Quarters":
                                        intervalEnd = intervalStart.AddDays(givenInterval * 365.25 / 4.0);
                                        break;

                                    case "Weeks":
                                        intervalEnd = intervalStart.AddDays(givenInterval * 7);
                                        break;

                                    case "Days":
                                        intervalEnd = intervalStart.AddDays(givenInterval);
                                        break;

                                    case "Hours":
                                        intervalEnd = intervalStart.AddHours(givenInterval);
                                        break;

                                    case "Minutes":
                                        intervalEnd = intervalStart.AddMinutes(givenInterval);
                                        break;

                                    case "Seconds":
                                        intervalEnd = intervalStart.AddSeconds(givenInterval);
                                        break;
                                    }
                                }

                                string seriesName       = string.Empty;
                                object independentValue = new object();

                                independentValue = BuildIndependentValue(independentVariable, row, config);

                                if (string.IsNullOrEmpty(seriesName))
                                {
                                    seriesName = SilverlightStatics.COUNT;

                                    if (_independentVariableArray.Length > 1)
                                    {
                                        seriesName = independentVariable;
                                    }

                                    if (string.IsNullOrEmpty(_aggregateFunction) == false)
                                    {
                                        seriesName = _aggregateFunction;
                                    }
                                }

                                if (string.IsNullOrEmpty(_weightVar))
                                {
                                    double dependentVal;

                                    if (double.TryParse(row["__Count__"].ToString(), out dependentVal))
                                    {
                                        if ((dateTimeValue >= intervalStart) && (dateTimeValue < intervalEnd))
                                        {
                                            string    expression = "Predictor = #" + intervalStart.ToString() + "#";
                                            DataRow[] foundRows  = _regressionTable.Select(expression);

                                            if (foundRows.Length == 0)
                                            {
                                                _regressionTable.Rows.Add(seriesName, intervalStart, dependentVal);
                                            }
                                            else
                                            {
                                                foundRows[0]["Response"] = (double)foundRows[0]["Response"] + dependentVal;
                                                _regressionTable.AcceptChanges();
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    filter.independentVarValue = row["__Values__"];
                                    filter.independentVarName  = independentVariable;
                                    filter.weightVarName       = _weightVar;
                                    double dependentVal = GetAggregateValue(sourceTable, filter);
                                    _regressionTable.Rows.Add(seriesName, independentValue, dependentVal);
                                }
                            }
                        }
                    }
                }
                else
                {
                    string categoryName = string.Empty;
                    Dictionary <object, double> indDepValuePairCollection = new Dictionary <object, double>();

                    List <string> StrataVarNameList  = new List <string>();
                    List <string> StrataVarValueList = new List <string>();

                    foreach (string independentVariable in _independentVariableArray)
                    {
                        StrataVarNameList.Add(filter.strataVarName);
                        StrataVarValueList.Add(filter.strataVarValue);

                        DataTable workingTable = cWorkingTable.CreateWorkingTable(
                            independentVariable,
                            "",
                            config,
                            sourceTable,
                            StrataVarNameList,
                            StrataVarValueList,
                            _weightVar);

                        foreach (DataRow row in workingTable.Rows)
                        {
                            if (row["__Values__"] != DBNull.Value)
                            {
                                string seriesName       = string.Empty;
                                object independentValue = new object();

                                if (!_independentValueTypesSame || _graphType == SilverlightStatics.Pie)
                                {
                                    independentValue = BuildIndependentValue(independentVariable, row, config);
                                }
                                else if (_independentValuesAllBool)
                                {
                                    independentValue = independentVariable;
                                    byte value = (byte)(row["__Values__"]);

                                    seriesName = row["__Values__"].ToString();

                                    if (value == 0)
                                    {
                                        seriesName = config["RepresentationOfNo"];
                                    }
                                    else if (value == 1)
                                    {
                                        seriesName = config["RepresentationOfYes"];
                                    }
                                }
                                else
                                {
                                    independentValue = BuildIndependentValue(independentVariable, row, config);
                                }

                                if (string.IsNullOrEmpty(seriesName))
                                {
                                    seriesName = SilverlightStatics.COUNT;

                                    if (_independentVariableArray.Length > 1)
                                    {
                                        seriesName = independentVariable;
                                    }

                                    if (string.IsNullOrEmpty(_aggregateFunction) == false)
                                    {
                                        seriesName = _aggregateFunction;
                                    }
                                }

                                if (string.IsNullOrEmpty(_weightVar))
                                {
                                    //
                                    if (independentValue.ToString().ToUpperInvariant() == "TRUE")
                                    {
                                        independentValue = config["RepresentationOfYes"];
                                    }
                                    if (independentValue.ToString().ToUpperInvariant() == "FALSE")
                                    {
                                        independentValue = config["RepresentationOfNo"];
                                    }
                                    //
                                    double dependentVal;

                                    if (double.TryParse(row["__Count__"].ToString(), out dependentVal))
                                    {
                                        if ((_graphType == "EPICURVE" && independentValue is DateTime && ((DateTime)independentValue) <= _graphStartFrom) == false)
                                        {
                                            _regressionTable.Rows.Add(seriesName, independentValue, dependentVal);
                                        }
                                    }
                                }
                                else
                                {
                                    //
                                    if (independentValue.ToString().ToUpperInvariant() == "TRUE")
                                    {
                                        independentValue = config["RepresentationOfYes"];
                                    }
                                    if (independentValue.ToString().ToUpperInvariant() == "FALSE")
                                    {
                                        independentValue = config["RepresentationOfNo"];
                                    }
                                    //
                                    filter.independentVarValue = row["__Values__"];
                                    filter.independentVarName  = independentVariable;
                                    filter.weightVarName       = _weightVar;
                                    double dependentVal = GetAggregateValue(sourceTable, filter);
                                    _regressionTable.Rows.Add(seriesName, independentValue, dependentVal);
                                }
                            }
                        }
                    }
                }

                string graphTitle = _graphTitle;

                if (sourceTable.Columns.Contains(filter.strataVarName))
                {
                    Type   _strataVarDataType = sourceTable.Columns[filter.strataVarName].DataType;
                    string strataVarText      = filter.strataVarValue;

                    strataVarText = GetPrintValue(filter.strataVarName, _strataVarDataType.Name, filter.strataVarValue, config);

                    if (string.IsNullOrEmpty(_strataVar) == false)
                    {
                        graphTitle = string.Format("{0} {1}={2}", _graphTitle, filter.strataVarName, strataVarText);
                    }
                }

                DataView  view           = new DataView(_regressionTable);
                DataTable distinctValues = new DataTable();
                distinctValues = view.ToTable(true, "SeriesName");

                bool hideLegend = false;

                if (distinctValues.Rows.Count == 1 && distinctValues.Rows[0][0].ToString() == "COUNT")
                {
                    hideLegend = true;
                }

                objectElement = objectElement
                                + silverlight.Graph
                                (
                    _graphType,
                    graphTitle,
                    _graphIndependentAxisLabel,
                    _graphDependentAxisLabel,
                    "",
                    "",
                    _graphInterval,
                    _graphIntervalUnits,
                    _graphStartFrom,
                    _regressionTable,
                    hideLegend
                                );

                _regressionTable.Rows.Clear();
            }

            string data = string.Empty;

            if (objectElement != "")
            {
                data = objectElement + @"<hr/>";
            }
            else
            {
                data = SharedStrings.UNABLE_CREATE_GRAPH;
            }

            args.Add("COMMANDNAME", CommandNames.GRAPH);
            args.Add("DATA", data);
            args.Add("COMMANDTEXT", _commandText.Trim());
            Context.Display(args);
        }