예제 #1
0
        public ClusterDataSet <RowItem, int> .DataFrame MakeDataFrame(PivotedProperties.Series series, ClusterRole.Transform clusterValueTransform)
        {
            var rows = new List <List <double> >();

            foreach (var rowItem in RowItems)
            {
                var rawValues   = series.PropertyDescriptors.Select(pd => pd.GetValue(rowItem)).ToList();
                var valuesToAdd = clusterValueTransform.TransformRow(rawValues)
                                  .Select(value => value ?? clusterValueTransform.ValueForNull).ToList();
#if DEBUG
                foreach (var value in valuesToAdd)
                {
                    if (double.IsNaN(value) || double.IsInfinity(value))
                    {
                        Debug.WriteLine(@"{0} is not a valid double", value);
                    }
                }
#endif
                rows.Add(valuesToAdd);
            }
            var columnDatas = new List <ImmutableList <double> >();
            for (int i = 0; i < series.PropertyIndexes.Count; i++)
            {
                columnDatas.Add(ImmutableList.ValueOf(rows.Select(row => row[i]).ToList()));
            }
            return(new ClusterDataSet <RowItem, int> .DataFrame(Enumerable.Range(0, columnDatas.Count), columnDatas));
        }
예제 #2
0
        public IEnumerable <Color?> GetSeriesColors(PivotedProperties.Series series, RowItem rowItem)
        {
            if (!_seriesColorManagers.TryGetValue(series.SeriesId, out ColorManager colorManager))
            {
                return(Enumerable.Repeat((Color?)null, series.PropertyIndexes.Count));
            }

            return(colorManager.GetRowValues(rowItem).Select(colorManager.ColorScheme.GetColor));
        }
예제 #3
0
        private CaptionedValues GetColumnHeaderLevel(IList <RowItem> rowItems, PivotedProperties.Series series)
        {
            var values = new List <object>();

            foreach (var propertyDescriptor in series.PropertyDescriptors)
            {
                values.Add(rowItems.Select(propertyDescriptor.GetValue).FirstOrDefault(v => null != v));
            }
            return(new CaptionedValues(series.SeriesCaption, series.PropertyType, values));
        }
예제 #4
0
        public Color?GetColor(PivotedProperties.Series series, object value)
        {
            if (!_colorManagers.TryGetValue(
                    ClusteredProperties.PivotedProperties.ItemProperties[series.PropertyIndexes[0]].Name,
                    out ColorManager colorManager))
            {
                return(null);
            }

            return(colorManager.ColorScheme.GetColor(value));
        }
예제 #5
0
            public static ColumnRef FromPivotedPropertySeries(PivotedProperties.Series series)
            {
                if (series.SeriesId is PropertyPath propertyPath)
                {
                    return(new ColumnRef(propertyPath));
                }

                if (series.SeriesId is IColumnCaption caption)
                {
                    return(new ColumnRef(new ColumnId(caption)));
                }

                return(null);
            }
예제 #6
0
        public static bool EqualValuesInAllRows(CancellationToken cancellationToken, ReportResults reportResults, PivotedProperties.Series series)
        {
            foreach (var propertyDescriptor in series.PropertyDescriptors)
            {
                cancellationToken.ThrowIfCancellationRequested();
                var distinctValues = reportResults.RowItems.Select(propertyDescriptor.GetValue)
                                     .Where(value => null != value).Distinct();
                if (distinctValues.Skip(1).Any())
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #7
0
 public ClusterRole GetColumnRole(PivotedProperties.Series series)
 {
     _columnRoles.TryGetValue(series.SeriesId, out ClusterRole role);
     return(role);
 }
예제 #8
0
 private static ClusteringSpec.ColumnRef ToColumnRef(PivotedProperties.Series series)
 {
     return(ClusteringSpec.ColumnRef.FromPivotedPropertySeries(series));
 }