/// <summary>
 ///		Безопасная печать <see cref="BrickDataSet.Preferences"/> с проверкой на NOT NULL
 /// </summary>
 /// <param name="dataSet">Исходный датасет</param>
 public static void PrintPreferences(this BrickDataSet dataSet)
 {
     if (dataSet != null && dataSet.Preferences != null)
     {
         dataSet.Preferences.PrintPreferences();
     }
 }
        /// <summary>
        ///     Собирает упорядоченное перечисление колонок данных графика в виде <see cref="DataItemColon"/>
        /// </summary>
        /// <param name="dataSet">Датасет</param>
        /// <returns>Упорядоченное перечисление колонок данных графика в виде <see cref="DataItemColon"/></returns>
        public static IEnumerable <DataItemColon> GetColons(this BrickDataSet dataSet)
        {
            var subresult = dataSet.DataItems.GroupBy(_ => _.Idx).Select(_ => _.Select(__ => __).ToArray());

            foreach (var ds in subresult)
            {
                yield return(new DataItemColon(ds));
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="dataset"></param>
 public static void PrintDataset(this BrickDataSet dataset)
 {
     foreach (var seria in dataset.Series)
     {
         Console.WriteLine("Seria: " + seria.SeriaNumber);
         foreach (var row in seria.Rows)
         {
             Console.WriteLine("\tRow: {0}, Sum: {1}, Scale: {2}", row.RowNumber, row.Sum(_ => _.Value), row.ScaleType.ToString());
             foreach (var item in row)
             {
                 Console.WriteLine("\t\tItem: {0}, Value: {1}", item.Idx, item.Value);
             }
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 ///     Преобразует данные из <see cref="BrickDataSet"/> в <see cref="IChart"/>
 /// </summary>
 /// <param name="brickDataSet">Исходный датасет в виде <see cref="BrickDataSet"/></param>
 /// <returns>Эквивалентный экземпляр <see cref="IChart"/></returns>
 public static IChart ParseBrickDataSet(BrickDataSet brickDataSet) {
     return ParseDatasets(string.Join(";", brickDataSet.GetSeries().Select(_ => _.ToString())));
 }
Esempio n. 5
0
	    private BrickDataSet GetNormalizedRecord() {
			var result = new BrickDataSet {_isNormalizedRecord = true};
			foreach (var scaleType in new[]{ScaleType.First,ScaleType.Second}) {
				var rows = Rows.Where(_ => _.ScaleType == scaleType).ToArray();
				if (rows.Length == 0) continue;
				var maxCount = rows.Select(_ => _.Items.Count).Max();
				var scaleRow = InitNormalizedScaleRow(scaleType, maxCount);
                result.EnsureSeria(0).Add(scaleRow);
				var serias = rows.GroupBy(_ => _.SeriaNumber).ToArray();
				for (var i = 0; i < maxCount; i++)
				{
				
					var currentPosMax = 0 != (Preferences.SeriaCalcMode & SeriaCalcMode.SeriaSum) ? 0 : decimal.MinValue;
					var currentPosMin =  decimal.MaxValue;
					var currentNegMax =  decimal.MinValue;
					var currentNegMin = 0 != (Preferences.SeriaCalcMode & SeriaCalcMode.SeriaSum) ? 0 : decimal.MaxValue;

					foreach (var seria in serias) {
						var seriaPosMax = 0 != (Preferences.SeriaCalcMode & SeriaCalcMode.SeriaSum) ? 0 : decimal.MinValue;
						var seriaNegMin = 0 != (Preferences.SeriaCalcMode & SeriaCalcMode.SeriaSum) ? 0 : decimal.MaxValue;
						foreach (var row in seria) {
							decimal val = 0;
							if (i < row.Items.Count) {
								val = row.Items[i].Value;
							}
							if (0 != (Preferences.SeriaCalcMode & SeriaCalcMode.SeriaSum)) {
								if (val >= 0) {
									if (0 != (Preferences.SeriaCalcMode & SeriaCalcMode.CrossSeriaSum)) {
										currentPosMax += val;
									}
									seriaPosMax += val;
								} else {
									if (0 != (Preferences.SeriaCalcMode & SeriaCalcMode.CrossSeriaSum)) {
										currentNegMin += val;
									}
									seriaNegMin += val;
								}
								
							} else {
								if (val >= 0) {
									currentPosMax = Math.Max(val,currentPosMax);
									currentPosMin = Math.Min(val, currentPosMin);
								} else {
									currentNegMin = Math.Min(val,currentNegMin);
									currentNegMax = Math.Max(val, currentNegMax);
								}
							}
						}
						if (0 != (Preferences.SeriaCalcMode & SeriaCalcMode.SeriaSum)) {
							currentNegMax = Math.Max(currentNegMax, seriaNegMin);
							currentPosMin = Math.Min(currentPosMin, seriaPosMax);
							if (0 == (Preferences.SeriaCalcMode & SeriaCalcMode.CrossSeriaSum)) {
								currentPosMax = Math.Max(currentPosMax, seriaPosMax);
								currentNegMin = Math.Min(currentNegMin, seriaNegMin);
							}
						}
						
					}
					if (0 != (Preferences.SeriaCalcMode & SeriaCalcMode.CrossSeriaSum)) {
						scaleRow.Items[i].PosMax += currentPosMax;
						scaleRow.Items[i].NegMin += currentNegMin;
					} else {
						scaleRow.Items[i].PosMax = Math.Max(currentPosMax, scaleRow.Items[i].PosMax);
						scaleRow.Items[i].NegMin = Math.Min(currentNegMin, scaleRow.Items[i].NegMin);
						scaleRow.Items[i].NegMax = Math.Max(currentNegMax, scaleRow.Items[i].NegMax);
						scaleRow.Items[i].PosMin = Math.Min(currentPosMin, scaleRow.Items[i].PosMin);
					}
				}
				
			}
			return result;
		}
 /// <summary>
 ///     Возвращает упорядоченное перечисление серий из <see cref="BrickDataSet"/>
 /// </summary>
 /// <param name="dataSet">Датасет</param>
 /// <returns>Упорядоченное перечисление серий из <see cref="BrickDataSet"/></returns>
 public static IEnumerable <BrickDataSetSeria> GetSeries(this BrickDataSet dataSet)
 {
     return(dataSet.Series);
 }
Esempio n. 7
0
        private BrickDataSet GetNormalizedRecord()
        {
            var result = new BrickDataSet {
                _isNormalizedRecord = true
            };

            foreach (var scaleType in new[] { ScaleType.First, ScaleType.Second })
            {
                var rows = Rows.Where(_ => _.ScaleType == scaleType).ToArray();
                if (rows.Length == 0)
                {
                    continue;
                }
                var maxCount = rows.Select(_ => _.Items.Count).Max();
                var scaleRow = InitNormalizedScaleRow(scaleType, maxCount);
                result.EnsureSeria(0).Add(scaleRow);
                var serias = rows.GroupBy(_ => _.SeriaNumber).ToArray();
                for (var i = 0; i < maxCount; i++)
                {
                    var currentPosMax = 0 != (Preferences.SeriaCalcMode & SeriaCalcMode.SeriaSum) ? 0 : decimal.MinValue;
                    var currentPosMin = decimal.MaxValue;
                    var currentNegMax = decimal.MinValue;
                    var currentNegMin = 0 != (Preferences.SeriaCalcMode & SeriaCalcMode.SeriaSum) ? 0 : decimal.MaxValue;

                    foreach (var seria in serias)
                    {
                        var seriaPosMax = 0 != (Preferences.SeriaCalcMode & SeriaCalcMode.SeriaSum) ? 0 : decimal.MinValue;
                        var seriaNegMin = 0 != (Preferences.SeriaCalcMode & SeriaCalcMode.SeriaSum) ? 0 : decimal.MaxValue;
                        foreach (var row in seria)
                        {
                            decimal val = 0;
                            if (i < row.Items.Count)
                            {
                                val = row.Items[i].Value;
                            }
                            if (0 != (Preferences.SeriaCalcMode & SeriaCalcMode.SeriaSum))
                            {
                                if (val >= 0)
                                {
                                    if (0 != (Preferences.SeriaCalcMode & SeriaCalcMode.CrossSeriaSum))
                                    {
                                        currentPosMax += val;
                                    }
                                    seriaPosMax += val;
                                }
                                else
                                {
                                    if (0 != (Preferences.SeriaCalcMode & SeriaCalcMode.CrossSeriaSum))
                                    {
                                        currentNegMin += val;
                                    }
                                    seriaNegMin += val;
                                }
                            }
                            else
                            {
                                if (val >= 0)
                                {
                                    currentPosMax = Math.Max(val, currentPosMax);
                                    currentPosMin = Math.Min(val, currentPosMin);
                                }
                                else
                                {
                                    currentNegMin = Math.Min(val, currentNegMin);
                                    currentNegMax = Math.Max(val, currentNegMax);
                                }
                            }
                        }
                        if (0 != (Preferences.SeriaCalcMode & SeriaCalcMode.SeriaSum))
                        {
                            currentNegMax = Math.Max(currentNegMax, seriaNegMin);
                            currentPosMin = Math.Min(currentPosMin, seriaPosMax);
                            if (0 == (Preferences.SeriaCalcMode & SeriaCalcMode.CrossSeriaSum))
                            {
                                currentPosMax = Math.Max(currentPosMax, seriaPosMax);
                                currentNegMin = Math.Min(currentNegMin, seriaNegMin);
                            }
                        }
                    }
                    if (0 != (Preferences.SeriaCalcMode & SeriaCalcMode.CrossSeriaSum))
                    {
                        scaleRow.Items[i].PosMax += currentPosMax;
                        scaleRow.Items[i].NegMin += currentNegMin;
                    }
                    else
                    {
                        scaleRow.Items[i].PosMax = Math.Max(currentPosMax, scaleRow.Items[i].PosMax);
                        scaleRow.Items[i].NegMin = Math.Min(currentNegMin, scaleRow.Items[i].NegMin);
                        scaleRow.Items[i].NegMax = Math.Max(currentNegMax, scaleRow.Items[i].NegMax);
                        scaleRow.Items[i].PosMin = Math.Min(currentPosMin, scaleRow.Items[i].PosMin);
                    }
                }
            }
            return(result);
        }