private Dictionary <ImmutableList <HeaderLevel>, PointPairList> GetColumnPointPairLists( PivotedProperties.SeriesGroup seriesGroup, int xAxisIndex, int yAxisIndex) { var pointLists = new Dictionary <ImmutableList <HeaderLevel>, PointPairList>(); var results = Clusterer.PerformPcaOnColumnGroup(seriesGroup, Math.Max(xAxisIndex, yAxisIndex) + 1); var headerLevels = Clusterer.Properties.GetColumnHeaders(seriesGroup).ToList(); for (int iColumn = 0; iColumn < results.ItemComponents.Count; iColumn++) { var headers = new List <HeaderLevel>(); foreach (var series in headerLevels) { var pd = series.PropertyDescriptors[iColumn]; var objectValue = Clusterer.RowItems.Select(pd.GetValue).FirstOrDefault(value => null != value); headers.Add(new HeaderLevel(series.SeriesCaption, objectValue, ColorScheme.GetColor(series, objectValue) ?? MISSING_COLOR)); } var key = ImmutableList.ValueOf(headers); PointPairList pointPairList; if (!pointLists.TryGetValue(key, out pointPairList)) { pointPairList = new PointPairList(); pointLists.Add(key, pointPairList); } var pointInfo = new PointInfo(key); var cellLocator = CellLocator.ForColumn(headerLevels.Select(series => series.PropertyDescriptors[iColumn]).ToList(), ImmutableList.Empty <DataPropertyDescriptor>()); var rowItem = Clusterer.RowItems[0]; pointInfo = pointInfo.ChangeIdentityPath(cellLocator.GetSkylineDocNode(rowItem)?.IdentityPath) .ChangeReplicateName(cellLocator.GetReplicate(rowItem)?.Name); var pointPair = new PointPair(results.ItemComponents[iColumn][xAxisIndex], results.ItemComponents[iColumn][yAxisIndex]) { Tag = pointInfo }; pointPairList.Add(pointPair); } return(pointLists); }
public bool ShowHeatMap() { Tuple <Clusterer, ClusteredReportResults, ReportColorScheme> resultsTuple = GetClusteredResults(); if (resultsTuple == null) { return(false); } var clusteredResults = resultsTuple.Item2; var colorScheme = resultsTuple.Item3; var points = new List <ClusterGraphResults.Point>(); var rowHeaders = new List <ClusterGraphResults.Header>(); var columnValues = new List <PivotedProperties.Series>(); var columnGroups = new List <ClusterGraphResults.ColumnGroup>(); var dataSchemaLocalizer = BindingListSource.ViewInfo.DataSchema.DataSchemaLocalizer; var cellLocators = new List <CellLocator>(); for (int iGroup = 0; iGroup < clusteredResults.PivotedProperties.SeriesGroups.Count; iGroup++) { var group = clusteredResults.PivotedProperties.SeriesGroups[iGroup]; var groupColumnHeaders = clusteredResults.ClusteredProperties.GetColumnHeaders(group).ToList(); var groupHeaders = new List <ClusterGraphResults.Header>(); for (int iPivotKey = 0; iPivotKey < group.PivotKeys.Count; iPivotKey++) { var colors = new List <Color>(); foreach (var series in groupColumnHeaders) { var pd = series.PropertyDescriptors[iPivotKey]; colors.Add(colorScheme.GetColumnColor(pd) ?? Color.Transparent); } groupHeaders.Add(new ClusterGraphResults.Header(group.PivotCaptions[iPivotKey].GetCaption(dataSchemaLocalizer), colors)); } foreach (var series in group.SeriesList) { var transform = clusteredResults.ClusteredProperties.GetColumnRole(series) as ClusterRole.Transform; if (transform == null) { continue; } columnValues.Add(series); columnGroups.Add(new ClusterGraphResults.ColumnGroup( clusteredResults.ColumnGroupDendrogramDatas[iGroup].DendrogramData, groupHeaders)); for (int iProperty = 0; iProperty < series.PropertyIndexes.Count; iProperty++) { var columnHeaders = groupColumnHeaders.Prepend(series) .Select(s => s.PropertyDescriptors[iProperty]).ToList(); var cellLocator = CellLocator.ForColumn(columnHeaders, clusteredResults.ItemProperties); cellLocators.Add(cellLocator); } } } for (int iRow = 0; iRow < clusteredResults.RowCount; iRow++) { var rowItem = clusteredResults.RowItems[iRow]; var rowColors = new List <Color>(); var rowHeaderParts = new List <object>(); foreach (var rowHeader in clusteredResults.ClusteredProperties.RowHeaders) { rowHeaderParts.Add(rowHeader.GetValue(rowItem)); rowColors.Add(colorScheme.GetColor(rowHeader, rowItem) ?? Color.Transparent); } string rowCaption = CaptionComponentList.SpaceSeparate(rowHeaderParts) .GetCaption(DataSchemaLocalizer.INVARIANT); rowHeaders.Add(new ClusterGraphResults.Header(rowCaption, rowColors)); int iCol = 0; foreach (var series in columnValues) { foreach (var color in colorScheme.GetSeriesColors(series, rowItem)) { var point = new ClusterGraphResults.Point(iRow, iCol, color); var skylineDocNode = cellLocators[iCol].GetSkylineDocNode(rowItem); if (skylineDocNode != null) { point = point.ChangeIdentityPath(skylineDocNode.IdentityPath); } var replicate = cellLocators[iCol].GetReplicate(rowItem); if (replicate != null) { point = point.ChangeReplicateName(replicate.Name); } points.Add(point); iCol++; } } } var graphResults = new ClusterGraphResults(clusteredResults.RowDendrogramData?.DendrogramData, rowHeaders, columnGroups, points); var heatMapGraph = new HierarchicalClusterGraph() { SkylineWindow = DataSchemaSkylineWindow, GraphResults = graphResults }; heatMapGraph.Show(FormUtil.FindTopLevelOwner(this)); return(true); }